documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638
  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. * Detach the current controls from the specified dom element.
  24354. */
  24355. detachControl(): void;
  24356. private _collisionMask;
  24357. /**
  24358. * Define a collision mask to limit the list of object the camera can collide with
  24359. */
  24360. get collisionMask(): number;
  24361. set collisionMask(mask: number);
  24362. /** @hidden */
  24363. _collideWithWorld(displacement: Vector3): void;
  24364. private _onCollisionPositionChange;
  24365. /** @hidden */
  24366. _checkInputs(): void;
  24367. /** @hidden */
  24368. _decideIfNeedsToMove(): boolean;
  24369. /** @hidden */
  24370. _updatePosition(): void;
  24371. /**
  24372. * Destroy the camera and release the current resources hold by it.
  24373. */
  24374. dispose(): void;
  24375. /**
  24376. * Gets the current object class name.
  24377. * @return the class name
  24378. */
  24379. getClassName(): string;
  24380. }
  24381. }
  24382. declare module BABYLON {
  24383. /**
  24384. * Represents a gamepad control stick position
  24385. */
  24386. export class StickValues {
  24387. /**
  24388. * The x component of the control stick
  24389. */
  24390. x: number;
  24391. /**
  24392. * The y component of the control stick
  24393. */
  24394. y: number;
  24395. /**
  24396. * Initializes the gamepad x and y control stick values
  24397. * @param x The x component of the gamepad control stick value
  24398. * @param y The y component of the gamepad control stick value
  24399. */
  24400. constructor(
  24401. /**
  24402. * The x component of the control stick
  24403. */
  24404. x: number,
  24405. /**
  24406. * The y component of the control stick
  24407. */
  24408. y: number);
  24409. }
  24410. /**
  24411. * An interface which manages callbacks for gamepad button changes
  24412. */
  24413. export interface GamepadButtonChanges {
  24414. /**
  24415. * Called when a gamepad has been changed
  24416. */
  24417. changed: boolean;
  24418. /**
  24419. * Called when a gamepad press event has been triggered
  24420. */
  24421. pressChanged: boolean;
  24422. /**
  24423. * Called when a touch event has been triggered
  24424. */
  24425. touchChanged: boolean;
  24426. /**
  24427. * Called when a value has changed
  24428. */
  24429. valueChanged: boolean;
  24430. }
  24431. /**
  24432. * Represents a gamepad
  24433. */
  24434. export class Gamepad {
  24435. /**
  24436. * The id of the gamepad
  24437. */
  24438. id: string;
  24439. /**
  24440. * The index of the gamepad
  24441. */
  24442. index: number;
  24443. /**
  24444. * The browser gamepad
  24445. */
  24446. browserGamepad: any;
  24447. /**
  24448. * Specifies what type of gamepad this represents
  24449. */
  24450. type: number;
  24451. private _leftStick;
  24452. private _rightStick;
  24453. /** @hidden */
  24454. _isConnected: boolean;
  24455. private _leftStickAxisX;
  24456. private _leftStickAxisY;
  24457. private _rightStickAxisX;
  24458. private _rightStickAxisY;
  24459. /**
  24460. * Triggered when the left control stick has been changed
  24461. */
  24462. private _onleftstickchanged;
  24463. /**
  24464. * Triggered when the right control stick has been changed
  24465. */
  24466. private _onrightstickchanged;
  24467. /**
  24468. * Represents a gamepad controller
  24469. */
  24470. static GAMEPAD: number;
  24471. /**
  24472. * Represents a generic controller
  24473. */
  24474. static GENERIC: number;
  24475. /**
  24476. * Represents an XBox controller
  24477. */
  24478. static XBOX: number;
  24479. /**
  24480. * Represents a pose-enabled controller
  24481. */
  24482. static POSE_ENABLED: number;
  24483. /**
  24484. * Represents an Dual Shock controller
  24485. */
  24486. static DUALSHOCK: number;
  24487. /**
  24488. * Specifies whether the left control stick should be Y-inverted
  24489. */
  24490. protected _invertLeftStickY: boolean;
  24491. /**
  24492. * Specifies if the gamepad has been connected
  24493. */
  24494. get isConnected(): boolean;
  24495. /**
  24496. * Initializes the gamepad
  24497. * @param id The id of the gamepad
  24498. * @param index The index of the gamepad
  24499. * @param browserGamepad The browser gamepad
  24500. * @param leftStickX The x component of the left joystick
  24501. * @param leftStickY The y component of the left joystick
  24502. * @param rightStickX The x component of the right joystick
  24503. * @param rightStickY The y component of the right joystick
  24504. */
  24505. constructor(
  24506. /**
  24507. * The id of the gamepad
  24508. */
  24509. id: string,
  24510. /**
  24511. * The index of the gamepad
  24512. */
  24513. index: number,
  24514. /**
  24515. * The browser gamepad
  24516. */
  24517. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24518. /**
  24519. * Callback triggered when the left joystick has changed
  24520. * @param callback
  24521. */
  24522. onleftstickchanged(callback: (values: StickValues) => void): void;
  24523. /**
  24524. * Callback triggered when the right joystick has changed
  24525. * @param callback
  24526. */
  24527. onrightstickchanged(callback: (values: StickValues) => void): void;
  24528. /**
  24529. * Gets the left joystick
  24530. */
  24531. get leftStick(): StickValues;
  24532. /**
  24533. * Sets the left joystick values
  24534. */
  24535. set leftStick(newValues: StickValues);
  24536. /**
  24537. * Gets the right joystick
  24538. */
  24539. get rightStick(): StickValues;
  24540. /**
  24541. * Sets the right joystick value
  24542. */
  24543. set rightStick(newValues: StickValues);
  24544. /**
  24545. * Updates the gamepad joystick positions
  24546. */
  24547. update(): void;
  24548. /**
  24549. * Disposes the gamepad
  24550. */
  24551. dispose(): void;
  24552. }
  24553. /**
  24554. * Represents a generic gamepad
  24555. */
  24556. export class GenericPad extends Gamepad {
  24557. private _buttons;
  24558. private _onbuttondown;
  24559. private _onbuttonup;
  24560. /**
  24561. * Observable triggered when a button has been pressed
  24562. */
  24563. onButtonDownObservable: Observable<number>;
  24564. /**
  24565. * Observable triggered when a button has been released
  24566. */
  24567. onButtonUpObservable: Observable<number>;
  24568. /**
  24569. * Callback triggered when a button has been pressed
  24570. * @param callback Called when a button has been pressed
  24571. */
  24572. onbuttondown(callback: (buttonPressed: number) => void): void;
  24573. /**
  24574. * Callback triggered when a button has been released
  24575. * @param callback Called when a button has been released
  24576. */
  24577. onbuttonup(callback: (buttonReleased: number) => void): void;
  24578. /**
  24579. * Initializes the generic gamepad
  24580. * @param id The id of the generic gamepad
  24581. * @param index The index of the generic gamepad
  24582. * @param browserGamepad The browser gamepad
  24583. */
  24584. constructor(id: string, index: number, browserGamepad: any);
  24585. private _setButtonValue;
  24586. /**
  24587. * Updates the generic gamepad
  24588. */
  24589. update(): void;
  24590. /**
  24591. * Disposes the generic gamepad
  24592. */
  24593. dispose(): void;
  24594. }
  24595. }
  24596. declare module BABYLON {
  24597. /**
  24598. * Defines a runtime animation
  24599. */
  24600. export class RuntimeAnimation {
  24601. private _events;
  24602. /**
  24603. * The current frame of the runtime animation
  24604. */
  24605. private _currentFrame;
  24606. /**
  24607. * The animation used by the runtime animation
  24608. */
  24609. private _animation;
  24610. /**
  24611. * The target of the runtime animation
  24612. */
  24613. private _target;
  24614. /**
  24615. * The initiating animatable
  24616. */
  24617. private _host;
  24618. /**
  24619. * The original value of the runtime animation
  24620. */
  24621. private _originalValue;
  24622. /**
  24623. * The original blend value of the runtime animation
  24624. */
  24625. private _originalBlendValue;
  24626. /**
  24627. * The offsets cache of the runtime animation
  24628. */
  24629. private _offsetsCache;
  24630. /**
  24631. * The high limits cache of the runtime animation
  24632. */
  24633. private _highLimitsCache;
  24634. /**
  24635. * Specifies if the runtime animation has been stopped
  24636. */
  24637. private _stopped;
  24638. /**
  24639. * The blending factor of the runtime animation
  24640. */
  24641. private _blendingFactor;
  24642. /**
  24643. * The BabylonJS scene
  24644. */
  24645. private _scene;
  24646. /**
  24647. * The current value of the runtime animation
  24648. */
  24649. private _currentValue;
  24650. /** @hidden */
  24651. _animationState: _IAnimationState;
  24652. /**
  24653. * The active target of the runtime animation
  24654. */
  24655. private _activeTargets;
  24656. private _currentActiveTarget;
  24657. private _directTarget;
  24658. /**
  24659. * The target path of the runtime animation
  24660. */
  24661. private _targetPath;
  24662. /**
  24663. * The weight of the runtime animation
  24664. */
  24665. private _weight;
  24666. /**
  24667. * The ratio offset of the runtime animation
  24668. */
  24669. private _ratioOffset;
  24670. /**
  24671. * The previous delay of the runtime animation
  24672. */
  24673. private _previousDelay;
  24674. /**
  24675. * The previous ratio of the runtime animation
  24676. */
  24677. private _previousRatio;
  24678. private _enableBlending;
  24679. private _keys;
  24680. private _minFrame;
  24681. private _maxFrame;
  24682. private _minValue;
  24683. private _maxValue;
  24684. private _targetIsArray;
  24685. /**
  24686. * Gets the current frame of the runtime animation
  24687. */
  24688. get currentFrame(): number;
  24689. /**
  24690. * Gets the weight of the runtime animation
  24691. */
  24692. get weight(): number;
  24693. /**
  24694. * Gets the current value of the runtime animation
  24695. */
  24696. get currentValue(): any;
  24697. /**
  24698. * Gets the target path of the runtime animation
  24699. */
  24700. get targetPath(): string;
  24701. /**
  24702. * Gets the actual target of the runtime animation
  24703. */
  24704. get target(): any;
  24705. /**
  24706. * Gets the additive state of the runtime animation
  24707. */
  24708. get isAdditive(): boolean;
  24709. /** @hidden */
  24710. _onLoop: () => void;
  24711. /**
  24712. * Create a new RuntimeAnimation object
  24713. * @param target defines the target of the animation
  24714. * @param animation defines the source animation object
  24715. * @param scene defines the hosting scene
  24716. * @param host defines the initiating Animatable
  24717. */
  24718. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24719. private _preparePath;
  24720. /**
  24721. * Gets the animation from the runtime animation
  24722. */
  24723. get animation(): Animation;
  24724. /**
  24725. * Resets the runtime animation to the beginning
  24726. * @param restoreOriginal defines whether to restore the target property to the original value
  24727. */
  24728. reset(restoreOriginal?: boolean): void;
  24729. /**
  24730. * Specifies if the runtime animation is stopped
  24731. * @returns Boolean specifying if the runtime animation is stopped
  24732. */
  24733. isStopped(): boolean;
  24734. /**
  24735. * Disposes of the runtime animation
  24736. */
  24737. dispose(): void;
  24738. /**
  24739. * Apply the interpolated value to the target
  24740. * @param currentValue defines the value computed by the animation
  24741. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24742. */
  24743. setValue(currentValue: any, weight: number): void;
  24744. private _getOriginalValues;
  24745. private _setValue;
  24746. /**
  24747. * Gets the loop pmode of the runtime animation
  24748. * @returns Loop Mode
  24749. */
  24750. private _getCorrectLoopMode;
  24751. /**
  24752. * Move the current animation to a given frame
  24753. * @param frame defines the frame to move to
  24754. */
  24755. goToFrame(frame: number): void;
  24756. /**
  24757. * @hidden Internal use only
  24758. */
  24759. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24760. /**
  24761. * Execute the current animation
  24762. * @param delay defines the delay to add to the current frame
  24763. * @param from defines the lower bound of the animation range
  24764. * @param to defines the upper bound of the animation range
  24765. * @param loop defines if the current animation must loop
  24766. * @param speedRatio defines the current speed ratio
  24767. * @param weight defines the weight of the animation (default is -1 so no weight)
  24768. * @param onLoop optional callback called when animation loops
  24769. * @returns a boolean indicating if the animation is running
  24770. */
  24771. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24772. }
  24773. }
  24774. declare module BABYLON {
  24775. /**
  24776. * Class used to store an actual running animation
  24777. */
  24778. export class Animatable {
  24779. /** defines the target object */
  24780. target: any;
  24781. /** defines the starting frame number (default is 0) */
  24782. fromFrame: number;
  24783. /** defines the ending frame number (default is 100) */
  24784. toFrame: number;
  24785. /** defines if the animation must loop (default is false) */
  24786. loopAnimation: boolean;
  24787. /** defines a callback to call when animation ends if it is not looping */
  24788. onAnimationEnd?: (() => void) | null | undefined;
  24789. /** defines a callback to call when animation loops */
  24790. onAnimationLoop?: (() => void) | null | undefined;
  24791. /** defines whether the animation should be evaluated additively */
  24792. isAdditive: boolean;
  24793. private _localDelayOffset;
  24794. private _pausedDelay;
  24795. private _runtimeAnimations;
  24796. private _paused;
  24797. private _scene;
  24798. private _speedRatio;
  24799. private _weight;
  24800. private _syncRoot;
  24801. /**
  24802. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24803. * This will only apply for non looping animation (default is true)
  24804. */
  24805. disposeOnEnd: boolean;
  24806. /**
  24807. * Gets a boolean indicating if the animation has started
  24808. */
  24809. animationStarted: boolean;
  24810. /**
  24811. * Observer raised when the animation ends
  24812. */
  24813. onAnimationEndObservable: Observable<Animatable>;
  24814. /**
  24815. * Observer raised when the animation loops
  24816. */
  24817. onAnimationLoopObservable: Observable<Animatable>;
  24818. /**
  24819. * Gets the root Animatable used to synchronize and normalize animations
  24820. */
  24821. get syncRoot(): Nullable<Animatable>;
  24822. /**
  24823. * Gets the current frame of the first RuntimeAnimation
  24824. * Used to synchronize Animatables
  24825. */
  24826. get masterFrame(): number;
  24827. /**
  24828. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24829. */
  24830. get weight(): number;
  24831. set weight(value: number);
  24832. /**
  24833. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24834. */
  24835. get speedRatio(): number;
  24836. set speedRatio(value: number);
  24837. /**
  24838. * Creates a new Animatable
  24839. * @param scene defines the hosting scene
  24840. * @param target defines the target object
  24841. * @param fromFrame defines the starting frame number (default is 0)
  24842. * @param toFrame defines the ending frame number (default is 100)
  24843. * @param loopAnimation defines if the animation must loop (default is false)
  24844. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24845. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24846. * @param animations defines a group of animation to add to the new Animatable
  24847. * @param onAnimationLoop defines a callback to call when animation loops
  24848. * @param isAdditive defines whether the animation should be evaluated additively
  24849. */
  24850. constructor(scene: Scene,
  24851. /** defines the target object */
  24852. target: any,
  24853. /** defines the starting frame number (default is 0) */
  24854. fromFrame?: number,
  24855. /** defines the ending frame number (default is 100) */
  24856. toFrame?: number,
  24857. /** defines if the animation must loop (default is false) */
  24858. loopAnimation?: boolean, speedRatio?: number,
  24859. /** defines a callback to call when animation ends if it is not looping */
  24860. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24861. /** defines a callback to call when animation loops */
  24862. onAnimationLoop?: (() => void) | null | undefined,
  24863. /** defines whether the animation should be evaluated additively */
  24864. isAdditive?: boolean);
  24865. /**
  24866. * Synchronize and normalize current Animatable with a source Animatable
  24867. * This is useful when using animation weights and when animations are not of the same length
  24868. * @param root defines the root Animatable to synchronize with
  24869. * @returns the current Animatable
  24870. */
  24871. syncWith(root: Animatable): Animatable;
  24872. /**
  24873. * Gets the list of runtime animations
  24874. * @returns an array of RuntimeAnimation
  24875. */
  24876. getAnimations(): RuntimeAnimation[];
  24877. /**
  24878. * Adds more animations to the current animatable
  24879. * @param target defines the target of the animations
  24880. * @param animations defines the new animations to add
  24881. */
  24882. appendAnimations(target: any, animations: Animation[]): void;
  24883. /**
  24884. * Gets the source animation for a specific property
  24885. * @param property defines the propertyu to look for
  24886. * @returns null or the source animation for the given property
  24887. */
  24888. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24889. /**
  24890. * Gets the runtime animation for a specific property
  24891. * @param property defines the propertyu to look for
  24892. * @returns null or the runtime animation for the given property
  24893. */
  24894. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24895. /**
  24896. * Resets the animatable to its original state
  24897. */
  24898. reset(): void;
  24899. /**
  24900. * Allows the animatable to blend with current running animations
  24901. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24902. * @param blendingSpeed defines the blending speed to use
  24903. */
  24904. enableBlending(blendingSpeed: number): void;
  24905. /**
  24906. * Disable animation blending
  24907. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24908. */
  24909. disableBlending(): void;
  24910. /**
  24911. * Jump directly to a given frame
  24912. * @param frame defines the frame to jump to
  24913. */
  24914. goToFrame(frame: number): void;
  24915. /**
  24916. * Pause the animation
  24917. */
  24918. pause(): void;
  24919. /**
  24920. * Restart the animation
  24921. */
  24922. restart(): void;
  24923. private _raiseOnAnimationEnd;
  24924. /**
  24925. * Stop and delete the current animation
  24926. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24927. * @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)
  24928. */
  24929. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24930. /**
  24931. * Wait asynchronously for the animation to end
  24932. * @returns a promise which will be fullfilled when the animation ends
  24933. */
  24934. waitAsync(): Promise<Animatable>;
  24935. /** @hidden */
  24936. _animate(delay: number): boolean;
  24937. }
  24938. interface Scene {
  24939. /** @hidden */
  24940. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24941. /** @hidden */
  24942. _processLateAnimationBindingsForMatrices(holder: {
  24943. totalWeight: number;
  24944. totalAdditiveWeight: number;
  24945. animations: RuntimeAnimation[];
  24946. additiveAnimations: RuntimeAnimation[];
  24947. originalValue: Matrix;
  24948. }): any;
  24949. /** @hidden */
  24950. _processLateAnimationBindingsForQuaternions(holder: {
  24951. totalWeight: number;
  24952. totalAdditiveWeight: number;
  24953. animations: RuntimeAnimation[];
  24954. additiveAnimations: RuntimeAnimation[];
  24955. originalValue: Quaternion;
  24956. }, refQuaternion: Quaternion): Quaternion;
  24957. /** @hidden */
  24958. _processLateAnimationBindings(): void;
  24959. /**
  24960. * Will start the animation sequence of a given target
  24961. * @param target defines the target
  24962. * @param from defines from which frame should animation start
  24963. * @param to defines until which frame should animation run.
  24964. * @param weight defines the weight to apply to the animation (1.0 by default)
  24965. * @param loop defines if the animation loops
  24966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24967. * @param onAnimationEnd defines the function to be executed when the animation ends
  24968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24969. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24970. * @param onAnimationLoop defines the callback to call when an animation loops
  24971. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24972. * @returns the animatable object created for this animation
  24973. */
  24974. 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;
  24975. /**
  24976. * Will start the animation sequence of a given target
  24977. * @param target defines the target
  24978. * @param from defines from which frame should animation start
  24979. * @param to defines until which frame should animation run.
  24980. * @param loop defines if the animation loops
  24981. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24982. * @param onAnimationEnd defines the function to be executed when the animation ends
  24983. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24984. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24985. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24986. * @param onAnimationLoop defines the callback to call when an animation loops
  24987. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  24988. * @returns the animatable object created for this animation
  24989. */
  24990. 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;
  24991. /**
  24992. * Will start the animation sequence of a given target and its hierarchy
  24993. * @param target defines the target
  24994. * @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.
  24995. * @param from defines from which frame should animation start
  24996. * @param to defines until which frame should animation run.
  24997. * @param loop defines if the animation loops
  24998. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24999. * @param onAnimationEnd defines the function to be executed when the animation ends
  25000. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25001. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25002. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25003. * @param onAnimationLoop defines the callback to call when an animation loops
  25004. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25005. * @returns the list of created animatables
  25006. */
  25007. 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[];
  25008. /**
  25009. * Begin a new animation on a given node
  25010. * @param target defines the target where the animation will take place
  25011. * @param animations defines the list of animations to start
  25012. * @param from defines the initial value
  25013. * @param to defines the final value
  25014. * @param loop defines if you want animation to loop (off by default)
  25015. * @param speedRatio defines the speed ratio to apply to all animations
  25016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25017. * @param onAnimationLoop defines the callback to call when an animation loops
  25018. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25019. * @returns the list of created animatables
  25020. */
  25021. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25022. /**
  25023. * Begin a new animation on a given node and its hierarchy
  25024. * @param target defines the root node where the animation will take place
  25025. * @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.
  25026. * @param animations defines the list of animations to start
  25027. * @param from defines the initial value
  25028. * @param to defines the final value
  25029. * @param loop defines if you want animation to loop (off by default)
  25030. * @param speedRatio defines the speed ratio to apply to all animations
  25031. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25032. * @param onAnimationLoop defines the callback to call when an animation loops
  25033. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25034. * @returns the list of animatables created for all nodes
  25035. */
  25036. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25037. /**
  25038. * Gets the animatable associated with a specific target
  25039. * @param target defines the target of the animatable
  25040. * @returns the required animatable if found
  25041. */
  25042. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25043. /**
  25044. * Gets all animatables associated with a given target
  25045. * @param target defines the target to look animatables for
  25046. * @returns an array of Animatables
  25047. */
  25048. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25049. /**
  25050. * Stops and removes all animations that have been applied to the scene
  25051. */
  25052. stopAllAnimations(): void;
  25053. /**
  25054. * Gets the current delta time used by animation engine
  25055. */
  25056. deltaTime: number;
  25057. }
  25058. interface Bone {
  25059. /**
  25060. * Copy an animation range from another bone
  25061. * @param source defines the source bone
  25062. * @param rangeName defines the range name to copy
  25063. * @param frameOffset defines the frame offset
  25064. * @param rescaleAsRequired defines if rescaling must be applied if required
  25065. * @param skelDimensionsRatio defines the scaling ratio
  25066. * @returns true if operation was successful
  25067. */
  25068. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25069. }
  25070. }
  25071. declare module BABYLON {
  25072. /**
  25073. * Class used to override all child animations of a given target
  25074. */
  25075. export class AnimationPropertiesOverride {
  25076. /**
  25077. * Gets or sets a value indicating if animation blending must be used
  25078. */
  25079. enableBlending: boolean;
  25080. /**
  25081. * Gets or sets the blending speed to use when enableBlending is true
  25082. */
  25083. blendingSpeed: number;
  25084. /**
  25085. * Gets or sets the default loop mode to use
  25086. */
  25087. loopMode: number;
  25088. }
  25089. }
  25090. declare module BABYLON {
  25091. /**
  25092. * Class used to handle skinning animations
  25093. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25094. */
  25095. export class Skeleton implements IAnimatable {
  25096. /** defines the skeleton name */
  25097. name: string;
  25098. /** defines the skeleton Id */
  25099. id: string;
  25100. /**
  25101. * Defines the list of child bones
  25102. */
  25103. bones: Bone[];
  25104. /**
  25105. * Defines an estimate of the dimension of the skeleton at rest
  25106. */
  25107. dimensionsAtRest: Vector3;
  25108. /**
  25109. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25110. */
  25111. needInitialSkinMatrix: boolean;
  25112. /**
  25113. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25114. */
  25115. overrideMesh: Nullable<AbstractMesh>;
  25116. /**
  25117. * Gets the list of animations attached to this skeleton
  25118. */
  25119. animations: Array<Animation>;
  25120. private _scene;
  25121. private _isDirty;
  25122. private _transformMatrices;
  25123. private _transformMatrixTexture;
  25124. private _meshesWithPoseMatrix;
  25125. private _animatables;
  25126. private _identity;
  25127. private _synchronizedWithMesh;
  25128. private _ranges;
  25129. private _lastAbsoluteTransformsUpdateId;
  25130. private _canUseTextureForBones;
  25131. private _uniqueId;
  25132. /** @hidden */
  25133. _numBonesWithLinkedTransformNode: number;
  25134. /** @hidden */
  25135. _hasWaitingData: Nullable<boolean>;
  25136. /** @hidden */
  25137. _waitingOverrideMeshId: Nullable<string>;
  25138. /**
  25139. * Specifies if the skeleton should be serialized
  25140. */
  25141. doNotSerialize: boolean;
  25142. private _useTextureToStoreBoneMatrices;
  25143. /**
  25144. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25145. * Please note that this option is not available if the hardware does not support it
  25146. */
  25147. get useTextureToStoreBoneMatrices(): boolean;
  25148. set useTextureToStoreBoneMatrices(value: boolean);
  25149. private _animationPropertiesOverride;
  25150. /**
  25151. * Gets or sets the animation properties override
  25152. */
  25153. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25154. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25155. /**
  25156. * List of inspectable custom properties (used by the Inspector)
  25157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25158. */
  25159. inspectableCustomProperties: IInspectable[];
  25160. /**
  25161. * An observable triggered before computing the skeleton's matrices
  25162. */
  25163. onBeforeComputeObservable: Observable<Skeleton>;
  25164. /**
  25165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25166. */
  25167. get isUsingTextureForMatrices(): boolean;
  25168. /**
  25169. * Gets the unique ID of this skeleton
  25170. */
  25171. get uniqueId(): number;
  25172. /**
  25173. * Creates a new skeleton
  25174. * @param name defines the skeleton name
  25175. * @param id defines the skeleton Id
  25176. * @param scene defines the hosting scene
  25177. */
  25178. constructor(
  25179. /** defines the skeleton name */
  25180. name: string,
  25181. /** defines the skeleton Id */
  25182. id: string, scene: Scene);
  25183. /**
  25184. * Gets the current object class name.
  25185. * @return the class name
  25186. */
  25187. getClassName(): string;
  25188. /**
  25189. * Returns an array containing the root bones
  25190. * @returns an array containing the root bones
  25191. */
  25192. getChildren(): Array<Bone>;
  25193. /**
  25194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25196. * @returns a Float32Array containing matrices data
  25197. */
  25198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25199. /**
  25200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25202. * @returns a raw texture containing the data
  25203. */
  25204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25205. /**
  25206. * Gets the current hosting scene
  25207. * @returns a scene object
  25208. */
  25209. getScene(): Scene;
  25210. /**
  25211. * Gets a string representing the current skeleton data
  25212. * @param fullDetails defines a boolean indicating if we want a verbose version
  25213. * @returns a string representing the current skeleton data
  25214. */
  25215. toString(fullDetails?: boolean): string;
  25216. /**
  25217. * Get bone's index searching by name
  25218. * @param name defines bone's name to search for
  25219. * @return the indice of the bone. Returns -1 if not found
  25220. */
  25221. getBoneIndexByName(name: string): number;
  25222. /**
  25223. * Creater a new animation range
  25224. * @param name defines the name of the range
  25225. * @param from defines the start key
  25226. * @param to defines the end key
  25227. */
  25228. createAnimationRange(name: string, from: number, to: number): void;
  25229. /**
  25230. * Delete a specific animation range
  25231. * @param name defines the name of the range
  25232. * @param deleteFrames defines if frames must be removed as well
  25233. */
  25234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25235. /**
  25236. * Gets a specific animation range
  25237. * @param name defines the name of the range to look for
  25238. * @returns the requested animation range or null if not found
  25239. */
  25240. getAnimationRange(name: string): Nullable<AnimationRange>;
  25241. /**
  25242. * Gets the list of all animation ranges defined on this skeleton
  25243. * @returns an array
  25244. */
  25245. getAnimationRanges(): Nullable<AnimationRange>[];
  25246. /**
  25247. * Copy animation range from a source skeleton.
  25248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25249. * @param source defines the source skeleton
  25250. * @param name defines the name of the range to copy
  25251. * @param rescaleAsRequired defines if rescaling must be applied if required
  25252. * @returns true if operation was successful
  25253. */
  25254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25255. /**
  25256. * Forces the skeleton to go to rest pose
  25257. */
  25258. returnToRest(): void;
  25259. private _getHighestAnimationFrame;
  25260. /**
  25261. * Begin a specific animation range
  25262. * @param name defines the name of the range to start
  25263. * @param loop defines if looping must be turned on (false by default)
  25264. * @param speedRatio defines the speed ratio to apply (1 by default)
  25265. * @param onAnimationEnd defines a callback which will be called when animation will end
  25266. * @returns a new animatable
  25267. */
  25268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25269. /**
  25270. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25271. * @param skeleton defines the Skeleton containing the animation range to convert
  25272. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25273. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25274. * @returns the original skeleton
  25275. */
  25276. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25277. /** @hidden */
  25278. _markAsDirty(): void;
  25279. /** @hidden */
  25280. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25281. /** @hidden */
  25282. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25283. private _computeTransformMatrices;
  25284. /**
  25285. * Build all resources required to render a skeleton
  25286. */
  25287. prepare(): void;
  25288. /**
  25289. * Gets the list of animatables currently running for this skeleton
  25290. * @returns an array of animatables
  25291. */
  25292. getAnimatables(): IAnimatable[];
  25293. /**
  25294. * Clone the current skeleton
  25295. * @param name defines the name of the new skeleton
  25296. * @param id defines the id of the new skeleton
  25297. * @returns the new skeleton
  25298. */
  25299. clone(name: string, id?: string): Skeleton;
  25300. /**
  25301. * Enable animation blending for this skeleton
  25302. * @param blendingSpeed defines the blending speed to apply
  25303. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25304. */
  25305. enableBlending(blendingSpeed?: number): void;
  25306. /**
  25307. * Releases all resources associated with the current skeleton
  25308. */
  25309. dispose(): void;
  25310. /**
  25311. * Serialize the skeleton in a JSON object
  25312. * @returns a JSON object
  25313. */
  25314. serialize(): any;
  25315. /**
  25316. * Creates a new skeleton from serialized data
  25317. * @param parsedSkeleton defines the serialized data
  25318. * @param scene defines the hosting scene
  25319. * @returns a new skeleton
  25320. */
  25321. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25322. /**
  25323. * Compute all node absolute transforms
  25324. * @param forceUpdate defines if computation must be done even if cache is up to date
  25325. */
  25326. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25327. /**
  25328. * Gets the root pose matrix
  25329. * @returns a matrix
  25330. */
  25331. getPoseMatrix(): Nullable<Matrix>;
  25332. /**
  25333. * Sorts bones per internal index
  25334. */
  25335. sortBones(): void;
  25336. private _sortBones;
  25337. /**
  25338. * Set the current local matrix as the restPose for all bones in the skeleton.
  25339. */
  25340. setCurrentPoseAsRest(): void;
  25341. }
  25342. }
  25343. declare module BABYLON {
  25344. /**
  25345. * Class used to store bone information
  25346. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25347. */
  25348. export class Bone extends Node {
  25349. /**
  25350. * defines the bone name
  25351. */
  25352. name: string;
  25353. private static _tmpVecs;
  25354. private static _tmpQuat;
  25355. private static _tmpMats;
  25356. /**
  25357. * Gets the list of child bones
  25358. */
  25359. children: Bone[];
  25360. /** Gets the animations associated with this bone */
  25361. animations: Animation[];
  25362. /**
  25363. * Gets or sets bone length
  25364. */
  25365. length: number;
  25366. /**
  25367. * @hidden Internal only
  25368. * Set this value to map this bone to a different index in the transform matrices
  25369. * Set this value to -1 to exclude the bone from the transform matrices
  25370. */
  25371. _index: Nullable<number>;
  25372. private _skeleton;
  25373. private _localMatrix;
  25374. private _restPose;
  25375. private _bindPose;
  25376. private _baseMatrix;
  25377. private _absoluteTransform;
  25378. private _invertedAbsoluteTransform;
  25379. private _parent;
  25380. private _scalingDeterminant;
  25381. private _worldTransform;
  25382. private _localScaling;
  25383. private _localRotation;
  25384. private _localPosition;
  25385. private _needToDecompose;
  25386. private _needToCompose;
  25387. /** @hidden */
  25388. _linkedTransformNode: Nullable<TransformNode>;
  25389. /** @hidden */
  25390. _waitingTransformNodeId: Nullable<string>;
  25391. /** @hidden */
  25392. get _matrix(): Matrix;
  25393. /** @hidden */
  25394. set _matrix(value: Matrix);
  25395. /**
  25396. * Create a new bone
  25397. * @param name defines the bone name
  25398. * @param skeleton defines the parent skeleton
  25399. * @param parentBone defines the parent (can be null if the bone is the root)
  25400. * @param localMatrix defines the local matrix
  25401. * @param restPose defines the rest pose matrix
  25402. * @param baseMatrix defines the base matrix
  25403. * @param index defines index of the bone in the hiearchy
  25404. */
  25405. constructor(
  25406. /**
  25407. * defines the bone name
  25408. */
  25409. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25410. /**
  25411. * Gets the current object class name.
  25412. * @return the class name
  25413. */
  25414. getClassName(): string;
  25415. /**
  25416. * Gets the parent skeleton
  25417. * @returns a skeleton
  25418. */
  25419. getSkeleton(): Skeleton;
  25420. /**
  25421. * Gets parent bone
  25422. * @returns a bone or null if the bone is the root of the bone hierarchy
  25423. */
  25424. getParent(): Nullable<Bone>;
  25425. /**
  25426. * Returns an array containing the root bones
  25427. * @returns an array containing the root bones
  25428. */
  25429. getChildren(): Array<Bone>;
  25430. /**
  25431. * Gets the node index in matrix array generated for rendering
  25432. * @returns the node index
  25433. */
  25434. getIndex(): number;
  25435. /**
  25436. * Sets the parent bone
  25437. * @param parent defines the parent (can be null if the bone is the root)
  25438. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25439. */
  25440. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25441. /**
  25442. * Gets the local matrix
  25443. * @returns a matrix
  25444. */
  25445. getLocalMatrix(): Matrix;
  25446. /**
  25447. * Gets the base matrix (initial matrix which remains unchanged)
  25448. * @returns a matrix
  25449. */
  25450. getBaseMatrix(): Matrix;
  25451. /**
  25452. * Gets the rest pose matrix
  25453. * @returns a matrix
  25454. */
  25455. getRestPose(): Matrix;
  25456. /**
  25457. * Sets the rest pose matrix
  25458. * @param matrix the local-space rest pose to set for this bone
  25459. */
  25460. setRestPose(matrix: Matrix): void;
  25461. /**
  25462. * Gets the bind pose matrix
  25463. * @returns the bind pose matrix
  25464. */
  25465. getBindPose(): Matrix;
  25466. /**
  25467. * Sets the bind pose matrix
  25468. * @param matrix the local-space bind pose to set for this bone
  25469. */
  25470. setBindPose(matrix: Matrix): void;
  25471. /**
  25472. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25473. */
  25474. getWorldMatrix(): Matrix;
  25475. /**
  25476. * Sets the local matrix to rest pose matrix
  25477. */
  25478. returnToRest(): void;
  25479. /**
  25480. * Gets the inverse of the absolute transform matrix.
  25481. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25482. * @returns a matrix
  25483. */
  25484. getInvertedAbsoluteTransform(): Matrix;
  25485. /**
  25486. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25487. * @returns a matrix
  25488. */
  25489. getAbsoluteTransform(): Matrix;
  25490. /**
  25491. * Links with the given transform node.
  25492. * The local matrix of this bone is copied from the transform node every frame.
  25493. * @param transformNode defines the transform node to link to
  25494. */
  25495. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25496. /**
  25497. * Gets the node used to drive the bone's transformation
  25498. * @returns a transform node or null
  25499. */
  25500. getTransformNode(): Nullable<TransformNode>;
  25501. /** Gets or sets current position (in local space) */
  25502. get position(): Vector3;
  25503. set position(newPosition: Vector3);
  25504. /** Gets or sets current rotation (in local space) */
  25505. get rotation(): Vector3;
  25506. set rotation(newRotation: Vector3);
  25507. /** Gets or sets current rotation quaternion (in local space) */
  25508. get rotationQuaternion(): Quaternion;
  25509. set rotationQuaternion(newRotation: Quaternion);
  25510. /** Gets or sets current scaling (in local space) */
  25511. get scaling(): Vector3;
  25512. set scaling(newScaling: Vector3);
  25513. /**
  25514. * Gets the animation properties override
  25515. */
  25516. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25517. private _decompose;
  25518. private _compose;
  25519. /**
  25520. * Update the base and local matrices
  25521. * @param matrix defines the new base or local matrix
  25522. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25523. * @param updateLocalMatrix defines if the local matrix should be updated
  25524. */
  25525. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25526. /** @hidden */
  25527. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25528. /**
  25529. * Flag the bone as dirty (Forcing it to update everything)
  25530. */
  25531. markAsDirty(): void;
  25532. /** @hidden */
  25533. _markAsDirtyAndCompose(): void;
  25534. private _markAsDirtyAndDecompose;
  25535. /**
  25536. * Translate the bone in local or world space
  25537. * @param vec The amount to translate the bone
  25538. * @param space The space that the translation is in
  25539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25540. */
  25541. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25542. /**
  25543. * Set the postion of the bone in local or world space
  25544. * @param position The position to set the bone
  25545. * @param space The space that the position is in
  25546. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25547. */
  25548. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25549. /**
  25550. * Set the absolute position of the bone (world space)
  25551. * @param position The position to set the bone
  25552. * @param mesh The mesh that this bone is attached to
  25553. */
  25554. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25555. /**
  25556. * Scale the bone on the x, y and z axes (in local space)
  25557. * @param x The amount to scale the bone on the x axis
  25558. * @param y The amount to scale the bone on the y axis
  25559. * @param z The amount to scale the bone on the z axis
  25560. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25561. */
  25562. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25563. /**
  25564. * Set the bone scaling in local space
  25565. * @param scale defines the scaling vector
  25566. */
  25567. setScale(scale: Vector3): void;
  25568. /**
  25569. * Gets the current scaling in local space
  25570. * @returns the current scaling vector
  25571. */
  25572. getScale(): Vector3;
  25573. /**
  25574. * Gets the current scaling in local space and stores it in a target vector
  25575. * @param result defines the target vector
  25576. */
  25577. getScaleToRef(result: Vector3): void;
  25578. /**
  25579. * Set the yaw, pitch, and roll of the bone in local or world space
  25580. * @param yaw The rotation of the bone on the y axis
  25581. * @param pitch The rotation of the bone on the x axis
  25582. * @param roll The rotation of the bone on the z axis
  25583. * @param space The space that the axes of rotation are in
  25584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25585. */
  25586. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25587. /**
  25588. * Add a rotation to the bone on an axis in local or world space
  25589. * @param axis The axis to rotate the bone on
  25590. * @param amount The amount to rotate the bone
  25591. * @param space The space that the axis is in
  25592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25593. */
  25594. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25595. /**
  25596. * Set the rotation of the bone to a particular axis angle in local or world space
  25597. * @param axis The axis to rotate the bone on
  25598. * @param angle The angle that the bone should be rotated to
  25599. * @param space The space that the axis is in
  25600. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25601. */
  25602. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25603. /**
  25604. * Set the euler rotation of the bone in local or world space
  25605. * @param rotation The euler rotation that the bone should be set to
  25606. * @param space The space that the rotation is in
  25607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25608. */
  25609. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25610. /**
  25611. * Set the quaternion rotation of the bone in local or world space
  25612. * @param quat The quaternion rotation that the bone should be set to
  25613. * @param space The space that the rotation is in
  25614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25615. */
  25616. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25617. /**
  25618. * Set the rotation matrix of the bone in local or world space
  25619. * @param rotMat The rotation matrix that the bone should be set to
  25620. * @param space The space that the rotation is in
  25621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25622. */
  25623. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25624. private _rotateWithMatrix;
  25625. private _getNegativeRotationToRef;
  25626. /**
  25627. * Get the position of the bone in local or world space
  25628. * @param space The space that the returned position is in
  25629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25630. * @returns The position of the bone
  25631. */
  25632. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25633. /**
  25634. * Copy the position of the bone to a vector3 in local or world space
  25635. * @param space The space that the returned position is in
  25636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25637. * @param result The vector3 to copy the position to
  25638. */
  25639. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25640. /**
  25641. * Get the absolute position of the bone (world space)
  25642. * @param mesh The mesh that this bone is attached to
  25643. * @returns The absolute position of the bone
  25644. */
  25645. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25646. /**
  25647. * Copy the absolute position of the bone (world space) to the result param
  25648. * @param mesh The mesh that this bone is attached to
  25649. * @param result The vector3 to copy the absolute position to
  25650. */
  25651. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25652. /**
  25653. * Compute the absolute transforms of this bone and its children
  25654. */
  25655. computeAbsoluteTransforms(): void;
  25656. /**
  25657. * Get the world direction from an axis that is in the local space of the bone
  25658. * @param localAxis The local direction that is used to compute the world direction
  25659. * @param mesh The mesh that this bone is attached to
  25660. * @returns The world direction
  25661. */
  25662. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25663. /**
  25664. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25665. * @param localAxis The local direction that is used to compute the world direction
  25666. * @param mesh The mesh that this bone is attached to
  25667. * @param result The vector3 that the world direction will be copied to
  25668. */
  25669. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25670. /**
  25671. * Get the euler rotation of the bone in local or world space
  25672. * @param space The space that the rotation should be in
  25673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25674. * @returns The euler rotation
  25675. */
  25676. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25677. /**
  25678. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25679. * @param space The space that the rotation should be in
  25680. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25681. * @param result The vector3 that the rotation should be copied to
  25682. */
  25683. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25684. /**
  25685. * Get the quaternion rotation of the bone in either local or world space
  25686. * @param space The space that the rotation should be in
  25687. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25688. * @returns The quaternion rotation
  25689. */
  25690. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25691. /**
  25692. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25693. * @param space The space that the rotation should be in
  25694. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25695. * @param result The quaternion that the rotation should be copied to
  25696. */
  25697. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25698. /**
  25699. * Get the rotation matrix of the bone in local or world space
  25700. * @param space The space that the rotation should be in
  25701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25702. * @returns The rotation matrix
  25703. */
  25704. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25705. /**
  25706. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25707. * @param space The space that the rotation should be in
  25708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25709. * @param result The quaternion that the rotation should be copied to
  25710. */
  25711. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25712. /**
  25713. * Get the world position of a point that is in the local space of the bone
  25714. * @param position The local position
  25715. * @param mesh The mesh that this bone is attached to
  25716. * @returns The world position
  25717. */
  25718. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25719. /**
  25720. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25721. * @param position The local position
  25722. * @param mesh The mesh that this bone is attached to
  25723. * @param result The vector3 that the world position should be copied to
  25724. */
  25725. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25726. /**
  25727. * Get the local position of a point that is in world space
  25728. * @param position The world position
  25729. * @param mesh The mesh that this bone is attached to
  25730. * @returns The local position
  25731. */
  25732. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25733. /**
  25734. * Get the local position of a point that is in world space and copy it to the result param
  25735. * @param position The world position
  25736. * @param mesh The mesh that this bone is attached to
  25737. * @param result The vector3 that the local position should be copied to
  25738. */
  25739. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25740. /**
  25741. * Set the current local matrix as the restPose for this bone.
  25742. */
  25743. setCurrentPoseAsRest(): void;
  25744. }
  25745. }
  25746. declare module BABYLON {
  25747. /**
  25748. * 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.
  25749. * @see https://doc.babylonjs.com/how_to/transformnode
  25750. */
  25751. export class TransformNode extends Node {
  25752. /**
  25753. * Object will not rotate to face the camera
  25754. */
  25755. static BILLBOARDMODE_NONE: number;
  25756. /**
  25757. * Object will rotate to face the camera but only on the x axis
  25758. */
  25759. static BILLBOARDMODE_X: number;
  25760. /**
  25761. * Object will rotate to face the camera but only on the y axis
  25762. */
  25763. static BILLBOARDMODE_Y: number;
  25764. /**
  25765. * Object will rotate to face the camera but only on the z axis
  25766. */
  25767. static BILLBOARDMODE_Z: number;
  25768. /**
  25769. * Object will rotate to face the camera
  25770. */
  25771. static BILLBOARDMODE_ALL: number;
  25772. /**
  25773. * Object will rotate to face the camera's position instead of orientation
  25774. */
  25775. static BILLBOARDMODE_USE_POSITION: number;
  25776. private static _TmpRotation;
  25777. private static _TmpScaling;
  25778. private static _TmpTranslation;
  25779. private _forward;
  25780. private _forwardInverted;
  25781. private _up;
  25782. private _right;
  25783. private _rightInverted;
  25784. private _position;
  25785. private _rotation;
  25786. private _rotationQuaternion;
  25787. protected _scaling: Vector3;
  25788. protected _isDirty: boolean;
  25789. private _transformToBoneReferal;
  25790. private _isAbsoluteSynced;
  25791. private _billboardMode;
  25792. /**
  25793. * Gets or sets the billboard mode. Default is 0.
  25794. *
  25795. * | Value | Type | Description |
  25796. * | --- | --- | --- |
  25797. * | 0 | BILLBOARDMODE_NONE | |
  25798. * | 1 | BILLBOARDMODE_X | |
  25799. * | 2 | BILLBOARDMODE_Y | |
  25800. * | 4 | BILLBOARDMODE_Z | |
  25801. * | 7 | BILLBOARDMODE_ALL | |
  25802. *
  25803. */
  25804. get billboardMode(): number;
  25805. set billboardMode(value: number);
  25806. private _preserveParentRotationForBillboard;
  25807. /**
  25808. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25809. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25810. */
  25811. get preserveParentRotationForBillboard(): boolean;
  25812. set preserveParentRotationForBillboard(value: boolean);
  25813. /**
  25814. * 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
  25815. */
  25816. scalingDeterminant: number;
  25817. private _infiniteDistance;
  25818. /**
  25819. * Gets or sets the distance of the object to max, often used by skybox
  25820. */
  25821. get infiniteDistance(): boolean;
  25822. set infiniteDistance(value: boolean);
  25823. /**
  25824. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25825. * By default the system will update normals to compensate
  25826. */
  25827. ignoreNonUniformScaling: boolean;
  25828. /**
  25829. * 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
  25830. */
  25831. reIntegrateRotationIntoRotationQuaternion: boolean;
  25832. /** @hidden */
  25833. _poseMatrix: Nullable<Matrix>;
  25834. /** @hidden */
  25835. _localMatrix: Matrix;
  25836. private _usePivotMatrix;
  25837. private _absolutePosition;
  25838. private _absoluteScaling;
  25839. private _absoluteRotationQuaternion;
  25840. private _pivotMatrix;
  25841. private _pivotMatrixInverse;
  25842. /** @hidden */
  25843. _postMultiplyPivotMatrix: boolean;
  25844. protected _isWorldMatrixFrozen: boolean;
  25845. /** @hidden */
  25846. _indexInSceneTransformNodesArray: number;
  25847. /**
  25848. * An event triggered after the world matrix is updated
  25849. */
  25850. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25851. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25852. /**
  25853. * Gets a string identifying the name of the class
  25854. * @returns "TransformNode" string
  25855. */
  25856. getClassName(): string;
  25857. /**
  25858. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25859. */
  25860. get position(): Vector3;
  25861. set position(newPosition: Vector3);
  25862. /**
  25863. * 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)).
  25864. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25865. */
  25866. get rotation(): Vector3;
  25867. set rotation(newRotation: Vector3);
  25868. /**
  25869. * 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)).
  25870. */
  25871. get scaling(): Vector3;
  25872. set scaling(newScaling: Vector3);
  25873. /**
  25874. * 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).
  25875. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25876. */
  25877. get rotationQuaternion(): Nullable<Quaternion>;
  25878. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25879. /**
  25880. * The forward direction of that transform in world space.
  25881. */
  25882. get forward(): Vector3;
  25883. /**
  25884. * The up direction of that transform in world space.
  25885. */
  25886. get up(): Vector3;
  25887. /**
  25888. * The right direction of that transform in world space.
  25889. */
  25890. get right(): Vector3;
  25891. /**
  25892. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25893. * @param matrix the matrix to copy the pose from
  25894. * @returns this TransformNode.
  25895. */
  25896. updatePoseMatrix(matrix: Matrix): TransformNode;
  25897. /**
  25898. * Returns the mesh Pose matrix.
  25899. * @returns the pose matrix
  25900. */
  25901. getPoseMatrix(): Matrix;
  25902. /** @hidden */
  25903. _isSynchronized(): boolean;
  25904. /** @hidden */
  25905. _initCache(): void;
  25906. /**
  25907. * Flag the transform node as dirty (Forcing it to update everything)
  25908. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25909. * @returns this transform node
  25910. */
  25911. markAsDirty(property: string): TransformNode;
  25912. /**
  25913. * Returns the current mesh absolute position.
  25914. * Returns a Vector3.
  25915. */
  25916. get absolutePosition(): Vector3;
  25917. /**
  25918. * Returns the current mesh absolute scaling.
  25919. * Returns a Vector3.
  25920. */
  25921. get absoluteScaling(): Vector3;
  25922. /**
  25923. * Returns the current mesh absolute rotation.
  25924. * Returns a Quaternion.
  25925. */
  25926. get absoluteRotationQuaternion(): Quaternion;
  25927. /**
  25928. * Sets a new matrix to apply before all other transformation
  25929. * @param matrix defines the transform matrix
  25930. * @returns the current TransformNode
  25931. */
  25932. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25933. /**
  25934. * Sets a new pivot matrix to the current node
  25935. * @param matrix defines the new pivot matrix to use
  25936. * @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
  25937. * @returns the current TransformNode
  25938. */
  25939. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25940. /**
  25941. * Returns the mesh pivot matrix.
  25942. * Default : Identity.
  25943. * @returns the matrix
  25944. */
  25945. getPivotMatrix(): Matrix;
  25946. /**
  25947. * Instantiate (when possible) or clone that node with its hierarchy
  25948. * @param newParent defines the new parent to use for the instance (or clone)
  25949. * @param options defines options to configure how copy is done
  25950. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  25951. * @returns an instance (or a clone) of the current node with its hiearchy
  25952. */
  25953. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25954. doNotInstantiate: boolean;
  25955. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25956. /**
  25957. * Prevents the World matrix to be computed any longer
  25958. * @param newWorldMatrix defines an optional matrix to use as world matrix
  25959. * @returns the TransformNode.
  25960. */
  25961. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  25962. /**
  25963. * Allows back the World matrix computation.
  25964. * @returns the TransformNode.
  25965. */
  25966. unfreezeWorldMatrix(): this;
  25967. /**
  25968. * True if the World matrix has been frozen.
  25969. */
  25970. get isWorldMatrixFrozen(): boolean;
  25971. /**
  25972. * Retuns the mesh absolute position in the World.
  25973. * @returns a Vector3.
  25974. */
  25975. getAbsolutePosition(): Vector3;
  25976. /**
  25977. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  25978. * @param absolutePosition the absolute position to set
  25979. * @returns the TransformNode.
  25980. */
  25981. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  25982. /**
  25983. * Sets the mesh position in its local space.
  25984. * @param vector3 the position to set in localspace
  25985. * @returns the TransformNode.
  25986. */
  25987. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  25988. /**
  25989. * Returns the mesh position in the local space from the current World matrix values.
  25990. * @returns a new Vector3.
  25991. */
  25992. getPositionExpressedInLocalSpace(): Vector3;
  25993. /**
  25994. * Translates the mesh along the passed Vector3 in its local space.
  25995. * @param vector3 the distance to translate in localspace
  25996. * @returns the TransformNode.
  25997. */
  25998. locallyTranslate(vector3: Vector3): TransformNode;
  25999. private static _lookAtVectorCache;
  26000. /**
  26001. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26002. * @param targetPoint the position (must be in same space as current mesh) to look at
  26003. * @param yawCor optional yaw (y-axis) correction in radians
  26004. * @param pitchCor optional pitch (x-axis) correction in radians
  26005. * @param rollCor optional roll (z-axis) correction in radians
  26006. * @param space the choosen space of the target
  26007. * @returns the TransformNode.
  26008. */
  26009. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26010. /**
  26011. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26012. * This Vector3 is expressed in the World space.
  26013. * @param localAxis axis to rotate
  26014. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26015. */
  26016. getDirection(localAxis: Vector3): Vector3;
  26017. /**
  26018. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26019. * localAxis is expressed in the mesh local space.
  26020. * result is computed in the Wordl space from the mesh World matrix.
  26021. * @param localAxis axis to rotate
  26022. * @param result the resulting transformnode
  26023. * @returns this TransformNode.
  26024. */
  26025. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26026. /**
  26027. * Sets this transform node rotation to the given local axis.
  26028. * @param localAxis the axis in local space
  26029. * @param yawCor optional yaw (y-axis) correction in radians
  26030. * @param pitchCor optional pitch (x-axis) correction in radians
  26031. * @param rollCor optional roll (z-axis) correction in radians
  26032. * @returns this TransformNode
  26033. */
  26034. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26035. /**
  26036. * Sets a new pivot point to the current node
  26037. * @param point defines the new pivot point to use
  26038. * @param space defines if the point is in world or local space (local by default)
  26039. * @returns the current TransformNode
  26040. */
  26041. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26042. /**
  26043. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26044. * @returns the pivot point
  26045. */
  26046. getPivotPoint(): Vector3;
  26047. /**
  26048. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26049. * @param result the vector3 to store the result
  26050. * @returns this TransformNode.
  26051. */
  26052. getPivotPointToRef(result: Vector3): TransformNode;
  26053. /**
  26054. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26055. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26056. */
  26057. getAbsolutePivotPoint(): Vector3;
  26058. /**
  26059. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26060. * @param result vector3 to store the result
  26061. * @returns this TransformNode.
  26062. */
  26063. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26064. /**
  26065. * Defines the passed node as the parent of the current node.
  26066. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26067. * @see https://doc.babylonjs.com/how_to/parenting
  26068. * @param node the node ot set as the parent
  26069. * @returns this TransformNode.
  26070. */
  26071. setParent(node: Nullable<Node>): TransformNode;
  26072. private _nonUniformScaling;
  26073. /**
  26074. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26075. */
  26076. get nonUniformScaling(): boolean;
  26077. /** @hidden */
  26078. _updateNonUniformScalingState(value: boolean): boolean;
  26079. /**
  26080. * Attach the current TransformNode to another TransformNode associated with a bone
  26081. * @param bone Bone affecting the TransformNode
  26082. * @param affectedTransformNode TransformNode associated with the bone
  26083. * @returns this object
  26084. */
  26085. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26086. /**
  26087. * Detach the transform node if its associated with a bone
  26088. * @returns this object
  26089. */
  26090. detachFromBone(): TransformNode;
  26091. private static _rotationAxisCache;
  26092. /**
  26093. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26094. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26095. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26096. * The passed axis is also normalized.
  26097. * @param axis the axis to rotate around
  26098. * @param amount the amount to rotate in radians
  26099. * @param space Space to rotate in (Default: local)
  26100. * @returns the TransformNode.
  26101. */
  26102. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26103. /**
  26104. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26105. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26106. * The passed axis is also normalized. .
  26107. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26108. * @param point the point to rotate around
  26109. * @param axis the axis to rotate around
  26110. * @param amount the amount to rotate in radians
  26111. * @returns the TransformNode
  26112. */
  26113. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26114. /**
  26115. * Translates the mesh along the axis vector for the passed distance in the given space.
  26116. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26117. * @param axis the axis to translate in
  26118. * @param distance the distance to translate
  26119. * @param space Space to rotate in (Default: local)
  26120. * @returns the TransformNode.
  26121. */
  26122. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26123. /**
  26124. * Adds a rotation step to the mesh current rotation.
  26125. * x, y, z are Euler angles expressed in radians.
  26126. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26127. * This means this rotation is made in the mesh local space only.
  26128. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26129. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26130. * ```javascript
  26131. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26132. * ```
  26133. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26134. * 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.
  26135. * @param x Rotation to add
  26136. * @param y Rotation to add
  26137. * @param z Rotation to add
  26138. * @returns the TransformNode.
  26139. */
  26140. addRotation(x: number, y: number, z: number): TransformNode;
  26141. /**
  26142. * @hidden
  26143. */
  26144. protected _getEffectiveParent(): Nullable<Node>;
  26145. /**
  26146. * Computes the world matrix of the node
  26147. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26148. * @returns the world matrix
  26149. */
  26150. computeWorldMatrix(force?: boolean): Matrix;
  26151. /**
  26152. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26153. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26154. */
  26155. resetLocalMatrix(independentOfChildren?: boolean): void;
  26156. protected _afterComputeWorldMatrix(): void;
  26157. /**
  26158. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26159. * @param func callback function to add
  26160. *
  26161. * @returns the TransformNode.
  26162. */
  26163. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26164. /**
  26165. * Removes a registered callback function.
  26166. * @param func callback function to remove
  26167. * @returns the TransformNode.
  26168. */
  26169. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26170. /**
  26171. * Gets the position of the current mesh in camera space
  26172. * @param camera defines the camera to use
  26173. * @returns a position
  26174. */
  26175. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26176. /**
  26177. * Returns the distance from the mesh to the active camera
  26178. * @param camera defines the camera to use
  26179. * @returns the distance
  26180. */
  26181. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26182. /**
  26183. * Clone the current transform node
  26184. * @param name Name of the new clone
  26185. * @param newParent New parent for the clone
  26186. * @param doNotCloneChildren Do not clone children hierarchy
  26187. * @returns the new transform node
  26188. */
  26189. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26190. /**
  26191. * Serializes the objects information.
  26192. * @param currentSerializationObject defines the object to serialize in
  26193. * @returns the serialized object
  26194. */
  26195. serialize(currentSerializationObject?: any): any;
  26196. /**
  26197. * Returns a new TransformNode object parsed from the source provided.
  26198. * @param parsedTransformNode is the source.
  26199. * @param scene the scne the object belongs to
  26200. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26201. * @returns a new TransformNode object parsed from the source provided.
  26202. */
  26203. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26204. /**
  26205. * Get all child-transformNodes of this node
  26206. * @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
  26207. * @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
  26208. * @returns an array of TransformNode
  26209. */
  26210. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26211. /**
  26212. * Releases resources associated with this transform node.
  26213. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26214. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26215. */
  26216. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26217. /**
  26218. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26219. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26220. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26221. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26222. * @returns the current mesh
  26223. */
  26224. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26225. private _syncAbsoluteScalingAndRotation;
  26226. }
  26227. }
  26228. declare module BABYLON {
  26229. /**
  26230. * Defines the types of pose enabled controllers that are supported
  26231. */
  26232. export enum PoseEnabledControllerType {
  26233. /**
  26234. * HTC Vive
  26235. */
  26236. VIVE = 0,
  26237. /**
  26238. * Oculus Rift
  26239. */
  26240. OCULUS = 1,
  26241. /**
  26242. * Windows mixed reality
  26243. */
  26244. WINDOWS = 2,
  26245. /**
  26246. * Samsung gear VR
  26247. */
  26248. GEAR_VR = 3,
  26249. /**
  26250. * Google Daydream
  26251. */
  26252. DAYDREAM = 4,
  26253. /**
  26254. * Generic
  26255. */
  26256. GENERIC = 5
  26257. }
  26258. /**
  26259. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26260. */
  26261. export interface MutableGamepadButton {
  26262. /**
  26263. * Value of the button/trigger
  26264. */
  26265. value: number;
  26266. /**
  26267. * If the button/trigger is currently touched
  26268. */
  26269. touched: boolean;
  26270. /**
  26271. * If the button/trigger is currently pressed
  26272. */
  26273. pressed: boolean;
  26274. }
  26275. /**
  26276. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26277. * @hidden
  26278. */
  26279. export interface ExtendedGamepadButton extends GamepadButton {
  26280. /**
  26281. * If the button/trigger is currently pressed
  26282. */
  26283. readonly pressed: boolean;
  26284. /**
  26285. * If the button/trigger is currently touched
  26286. */
  26287. readonly touched: boolean;
  26288. /**
  26289. * Value of the button/trigger
  26290. */
  26291. readonly value: number;
  26292. }
  26293. /** @hidden */
  26294. export interface _GamePadFactory {
  26295. /**
  26296. * Returns whether or not the current gamepad can be created for this type of controller.
  26297. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26298. * @returns true if it can be created, otherwise false
  26299. */
  26300. canCreate(gamepadInfo: any): boolean;
  26301. /**
  26302. * Creates a new instance of the Gamepad.
  26303. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26304. * @returns the new gamepad instance
  26305. */
  26306. create(gamepadInfo: any): Gamepad;
  26307. }
  26308. /**
  26309. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26310. */
  26311. export class PoseEnabledControllerHelper {
  26312. /** @hidden */
  26313. static _ControllerFactories: _GamePadFactory[];
  26314. /** @hidden */
  26315. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26316. /**
  26317. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26318. * @param vrGamepad the gamepad to initialized
  26319. * @returns a vr controller of the type the gamepad identified as
  26320. */
  26321. static InitiateController(vrGamepad: any): Gamepad;
  26322. }
  26323. /**
  26324. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26325. */
  26326. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26327. /**
  26328. * If the controller is used in a webXR session
  26329. */
  26330. isXR: boolean;
  26331. private _deviceRoomPosition;
  26332. private _deviceRoomRotationQuaternion;
  26333. /**
  26334. * The device position in babylon space
  26335. */
  26336. devicePosition: Vector3;
  26337. /**
  26338. * The device rotation in babylon space
  26339. */
  26340. deviceRotationQuaternion: Quaternion;
  26341. /**
  26342. * The scale factor of the device in babylon space
  26343. */
  26344. deviceScaleFactor: number;
  26345. /**
  26346. * (Likely devicePosition should be used instead) The device position in its room space
  26347. */
  26348. position: Vector3;
  26349. /**
  26350. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26351. */
  26352. rotationQuaternion: Quaternion;
  26353. /**
  26354. * The type of controller (Eg. Windows mixed reality)
  26355. */
  26356. controllerType: PoseEnabledControllerType;
  26357. protected _calculatedPosition: Vector3;
  26358. private _calculatedRotation;
  26359. /**
  26360. * The raw pose from the device
  26361. */
  26362. rawPose: DevicePose;
  26363. private _trackPosition;
  26364. private _maxRotationDistFromHeadset;
  26365. private _draggedRoomRotation;
  26366. /**
  26367. * @hidden
  26368. */
  26369. _disableTrackPosition(fixedPosition: Vector3): void;
  26370. /**
  26371. * Internal, the mesh attached to the controller
  26372. * @hidden
  26373. */
  26374. _mesh: Nullable<AbstractMesh>;
  26375. private _poseControlledCamera;
  26376. private _leftHandSystemQuaternion;
  26377. /**
  26378. * Internal, matrix used to convert room space to babylon space
  26379. * @hidden
  26380. */
  26381. _deviceToWorld: Matrix;
  26382. /**
  26383. * Node to be used when casting a ray from the controller
  26384. * @hidden
  26385. */
  26386. _pointingPoseNode: Nullable<TransformNode>;
  26387. /**
  26388. * Name of the child mesh that can be used to cast a ray from the controller
  26389. */
  26390. static readonly POINTING_POSE: string;
  26391. /**
  26392. * Creates a new PoseEnabledController from a gamepad
  26393. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26394. */
  26395. constructor(browserGamepad: any);
  26396. private _workingMatrix;
  26397. /**
  26398. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26399. */
  26400. update(): void;
  26401. /**
  26402. * Updates only the pose device and mesh without doing any button event checking
  26403. */
  26404. protected _updatePoseAndMesh(): void;
  26405. /**
  26406. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26407. * @param poseData raw pose fromthe device
  26408. */
  26409. updateFromDevice(poseData: DevicePose): void;
  26410. /**
  26411. * @hidden
  26412. */
  26413. _meshAttachedObservable: Observable<AbstractMesh>;
  26414. /**
  26415. * Attaches a mesh to the controller
  26416. * @param mesh the mesh to be attached
  26417. */
  26418. attachToMesh(mesh: AbstractMesh): void;
  26419. /**
  26420. * Attaches the controllers mesh to a camera
  26421. * @param camera the camera the mesh should be attached to
  26422. */
  26423. attachToPoseControlledCamera(camera: TargetCamera): void;
  26424. /**
  26425. * Disposes of the controller
  26426. */
  26427. dispose(): void;
  26428. /**
  26429. * The mesh that is attached to the controller
  26430. */
  26431. get mesh(): Nullable<AbstractMesh>;
  26432. /**
  26433. * Gets the ray of the controller in the direction the controller is pointing
  26434. * @param length the length the resulting ray should be
  26435. * @returns a ray in the direction the controller is pointing
  26436. */
  26437. getForwardRay(length?: number): Ray;
  26438. }
  26439. }
  26440. declare module BABYLON {
  26441. /**
  26442. * Defines the WebVRController object that represents controllers tracked in 3D space
  26443. */
  26444. export abstract class WebVRController extends PoseEnabledController {
  26445. /**
  26446. * Internal, the default controller model for the controller
  26447. */
  26448. protected _defaultModel: Nullable<AbstractMesh>;
  26449. /**
  26450. * Fired when the trigger state has changed
  26451. */
  26452. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26453. /**
  26454. * Fired when the main button state has changed
  26455. */
  26456. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26457. /**
  26458. * Fired when the secondary button state has changed
  26459. */
  26460. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26461. /**
  26462. * Fired when the pad state has changed
  26463. */
  26464. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26465. /**
  26466. * Fired when controllers stick values have changed
  26467. */
  26468. onPadValuesChangedObservable: Observable<StickValues>;
  26469. /**
  26470. * Array of button availible on the controller
  26471. */
  26472. protected _buttons: Array<MutableGamepadButton>;
  26473. private _onButtonStateChange;
  26474. /**
  26475. * Fired when a controller button's state has changed
  26476. * @param callback the callback containing the button that was modified
  26477. */
  26478. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26479. /**
  26480. * X and Y axis corresponding to the controllers joystick
  26481. */
  26482. pad: StickValues;
  26483. /**
  26484. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26485. */
  26486. hand: string;
  26487. /**
  26488. * The default controller model for the controller
  26489. */
  26490. get defaultModel(): Nullable<AbstractMesh>;
  26491. /**
  26492. * Creates a new WebVRController from a gamepad
  26493. * @param vrGamepad the gamepad that the WebVRController should be created from
  26494. */
  26495. constructor(vrGamepad: any);
  26496. /**
  26497. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26498. */
  26499. update(): void;
  26500. /**
  26501. * Function to be called when a button is modified
  26502. */
  26503. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26504. /**
  26505. * Loads a mesh and attaches it to the controller
  26506. * @param scene the scene the mesh should be added to
  26507. * @param meshLoaded callback for when the mesh has been loaded
  26508. */
  26509. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26510. private _setButtonValue;
  26511. private _changes;
  26512. private _checkChanges;
  26513. /**
  26514. * Disposes of th webVRCOntroller
  26515. */
  26516. dispose(): void;
  26517. }
  26518. }
  26519. declare module BABYLON {
  26520. /**
  26521. * The HemisphericLight simulates the ambient environment light,
  26522. * so the passed direction is the light reflection direction, not the incoming direction.
  26523. */
  26524. export class HemisphericLight extends Light {
  26525. /**
  26526. * The groundColor is the light in the opposite direction to the one specified during creation.
  26527. * 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.
  26528. */
  26529. groundColor: Color3;
  26530. /**
  26531. * The light reflection direction, not the incoming direction.
  26532. */
  26533. direction: Vector3;
  26534. /**
  26535. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26536. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26537. * The HemisphericLight can't cast shadows.
  26538. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26539. * @param name The friendly name of the light
  26540. * @param direction The direction of the light reflection
  26541. * @param scene The scene the light belongs to
  26542. */
  26543. constructor(name: string, direction: Vector3, scene: Scene);
  26544. protected _buildUniformLayout(): void;
  26545. /**
  26546. * Returns the string "HemisphericLight".
  26547. * @return The class name
  26548. */
  26549. getClassName(): string;
  26550. /**
  26551. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26552. * Returns the updated direction.
  26553. * @param target The target the direction should point to
  26554. * @return The computed direction
  26555. */
  26556. setDirectionToTarget(target: Vector3): Vector3;
  26557. /**
  26558. * Returns the shadow generator associated to the light.
  26559. * @returns Always null for hemispheric lights because it does not support shadows.
  26560. */
  26561. getShadowGenerator(): Nullable<IShadowGenerator>;
  26562. /**
  26563. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26564. * @param effect The effect to update
  26565. * @param lightIndex The index of the light in the effect to update
  26566. * @returns The hemispheric light
  26567. */
  26568. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26569. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26570. /**
  26571. * Computes the world matrix of the node
  26572. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26573. * @param useWasUpdatedFlag defines a reserved property
  26574. * @returns the world matrix
  26575. */
  26576. computeWorldMatrix(): Matrix;
  26577. /**
  26578. * Returns the integer 3.
  26579. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26580. */
  26581. getTypeID(): number;
  26582. /**
  26583. * Prepares the list of defines specific to the light type.
  26584. * @param defines the list of defines
  26585. * @param lightIndex defines the index of the light for the effect
  26586. */
  26587. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26588. }
  26589. }
  26590. declare module BABYLON {
  26591. /** @hidden */
  26592. export var vrMultiviewToSingleviewPixelShader: {
  26593. name: string;
  26594. shader: string;
  26595. };
  26596. }
  26597. declare module BABYLON {
  26598. /**
  26599. * Renders to multiple views with a single draw call
  26600. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26601. */
  26602. export class MultiviewRenderTarget extends RenderTargetTexture {
  26603. /**
  26604. * Creates a multiview render target
  26605. * @param scene scene used with the render target
  26606. * @param size the size of the render target (used for each view)
  26607. */
  26608. constructor(scene: Scene, size?: number | {
  26609. width: number;
  26610. height: number;
  26611. } | {
  26612. ratio: number;
  26613. });
  26614. /**
  26615. * @hidden
  26616. * @param faceIndex the face index, if its a cube texture
  26617. */
  26618. _bindFrameBuffer(faceIndex?: number): void;
  26619. /**
  26620. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26621. * @returns the view count
  26622. */
  26623. getViewCount(): number;
  26624. }
  26625. }
  26626. declare module BABYLON {
  26627. interface Engine {
  26628. /**
  26629. * Creates a new multiview render target
  26630. * @param width defines the width of the texture
  26631. * @param height defines the height of the texture
  26632. * @returns the created multiview texture
  26633. */
  26634. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26635. /**
  26636. * Binds a multiview framebuffer to be drawn to
  26637. * @param multiviewTexture texture to bind
  26638. */
  26639. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26640. }
  26641. interface Camera {
  26642. /**
  26643. * @hidden
  26644. * 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)
  26645. */
  26646. _useMultiviewToSingleView: boolean;
  26647. /**
  26648. * @hidden
  26649. * 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)
  26650. */
  26651. _multiviewTexture: Nullable<RenderTargetTexture>;
  26652. /**
  26653. * @hidden
  26654. * ensures the multiview texture of the camera exists and has the specified width/height
  26655. * @param width height to set on the multiview texture
  26656. * @param height width to set on the multiview texture
  26657. */
  26658. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26659. }
  26660. interface Scene {
  26661. /** @hidden */
  26662. _transformMatrixR: Matrix;
  26663. /** @hidden */
  26664. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26665. /** @hidden */
  26666. _createMultiviewUbo(): void;
  26667. /** @hidden */
  26668. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26669. /** @hidden */
  26670. _renderMultiviewToSingleView(camera: Camera): void;
  26671. }
  26672. }
  26673. declare module BABYLON {
  26674. /**
  26675. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26676. * This will not be used for webXR as it supports displaying texture arrays directly
  26677. */
  26678. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26679. /**
  26680. * Gets a string identifying the name of the class
  26681. * @returns "VRMultiviewToSingleviewPostProcess" string
  26682. */
  26683. getClassName(): string;
  26684. /**
  26685. * Initializes a VRMultiviewToSingleview
  26686. * @param name name of the post process
  26687. * @param camera camera to be applied to
  26688. * @param scaleFactor scaling factor to the size of the output texture
  26689. */
  26690. constructor(name: string, camera: Camera, scaleFactor: number);
  26691. }
  26692. }
  26693. declare module BABYLON {
  26694. /**
  26695. * Interface used to define additional presentation attributes
  26696. */
  26697. export interface IVRPresentationAttributes {
  26698. /**
  26699. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26700. */
  26701. highRefreshRate: boolean;
  26702. /**
  26703. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26704. */
  26705. foveationLevel: number;
  26706. }
  26707. interface Engine {
  26708. /** @hidden */
  26709. _vrDisplay: any;
  26710. /** @hidden */
  26711. _vrSupported: boolean;
  26712. /** @hidden */
  26713. _oldSize: Size;
  26714. /** @hidden */
  26715. _oldHardwareScaleFactor: number;
  26716. /** @hidden */
  26717. _vrExclusivePointerMode: boolean;
  26718. /** @hidden */
  26719. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26720. /** @hidden */
  26721. _onVRDisplayPointerRestricted: () => void;
  26722. /** @hidden */
  26723. _onVRDisplayPointerUnrestricted: () => void;
  26724. /** @hidden */
  26725. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26726. /** @hidden */
  26727. _onVrDisplayDisconnect: Nullable<() => void>;
  26728. /** @hidden */
  26729. _onVrDisplayPresentChange: Nullable<() => void>;
  26730. /**
  26731. * Observable signaled when VR display mode changes
  26732. */
  26733. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26734. /**
  26735. * Observable signaled when VR request present is complete
  26736. */
  26737. onVRRequestPresentComplete: Observable<boolean>;
  26738. /**
  26739. * Observable signaled when VR request present starts
  26740. */
  26741. onVRRequestPresentStart: Observable<Engine>;
  26742. /**
  26743. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26744. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26745. */
  26746. isInVRExclusivePointerMode: boolean;
  26747. /**
  26748. * Gets a boolean indicating if a webVR device was detected
  26749. * @returns true if a webVR device was detected
  26750. */
  26751. isVRDevicePresent(): boolean;
  26752. /**
  26753. * Gets the current webVR device
  26754. * @returns the current webVR device (or null)
  26755. */
  26756. getVRDevice(): any;
  26757. /**
  26758. * Initializes a webVR display and starts listening to display change events
  26759. * The onVRDisplayChangedObservable will be notified upon these changes
  26760. * @returns A promise containing a VRDisplay and if vr is supported
  26761. */
  26762. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26763. /** @hidden */
  26764. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26765. /**
  26766. * Gets or sets the presentation attributes used to configure VR rendering
  26767. */
  26768. vrPresentationAttributes?: IVRPresentationAttributes;
  26769. /**
  26770. * Call this function to switch to webVR mode
  26771. * Will do nothing if webVR is not supported or if there is no webVR device
  26772. * @param options the webvr options provided to the camera. mainly used for multiview
  26773. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26774. */
  26775. enableVR(options: WebVROptions): void;
  26776. /** @hidden */
  26777. _onVRFullScreenTriggered(): void;
  26778. }
  26779. }
  26780. declare module BABYLON {
  26781. /**
  26782. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26783. * IMPORTANT!! The data is right-hand data.
  26784. * @export
  26785. * @interface DevicePose
  26786. */
  26787. export interface DevicePose {
  26788. /**
  26789. * The position of the device, values in array are [x,y,z].
  26790. */
  26791. readonly position: Nullable<Float32Array>;
  26792. /**
  26793. * The linearVelocity of the device, values in array are [x,y,z].
  26794. */
  26795. readonly linearVelocity: Nullable<Float32Array>;
  26796. /**
  26797. * The linearAcceleration of the device, values in array are [x,y,z].
  26798. */
  26799. readonly linearAcceleration: Nullable<Float32Array>;
  26800. /**
  26801. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26802. */
  26803. readonly orientation: Nullable<Float32Array>;
  26804. /**
  26805. * The angularVelocity of the device, values in array are [x,y,z].
  26806. */
  26807. readonly angularVelocity: Nullable<Float32Array>;
  26808. /**
  26809. * The angularAcceleration of the device, values in array are [x,y,z].
  26810. */
  26811. readonly angularAcceleration: Nullable<Float32Array>;
  26812. }
  26813. /**
  26814. * Interface representing a pose controlled object in Babylon.
  26815. * A pose controlled object has both regular pose values as well as pose values
  26816. * from an external device such as a VR head mounted display
  26817. */
  26818. export interface PoseControlled {
  26819. /**
  26820. * The position of the object in babylon space.
  26821. */
  26822. position: Vector3;
  26823. /**
  26824. * The rotation quaternion of the object in babylon space.
  26825. */
  26826. rotationQuaternion: Quaternion;
  26827. /**
  26828. * The position of the device in babylon space.
  26829. */
  26830. devicePosition?: Vector3;
  26831. /**
  26832. * The rotation quaternion of the device in babylon space.
  26833. */
  26834. deviceRotationQuaternion: Quaternion;
  26835. /**
  26836. * The raw pose coming from the device.
  26837. */
  26838. rawPose: Nullable<DevicePose>;
  26839. /**
  26840. * The scale of the device to be used when translating from device space to babylon space.
  26841. */
  26842. deviceScaleFactor: number;
  26843. /**
  26844. * Updates the poseControlled values based on the input device pose.
  26845. * @param poseData the pose data to update the object with
  26846. */
  26847. updateFromDevice(poseData: DevicePose): void;
  26848. }
  26849. /**
  26850. * Set of options to customize the webVRCamera
  26851. */
  26852. export interface WebVROptions {
  26853. /**
  26854. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26855. */
  26856. trackPosition?: boolean;
  26857. /**
  26858. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26859. */
  26860. positionScale?: number;
  26861. /**
  26862. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26863. */
  26864. displayName?: string;
  26865. /**
  26866. * Should the native controller meshes be initialized. (default: true)
  26867. */
  26868. controllerMeshes?: boolean;
  26869. /**
  26870. * Creating a default HemiLight only on controllers. (default: true)
  26871. */
  26872. defaultLightingOnControllers?: boolean;
  26873. /**
  26874. * If you don't want to use the default VR button of the helper. (default: false)
  26875. */
  26876. useCustomVRButton?: boolean;
  26877. /**
  26878. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26879. */
  26880. customVRButton?: HTMLButtonElement;
  26881. /**
  26882. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26883. */
  26884. rayLength?: number;
  26885. /**
  26886. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26887. */
  26888. defaultHeight?: number;
  26889. /**
  26890. * If multiview should be used if availible (default: false)
  26891. */
  26892. useMultiview?: boolean;
  26893. }
  26894. /**
  26895. * This represents a WebVR camera.
  26896. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26897. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26898. */
  26899. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26900. private webVROptions;
  26901. /**
  26902. * @hidden
  26903. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26904. */
  26905. _vrDevice: any;
  26906. /**
  26907. * The rawPose of the vrDevice.
  26908. */
  26909. rawPose: Nullable<DevicePose>;
  26910. private _onVREnabled;
  26911. private _specsVersion;
  26912. private _attached;
  26913. private _frameData;
  26914. protected _descendants: Array<Node>;
  26915. private _deviceRoomPosition;
  26916. /** @hidden */
  26917. _deviceRoomRotationQuaternion: Quaternion;
  26918. private _standingMatrix;
  26919. /**
  26920. * Represents device position in babylon space.
  26921. */
  26922. devicePosition: Vector3;
  26923. /**
  26924. * Represents device rotation in babylon space.
  26925. */
  26926. deviceRotationQuaternion: Quaternion;
  26927. /**
  26928. * The scale of the device to be used when translating from device space to babylon space.
  26929. */
  26930. deviceScaleFactor: number;
  26931. private _deviceToWorld;
  26932. private _worldToDevice;
  26933. /**
  26934. * References to the webVR controllers for the vrDevice.
  26935. */
  26936. controllers: Array<WebVRController>;
  26937. /**
  26938. * Emits an event when a controller is attached.
  26939. */
  26940. onControllersAttachedObservable: Observable<WebVRController[]>;
  26941. /**
  26942. * Emits an event when a controller's mesh has been loaded;
  26943. */
  26944. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26945. /**
  26946. * Emits an event when the HMD's pose has been updated.
  26947. */
  26948. onPoseUpdatedFromDeviceObservable: Observable<any>;
  26949. private _poseSet;
  26950. /**
  26951. * If the rig cameras be used as parent instead of this camera.
  26952. */
  26953. rigParenting: boolean;
  26954. private _lightOnControllers;
  26955. private _defaultHeight?;
  26956. /**
  26957. * Instantiates a WebVRFreeCamera.
  26958. * @param name The name of the WebVRFreeCamera
  26959. * @param position The starting anchor position for the camera
  26960. * @param scene The scene the camera belongs to
  26961. * @param webVROptions a set of customizable options for the webVRCamera
  26962. */
  26963. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  26964. /**
  26965. * Gets the device distance from the ground in meters.
  26966. * @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.
  26967. */
  26968. deviceDistanceToRoomGround(): number;
  26969. /**
  26970. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26971. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  26972. */
  26973. useStandingMatrix(callback?: (bool: boolean) => void): void;
  26974. /**
  26975. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  26976. * @returns A promise with a boolean set to if the standing matrix is supported.
  26977. */
  26978. useStandingMatrixAsync(): Promise<boolean>;
  26979. /**
  26980. * Disposes the camera
  26981. */
  26982. dispose(): void;
  26983. /**
  26984. * Gets a vrController by name.
  26985. * @param name The name of the controller to retreive
  26986. * @returns the controller matching the name specified or null if not found
  26987. */
  26988. getControllerByName(name: string): Nullable<WebVRController>;
  26989. private _leftController;
  26990. /**
  26991. * The controller corresponding to the users left hand.
  26992. */
  26993. get leftController(): Nullable<WebVRController>;
  26994. private _rightController;
  26995. /**
  26996. * The controller corresponding to the users right hand.
  26997. */
  26998. get rightController(): Nullable<WebVRController>;
  26999. /**
  27000. * Casts a ray forward from the vrCamera's gaze.
  27001. * @param length Length of the ray (default: 100)
  27002. * @returns the ray corresponding to the gaze
  27003. */
  27004. getForwardRay(length?: number): Ray;
  27005. /**
  27006. * @hidden
  27007. * Updates the camera based on device's frame data
  27008. */
  27009. _checkInputs(): void;
  27010. /**
  27011. * Updates the poseControlled values based on the input device pose.
  27012. * @param poseData Pose coming from the device
  27013. */
  27014. updateFromDevice(poseData: DevicePose): void;
  27015. private _detachIfAttached;
  27016. /**
  27017. * WebVR's attach control will start broadcasting frames to the device.
  27018. * Note that in certain browsers (chrome for example) this function must be called
  27019. * within a user-interaction callback. Example:
  27020. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27021. *
  27022. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27023. */
  27024. attachControl(noPreventDefault?: boolean): void;
  27025. /**
  27026. * Detach the current controls from the specified dom element.
  27027. */
  27028. detachControl(): void;
  27029. /**
  27030. * @returns the name of this class
  27031. */
  27032. getClassName(): string;
  27033. /**
  27034. * Calls resetPose on the vrDisplay
  27035. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27036. */
  27037. resetToCurrentRotation(): void;
  27038. /**
  27039. * @hidden
  27040. * Updates the rig cameras (left and right eye)
  27041. */
  27042. _updateRigCameras(): void;
  27043. private _workingVector;
  27044. private _oneVector;
  27045. private _workingMatrix;
  27046. private updateCacheCalled;
  27047. private _correctPositionIfNotTrackPosition;
  27048. /**
  27049. * @hidden
  27050. * Updates the cached values of the camera
  27051. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27052. */
  27053. _updateCache(ignoreParentClass?: boolean): void;
  27054. /**
  27055. * @hidden
  27056. * Get current device position in babylon world
  27057. */
  27058. _computeDevicePosition(): void;
  27059. /**
  27060. * Updates the current device position and rotation in the babylon world
  27061. */
  27062. update(): void;
  27063. /**
  27064. * @hidden
  27065. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27066. * @returns an identity matrix
  27067. */
  27068. _getViewMatrix(): Matrix;
  27069. private _tmpMatrix;
  27070. /**
  27071. * This function is called by the two RIG cameras.
  27072. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27073. * @hidden
  27074. */
  27075. _getWebVRViewMatrix(): Matrix;
  27076. /** @hidden */
  27077. _getWebVRProjectionMatrix(): Matrix;
  27078. private _onGamepadConnectedObserver;
  27079. private _onGamepadDisconnectedObserver;
  27080. private _updateCacheWhenTrackingDisabledObserver;
  27081. /**
  27082. * Initializes the controllers and their meshes
  27083. */
  27084. initControllers(): void;
  27085. }
  27086. }
  27087. declare module BABYLON {
  27088. /**
  27089. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27090. *
  27091. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27092. *
  27093. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27094. */
  27095. export class MaterialHelper {
  27096. /**
  27097. * Bind the current view position to an effect.
  27098. * @param effect The effect to be bound
  27099. * @param scene The scene the eyes position is used from
  27100. * @param variableName name of the shader variable that will hold the eye position
  27101. */
  27102. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27103. /**
  27104. * Helps preparing the defines values about the UVs in used in the effect.
  27105. * UVs are shared as much as we can accross channels in the shaders.
  27106. * @param texture The texture we are preparing the UVs for
  27107. * @param defines The defines to update
  27108. * @param key The channel key "diffuse", "specular"... used in the shader
  27109. */
  27110. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27111. /**
  27112. * Binds a texture matrix value to its corrsponding uniform
  27113. * @param texture The texture to bind the matrix for
  27114. * @param uniformBuffer The uniform buffer receivin the data
  27115. * @param key The channel key "diffuse", "specular"... used in the shader
  27116. */
  27117. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27118. /**
  27119. * Gets the current status of the fog (should it be enabled?)
  27120. * @param mesh defines the mesh to evaluate for fog support
  27121. * @param scene defines the hosting scene
  27122. * @returns true if fog must be enabled
  27123. */
  27124. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27125. /**
  27126. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27127. * @param mesh defines the current mesh
  27128. * @param scene defines the current scene
  27129. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27130. * @param pointsCloud defines if point cloud rendering has to be turned on
  27131. * @param fogEnabled defines if fog has to be turned on
  27132. * @param alphaTest defines if alpha testing has to be turned on
  27133. * @param defines defines the current list of defines
  27134. */
  27135. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27136. /**
  27137. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27138. * @param scene defines the current scene
  27139. * @param engine defines the current engine
  27140. * @param defines specifies the list of active defines
  27141. * @param useInstances defines if instances have to be turned on
  27142. * @param useClipPlane defines if clip plane have to be turned on
  27143. * @param useInstances defines if instances have to be turned on
  27144. * @param useThinInstances defines if thin instances have to be turned on
  27145. */
  27146. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27147. /**
  27148. * Prepares the defines for bones
  27149. * @param mesh The mesh containing the geometry data we will draw
  27150. * @param defines The defines to update
  27151. */
  27152. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27153. /**
  27154. * Prepares the defines for morph targets
  27155. * @param mesh The mesh containing the geometry data we will draw
  27156. * @param defines The defines to update
  27157. */
  27158. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27159. /**
  27160. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27161. * @param mesh The mesh containing the geometry data we will draw
  27162. * @param defines The defines to update
  27163. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27164. * @param useBones Precise whether bones should be used or not (override mesh info)
  27165. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27166. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27167. * @returns false if defines are considered not dirty and have not been checked
  27168. */
  27169. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27170. /**
  27171. * Prepares the defines related to multiview
  27172. * @param scene The scene we are intending to draw
  27173. * @param defines The defines to update
  27174. */
  27175. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27176. /**
  27177. * Prepares the defines related to the prepass
  27178. * @param scene The scene we are intending to draw
  27179. * @param defines The defines to update
  27180. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27181. */
  27182. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27183. /**
  27184. * Prepares the defines related to the light information passed in parameter
  27185. * @param scene The scene we are intending to draw
  27186. * @param mesh The mesh the effect is compiling for
  27187. * @param light The light the effect is compiling for
  27188. * @param lightIndex The index of the light
  27189. * @param defines The defines to update
  27190. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27191. * @param state Defines the current state regarding what is needed (normals, etc...)
  27192. */
  27193. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27194. needNormals: boolean;
  27195. needRebuild: boolean;
  27196. shadowEnabled: boolean;
  27197. specularEnabled: boolean;
  27198. lightmapMode: boolean;
  27199. }): void;
  27200. /**
  27201. * Prepares the defines related to the light information passed in parameter
  27202. * @param scene The scene we are intending to draw
  27203. * @param mesh The mesh the effect is compiling for
  27204. * @param defines The defines to update
  27205. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27206. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27207. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27208. * @returns true if normals will be required for the rest of the effect
  27209. */
  27210. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27211. /**
  27212. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27213. * @param lightIndex defines the light index
  27214. * @param uniformsList The uniform list
  27215. * @param samplersList The sampler list
  27216. * @param projectedLightTexture defines if projected texture must be used
  27217. * @param uniformBuffersList defines an optional list of uniform buffers
  27218. */
  27219. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  27220. /**
  27221. * Prepares the uniforms and samplers list to be used in the effect
  27222. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27223. * @param samplersList The sampler list
  27224. * @param defines The defines helping in the list generation
  27225. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27226. */
  27227. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27228. /**
  27229. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27230. * @param defines The defines to update while falling back
  27231. * @param fallbacks The authorized effect fallbacks
  27232. * @param maxSimultaneousLights The maximum number of lights allowed
  27233. * @param rank the current rank of the Effect
  27234. * @returns The newly affected rank
  27235. */
  27236. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27237. private static _TmpMorphInfluencers;
  27238. /**
  27239. * Prepares the list of attributes required for morph targets according to the effect defines.
  27240. * @param attribs The current list of supported attribs
  27241. * @param mesh The mesh to prepare the morph targets attributes for
  27242. * @param influencers The number of influencers
  27243. */
  27244. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27245. /**
  27246. * Prepares the list of attributes required for morph targets according to the effect defines.
  27247. * @param attribs The current list of supported attribs
  27248. * @param mesh The mesh to prepare the morph targets attributes for
  27249. * @param defines The current Defines of the effect
  27250. */
  27251. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27252. /**
  27253. * Prepares the list of attributes required for bones according to the effect defines.
  27254. * @param attribs The current list of supported attribs
  27255. * @param mesh The mesh to prepare the bones attributes for
  27256. * @param defines The current Defines of the effect
  27257. * @param fallbacks The current efffect fallback strategy
  27258. */
  27259. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27260. /**
  27261. * Check and prepare the list of attributes required for instances according to the effect defines.
  27262. * @param attribs The current list of supported attribs
  27263. * @param defines The current MaterialDefines of the effect
  27264. */
  27265. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27266. /**
  27267. * Add the list of attributes required for instances to the attribs array.
  27268. * @param attribs The current list of supported attribs
  27269. */
  27270. static PushAttributesForInstances(attribs: string[]): void;
  27271. /**
  27272. * Binds the light information to the effect.
  27273. * @param light The light containing the generator
  27274. * @param effect The effect we are binding the data to
  27275. * @param lightIndex The light index in the effect used to render
  27276. */
  27277. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27278. /**
  27279. * Binds the lights information from the scene to the effect for the given mesh.
  27280. * @param light Light to bind
  27281. * @param lightIndex Light index
  27282. * @param scene The scene where the light belongs to
  27283. * @param effect The effect we are binding the data to
  27284. * @param useSpecular Defines if specular is supported
  27285. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27286. */
  27287. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27288. /**
  27289. * Binds the lights information from the scene to the effect for the given mesh.
  27290. * @param scene The scene the lights belongs to
  27291. * @param mesh The mesh we are binding the information to render
  27292. * @param effect The effect we are binding the data to
  27293. * @param defines The generated defines for the effect
  27294. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27295. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27296. */
  27297. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27298. private static _tempFogColor;
  27299. /**
  27300. * Binds the fog information from the scene to the effect for the given mesh.
  27301. * @param scene The scene the lights belongs to
  27302. * @param mesh The mesh we are binding the information to render
  27303. * @param effect The effect we are binding the data to
  27304. * @param linearSpace Defines if the fog effect is applied in linear space
  27305. */
  27306. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27307. /**
  27308. * Binds the bones information from the mesh to the effect.
  27309. * @param mesh The mesh we are binding the information to render
  27310. * @param effect The effect we are binding the data to
  27311. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27312. */
  27313. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27314. private static _CopyBonesTransformationMatrices;
  27315. /**
  27316. * Binds the morph targets information from the mesh to the effect.
  27317. * @param abstractMesh The mesh we are binding the information to render
  27318. * @param effect The effect we are binding the data to
  27319. */
  27320. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27321. /**
  27322. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27323. * @param defines The generated defines used in the effect
  27324. * @param effect The effect we are binding the data to
  27325. * @param scene The scene we are willing to render with logarithmic scale for
  27326. */
  27327. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27328. /**
  27329. * Binds the clip plane information from the scene to the effect.
  27330. * @param scene The scene the clip plane information are extracted from
  27331. * @param effect The effect we are binding the data to
  27332. */
  27333. static BindClipPlane(effect: Effect, scene: Scene): void;
  27334. }
  27335. }
  27336. declare module BABYLON {
  27337. /** @hidden */
  27338. export var bayerDitherFunctions: {
  27339. name: string;
  27340. shader: string;
  27341. };
  27342. }
  27343. declare module BABYLON {
  27344. /** @hidden */
  27345. export var shadowMapFragmentDeclaration: {
  27346. name: string;
  27347. shader: string;
  27348. };
  27349. }
  27350. declare module BABYLON {
  27351. /** @hidden */
  27352. export var shadowMapFragment: {
  27353. name: string;
  27354. shader: string;
  27355. };
  27356. }
  27357. declare module BABYLON {
  27358. /** @hidden */
  27359. export var shadowMapPixelShader: {
  27360. name: string;
  27361. shader: string;
  27362. };
  27363. }
  27364. declare module BABYLON {
  27365. /** @hidden */
  27366. export var shadowMapVertexDeclaration: {
  27367. name: string;
  27368. shader: string;
  27369. };
  27370. }
  27371. declare module BABYLON {
  27372. /** @hidden */
  27373. export var shadowMapVertexNormalBias: {
  27374. name: string;
  27375. shader: string;
  27376. };
  27377. }
  27378. declare module BABYLON {
  27379. /** @hidden */
  27380. export var shadowMapVertexMetric: {
  27381. name: string;
  27382. shader: string;
  27383. };
  27384. }
  27385. declare module BABYLON {
  27386. /** @hidden */
  27387. export var shadowMapVertexShader: {
  27388. name: string;
  27389. shader: string;
  27390. };
  27391. }
  27392. declare module BABYLON {
  27393. /** @hidden */
  27394. export var depthBoxBlurPixelShader: {
  27395. name: string;
  27396. shader: string;
  27397. };
  27398. }
  27399. declare module BABYLON {
  27400. /** @hidden */
  27401. export var shadowMapFragmentSoftTransparentShadow: {
  27402. name: string;
  27403. shader: string;
  27404. };
  27405. }
  27406. declare module BABYLON {
  27407. /**
  27408. * Creates an instance based on a source mesh.
  27409. */
  27410. export class InstancedMesh extends AbstractMesh {
  27411. private _sourceMesh;
  27412. private _currentLOD;
  27413. /** @hidden */
  27414. _indexInSourceMeshInstanceArray: number;
  27415. constructor(name: string, source: Mesh);
  27416. /**
  27417. * Returns the string "InstancedMesh".
  27418. */
  27419. getClassName(): string;
  27420. /** Gets the list of lights affecting that mesh */
  27421. get lightSources(): Light[];
  27422. _resyncLightSources(): void;
  27423. _resyncLightSource(light: Light): void;
  27424. _removeLightSource(light: Light, dispose: boolean): void;
  27425. /**
  27426. * If the source mesh receives shadows
  27427. */
  27428. get receiveShadows(): boolean;
  27429. /**
  27430. * The material of the source mesh
  27431. */
  27432. get material(): Nullable<Material>;
  27433. /**
  27434. * Visibility of the source mesh
  27435. */
  27436. get visibility(): number;
  27437. /**
  27438. * Skeleton of the source mesh
  27439. */
  27440. get skeleton(): Nullable<Skeleton>;
  27441. /**
  27442. * Rendering ground id of the source mesh
  27443. */
  27444. get renderingGroupId(): number;
  27445. set renderingGroupId(value: number);
  27446. /**
  27447. * Returns the total number of vertices (integer).
  27448. */
  27449. getTotalVertices(): number;
  27450. /**
  27451. * Returns a positive integer : the total number of indices in this mesh geometry.
  27452. * @returns the numner of indices or zero if the mesh has no geometry.
  27453. */
  27454. getTotalIndices(): number;
  27455. /**
  27456. * The source mesh of the instance
  27457. */
  27458. get sourceMesh(): Mesh;
  27459. /**
  27460. * Creates a new InstancedMesh object from the mesh model.
  27461. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27462. * @param name defines the name of the new instance
  27463. * @returns a new InstancedMesh
  27464. */
  27465. createInstance(name: string): InstancedMesh;
  27466. /**
  27467. * Is this node ready to be used/rendered
  27468. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27469. * @return {boolean} is it ready
  27470. */
  27471. isReady(completeCheck?: boolean): boolean;
  27472. /**
  27473. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27474. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27475. * @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.
  27476. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27477. */
  27478. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27479. /**
  27480. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27481. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27482. * The `data` are either a numeric array either a Float32Array.
  27483. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27484. * 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).
  27485. * Note that a new underlying VertexBuffer object is created each call.
  27486. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27487. *
  27488. * Possible `kind` values :
  27489. * - VertexBuffer.PositionKind
  27490. * - VertexBuffer.UVKind
  27491. * - VertexBuffer.UV2Kind
  27492. * - VertexBuffer.UV3Kind
  27493. * - VertexBuffer.UV4Kind
  27494. * - VertexBuffer.UV5Kind
  27495. * - VertexBuffer.UV6Kind
  27496. * - VertexBuffer.ColorKind
  27497. * - VertexBuffer.MatricesIndicesKind
  27498. * - VertexBuffer.MatricesIndicesExtraKind
  27499. * - VertexBuffer.MatricesWeightsKind
  27500. * - VertexBuffer.MatricesWeightsExtraKind
  27501. *
  27502. * Returns the Mesh.
  27503. */
  27504. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27505. /**
  27506. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27507. * If the mesh has no geometry, it is simply returned as it is.
  27508. * The `data` are either a numeric array either a Float32Array.
  27509. * No new underlying VertexBuffer object is created.
  27510. * 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.
  27511. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27512. *
  27513. * Possible `kind` values :
  27514. * - VertexBuffer.PositionKind
  27515. * - VertexBuffer.UVKind
  27516. * - VertexBuffer.UV2Kind
  27517. * - VertexBuffer.UV3Kind
  27518. * - VertexBuffer.UV4Kind
  27519. * - VertexBuffer.UV5Kind
  27520. * - VertexBuffer.UV6Kind
  27521. * - VertexBuffer.ColorKind
  27522. * - VertexBuffer.MatricesIndicesKind
  27523. * - VertexBuffer.MatricesIndicesExtraKind
  27524. * - VertexBuffer.MatricesWeightsKind
  27525. * - VertexBuffer.MatricesWeightsExtraKind
  27526. *
  27527. * Returns the Mesh.
  27528. */
  27529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27530. /**
  27531. * Sets the mesh indices.
  27532. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27533. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27534. * This method creates a new index buffer each call.
  27535. * Returns the Mesh.
  27536. */
  27537. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27538. /**
  27539. * Boolean : True if the mesh owns the requested kind of data.
  27540. */
  27541. isVerticesDataPresent(kind: string): boolean;
  27542. /**
  27543. * Returns an array of indices (IndicesArray).
  27544. */
  27545. getIndices(): Nullable<IndicesArray>;
  27546. get _positions(): Nullable<Vector3[]>;
  27547. /**
  27548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27549. * This means the mesh underlying bounding box and sphere are recomputed.
  27550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27551. * @returns the current mesh
  27552. */
  27553. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27554. /** @hidden */
  27555. _preActivate(): InstancedMesh;
  27556. /** @hidden */
  27557. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27558. /** @hidden */
  27559. _postActivate(): void;
  27560. getWorldMatrix(): Matrix;
  27561. get isAnInstance(): boolean;
  27562. /**
  27563. * Returns the current associated LOD AbstractMesh.
  27564. */
  27565. getLOD(camera: Camera): AbstractMesh;
  27566. /** @hidden */
  27567. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27568. /** @hidden */
  27569. _syncSubMeshes(): InstancedMesh;
  27570. /** @hidden */
  27571. _generatePointsArray(): boolean;
  27572. /** @hidden */
  27573. _updateBoundingInfo(): AbstractMesh;
  27574. /**
  27575. * Creates a new InstancedMesh from the current mesh.
  27576. * - name (string) : the cloned mesh name
  27577. * - newParent (optional Node) : the optional Node to parent the clone to.
  27578. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27579. *
  27580. * Returns the clone.
  27581. */
  27582. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27583. /**
  27584. * Disposes the InstancedMesh.
  27585. * Returns nothing.
  27586. */
  27587. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27588. }
  27589. interface Mesh {
  27590. /**
  27591. * Register a custom buffer that will be instanced
  27592. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27593. * @param kind defines the buffer kind
  27594. * @param stride defines the stride in floats
  27595. */
  27596. registerInstancedBuffer(kind: string, stride: number): void;
  27597. /**
  27598. * true to use the edge renderer for all instances of this mesh
  27599. */
  27600. edgesShareWithInstances: boolean;
  27601. /** @hidden */
  27602. _userInstancedBuffersStorage: {
  27603. data: {
  27604. [key: string]: Float32Array;
  27605. };
  27606. sizes: {
  27607. [key: string]: number;
  27608. };
  27609. vertexBuffers: {
  27610. [key: string]: Nullable<VertexBuffer>;
  27611. };
  27612. strides: {
  27613. [key: string]: number;
  27614. };
  27615. };
  27616. }
  27617. interface AbstractMesh {
  27618. /**
  27619. * Object used to store instanced buffers defined by user
  27620. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27621. */
  27622. instancedBuffers: {
  27623. [key: string]: any;
  27624. };
  27625. }
  27626. }
  27627. declare module BABYLON {
  27628. /**
  27629. * Defines the options associated with the creation of a shader material.
  27630. */
  27631. export interface IShaderMaterialOptions {
  27632. /**
  27633. * Does the material work in alpha blend mode
  27634. */
  27635. needAlphaBlending: boolean;
  27636. /**
  27637. * Does the material work in alpha test mode
  27638. */
  27639. needAlphaTesting: boolean;
  27640. /**
  27641. * The list of attribute names used in the shader
  27642. */
  27643. attributes: string[];
  27644. /**
  27645. * The list of unifrom names used in the shader
  27646. */
  27647. uniforms: string[];
  27648. /**
  27649. * The list of UBO names used in the shader
  27650. */
  27651. uniformBuffers: string[];
  27652. /**
  27653. * The list of sampler names used in the shader
  27654. */
  27655. samplers: string[];
  27656. /**
  27657. * The list of defines used in the shader
  27658. */
  27659. defines: string[];
  27660. }
  27661. /**
  27662. * 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.
  27663. *
  27664. * This returned material effects how the mesh will look based on the code in the shaders.
  27665. *
  27666. * @see https://doc.babylonjs.com/how_to/shader_material
  27667. */
  27668. export class ShaderMaterial extends Material {
  27669. private _shaderPath;
  27670. private _options;
  27671. private _textures;
  27672. private _textureArrays;
  27673. private _floats;
  27674. private _ints;
  27675. private _floatsArrays;
  27676. private _colors3;
  27677. private _colors3Arrays;
  27678. private _colors4;
  27679. private _colors4Arrays;
  27680. private _vectors2;
  27681. private _vectors3;
  27682. private _vectors4;
  27683. private _matrices;
  27684. private _matrixArrays;
  27685. private _matrices3x3;
  27686. private _matrices2x2;
  27687. private _vectors2Arrays;
  27688. private _vectors3Arrays;
  27689. private _vectors4Arrays;
  27690. private _cachedWorldViewMatrix;
  27691. private _cachedWorldViewProjectionMatrix;
  27692. private _renderId;
  27693. private _multiview;
  27694. private _cachedDefines;
  27695. /** Define the Url to load snippets */
  27696. static SnippetUrl: string;
  27697. /** Snippet ID if the material was created from the snippet server */
  27698. snippetId: string;
  27699. /**
  27700. * Instantiate a new shader material.
  27701. * 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.
  27702. * This returned material effects how the mesh will look based on the code in the shaders.
  27703. * @see https://doc.babylonjs.com/how_to/shader_material
  27704. * @param name Define the name of the material in the scene
  27705. * @param scene Define the scene the material belongs to
  27706. * @param shaderPath Defines the route to the shader code in one of three ways:
  27707. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27708. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27709. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27710. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27711. * @param options Define the options used to create the shader
  27712. */
  27713. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27714. /**
  27715. * Gets the shader path used to define the shader code
  27716. * It can be modified to trigger a new compilation
  27717. */
  27718. get shaderPath(): any;
  27719. /**
  27720. * Sets the shader path used to define the shader code
  27721. * It can be modified to trigger a new compilation
  27722. */
  27723. set shaderPath(shaderPath: any);
  27724. /**
  27725. * Gets the options used to compile the shader.
  27726. * They can be modified to trigger a new compilation
  27727. */
  27728. get options(): IShaderMaterialOptions;
  27729. /**
  27730. * Gets the current class name of the material e.g. "ShaderMaterial"
  27731. * Mainly use in serialization.
  27732. * @returns the class name
  27733. */
  27734. getClassName(): string;
  27735. /**
  27736. * Specifies if the material will require alpha blending
  27737. * @returns a boolean specifying if alpha blending is needed
  27738. */
  27739. needAlphaBlending(): boolean;
  27740. /**
  27741. * Specifies if this material should be rendered in alpha test mode
  27742. * @returns a boolean specifying if an alpha test is needed.
  27743. */
  27744. needAlphaTesting(): boolean;
  27745. private _checkUniform;
  27746. /**
  27747. * Set a texture in the shader.
  27748. * @param name Define the name of the uniform samplers as defined in the shader
  27749. * @param texture Define the texture to bind to this sampler
  27750. * @return the material itself allowing "fluent" like uniform updates
  27751. */
  27752. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27753. /**
  27754. * Set a texture array in the shader.
  27755. * @param name Define the name of the uniform sampler array as defined in the shader
  27756. * @param textures Define the list of textures to bind to this sampler
  27757. * @return the material itself allowing "fluent" like uniform updates
  27758. */
  27759. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27760. /**
  27761. * Set a float in the shader.
  27762. * @param name Define the name of the uniform as defined in the shader
  27763. * @param value Define the value to give to the uniform
  27764. * @return the material itself allowing "fluent" like uniform updates
  27765. */
  27766. setFloat(name: string, value: number): ShaderMaterial;
  27767. /**
  27768. * Set a int in the shader.
  27769. * @param name Define the name of the uniform as defined in the shader
  27770. * @param value Define the value to give to the uniform
  27771. * @return the material itself allowing "fluent" like uniform updates
  27772. */
  27773. setInt(name: string, value: number): ShaderMaterial;
  27774. /**
  27775. * Set an array of floats in the shader.
  27776. * @param name Define the name of the uniform as defined in the shader
  27777. * @param value Define the value to give to the uniform
  27778. * @return the material itself allowing "fluent" like uniform updates
  27779. */
  27780. setFloats(name: string, value: number[]): ShaderMaterial;
  27781. /**
  27782. * Set a vec3 in the shader from a Color3.
  27783. * @param name Define the name of the uniform as defined in the shader
  27784. * @param value Define the value to give to the uniform
  27785. * @return the material itself allowing "fluent" like uniform updates
  27786. */
  27787. setColor3(name: string, value: Color3): ShaderMaterial;
  27788. /**
  27789. * Set a vec3 array in the shader from a Color3 array.
  27790. * @param name Define the name of the uniform as defined in the shader
  27791. * @param value Define the value to give to the uniform
  27792. * @return the material itself allowing "fluent" like uniform updates
  27793. */
  27794. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27795. /**
  27796. * Set a vec4 in the shader from a Color4.
  27797. * @param name Define the name of the uniform as defined in the shader
  27798. * @param value Define the value to give to the uniform
  27799. * @return the material itself allowing "fluent" like uniform updates
  27800. */
  27801. setColor4(name: string, value: Color4): ShaderMaterial;
  27802. /**
  27803. * Set a vec4 array in the shader from a Color4 array.
  27804. * @param name Define the name of the uniform as defined in the shader
  27805. * @param value Define the value to give to the uniform
  27806. * @return the material itself allowing "fluent" like uniform updates
  27807. */
  27808. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27809. /**
  27810. * Set a vec2 in the shader from a Vector2.
  27811. * @param name Define the name of the uniform as defined in the shader
  27812. * @param value Define the value to give to the uniform
  27813. * @return the material itself allowing "fluent" like uniform updates
  27814. */
  27815. setVector2(name: string, value: Vector2): ShaderMaterial;
  27816. /**
  27817. * Set a vec3 in the shader from a Vector3.
  27818. * @param name Define the name of the uniform as defined in the shader
  27819. * @param value Define the value to give to the uniform
  27820. * @return the material itself allowing "fluent" like uniform updates
  27821. */
  27822. setVector3(name: string, value: Vector3): ShaderMaterial;
  27823. /**
  27824. * Set a vec4 in the shader from a Vector4.
  27825. * @param name Define the name of the uniform as defined in the shader
  27826. * @param value Define the value to give to the uniform
  27827. * @return the material itself allowing "fluent" like uniform updates
  27828. */
  27829. setVector4(name: string, value: Vector4): ShaderMaterial;
  27830. /**
  27831. * Set a mat4 in the shader from a Matrix.
  27832. * @param name Define the name of the uniform as defined in the shader
  27833. * @param value Define the value to give to the uniform
  27834. * @return the material itself allowing "fluent" like uniform updates
  27835. */
  27836. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27837. /**
  27838. * Set a float32Array in the shader from a matrix array.
  27839. * @param name Define the name of the uniform as defined in the shader
  27840. * @param value Define the value to give to the uniform
  27841. * @return the material itself allowing "fluent" like uniform updates
  27842. */
  27843. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27844. /**
  27845. * Set a mat3 in the shader from a Float32Array.
  27846. * @param name Define the name of the uniform as defined in the shader
  27847. * @param value Define the value to give to the uniform
  27848. * @return the material itself allowing "fluent" like uniform updates
  27849. */
  27850. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27851. /**
  27852. * Set a mat2 in the shader from a Float32Array.
  27853. * @param name Define the name of the uniform as defined in the shader
  27854. * @param value Define the value to give to the uniform
  27855. * @return the material itself allowing "fluent" like uniform updates
  27856. */
  27857. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27858. /**
  27859. * Set a vec2 array in the shader from a number array.
  27860. * @param name Define the name of the uniform as defined in the shader
  27861. * @param value Define the value to give to the uniform
  27862. * @return the material itself allowing "fluent" like uniform updates
  27863. */
  27864. setArray2(name: string, value: number[]): ShaderMaterial;
  27865. /**
  27866. * Set a vec3 array in the shader from a number array.
  27867. * @param name Define the name of the uniform as defined in the shader
  27868. * @param value Define the value to give to the uniform
  27869. * @return the material itself allowing "fluent" like uniform updates
  27870. */
  27871. setArray3(name: string, value: number[]): ShaderMaterial;
  27872. /**
  27873. * Set a vec4 array in the shader from a number array.
  27874. * @param name Define the name of the uniform as defined in the shader
  27875. * @param value Define the value to give to the uniform
  27876. * @return the material itself allowing "fluent" like uniform updates
  27877. */
  27878. setArray4(name: string, value: number[]): ShaderMaterial;
  27879. private _checkCache;
  27880. /**
  27881. * Specifies that the submesh is ready to be used
  27882. * @param mesh defines the mesh to check
  27883. * @param subMesh defines which submesh to check
  27884. * @param useInstances specifies that instances should be used
  27885. * @returns a boolean indicating that the submesh is ready or not
  27886. */
  27887. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27888. /**
  27889. * Checks if the material is ready to render the requested mesh
  27890. * @param mesh Define the mesh to render
  27891. * @param useInstances Define whether or not the material is used with instances
  27892. * @returns true if ready, otherwise false
  27893. */
  27894. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27895. /**
  27896. * Binds the world matrix to the material
  27897. * @param world defines the world transformation matrix
  27898. * @param effectOverride - If provided, use this effect instead of internal effect
  27899. */
  27900. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27901. /**
  27902. * Binds the submesh to this material by preparing the effect and shader to draw
  27903. * @param world defines the world transformation matrix
  27904. * @param mesh defines the mesh containing the submesh
  27905. * @param subMesh defines the submesh to bind the material to
  27906. */
  27907. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27908. /**
  27909. * Binds the material to the mesh
  27910. * @param world defines the world transformation matrix
  27911. * @param mesh defines the mesh to bind the material to
  27912. * @param effectOverride - If provided, use this effect instead of internal effect
  27913. */
  27914. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27915. protected _afterBind(mesh?: Mesh): void;
  27916. /**
  27917. * Gets the active textures from the material
  27918. * @returns an array of textures
  27919. */
  27920. getActiveTextures(): BaseTexture[];
  27921. /**
  27922. * Specifies if the material uses a texture
  27923. * @param texture defines the texture to check against the material
  27924. * @returns a boolean specifying if the material uses the texture
  27925. */
  27926. hasTexture(texture: BaseTexture): boolean;
  27927. /**
  27928. * Makes a duplicate of the material, and gives it a new name
  27929. * @param name defines the new name for the duplicated material
  27930. * @returns the cloned material
  27931. */
  27932. clone(name: string): ShaderMaterial;
  27933. /**
  27934. * Disposes the material
  27935. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27936. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27937. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27938. */
  27939. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27940. /**
  27941. * Serializes this material in a JSON representation
  27942. * @returns the serialized material object
  27943. */
  27944. serialize(): any;
  27945. /**
  27946. * Creates a shader material from parsed shader material data
  27947. * @param source defines the JSON represnetation of the material
  27948. * @param scene defines the hosting scene
  27949. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27950. * @returns a new material
  27951. */
  27952. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  27953. /**
  27954. * Creates a new ShaderMaterial from a snippet saved in a remote file
  27955. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  27956. * @param url defines the url to load from
  27957. * @param scene defines the hosting scene
  27958. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27959. * @returns a promise that will resolve to the new ShaderMaterial
  27960. */
  27961. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27962. /**
  27963. * Creates a ShaderMaterial from a snippet saved by the Inspector
  27964. * @param snippetId defines the snippet to load
  27965. * @param scene defines the hosting scene
  27966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27967. * @returns a promise that will resolve to the new ShaderMaterial
  27968. */
  27969. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27970. }
  27971. }
  27972. declare module BABYLON {
  27973. /** @hidden */
  27974. export var colorPixelShader: {
  27975. name: string;
  27976. shader: string;
  27977. };
  27978. }
  27979. declare module BABYLON {
  27980. /** @hidden */
  27981. export var colorVertexShader: {
  27982. name: string;
  27983. shader: string;
  27984. };
  27985. }
  27986. declare module BABYLON {
  27987. /**
  27988. * Line mesh
  27989. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  27990. */
  27991. export class LinesMesh extends Mesh {
  27992. /**
  27993. * If vertex color should be applied to the mesh
  27994. */
  27995. readonly useVertexColor?: boolean | undefined;
  27996. /**
  27997. * If vertex alpha should be applied to the mesh
  27998. */
  27999. readonly useVertexAlpha?: boolean | undefined;
  28000. /**
  28001. * Color of the line (Default: White)
  28002. */
  28003. color: Color3;
  28004. /**
  28005. * Alpha of the line (Default: 1)
  28006. */
  28007. alpha: number;
  28008. /**
  28009. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28010. * This margin is expressed in world space coordinates, so its value may vary.
  28011. * Default value is 0.1
  28012. */
  28013. intersectionThreshold: number;
  28014. private _colorShader;
  28015. private color4;
  28016. /**
  28017. * Creates a new LinesMesh
  28018. * @param name defines the name
  28019. * @param scene defines the hosting scene
  28020. * @param parent defines the parent mesh if any
  28021. * @param source defines the optional source LinesMesh used to clone data from
  28022. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28023. * When false, achieved by calling a clone(), also passing False.
  28024. * This will make creation of children, recursive.
  28025. * @param useVertexColor defines if this LinesMesh supports vertex color
  28026. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28027. */
  28028. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28029. /**
  28030. * If vertex color should be applied to the mesh
  28031. */
  28032. useVertexColor?: boolean | undefined,
  28033. /**
  28034. * If vertex alpha should be applied to the mesh
  28035. */
  28036. useVertexAlpha?: boolean | undefined);
  28037. private _addClipPlaneDefine;
  28038. private _removeClipPlaneDefine;
  28039. isReady(): boolean;
  28040. /**
  28041. * Returns the string "LineMesh"
  28042. */
  28043. getClassName(): string;
  28044. /**
  28045. * @hidden
  28046. */
  28047. get material(): Material;
  28048. /**
  28049. * @hidden
  28050. */
  28051. set material(value: Material);
  28052. /**
  28053. * @hidden
  28054. */
  28055. get checkCollisions(): boolean;
  28056. /** @hidden */
  28057. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28058. /** @hidden */
  28059. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28060. /**
  28061. * Disposes of the line mesh
  28062. * @param doNotRecurse If children should be disposed
  28063. */
  28064. dispose(doNotRecurse?: boolean): void;
  28065. /**
  28066. * Returns a new LineMesh object cloned from the current one.
  28067. */
  28068. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28069. /**
  28070. * Creates a new InstancedLinesMesh object from the mesh model.
  28071. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28072. * @param name defines the name of the new instance
  28073. * @returns a new InstancedLinesMesh
  28074. */
  28075. createInstance(name: string): InstancedLinesMesh;
  28076. }
  28077. /**
  28078. * Creates an instance based on a source LinesMesh
  28079. */
  28080. export class InstancedLinesMesh extends InstancedMesh {
  28081. /**
  28082. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28083. * This margin is expressed in world space coordinates, so its value may vary.
  28084. * Initilized with the intersectionThreshold value of the source LinesMesh
  28085. */
  28086. intersectionThreshold: number;
  28087. constructor(name: string, source: LinesMesh);
  28088. /**
  28089. * Returns the string "InstancedLinesMesh".
  28090. */
  28091. getClassName(): string;
  28092. }
  28093. }
  28094. declare module BABYLON {
  28095. /** @hidden */
  28096. export var linePixelShader: {
  28097. name: string;
  28098. shader: string;
  28099. };
  28100. }
  28101. declare module BABYLON {
  28102. /** @hidden */
  28103. export var lineVertexShader: {
  28104. name: string;
  28105. shader: string;
  28106. };
  28107. }
  28108. declare module BABYLON {
  28109. interface Scene {
  28110. /** @hidden */
  28111. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28112. }
  28113. interface AbstractMesh {
  28114. /**
  28115. * Gets the edgesRenderer associated with the mesh
  28116. */
  28117. edgesRenderer: Nullable<EdgesRenderer>;
  28118. }
  28119. interface LinesMesh {
  28120. /**
  28121. * Enables the edge rendering mode on the mesh.
  28122. * This mode makes the mesh edges visible
  28123. * @param epsilon defines the maximal distance between two angles to detect a face
  28124. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28125. * @returns the currentAbstractMesh
  28126. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28127. */
  28128. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28129. }
  28130. interface InstancedLinesMesh {
  28131. /**
  28132. * Enables the edge rendering mode on the mesh.
  28133. * This mode makes the mesh edges visible
  28134. * @param epsilon defines the maximal distance between two angles to detect a face
  28135. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28136. * @returns the current InstancedLinesMesh
  28137. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28138. */
  28139. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28140. }
  28141. /**
  28142. * Defines the minimum contract an Edges renderer should follow.
  28143. */
  28144. export interface IEdgesRenderer extends IDisposable {
  28145. /**
  28146. * Gets or sets a boolean indicating if the edgesRenderer is active
  28147. */
  28148. isEnabled: boolean;
  28149. /**
  28150. * Renders the edges of the attached mesh,
  28151. */
  28152. render(): void;
  28153. /**
  28154. * Checks wether or not the edges renderer is ready to render.
  28155. * @return true if ready, otherwise false.
  28156. */
  28157. isReady(): boolean;
  28158. /**
  28159. * List of instances to render in case the source mesh has instances
  28160. */
  28161. customInstances: SmartArray<Matrix>;
  28162. }
  28163. /**
  28164. * Defines the additional options of the edges renderer
  28165. */
  28166. export interface IEdgesRendererOptions {
  28167. /**
  28168. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28169. * If not defined, the default value is true
  28170. */
  28171. useAlternateEdgeFinder?: boolean;
  28172. /**
  28173. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28174. * If not defined, the default value is true.
  28175. * 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)
  28176. * This option is used only if useAlternateEdgeFinder = true
  28177. */
  28178. useFastVertexMerger?: boolean;
  28179. /**
  28180. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28181. * The default value is 1e-6
  28182. * This option is used only if useAlternateEdgeFinder = true
  28183. */
  28184. epsilonVertexMerge?: number;
  28185. /**
  28186. * 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
  28187. * 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.
  28188. * This option is used only if useAlternateEdgeFinder = true
  28189. */
  28190. applyTessellation?: boolean;
  28191. /**
  28192. * 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
  28193. * The default value is 1e-6
  28194. * This option is used only if useAlternateEdgeFinder = true
  28195. */
  28196. epsilonVertexAligned?: number;
  28197. }
  28198. /**
  28199. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28200. */
  28201. export class EdgesRenderer implements IEdgesRenderer {
  28202. /**
  28203. * Define the size of the edges with an orthographic camera
  28204. */
  28205. edgesWidthScalerForOrthographic: number;
  28206. /**
  28207. * Define the size of the edges with a perspective camera
  28208. */
  28209. edgesWidthScalerForPerspective: number;
  28210. protected _source: AbstractMesh;
  28211. protected _linesPositions: number[];
  28212. protected _linesNormals: number[];
  28213. protected _linesIndices: number[];
  28214. protected _epsilon: number;
  28215. protected _indicesCount: number;
  28216. protected _lineShader: ShaderMaterial;
  28217. protected _ib: DataBuffer;
  28218. protected _buffers: {
  28219. [key: string]: Nullable<VertexBuffer>;
  28220. };
  28221. protected _buffersForInstances: {
  28222. [key: string]: Nullable<VertexBuffer>;
  28223. };
  28224. protected _checkVerticesInsteadOfIndices: boolean;
  28225. protected _options: Nullable<IEdgesRendererOptions>;
  28226. private _meshRebuildObserver;
  28227. private _meshDisposeObserver;
  28228. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28229. isEnabled: boolean;
  28230. /** Gets the vertices generated by the edge renderer */
  28231. get linesPositions(): Immutable<Array<number>>;
  28232. /** Gets the normals generated by the edge renderer */
  28233. get linesNormals(): Immutable<Array<number>>;
  28234. /** Gets the indices generated by the edge renderer */
  28235. get linesIndices(): Immutable<Array<number>>;
  28236. /**
  28237. * List of instances to render in case the source mesh has instances
  28238. */
  28239. customInstances: SmartArray<Matrix>;
  28240. private static GetShader;
  28241. /**
  28242. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28243. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28244. * @param source Mesh used to create edges
  28245. * @param epsilon sum of angles in adjacency to check for edge
  28246. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28247. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28248. * @param options The options to apply when generating the edges
  28249. */
  28250. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28251. protected _prepareRessources(): void;
  28252. /** @hidden */
  28253. _rebuild(): void;
  28254. /**
  28255. * Releases the required resources for the edges renderer
  28256. */
  28257. dispose(): void;
  28258. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28259. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28260. /**
  28261. * Checks if the pair of p0 and p1 is en edge
  28262. * @param faceIndex
  28263. * @param edge
  28264. * @param faceNormals
  28265. * @param p0
  28266. * @param p1
  28267. * @private
  28268. */
  28269. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28270. /**
  28271. * push line into the position, normal and index buffer
  28272. * @protected
  28273. */
  28274. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28275. /**
  28276. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28277. */
  28278. private _tessellateTriangle;
  28279. private _generateEdgesLinesAlternate;
  28280. /**
  28281. * Generates lines edges from adjacencjes
  28282. * @private
  28283. */
  28284. _generateEdgesLines(): void;
  28285. /**
  28286. * Checks wether or not the edges renderer is ready to render.
  28287. * @return true if ready, otherwise false.
  28288. */
  28289. isReady(): boolean;
  28290. /**
  28291. * Renders the edges of the attached mesh,
  28292. */
  28293. render(): void;
  28294. }
  28295. /**
  28296. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28297. */
  28298. export class LineEdgesRenderer extends EdgesRenderer {
  28299. /**
  28300. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28301. * @param source LineMesh used to generate edges
  28302. * @param epsilon not important (specified angle for edge detection)
  28303. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28304. */
  28305. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28306. /**
  28307. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28308. */
  28309. _generateEdgesLines(): void;
  28310. }
  28311. }
  28312. declare module BABYLON {
  28313. /**
  28314. * This represents the object necessary to create a rendering group.
  28315. * This is exclusively used and created by the rendering manager.
  28316. * To modify the behavior, you use the available helpers in your scene or meshes.
  28317. * @hidden
  28318. */
  28319. export class RenderingGroup {
  28320. index: number;
  28321. private static _zeroVector;
  28322. private _scene;
  28323. private _opaqueSubMeshes;
  28324. private _transparentSubMeshes;
  28325. private _alphaTestSubMeshes;
  28326. private _depthOnlySubMeshes;
  28327. private _particleSystems;
  28328. private _spriteManagers;
  28329. private _opaqueSortCompareFn;
  28330. private _alphaTestSortCompareFn;
  28331. private _transparentSortCompareFn;
  28332. private _renderOpaque;
  28333. private _renderAlphaTest;
  28334. private _renderTransparent;
  28335. /** @hidden */
  28336. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28337. onBeforeTransparentRendering: () => void;
  28338. /**
  28339. * Set the opaque sort comparison function.
  28340. * If null the sub meshes will be render in the order they were created
  28341. */
  28342. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28343. /**
  28344. * Set the alpha test sort comparison function.
  28345. * If null the sub meshes will be render in the order they were created
  28346. */
  28347. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28348. /**
  28349. * Set the transparent sort comparison function.
  28350. * If null the sub meshes will be render in the order they were created
  28351. */
  28352. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28353. /**
  28354. * Creates a new rendering group.
  28355. * @param index The rendering group index
  28356. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28357. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28358. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28359. */
  28360. 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>);
  28361. /**
  28362. * Render all the sub meshes contained in the group.
  28363. * @param customRenderFunction Used to override the default render behaviour of the group.
  28364. * @returns true if rendered some submeshes.
  28365. */
  28366. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28367. /**
  28368. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28369. * @param subMeshes The submeshes to render
  28370. */
  28371. private renderOpaqueSorted;
  28372. /**
  28373. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28374. * @param subMeshes The submeshes to render
  28375. */
  28376. private renderAlphaTestSorted;
  28377. /**
  28378. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28379. * @param subMeshes The submeshes to render
  28380. */
  28381. private renderTransparentSorted;
  28382. /**
  28383. * Renders the submeshes in a specified order.
  28384. * @param subMeshes The submeshes to sort before render
  28385. * @param sortCompareFn The comparison function use to sort
  28386. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28387. * @param transparent Specifies to activate blending if true
  28388. */
  28389. private static renderSorted;
  28390. /**
  28391. * Renders the submeshes in the order they were dispatched (no sort applied).
  28392. * @param subMeshes The submeshes to render
  28393. */
  28394. private static renderUnsorted;
  28395. /**
  28396. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28397. * are rendered back to front if in the same alpha index.
  28398. *
  28399. * @param a The first submesh
  28400. * @param b The second submesh
  28401. * @returns The result of the comparison
  28402. */
  28403. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28404. /**
  28405. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28406. * are rendered back to front.
  28407. *
  28408. * @param a The first submesh
  28409. * @param b The second submesh
  28410. * @returns The result of the comparison
  28411. */
  28412. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28413. /**
  28414. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28415. * are rendered front to back (prevent overdraw).
  28416. *
  28417. * @param a The first submesh
  28418. * @param b The second submesh
  28419. * @returns The result of the comparison
  28420. */
  28421. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28422. /**
  28423. * Resets the different lists of submeshes to prepare a new frame.
  28424. */
  28425. prepare(): void;
  28426. dispose(): void;
  28427. /**
  28428. * Inserts the submesh in its correct queue depending on its material.
  28429. * @param subMesh The submesh to dispatch
  28430. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28431. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28432. */
  28433. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28434. dispatchSprites(spriteManager: ISpriteManager): void;
  28435. dispatchParticles(particleSystem: IParticleSystem): void;
  28436. private _renderParticles;
  28437. private _renderSprites;
  28438. }
  28439. }
  28440. declare module BABYLON {
  28441. /**
  28442. * Interface describing the different options available in the rendering manager
  28443. * regarding Auto Clear between groups.
  28444. */
  28445. export interface IRenderingManagerAutoClearSetup {
  28446. /**
  28447. * Defines whether or not autoclear is enable.
  28448. */
  28449. autoClear: boolean;
  28450. /**
  28451. * Defines whether or not to autoclear the depth buffer.
  28452. */
  28453. depth: boolean;
  28454. /**
  28455. * Defines whether or not to autoclear the stencil buffer.
  28456. */
  28457. stencil: boolean;
  28458. }
  28459. /**
  28460. * This class is used by the onRenderingGroupObservable
  28461. */
  28462. export class RenderingGroupInfo {
  28463. /**
  28464. * The Scene that being rendered
  28465. */
  28466. scene: Scene;
  28467. /**
  28468. * The camera currently used for the rendering pass
  28469. */
  28470. camera: Nullable<Camera>;
  28471. /**
  28472. * The ID of the renderingGroup being processed
  28473. */
  28474. renderingGroupId: number;
  28475. }
  28476. /**
  28477. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28478. * It is enable to manage the different groups as well as the different necessary sort functions.
  28479. * This should not be used directly aside of the few static configurations
  28480. */
  28481. export class RenderingManager {
  28482. /**
  28483. * The max id used for rendering groups (not included)
  28484. */
  28485. static MAX_RENDERINGGROUPS: number;
  28486. /**
  28487. * The min id used for rendering groups (included)
  28488. */
  28489. static MIN_RENDERINGGROUPS: number;
  28490. /**
  28491. * Used to globally prevent autoclearing scenes.
  28492. */
  28493. static AUTOCLEAR: boolean;
  28494. /**
  28495. * @hidden
  28496. */
  28497. _useSceneAutoClearSetup: boolean;
  28498. private _scene;
  28499. private _renderingGroups;
  28500. private _depthStencilBufferAlreadyCleaned;
  28501. private _autoClearDepthStencil;
  28502. private _customOpaqueSortCompareFn;
  28503. private _customAlphaTestSortCompareFn;
  28504. private _customTransparentSortCompareFn;
  28505. private _renderingGroupInfo;
  28506. /**
  28507. * Instantiates a new rendering group for a particular scene
  28508. * @param scene Defines the scene the groups belongs to
  28509. */
  28510. constructor(scene: Scene);
  28511. private _clearDepthStencilBuffer;
  28512. /**
  28513. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28514. * @hidden
  28515. */
  28516. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28517. /**
  28518. * Resets the different information of the group to prepare a new frame
  28519. * @hidden
  28520. */
  28521. reset(): void;
  28522. /**
  28523. * Dispose and release the group and its associated resources.
  28524. * @hidden
  28525. */
  28526. dispose(): void;
  28527. /**
  28528. * Clear the info related to rendering groups preventing retention points during dispose.
  28529. */
  28530. freeRenderingGroups(): void;
  28531. private _prepareRenderingGroup;
  28532. /**
  28533. * Add a sprite manager to the rendering manager in order to render it this frame.
  28534. * @param spriteManager Define the sprite manager to render
  28535. */
  28536. dispatchSprites(spriteManager: ISpriteManager): void;
  28537. /**
  28538. * Add a particle system to the rendering manager in order to render it this frame.
  28539. * @param particleSystem Define the particle system to render
  28540. */
  28541. dispatchParticles(particleSystem: IParticleSystem): void;
  28542. /**
  28543. * Add a submesh to the manager in order to render it this frame
  28544. * @param subMesh The submesh to dispatch
  28545. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28546. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28547. */
  28548. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28549. /**
  28550. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28551. * This allowed control for front to back rendering or reversly depending of the special needs.
  28552. *
  28553. * @param renderingGroupId The rendering group id corresponding to its index
  28554. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28555. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28556. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28557. */
  28558. 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;
  28559. /**
  28560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28561. *
  28562. * @param renderingGroupId The rendering group id corresponding to its index
  28563. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28564. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28565. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28566. */
  28567. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28568. /**
  28569. * Gets the current auto clear configuration for one rendering group of the rendering
  28570. * manager.
  28571. * @param index the rendering group index to get the information for
  28572. * @returns The auto clear setup for the requested rendering group
  28573. */
  28574. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28575. }
  28576. }
  28577. declare module BABYLON {
  28578. /**
  28579. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28580. */
  28581. export interface ICustomShaderOptions {
  28582. /**
  28583. * Gets or sets the custom shader name to use
  28584. */
  28585. shaderName: string;
  28586. /**
  28587. * The list of attribute names used in the shader
  28588. */
  28589. attributes?: string[];
  28590. /**
  28591. * The list of unifrom names used in the shader
  28592. */
  28593. uniforms?: string[];
  28594. /**
  28595. * The list of sampler names used in the shader
  28596. */
  28597. samplers?: string[];
  28598. /**
  28599. * The list of defines used in the shader
  28600. */
  28601. defines?: string[];
  28602. }
  28603. /**
  28604. * Interface to implement to create a shadow generator compatible with BJS.
  28605. */
  28606. export interface IShadowGenerator {
  28607. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28608. id: string;
  28609. /**
  28610. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28611. * @returns The render target texture if present otherwise, null
  28612. */
  28613. getShadowMap(): Nullable<RenderTargetTexture>;
  28614. /**
  28615. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28616. * @param subMesh The submesh we want to render in the shadow map
  28617. * @param useInstances Defines wether will draw in the map using instances
  28618. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28619. * @returns true if ready otherwise, false
  28620. */
  28621. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28622. /**
  28623. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28624. * @param defines Defines of the material we want to update
  28625. * @param lightIndex Index of the light in the enabled light list of the material
  28626. */
  28627. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28628. /**
  28629. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28630. * defined in the generator but impacting the effect).
  28631. * It implies the unifroms available on the materials are the standard BJS ones.
  28632. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28633. * @param effect The effect we are binfing the information for
  28634. */
  28635. bindShadowLight(lightIndex: string, effect: Effect): void;
  28636. /**
  28637. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28638. * (eq to shadow prjection matrix * light transform matrix)
  28639. * @returns The transform matrix used to create the shadow map
  28640. */
  28641. getTransformMatrix(): Matrix;
  28642. /**
  28643. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28644. * Cube and 2D textures for instance.
  28645. */
  28646. recreateShadowMap(): void;
  28647. /**
  28648. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28649. * @param onCompiled Callback triggered at the and of the effects compilation
  28650. * @param options Sets of optional options forcing the compilation with different modes
  28651. */
  28652. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28653. useInstances: boolean;
  28654. }>): void;
  28655. /**
  28656. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28657. * @param options Sets of optional options forcing the compilation with different modes
  28658. * @returns A promise that resolves when the compilation completes
  28659. */
  28660. forceCompilationAsync(options?: Partial<{
  28661. useInstances: boolean;
  28662. }>): Promise<void>;
  28663. /**
  28664. * Serializes the shadow generator setup to a json object.
  28665. * @returns The serialized JSON object
  28666. */
  28667. serialize(): any;
  28668. /**
  28669. * Disposes the Shadow map and related Textures and effects.
  28670. */
  28671. dispose(): void;
  28672. }
  28673. /**
  28674. * Default implementation IShadowGenerator.
  28675. * This is the main object responsible of generating shadows in the framework.
  28676. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28677. */
  28678. export class ShadowGenerator implements IShadowGenerator {
  28679. /**
  28680. * Name of the shadow generator class
  28681. */
  28682. static CLASSNAME: string;
  28683. /**
  28684. * Shadow generator mode None: no filtering applied.
  28685. */
  28686. static readonly FILTER_NONE: number;
  28687. /**
  28688. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28689. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28690. */
  28691. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28692. /**
  28693. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28694. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28695. */
  28696. static readonly FILTER_POISSONSAMPLING: number;
  28697. /**
  28698. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28699. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28700. */
  28701. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28702. /**
  28703. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28704. * edge artifacts on steep falloff.
  28705. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28706. */
  28707. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28708. /**
  28709. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28710. * edge artifacts on steep falloff.
  28711. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28712. */
  28713. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28714. /**
  28715. * Shadow generator mode PCF: Percentage Closer Filtering
  28716. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28717. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28718. */
  28719. static readonly FILTER_PCF: number;
  28720. /**
  28721. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28722. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28723. * Contact Hardening
  28724. */
  28725. static readonly FILTER_PCSS: number;
  28726. /**
  28727. * Reserved for PCF and PCSS
  28728. * Highest Quality.
  28729. *
  28730. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28731. *
  28732. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28733. */
  28734. static readonly QUALITY_HIGH: number;
  28735. /**
  28736. * Reserved for PCF and PCSS
  28737. * Good tradeoff for quality/perf cross devices
  28738. *
  28739. * Execute PCF on a 3*3 kernel.
  28740. *
  28741. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28742. */
  28743. static readonly QUALITY_MEDIUM: number;
  28744. /**
  28745. * Reserved for PCF and PCSS
  28746. * The lowest quality but the fastest.
  28747. *
  28748. * Execute PCF on a 1*1 kernel.
  28749. *
  28750. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28751. */
  28752. static readonly QUALITY_LOW: number;
  28753. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28754. id: string;
  28755. /** Gets or sets the custom shader name to use */
  28756. customShaderOptions: ICustomShaderOptions;
  28757. /**
  28758. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28759. */
  28760. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28761. /**
  28762. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28763. */
  28764. onAfterShadowMapRenderObservable: Observable<Effect>;
  28765. /**
  28766. * Observable triggered before a mesh is rendered in the shadow map.
  28767. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28768. */
  28769. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28770. /**
  28771. * Observable triggered after a mesh is rendered in the shadow map.
  28772. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28773. */
  28774. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28775. protected _bias: number;
  28776. /**
  28777. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28778. */
  28779. get bias(): number;
  28780. /**
  28781. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28782. */
  28783. set bias(bias: number);
  28784. protected _normalBias: number;
  28785. /**
  28786. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28787. */
  28788. get normalBias(): number;
  28789. /**
  28790. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28791. */
  28792. set normalBias(normalBias: number);
  28793. protected _blurBoxOffset: number;
  28794. /**
  28795. * Gets the blur box offset: offset applied during the blur pass.
  28796. * Only useful if useKernelBlur = false
  28797. */
  28798. get blurBoxOffset(): number;
  28799. /**
  28800. * Sets the blur box offset: offset applied during the blur pass.
  28801. * Only useful if useKernelBlur = false
  28802. */
  28803. set blurBoxOffset(value: number);
  28804. protected _blurScale: number;
  28805. /**
  28806. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28807. * 2 means half of the size.
  28808. */
  28809. get blurScale(): number;
  28810. /**
  28811. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28812. * 2 means half of the size.
  28813. */
  28814. set blurScale(value: number);
  28815. protected _blurKernel: number;
  28816. /**
  28817. * Gets the blur kernel: kernel size of the blur pass.
  28818. * Only useful if useKernelBlur = true
  28819. */
  28820. get blurKernel(): number;
  28821. /**
  28822. * Sets the blur kernel: kernel size of the blur pass.
  28823. * Only useful if useKernelBlur = true
  28824. */
  28825. set blurKernel(value: number);
  28826. protected _useKernelBlur: boolean;
  28827. /**
  28828. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28829. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28830. */
  28831. get useKernelBlur(): boolean;
  28832. /**
  28833. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28834. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28835. */
  28836. set useKernelBlur(value: boolean);
  28837. protected _depthScale: number;
  28838. /**
  28839. * Gets the depth scale used in ESM mode.
  28840. */
  28841. get depthScale(): number;
  28842. /**
  28843. * Sets the depth scale used in ESM mode.
  28844. * This can override the scale stored on the light.
  28845. */
  28846. set depthScale(value: number);
  28847. protected _validateFilter(filter: number): number;
  28848. protected _filter: number;
  28849. /**
  28850. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28851. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28852. */
  28853. get filter(): number;
  28854. /**
  28855. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28856. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28857. */
  28858. set filter(value: number);
  28859. /**
  28860. * Gets if the current filter is set to Poisson Sampling.
  28861. */
  28862. get usePoissonSampling(): boolean;
  28863. /**
  28864. * Sets the current filter to Poisson Sampling.
  28865. */
  28866. set usePoissonSampling(value: boolean);
  28867. /**
  28868. * Gets if the current filter is set to ESM.
  28869. */
  28870. get useExponentialShadowMap(): boolean;
  28871. /**
  28872. * Sets the current filter is to ESM.
  28873. */
  28874. set useExponentialShadowMap(value: boolean);
  28875. /**
  28876. * Gets if the current filter is set to filtered ESM.
  28877. */
  28878. get useBlurExponentialShadowMap(): boolean;
  28879. /**
  28880. * Gets if the current filter is set to filtered ESM.
  28881. */
  28882. set useBlurExponentialShadowMap(value: boolean);
  28883. /**
  28884. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28885. * exponential to prevent steep falloff artifacts).
  28886. */
  28887. get useCloseExponentialShadowMap(): boolean;
  28888. /**
  28889. * Sets the current filter to "close ESM" (using the inverse of the
  28890. * exponential to prevent steep falloff artifacts).
  28891. */
  28892. set useCloseExponentialShadowMap(value: boolean);
  28893. /**
  28894. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28895. * exponential to prevent steep falloff artifacts).
  28896. */
  28897. get useBlurCloseExponentialShadowMap(): boolean;
  28898. /**
  28899. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28900. * exponential to prevent steep falloff artifacts).
  28901. */
  28902. set useBlurCloseExponentialShadowMap(value: boolean);
  28903. /**
  28904. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28905. */
  28906. get usePercentageCloserFiltering(): boolean;
  28907. /**
  28908. * Sets the current filter to "PCF" (percentage closer filtering).
  28909. */
  28910. set usePercentageCloserFiltering(value: boolean);
  28911. protected _filteringQuality: number;
  28912. /**
  28913. * Gets the PCF or PCSS Quality.
  28914. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28915. */
  28916. get filteringQuality(): number;
  28917. /**
  28918. * Sets the PCF or PCSS Quality.
  28919. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28920. */
  28921. set filteringQuality(filteringQuality: number);
  28922. /**
  28923. * Gets if the current filter is set to "PCSS" (contact hardening).
  28924. */
  28925. get useContactHardeningShadow(): boolean;
  28926. /**
  28927. * Sets the current filter to "PCSS" (contact hardening).
  28928. */
  28929. set useContactHardeningShadow(value: boolean);
  28930. protected _contactHardeningLightSizeUVRatio: number;
  28931. /**
  28932. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28933. * Using a ratio helps keeping shape stability independently of the map size.
  28934. *
  28935. * It does not account for the light projection as it was having too much
  28936. * instability during the light setup or during light position changes.
  28937. *
  28938. * Only valid if useContactHardeningShadow is true.
  28939. */
  28940. get contactHardeningLightSizeUVRatio(): number;
  28941. /**
  28942. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28943. * Using a ratio helps keeping shape stability independently of the map size.
  28944. *
  28945. * It does not account for the light projection as it was having too much
  28946. * instability during the light setup or during light position changes.
  28947. *
  28948. * Only valid if useContactHardeningShadow is true.
  28949. */
  28950. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  28951. protected _darkness: number;
  28952. /** Gets or sets the actual darkness of a shadow */
  28953. get darkness(): number;
  28954. set darkness(value: number);
  28955. /**
  28956. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28957. * 0 means strongest and 1 would means no shadow.
  28958. * @returns the darkness.
  28959. */
  28960. getDarkness(): number;
  28961. /**
  28962. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  28963. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  28964. * @returns the shadow generator allowing fluent coding.
  28965. */
  28966. setDarkness(darkness: number): ShadowGenerator;
  28967. protected _transparencyShadow: boolean;
  28968. /** Gets or sets the ability to have transparent shadow */
  28969. get transparencyShadow(): boolean;
  28970. set transparencyShadow(value: boolean);
  28971. /**
  28972. * Sets the ability to have transparent shadow (boolean).
  28973. * @param transparent True if transparent else False
  28974. * @returns the shadow generator allowing fluent coding
  28975. */
  28976. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  28977. /**
  28978. * Enables or disables shadows with varying strength based on the transparency
  28979. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  28980. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  28981. * mesh.visibility * alphaTexture.a
  28982. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  28983. */
  28984. enableSoftTransparentShadow: boolean;
  28985. protected _shadowMap: Nullable<RenderTargetTexture>;
  28986. protected _shadowMap2: Nullable<RenderTargetTexture>;
  28987. /**
  28988. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28989. * @returns The render target texture if present otherwise, null
  28990. */
  28991. getShadowMap(): Nullable<RenderTargetTexture>;
  28992. /**
  28993. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  28994. * @returns The render target texture if the shadow map is present otherwise, null
  28995. */
  28996. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  28997. /**
  28998. * Gets the class name of that object
  28999. * @returns "ShadowGenerator"
  29000. */
  29001. getClassName(): string;
  29002. /**
  29003. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29004. * @param mesh Mesh to add
  29005. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29006. * @returns the Shadow Generator itself
  29007. */
  29008. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29009. /**
  29010. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29011. * @param mesh Mesh to remove
  29012. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29013. * @returns the Shadow Generator itself
  29014. */
  29015. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29016. /**
  29017. * Controls the extent to which the shadows fade out at the edge of the frustum
  29018. */
  29019. frustumEdgeFalloff: number;
  29020. protected _light: IShadowLight;
  29021. /**
  29022. * Returns the associated light object.
  29023. * @returns the light generating the shadow
  29024. */
  29025. getLight(): IShadowLight;
  29026. /**
  29027. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29028. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29029. * It might on the other hand introduce peter panning.
  29030. */
  29031. forceBackFacesOnly: boolean;
  29032. protected _scene: Scene;
  29033. protected _lightDirection: Vector3;
  29034. protected _effect: Effect;
  29035. protected _viewMatrix: Matrix;
  29036. protected _projectionMatrix: Matrix;
  29037. protected _transformMatrix: Matrix;
  29038. protected _cachedPosition: Vector3;
  29039. protected _cachedDirection: Vector3;
  29040. protected _cachedDefines: string;
  29041. protected _currentRenderID: number;
  29042. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29043. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29044. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29045. protected _blurPostProcesses: PostProcess[];
  29046. protected _mapSize: number;
  29047. protected _currentFaceIndex: number;
  29048. protected _currentFaceIndexCache: number;
  29049. protected _textureType: number;
  29050. protected _defaultTextureMatrix: Matrix;
  29051. protected _storedUniqueId: Nullable<number>;
  29052. /** @hidden */
  29053. static _SceneComponentInitialization: (scene: Scene) => void;
  29054. /**
  29055. * Gets or sets the size of the texture what stores the shadows
  29056. */
  29057. get mapSize(): number;
  29058. set mapSize(size: number);
  29059. /**
  29060. * Creates a ShadowGenerator object.
  29061. * A ShadowGenerator is the required tool to use the shadows.
  29062. * Each light casting shadows needs to use its own ShadowGenerator.
  29063. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29064. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29065. * @param light The light object generating the shadows.
  29066. * @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.
  29067. */
  29068. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29069. protected _initializeGenerator(): void;
  29070. protected _createTargetRenderTexture(): void;
  29071. protected _initializeShadowMap(): void;
  29072. protected _initializeBlurRTTAndPostProcesses(): void;
  29073. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29074. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29075. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29076. protected _applyFilterValues(): void;
  29077. /**
  29078. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29079. * @param onCompiled Callback triggered at the and of the effects compilation
  29080. * @param options Sets of optional options forcing the compilation with different modes
  29081. */
  29082. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29083. useInstances: boolean;
  29084. }>): void;
  29085. /**
  29086. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29087. * @param options Sets of optional options forcing the compilation with different modes
  29088. * @returns A promise that resolves when the compilation completes
  29089. */
  29090. forceCompilationAsync(options?: Partial<{
  29091. useInstances: boolean;
  29092. }>): Promise<void>;
  29093. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29094. private _prepareShadowDefines;
  29095. /**
  29096. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29097. * @param subMesh The submesh we want to render in the shadow map
  29098. * @param useInstances Defines wether will draw in the map using instances
  29099. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29100. * @returns true if ready otherwise, false
  29101. */
  29102. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29103. /**
  29104. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29105. * @param defines Defines of the material we want to update
  29106. * @param lightIndex Index of the light in the enabled light list of the material
  29107. */
  29108. prepareDefines(defines: any, lightIndex: number): void;
  29109. /**
  29110. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29111. * defined in the generator but impacting the effect).
  29112. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29113. * @param effect The effect we are binfing the information for
  29114. */
  29115. bindShadowLight(lightIndex: string, effect: Effect): void;
  29116. /**
  29117. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29118. * (eq to shadow prjection matrix * light transform matrix)
  29119. * @returns The transform matrix used to create the shadow map
  29120. */
  29121. getTransformMatrix(): Matrix;
  29122. /**
  29123. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29124. * Cube and 2D textures for instance.
  29125. */
  29126. recreateShadowMap(): void;
  29127. protected _disposeBlurPostProcesses(): void;
  29128. protected _disposeRTTandPostProcesses(): void;
  29129. /**
  29130. * Disposes the ShadowGenerator.
  29131. * Returns nothing.
  29132. */
  29133. dispose(): void;
  29134. /**
  29135. * Serializes the shadow generator setup to a json object.
  29136. * @returns The serialized JSON object
  29137. */
  29138. serialize(): any;
  29139. /**
  29140. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29141. * @param parsedShadowGenerator The JSON object to parse
  29142. * @param scene The scene to create the shadow map for
  29143. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29144. * @returns The parsed shadow generator
  29145. */
  29146. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29147. }
  29148. }
  29149. declare module BABYLON {
  29150. /**
  29151. * Options to be used when creating a shadow depth material
  29152. */
  29153. export interface IIOptionShadowDepthMaterial {
  29154. /** Variables in the vertex shader code that need to have their names remapped.
  29155. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29156. * "var_name" should be either: worldPos or vNormalW
  29157. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29158. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29159. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29160. */
  29161. remappedVariables?: string[];
  29162. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29163. standalone?: boolean;
  29164. }
  29165. /**
  29166. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29167. */
  29168. export class ShadowDepthWrapper {
  29169. private _scene;
  29170. private _options?;
  29171. private _baseMaterial;
  29172. private _onEffectCreatedObserver;
  29173. private _subMeshToEffect;
  29174. private _subMeshToDepthEffect;
  29175. private _meshes;
  29176. /** @hidden */
  29177. _matriceNames: any;
  29178. /** Gets the standalone status of the wrapper */
  29179. get standalone(): boolean;
  29180. /** Gets the base material the wrapper is built upon */
  29181. get baseMaterial(): Material;
  29182. /**
  29183. * Instantiate a new shadow depth wrapper.
  29184. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29185. * generate the shadow depth map. For more information, please refer to the documentation:
  29186. * https://doc.babylonjs.com/babylon101/shadows
  29187. * @param baseMaterial Material to wrap
  29188. * @param scene Define the scene the material belongs to
  29189. * @param options Options used to create the wrapper
  29190. */
  29191. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29192. /**
  29193. * Gets the effect to use to generate the depth map
  29194. * @param subMesh subMesh to get the effect for
  29195. * @param shadowGenerator shadow generator to get the effect for
  29196. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29197. */
  29198. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29199. /**
  29200. * Specifies that the submesh is ready to be used for depth rendering
  29201. * @param subMesh submesh to check
  29202. * @param defines the list of defines to take into account when checking the effect
  29203. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29204. * @param useInstances specifies that instances should be used
  29205. * @returns a boolean indicating that the submesh is ready or not
  29206. */
  29207. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29208. /**
  29209. * Disposes the resources
  29210. */
  29211. dispose(): void;
  29212. private _makeEffect;
  29213. }
  29214. }
  29215. declare module BABYLON {
  29216. /**
  29217. * Options for compiling materials.
  29218. */
  29219. export interface IMaterialCompilationOptions {
  29220. /**
  29221. * Defines whether clip planes are enabled.
  29222. */
  29223. clipPlane: boolean;
  29224. /**
  29225. * Defines whether instances are enabled.
  29226. */
  29227. useInstances: boolean;
  29228. }
  29229. /**
  29230. * Options passed when calling customShaderNameResolve
  29231. */
  29232. export interface ICustomShaderNameResolveOptions {
  29233. /**
  29234. * 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
  29235. */
  29236. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29237. }
  29238. /**
  29239. * Base class for the main features of a material in Babylon.js
  29240. */
  29241. export class Material implements IAnimatable {
  29242. /**
  29243. * Returns the triangle fill mode
  29244. */
  29245. static readonly TriangleFillMode: number;
  29246. /**
  29247. * Returns the wireframe mode
  29248. */
  29249. static readonly WireFrameFillMode: number;
  29250. /**
  29251. * Returns the point fill mode
  29252. */
  29253. static readonly PointFillMode: number;
  29254. /**
  29255. * Returns the point list draw mode
  29256. */
  29257. static readonly PointListDrawMode: number;
  29258. /**
  29259. * Returns the line list draw mode
  29260. */
  29261. static readonly LineListDrawMode: number;
  29262. /**
  29263. * Returns the line loop draw mode
  29264. */
  29265. static readonly LineLoopDrawMode: number;
  29266. /**
  29267. * Returns the line strip draw mode
  29268. */
  29269. static readonly LineStripDrawMode: number;
  29270. /**
  29271. * Returns the triangle strip draw mode
  29272. */
  29273. static readonly TriangleStripDrawMode: number;
  29274. /**
  29275. * Returns the triangle fan draw mode
  29276. */
  29277. static readonly TriangleFanDrawMode: number;
  29278. /**
  29279. * Stores the clock-wise side orientation
  29280. */
  29281. static readonly ClockWiseSideOrientation: number;
  29282. /**
  29283. * Stores the counter clock-wise side orientation
  29284. */
  29285. static readonly CounterClockWiseSideOrientation: number;
  29286. /**
  29287. * The dirty texture flag value
  29288. */
  29289. static readonly TextureDirtyFlag: number;
  29290. /**
  29291. * The dirty light flag value
  29292. */
  29293. static readonly LightDirtyFlag: number;
  29294. /**
  29295. * The dirty fresnel flag value
  29296. */
  29297. static readonly FresnelDirtyFlag: number;
  29298. /**
  29299. * The dirty attribute flag value
  29300. */
  29301. static readonly AttributesDirtyFlag: number;
  29302. /**
  29303. * The dirty misc flag value
  29304. */
  29305. static readonly MiscDirtyFlag: number;
  29306. /**
  29307. * The dirty prepass flag value
  29308. */
  29309. static readonly PrePassDirtyFlag: number;
  29310. /**
  29311. * The all dirty flag value
  29312. */
  29313. static readonly AllDirtyFlag: number;
  29314. /**
  29315. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29316. */
  29317. static readonly MATERIAL_OPAQUE: number;
  29318. /**
  29319. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29320. */
  29321. static readonly MATERIAL_ALPHATEST: number;
  29322. /**
  29323. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29324. */
  29325. static readonly MATERIAL_ALPHABLEND: number;
  29326. /**
  29327. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29328. * They are also discarded below the alpha cutoff threshold to improve performances.
  29329. */
  29330. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29331. /**
  29332. * The Whiteout method is used to blend normals.
  29333. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29334. */
  29335. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29336. /**
  29337. * The Reoriented Normal Mapping method is used to blend normals.
  29338. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29339. */
  29340. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29341. /**
  29342. * Custom callback helping to override the default shader used in the material.
  29343. */
  29344. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29345. /**
  29346. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29347. */
  29348. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29349. /**
  29350. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29351. * This means that the material can keep using a previous shader while a new one is being compiled.
  29352. * This is mostly used when shader parallel compilation is supported (true by default)
  29353. */
  29354. allowShaderHotSwapping: boolean;
  29355. /**
  29356. * The ID of the material
  29357. */
  29358. id: string;
  29359. /**
  29360. * Gets or sets the unique id of the material
  29361. */
  29362. uniqueId: number;
  29363. /**
  29364. * The name of the material
  29365. */
  29366. name: string;
  29367. /**
  29368. * Gets or sets user defined metadata
  29369. */
  29370. metadata: any;
  29371. /**
  29372. * For internal use only. Please do not use.
  29373. */
  29374. reservedDataStore: any;
  29375. /**
  29376. * Specifies if the ready state should be checked on each call
  29377. */
  29378. checkReadyOnEveryCall: boolean;
  29379. /**
  29380. * Specifies if the ready state should be checked once
  29381. */
  29382. checkReadyOnlyOnce: boolean;
  29383. /**
  29384. * The state of the material
  29385. */
  29386. state: string;
  29387. /**
  29388. * If the material can be rendered to several textures with MRT extension
  29389. */
  29390. get canRenderToMRT(): boolean;
  29391. /**
  29392. * The alpha value of the material
  29393. */
  29394. protected _alpha: number;
  29395. /**
  29396. * List of inspectable custom properties (used by the Inspector)
  29397. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29398. */
  29399. inspectableCustomProperties: IInspectable[];
  29400. /**
  29401. * Sets the alpha value of the material
  29402. */
  29403. set alpha(value: number);
  29404. /**
  29405. * Gets the alpha value of the material
  29406. */
  29407. get alpha(): number;
  29408. /**
  29409. * Specifies if back face culling is enabled
  29410. */
  29411. protected _backFaceCulling: boolean;
  29412. /**
  29413. * Sets the back-face culling state
  29414. */
  29415. set backFaceCulling(value: boolean);
  29416. /**
  29417. * Gets the back-face culling state
  29418. */
  29419. get backFaceCulling(): boolean;
  29420. /**
  29421. * Stores the value for side orientation
  29422. */
  29423. sideOrientation: number;
  29424. /**
  29425. * Callback triggered when the material is compiled
  29426. */
  29427. onCompiled: Nullable<(effect: Effect) => void>;
  29428. /**
  29429. * Callback triggered when an error occurs
  29430. */
  29431. onError: Nullable<(effect: Effect, errors: string) => void>;
  29432. /**
  29433. * Callback triggered to get the render target textures
  29434. */
  29435. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29436. /**
  29437. * Gets a boolean indicating that current material needs to register RTT
  29438. */
  29439. get hasRenderTargetTextures(): boolean;
  29440. /**
  29441. * Specifies if the material should be serialized
  29442. */
  29443. doNotSerialize: boolean;
  29444. /**
  29445. * @hidden
  29446. */
  29447. _storeEffectOnSubMeshes: boolean;
  29448. /**
  29449. * Stores the animations for the material
  29450. */
  29451. animations: Nullable<Array<Animation>>;
  29452. /**
  29453. * An event triggered when the material is disposed
  29454. */
  29455. onDisposeObservable: Observable<Material>;
  29456. /**
  29457. * An observer which watches for dispose events
  29458. */
  29459. private _onDisposeObserver;
  29460. private _onUnBindObservable;
  29461. /**
  29462. * Called during a dispose event
  29463. */
  29464. set onDispose(callback: () => void);
  29465. private _onBindObservable;
  29466. /**
  29467. * An event triggered when the material is bound
  29468. */
  29469. get onBindObservable(): Observable<AbstractMesh>;
  29470. /**
  29471. * An observer which watches for bind events
  29472. */
  29473. private _onBindObserver;
  29474. /**
  29475. * Called during a bind event
  29476. */
  29477. set onBind(callback: (Mesh: AbstractMesh) => void);
  29478. /**
  29479. * An event triggered when the material is unbound
  29480. */
  29481. get onUnBindObservable(): Observable<Material>;
  29482. protected _onEffectCreatedObservable: Nullable<Observable<{
  29483. effect: Effect;
  29484. subMesh: Nullable<SubMesh>;
  29485. }>>;
  29486. /**
  29487. * An event triggered when the effect is (re)created
  29488. */
  29489. get onEffectCreatedObservable(): Observable<{
  29490. effect: Effect;
  29491. subMesh: Nullable<SubMesh>;
  29492. }>;
  29493. /**
  29494. * Stores the value of the alpha mode
  29495. */
  29496. private _alphaMode;
  29497. /**
  29498. * Sets the value of the alpha mode.
  29499. *
  29500. * | Value | Type | Description |
  29501. * | --- | --- | --- |
  29502. * | 0 | ALPHA_DISABLE | |
  29503. * | 1 | ALPHA_ADD | |
  29504. * | 2 | ALPHA_COMBINE | |
  29505. * | 3 | ALPHA_SUBTRACT | |
  29506. * | 4 | ALPHA_MULTIPLY | |
  29507. * | 5 | ALPHA_MAXIMIZED | |
  29508. * | 6 | ALPHA_ONEONE | |
  29509. * | 7 | ALPHA_PREMULTIPLIED | |
  29510. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29511. * | 9 | ALPHA_INTERPOLATE | |
  29512. * | 10 | ALPHA_SCREENMODE | |
  29513. *
  29514. */
  29515. set alphaMode(value: number);
  29516. /**
  29517. * Gets the value of the alpha mode
  29518. */
  29519. get alphaMode(): number;
  29520. /**
  29521. * Stores the state of the need depth pre-pass value
  29522. */
  29523. private _needDepthPrePass;
  29524. /**
  29525. * Sets the need depth pre-pass value
  29526. */
  29527. set needDepthPrePass(value: boolean);
  29528. /**
  29529. * Gets the depth pre-pass value
  29530. */
  29531. get needDepthPrePass(): boolean;
  29532. /**
  29533. * Specifies if depth writing should be disabled
  29534. */
  29535. disableDepthWrite: boolean;
  29536. /**
  29537. * Specifies if color writing should be disabled
  29538. */
  29539. disableColorWrite: boolean;
  29540. /**
  29541. * Specifies if depth writing should be forced
  29542. */
  29543. forceDepthWrite: boolean;
  29544. /**
  29545. * Specifies the depth function that should be used. 0 means the default engine function
  29546. */
  29547. depthFunction: number;
  29548. /**
  29549. * Specifies if there should be a separate pass for culling
  29550. */
  29551. separateCullingPass: boolean;
  29552. /**
  29553. * Stores the state specifing if fog should be enabled
  29554. */
  29555. private _fogEnabled;
  29556. /**
  29557. * Sets the state for enabling fog
  29558. */
  29559. set fogEnabled(value: boolean);
  29560. /**
  29561. * Gets the value of the fog enabled state
  29562. */
  29563. get fogEnabled(): boolean;
  29564. /**
  29565. * Stores the size of points
  29566. */
  29567. pointSize: number;
  29568. /**
  29569. * Stores the z offset value
  29570. */
  29571. zOffset: number;
  29572. get wireframe(): boolean;
  29573. /**
  29574. * Sets the state of wireframe mode
  29575. */
  29576. set wireframe(value: boolean);
  29577. /**
  29578. * Gets the value specifying if point clouds are enabled
  29579. */
  29580. get pointsCloud(): boolean;
  29581. /**
  29582. * Sets the state of point cloud mode
  29583. */
  29584. set pointsCloud(value: boolean);
  29585. /**
  29586. * Gets the material fill mode
  29587. */
  29588. get fillMode(): number;
  29589. /**
  29590. * Sets the material fill mode
  29591. */
  29592. set fillMode(value: number);
  29593. /**
  29594. * @hidden
  29595. * Stores the effects for the material
  29596. */
  29597. _effect: Nullable<Effect>;
  29598. /**
  29599. * Specifies if uniform buffers should be used
  29600. */
  29601. private _useUBO;
  29602. /**
  29603. * Stores a reference to the scene
  29604. */
  29605. private _scene;
  29606. /**
  29607. * Stores the fill mode state
  29608. */
  29609. private _fillMode;
  29610. /**
  29611. * Specifies if the depth write state should be cached
  29612. */
  29613. private _cachedDepthWriteState;
  29614. /**
  29615. * Specifies if the color write state should be cached
  29616. */
  29617. private _cachedColorWriteState;
  29618. /**
  29619. * Specifies if the depth function state should be cached
  29620. */
  29621. private _cachedDepthFunctionState;
  29622. /**
  29623. * Stores the uniform buffer
  29624. */
  29625. protected _uniformBuffer: UniformBuffer;
  29626. /** @hidden */
  29627. _indexInSceneMaterialArray: number;
  29628. /** @hidden */
  29629. meshMap: Nullable<{
  29630. [id: string]: AbstractMesh | undefined;
  29631. }>;
  29632. /**
  29633. * Creates a material instance
  29634. * @param name defines the name of the material
  29635. * @param scene defines the scene to reference
  29636. * @param doNotAdd specifies if the material should be added to the scene
  29637. */
  29638. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29639. /**
  29640. * Returns a string representation of the current material
  29641. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29642. * @returns a string with material information
  29643. */
  29644. toString(fullDetails?: boolean): string;
  29645. /**
  29646. * Gets the class name of the material
  29647. * @returns a string with the class name of the material
  29648. */
  29649. getClassName(): string;
  29650. /**
  29651. * Specifies if updates for the material been locked
  29652. */
  29653. get isFrozen(): boolean;
  29654. /**
  29655. * Locks updates for the material
  29656. */
  29657. freeze(): void;
  29658. /**
  29659. * Unlocks updates for the material
  29660. */
  29661. unfreeze(): void;
  29662. /**
  29663. * Specifies if the material is ready to be used
  29664. * @param mesh defines the mesh to check
  29665. * @param useInstances specifies if instances should be used
  29666. * @returns a boolean indicating if the material is ready to be used
  29667. */
  29668. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29669. /**
  29670. * Specifies that the submesh is ready to be used
  29671. * @param mesh defines the mesh to check
  29672. * @param subMesh defines which submesh to check
  29673. * @param useInstances specifies that instances should be used
  29674. * @returns a boolean indicating that the submesh is ready or not
  29675. */
  29676. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29677. /**
  29678. * Returns the material effect
  29679. * @returns the effect associated with the material
  29680. */
  29681. getEffect(): Nullable<Effect>;
  29682. /**
  29683. * Returns the current scene
  29684. * @returns a Scene
  29685. */
  29686. getScene(): Scene;
  29687. /**
  29688. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29689. */
  29690. protected _forceAlphaTest: boolean;
  29691. /**
  29692. * The transparency mode of the material.
  29693. */
  29694. protected _transparencyMode: Nullable<number>;
  29695. /**
  29696. * Gets the current transparency mode.
  29697. */
  29698. get transparencyMode(): Nullable<number>;
  29699. /**
  29700. * Sets the transparency mode of the material.
  29701. *
  29702. * | Value | Type | Description |
  29703. * | ----- | ----------------------------------- | ----------- |
  29704. * | 0 | OPAQUE | |
  29705. * | 1 | ALPHATEST | |
  29706. * | 2 | ALPHABLEND | |
  29707. * | 3 | ALPHATESTANDBLEND | |
  29708. *
  29709. */
  29710. set transparencyMode(value: Nullable<number>);
  29711. /**
  29712. * Returns true if alpha blending should be disabled.
  29713. */
  29714. protected get _disableAlphaBlending(): boolean;
  29715. /**
  29716. * Specifies whether or not this material should be rendered in alpha blend mode.
  29717. * @returns a boolean specifying if alpha blending is needed
  29718. */
  29719. needAlphaBlending(): boolean;
  29720. /**
  29721. * Specifies if the mesh will require alpha blending
  29722. * @param mesh defines the mesh to check
  29723. * @returns a boolean specifying if alpha blending is needed for the mesh
  29724. */
  29725. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29726. /**
  29727. * Specifies whether or not this material should be rendered in alpha test mode.
  29728. * @returns a boolean specifying if an alpha test is needed.
  29729. */
  29730. needAlphaTesting(): boolean;
  29731. /**
  29732. * Specifies if material alpha testing should be turned on for the mesh
  29733. * @param mesh defines the mesh to check
  29734. */
  29735. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29736. /**
  29737. * Gets the texture used for the alpha test
  29738. * @returns the texture to use for alpha testing
  29739. */
  29740. getAlphaTestTexture(): Nullable<BaseTexture>;
  29741. /**
  29742. * Marks the material to indicate that it needs to be re-calculated
  29743. */
  29744. markDirty(): void;
  29745. /** @hidden */
  29746. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29747. /**
  29748. * Binds the material to the mesh
  29749. * @param world defines the world transformation matrix
  29750. * @param mesh defines the mesh to bind the material to
  29751. */
  29752. bind(world: Matrix, mesh?: Mesh): void;
  29753. /**
  29754. * Binds the submesh to the material
  29755. * @param world defines the world transformation matrix
  29756. * @param mesh defines the mesh containing the submesh
  29757. * @param subMesh defines the submesh to bind the material to
  29758. */
  29759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29760. /**
  29761. * Binds the world matrix to the material
  29762. * @param world defines the world transformation matrix
  29763. */
  29764. bindOnlyWorldMatrix(world: Matrix): void;
  29765. /**
  29766. * Binds the scene's uniform buffer to the effect.
  29767. * @param effect defines the effect to bind to the scene uniform buffer
  29768. * @param sceneUbo defines the uniform buffer storing scene data
  29769. */
  29770. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29771. /**
  29772. * Binds the view matrix to the effect
  29773. * @param effect defines the effect to bind the view matrix to
  29774. */
  29775. bindView(effect: Effect): void;
  29776. /**
  29777. * Binds the view projection matrix to the effect
  29778. * @param effect defines the effect to bind the view projection matrix to
  29779. */
  29780. bindViewProjection(effect: Effect): void;
  29781. /**
  29782. * Processes to execute after binding the material to a mesh
  29783. * @param mesh defines the rendered mesh
  29784. */
  29785. protected _afterBind(mesh?: Mesh): void;
  29786. /**
  29787. * Unbinds the material from the mesh
  29788. */
  29789. unbind(): void;
  29790. /**
  29791. * Gets the active textures from the material
  29792. * @returns an array of textures
  29793. */
  29794. getActiveTextures(): BaseTexture[];
  29795. /**
  29796. * Specifies if the material uses a texture
  29797. * @param texture defines the texture to check against the material
  29798. * @returns a boolean specifying if the material uses the texture
  29799. */
  29800. hasTexture(texture: BaseTexture): boolean;
  29801. /**
  29802. * Makes a duplicate of the material, and gives it a new name
  29803. * @param name defines the new name for the duplicated material
  29804. * @returns the cloned material
  29805. */
  29806. clone(name: string): Nullable<Material>;
  29807. /**
  29808. * Gets the meshes bound to the material
  29809. * @returns an array of meshes bound to the material
  29810. */
  29811. getBindedMeshes(): AbstractMesh[];
  29812. /**
  29813. * Force shader compilation
  29814. * @param mesh defines the mesh associated with this material
  29815. * @param onCompiled defines a function to execute once the material is compiled
  29816. * @param options defines the options to configure the compilation
  29817. * @param onError defines a function to execute if the material fails compiling
  29818. */
  29819. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29820. /**
  29821. * Force shader compilation
  29822. * @param mesh defines the mesh that will use this material
  29823. * @param options defines additional options for compiling the shaders
  29824. * @returns a promise that resolves when the compilation completes
  29825. */
  29826. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29827. private static readonly _AllDirtyCallBack;
  29828. private static readonly _ImageProcessingDirtyCallBack;
  29829. private static readonly _TextureDirtyCallBack;
  29830. private static readonly _FresnelDirtyCallBack;
  29831. private static readonly _MiscDirtyCallBack;
  29832. private static readonly _PrePassDirtyCallBack;
  29833. private static readonly _LightsDirtyCallBack;
  29834. private static readonly _AttributeDirtyCallBack;
  29835. private static _FresnelAndMiscDirtyCallBack;
  29836. private static _TextureAndMiscDirtyCallBack;
  29837. private static readonly _DirtyCallbackArray;
  29838. private static readonly _RunDirtyCallBacks;
  29839. /**
  29840. * Marks a define in the material to indicate that it needs to be re-computed
  29841. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29842. */
  29843. markAsDirty(flag: number): void;
  29844. /**
  29845. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29846. * @param func defines a function which checks material defines against the submeshes
  29847. */
  29848. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29849. /**
  29850. * Indicates that the scene should check if the rendering now needs a prepass
  29851. */
  29852. protected _markScenePrePassDirty(): void;
  29853. /**
  29854. * Indicates that we need to re-calculated for all submeshes
  29855. */
  29856. protected _markAllSubMeshesAsAllDirty(): void;
  29857. /**
  29858. * Indicates that image processing needs to be re-calculated for all submeshes
  29859. */
  29860. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29861. /**
  29862. * Indicates that textures need to be re-calculated for all submeshes
  29863. */
  29864. protected _markAllSubMeshesAsTexturesDirty(): void;
  29865. /**
  29866. * Indicates that fresnel needs to be re-calculated for all submeshes
  29867. */
  29868. protected _markAllSubMeshesAsFresnelDirty(): void;
  29869. /**
  29870. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29871. */
  29872. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29873. /**
  29874. * Indicates that lights need to be re-calculated for all submeshes
  29875. */
  29876. protected _markAllSubMeshesAsLightsDirty(): void;
  29877. /**
  29878. * Indicates that attributes need to be re-calculated for all submeshes
  29879. */
  29880. protected _markAllSubMeshesAsAttributesDirty(): void;
  29881. /**
  29882. * Indicates that misc needs to be re-calculated for all submeshes
  29883. */
  29884. protected _markAllSubMeshesAsMiscDirty(): void;
  29885. /**
  29886. * Indicates that prepass needs to be re-calculated for all submeshes
  29887. */
  29888. protected _markAllSubMeshesAsPrePassDirty(): void;
  29889. /**
  29890. * Indicates that textures and misc need to be re-calculated for all submeshes
  29891. */
  29892. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29893. /**
  29894. * Sets the required values to the prepass renderer.
  29895. * @param prePassRenderer defines the prepass renderer to setup.
  29896. * @returns true if the pre pass is needed.
  29897. */
  29898. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29899. /**
  29900. * Disposes the material
  29901. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29902. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29903. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29904. */
  29905. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29906. /** @hidden */
  29907. private releaseVertexArrayObject;
  29908. /**
  29909. * Serializes this material
  29910. * @returns the serialized material object
  29911. */
  29912. serialize(): any;
  29913. /**
  29914. * Creates a material from parsed material data
  29915. * @param parsedMaterial defines parsed material data
  29916. * @param scene defines the hosting scene
  29917. * @param rootUrl defines the root URL to use to load textures
  29918. * @returns a new material
  29919. */
  29920. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29921. }
  29922. }
  29923. declare module BABYLON {
  29924. /**
  29925. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29926. * separate meshes. This can be use to improve performances.
  29927. * @see https://doc.babylonjs.com/how_to/multi_materials
  29928. */
  29929. export class MultiMaterial extends Material {
  29930. private _subMaterials;
  29931. /**
  29932. * Gets or Sets the list of Materials used within the multi material.
  29933. * They need to be ordered according to the submeshes order in the associated mesh
  29934. */
  29935. get subMaterials(): Nullable<Material>[];
  29936. set subMaterials(value: Nullable<Material>[]);
  29937. /**
  29938. * Function used to align with Node.getChildren()
  29939. * @returns the list of Materials used within the multi material
  29940. */
  29941. getChildren(): Nullable<Material>[];
  29942. /**
  29943. * Instantiates a new Multi Material
  29944. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29945. * separate meshes. This can be use to improve performances.
  29946. * @see https://doc.babylonjs.com/how_to/multi_materials
  29947. * @param name Define the name in the scene
  29948. * @param scene Define the scene the material belongs to
  29949. */
  29950. constructor(name: string, scene: Scene);
  29951. private _hookArray;
  29952. /**
  29953. * Get one of the submaterial by its index in the submaterials array
  29954. * @param index The index to look the sub material at
  29955. * @returns The Material if the index has been defined
  29956. */
  29957. getSubMaterial(index: number): Nullable<Material>;
  29958. /**
  29959. * Get the list of active textures for the whole sub materials list.
  29960. * @returns All the textures that will be used during the rendering
  29961. */
  29962. getActiveTextures(): BaseTexture[];
  29963. /**
  29964. * Gets the current class name of the material e.g. "MultiMaterial"
  29965. * Mainly use in serialization.
  29966. * @returns the class name
  29967. */
  29968. getClassName(): string;
  29969. /**
  29970. * Checks if the material is ready to render the requested sub mesh
  29971. * @param mesh Define the mesh the submesh belongs to
  29972. * @param subMesh Define the sub mesh to look readyness for
  29973. * @param useInstances Define whether or not the material is used with instances
  29974. * @returns true if ready, otherwise false
  29975. */
  29976. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29977. /**
  29978. * Clones the current material and its related sub materials
  29979. * @param name Define the name of the newly cloned material
  29980. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29981. * @returns the cloned material
  29982. */
  29983. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29984. /**
  29985. * Serializes the materials into a JSON representation.
  29986. * @returns the JSON representation
  29987. */
  29988. serialize(): any;
  29989. /**
  29990. * Dispose the material and release its associated resources
  29991. * @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)
  29992. * @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)
  29993. * @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)
  29994. */
  29995. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29996. /**
  29997. * Creates a MultiMaterial from parsed MultiMaterial data.
  29998. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29999. * @param scene defines the hosting scene
  30000. * @returns a new MultiMaterial
  30001. */
  30002. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30003. }
  30004. }
  30005. declare module BABYLON {
  30006. /**
  30007. * Defines a subdivision inside a mesh
  30008. */
  30009. export class SubMesh implements ICullable {
  30010. /** the material index to use */
  30011. materialIndex: number;
  30012. /** vertex index start */
  30013. verticesStart: number;
  30014. /** vertices count */
  30015. verticesCount: number;
  30016. /** index start */
  30017. indexStart: number;
  30018. /** indices count */
  30019. indexCount: number;
  30020. /** @hidden */
  30021. _materialDefines: Nullable<MaterialDefines>;
  30022. /** @hidden */
  30023. _materialEffect: Nullable<Effect>;
  30024. /** @hidden */
  30025. _effectOverride: Nullable<Effect>;
  30026. /**
  30027. * Gets material defines used by the effect associated to the sub mesh
  30028. */
  30029. get materialDefines(): Nullable<MaterialDefines>;
  30030. /**
  30031. * Sets material defines used by the effect associated to the sub mesh
  30032. */
  30033. set materialDefines(defines: Nullable<MaterialDefines>);
  30034. /**
  30035. * Gets associated effect
  30036. */
  30037. get effect(): Nullable<Effect>;
  30038. /**
  30039. * Sets associated effect (effect used to render this submesh)
  30040. * @param effect defines the effect to associate with
  30041. * @param defines defines the set of defines used to compile this effect
  30042. */
  30043. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30044. /** @hidden */
  30045. _linesIndexCount: number;
  30046. private _mesh;
  30047. private _renderingMesh;
  30048. private _boundingInfo;
  30049. private _linesIndexBuffer;
  30050. /** @hidden */
  30051. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30052. /** @hidden */
  30053. _trianglePlanes: Plane[];
  30054. /** @hidden */
  30055. _lastColliderTransformMatrix: Nullable<Matrix>;
  30056. /** @hidden */
  30057. _renderId: number;
  30058. /** @hidden */
  30059. _alphaIndex: number;
  30060. /** @hidden */
  30061. _distanceToCamera: number;
  30062. /** @hidden */
  30063. _id: number;
  30064. private _currentMaterial;
  30065. /**
  30066. * Add a new submesh to a mesh
  30067. * @param materialIndex defines the material index to use
  30068. * @param verticesStart defines vertex index start
  30069. * @param verticesCount defines vertices count
  30070. * @param indexStart defines index start
  30071. * @param indexCount defines indices count
  30072. * @param mesh defines the parent mesh
  30073. * @param renderingMesh defines an optional rendering mesh
  30074. * @param createBoundingBox defines if bounding box should be created for this submesh
  30075. * @returns the new submesh
  30076. */
  30077. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30078. /**
  30079. * Creates a new submesh
  30080. * @param materialIndex defines the material index to use
  30081. * @param verticesStart defines vertex index start
  30082. * @param verticesCount defines vertices count
  30083. * @param indexStart defines index start
  30084. * @param indexCount defines indices count
  30085. * @param mesh defines the parent mesh
  30086. * @param renderingMesh defines an optional rendering mesh
  30087. * @param createBoundingBox defines if bounding box should be created for this submesh
  30088. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30089. */
  30090. constructor(
  30091. /** the material index to use */
  30092. materialIndex: number,
  30093. /** vertex index start */
  30094. verticesStart: number,
  30095. /** vertices count */
  30096. verticesCount: number,
  30097. /** index start */
  30098. indexStart: number,
  30099. /** indices count */
  30100. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30101. /**
  30102. * Returns true if this submesh covers the entire parent mesh
  30103. * @ignorenaming
  30104. */
  30105. get IsGlobal(): boolean;
  30106. /**
  30107. * Returns the submesh BoudingInfo object
  30108. * @returns current bounding info (or mesh's one if the submesh is global)
  30109. */
  30110. getBoundingInfo(): BoundingInfo;
  30111. /**
  30112. * Sets the submesh BoundingInfo
  30113. * @param boundingInfo defines the new bounding info to use
  30114. * @returns the SubMesh
  30115. */
  30116. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30117. /**
  30118. * Returns the mesh of the current submesh
  30119. * @return the parent mesh
  30120. */
  30121. getMesh(): AbstractMesh;
  30122. /**
  30123. * Returns the rendering mesh of the submesh
  30124. * @returns the rendering mesh (could be different from parent mesh)
  30125. */
  30126. getRenderingMesh(): Mesh;
  30127. /**
  30128. * Returns the replacement mesh of the submesh
  30129. * @returns the replacement mesh (could be different from parent mesh)
  30130. */
  30131. getReplacementMesh(): Nullable<AbstractMesh>;
  30132. /**
  30133. * Returns the effective mesh of the submesh
  30134. * @returns the effective mesh (could be different from parent mesh)
  30135. */
  30136. getEffectiveMesh(): AbstractMesh;
  30137. /**
  30138. * Returns the submesh material
  30139. * @returns null or the current material
  30140. */
  30141. getMaterial(): Nullable<Material>;
  30142. private _IsMultiMaterial;
  30143. /**
  30144. * Sets a new updated BoundingInfo object to the submesh
  30145. * @param data defines an optional position array to use to determine the bounding info
  30146. * @returns the SubMesh
  30147. */
  30148. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30149. /** @hidden */
  30150. _checkCollision(collider: Collider): boolean;
  30151. /**
  30152. * Updates the submesh BoundingInfo
  30153. * @param world defines the world matrix to use to update the bounding info
  30154. * @returns the submesh
  30155. */
  30156. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30157. /**
  30158. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30159. * @param frustumPlanes defines the frustum planes
  30160. * @returns true if the submesh is intersecting with the frustum
  30161. */
  30162. isInFrustum(frustumPlanes: Plane[]): boolean;
  30163. /**
  30164. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30165. * @param frustumPlanes defines the frustum planes
  30166. * @returns true if the submesh is inside the frustum
  30167. */
  30168. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30169. /**
  30170. * Renders the submesh
  30171. * @param enableAlphaMode defines if alpha needs to be used
  30172. * @returns the submesh
  30173. */
  30174. render(enableAlphaMode: boolean): SubMesh;
  30175. /**
  30176. * @hidden
  30177. */
  30178. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30179. /**
  30180. * Checks if the submesh intersects with a ray
  30181. * @param ray defines the ray to test
  30182. * @returns true is the passed ray intersects the submesh bounding box
  30183. */
  30184. canIntersects(ray: Ray): boolean;
  30185. /**
  30186. * Intersects current submesh with a ray
  30187. * @param ray defines the ray to test
  30188. * @param positions defines mesh's positions array
  30189. * @param indices defines mesh's indices array
  30190. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30191. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30192. * @returns intersection info or null if no intersection
  30193. */
  30194. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30195. /** @hidden */
  30196. private _intersectLines;
  30197. /** @hidden */
  30198. private _intersectUnIndexedLines;
  30199. /** @hidden */
  30200. private _intersectTriangles;
  30201. /** @hidden */
  30202. private _intersectUnIndexedTriangles;
  30203. /** @hidden */
  30204. _rebuild(): void;
  30205. /**
  30206. * Creates a new submesh from the passed mesh
  30207. * @param newMesh defines the new hosting mesh
  30208. * @param newRenderingMesh defines an optional rendering mesh
  30209. * @returns the new submesh
  30210. */
  30211. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30212. /**
  30213. * Release associated resources
  30214. */
  30215. dispose(): void;
  30216. /**
  30217. * Gets the class name
  30218. * @returns the string "SubMesh".
  30219. */
  30220. getClassName(): string;
  30221. /**
  30222. * Creates a new submesh from indices data
  30223. * @param materialIndex the index of the main mesh material
  30224. * @param startIndex the index where to start the copy in the mesh indices array
  30225. * @param indexCount the number of indices to copy then from the startIndex
  30226. * @param mesh the main mesh to create the submesh from
  30227. * @param renderingMesh the optional rendering mesh
  30228. * @returns a new submesh
  30229. */
  30230. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30231. }
  30232. }
  30233. declare module BABYLON {
  30234. /**
  30235. * Class used to represent data loading progression
  30236. */
  30237. export class SceneLoaderFlags {
  30238. private static _ForceFullSceneLoadingForIncremental;
  30239. private static _ShowLoadingScreen;
  30240. private static _CleanBoneMatrixWeights;
  30241. private static _loggingLevel;
  30242. /**
  30243. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30244. */
  30245. static get ForceFullSceneLoadingForIncremental(): boolean;
  30246. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30247. /**
  30248. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30249. */
  30250. static get ShowLoadingScreen(): boolean;
  30251. static set ShowLoadingScreen(value: boolean);
  30252. /**
  30253. * Defines the current logging level (while loading the scene)
  30254. * @ignorenaming
  30255. */
  30256. static get loggingLevel(): number;
  30257. static set loggingLevel(value: number);
  30258. /**
  30259. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30260. */
  30261. static get CleanBoneMatrixWeights(): boolean;
  30262. static set CleanBoneMatrixWeights(value: boolean);
  30263. }
  30264. }
  30265. declare module BABYLON {
  30266. /**
  30267. * Class used to store geometry data (vertex buffers + index buffer)
  30268. */
  30269. export class Geometry implements IGetSetVerticesData {
  30270. /**
  30271. * Gets or sets the ID of the geometry
  30272. */
  30273. id: string;
  30274. /**
  30275. * Gets or sets the unique ID of the geometry
  30276. */
  30277. uniqueId: number;
  30278. /**
  30279. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30280. */
  30281. delayLoadState: number;
  30282. /**
  30283. * Gets the file containing the data to load when running in delay load state
  30284. */
  30285. delayLoadingFile: Nullable<string>;
  30286. /**
  30287. * Callback called when the geometry is updated
  30288. */
  30289. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30290. private _scene;
  30291. private _engine;
  30292. private _meshes;
  30293. private _totalVertices;
  30294. /** @hidden */
  30295. _indices: IndicesArray;
  30296. /** @hidden */
  30297. _vertexBuffers: {
  30298. [key: string]: VertexBuffer;
  30299. };
  30300. private _isDisposed;
  30301. private _extend;
  30302. private _boundingBias;
  30303. /** @hidden */
  30304. _delayInfo: Array<string>;
  30305. private _indexBuffer;
  30306. private _indexBufferIsUpdatable;
  30307. /** @hidden */
  30308. _boundingInfo: Nullable<BoundingInfo>;
  30309. /** @hidden */
  30310. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30311. /** @hidden */
  30312. _softwareSkinningFrameId: number;
  30313. private _vertexArrayObjects;
  30314. private _updatable;
  30315. /** @hidden */
  30316. _positions: Nullable<Vector3[]>;
  30317. private _positionsCache;
  30318. /**
  30319. * 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
  30320. */
  30321. get boundingBias(): Vector2;
  30322. /**
  30323. * 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
  30324. */
  30325. set boundingBias(value: Vector2);
  30326. /**
  30327. * Static function used to attach a new empty geometry to a mesh
  30328. * @param mesh defines the mesh to attach the geometry to
  30329. * @returns the new Geometry
  30330. */
  30331. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30332. /** Get the list of meshes using this geometry */
  30333. get meshes(): Mesh[];
  30334. /**
  30335. * 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
  30336. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30337. */
  30338. useBoundingInfoFromGeometry: boolean;
  30339. /**
  30340. * Creates a new geometry
  30341. * @param id defines the unique ID
  30342. * @param scene defines the hosting scene
  30343. * @param vertexData defines the VertexData used to get geometry data
  30344. * @param updatable defines if geometry must be updatable (false by default)
  30345. * @param mesh defines the mesh that will be associated with the geometry
  30346. */
  30347. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30348. /**
  30349. * Gets the current extend of the geometry
  30350. */
  30351. get extend(): {
  30352. minimum: Vector3;
  30353. maximum: Vector3;
  30354. };
  30355. /**
  30356. * Gets the hosting scene
  30357. * @returns the hosting Scene
  30358. */
  30359. getScene(): Scene;
  30360. /**
  30361. * Gets the hosting engine
  30362. * @returns the hosting Engine
  30363. */
  30364. getEngine(): Engine;
  30365. /**
  30366. * Defines if the geometry is ready to use
  30367. * @returns true if the geometry is ready to be used
  30368. */
  30369. isReady(): boolean;
  30370. /**
  30371. * Gets a value indicating that the geometry should not be serialized
  30372. */
  30373. get doNotSerialize(): boolean;
  30374. /** @hidden */
  30375. _rebuild(): void;
  30376. /**
  30377. * Affects all geometry data in one call
  30378. * @param vertexData defines the geometry data
  30379. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30380. */
  30381. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30382. /**
  30383. * Set specific vertex data
  30384. * @param kind defines the data kind (Position, normal, etc...)
  30385. * @param data defines the vertex data to use
  30386. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30387. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30388. */
  30389. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30390. /**
  30391. * Removes a specific vertex data
  30392. * @param kind defines the data kind (Position, normal, etc...)
  30393. */
  30394. removeVerticesData(kind: string): void;
  30395. /**
  30396. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30397. * @param buffer defines the vertex buffer to use
  30398. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30399. */
  30400. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30401. /**
  30402. * Update a specific vertex buffer
  30403. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30404. * It will do nothing if the buffer is not updatable
  30405. * @param kind defines the data kind (Position, normal, etc...)
  30406. * @param data defines the data to use
  30407. * @param offset defines the offset in the target buffer where to store the data
  30408. * @param useBytes set to true if the offset is in bytes
  30409. */
  30410. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30411. /**
  30412. * Update a specific vertex buffer
  30413. * This function will create a new buffer if the current one is not updatable
  30414. * @param kind defines the data kind (Position, normal, etc...)
  30415. * @param data defines the data to use
  30416. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30417. */
  30418. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30419. private _updateBoundingInfo;
  30420. /** @hidden */
  30421. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30422. /**
  30423. * Gets total number of vertices
  30424. * @returns the total number of vertices
  30425. */
  30426. getTotalVertices(): number;
  30427. /**
  30428. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30429. * @param kind defines the data kind (Position, normal, etc...)
  30430. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30431. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30432. * @returns a float array containing vertex data
  30433. */
  30434. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30435. /**
  30436. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30437. * @param kind defines the data kind (Position, normal, etc...)
  30438. * @returns true if the vertex buffer with the specified kind is updatable
  30439. */
  30440. isVertexBufferUpdatable(kind: string): boolean;
  30441. /**
  30442. * Gets a specific vertex buffer
  30443. * @param kind defines the data kind (Position, normal, etc...)
  30444. * @returns a VertexBuffer
  30445. */
  30446. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30447. /**
  30448. * Returns all vertex buffers
  30449. * @return an object holding all vertex buffers indexed by kind
  30450. */
  30451. getVertexBuffers(): Nullable<{
  30452. [key: string]: VertexBuffer;
  30453. }>;
  30454. /**
  30455. * Gets a boolean indicating if specific vertex buffer is present
  30456. * @param kind defines the data kind (Position, normal, etc...)
  30457. * @returns true if data is present
  30458. */
  30459. isVerticesDataPresent(kind: string): boolean;
  30460. /**
  30461. * Gets a list of all attached data kinds (Position, normal, etc...)
  30462. * @returns a list of string containing all kinds
  30463. */
  30464. getVerticesDataKinds(): string[];
  30465. /**
  30466. * Update index buffer
  30467. * @param indices defines the indices to store in the index buffer
  30468. * @param offset defines the offset in the target buffer where to store the data
  30469. * @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)
  30470. */
  30471. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30472. /**
  30473. * Creates a new index buffer
  30474. * @param indices defines the indices to store in the index buffer
  30475. * @param totalVertices defines the total number of vertices (could be null)
  30476. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30477. */
  30478. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30479. /**
  30480. * Return the total number of indices
  30481. * @returns the total number of indices
  30482. */
  30483. getTotalIndices(): number;
  30484. /**
  30485. * Gets the index buffer array
  30486. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30487. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30488. * @returns the index buffer array
  30489. */
  30490. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30491. /**
  30492. * Gets the index buffer
  30493. * @return the index buffer
  30494. */
  30495. getIndexBuffer(): Nullable<DataBuffer>;
  30496. /** @hidden */
  30497. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30498. /**
  30499. * Release the associated resources for a specific mesh
  30500. * @param mesh defines the source mesh
  30501. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30502. */
  30503. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30504. /**
  30505. * Apply current geometry to a given mesh
  30506. * @param mesh defines the mesh to apply geometry to
  30507. */
  30508. applyToMesh(mesh: Mesh): void;
  30509. private _updateExtend;
  30510. private _applyToMesh;
  30511. private notifyUpdate;
  30512. /**
  30513. * Load the geometry if it was flagged as delay loaded
  30514. * @param scene defines the hosting scene
  30515. * @param onLoaded defines a callback called when the geometry is loaded
  30516. */
  30517. load(scene: Scene, onLoaded?: () => void): void;
  30518. private _queueLoad;
  30519. /**
  30520. * Invert the geometry to move from a right handed system to a left handed one.
  30521. */
  30522. toLeftHanded(): void;
  30523. /** @hidden */
  30524. _resetPointsArrayCache(): void;
  30525. /** @hidden */
  30526. _generatePointsArray(): boolean;
  30527. /**
  30528. * Gets a value indicating if the geometry is disposed
  30529. * @returns true if the geometry was disposed
  30530. */
  30531. isDisposed(): boolean;
  30532. private _disposeVertexArrayObjects;
  30533. /**
  30534. * Free all associated resources
  30535. */
  30536. dispose(): void;
  30537. /**
  30538. * Clone the current geometry into a new geometry
  30539. * @param id defines the unique ID of the new geometry
  30540. * @returns a new geometry object
  30541. */
  30542. copy(id: string): Geometry;
  30543. /**
  30544. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30545. * @return a JSON representation of the current geometry data (without the vertices data)
  30546. */
  30547. serialize(): any;
  30548. private toNumberArray;
  30549. /**
  30550. * Serialize all vertices data into a JSON oject
  30551. * @returns a JSON representation of the current geometry data
  30552. */
  30553. serializeVerticeData(): any;
  30554. /**
  30555. * Extracts a clone of a mesh geometry
  30556. * @param mesh defines the source mesh
  30557. * @param id defines the unique ID of the new geometry object
  30558. * @returns the new geometry object
  30559. */
  30560. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30561. /**
  30562. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30563. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30564. * Be aware Math.random() could cause collisions, but:
  30565. * "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"
  30566. * @returns a string containing a new GUID
  30567. */
  30568. static RandomId(): string;
  30569. /** @hidden */
  30570. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30571. private static _CleanMatricesWeights;
  30572. /**
  30573. * Create a new geometry from persisted data (Using .babylon file format)
  30574. * @param parsedVertexData defines the persisted data
  30575. * @param scene defines the hosting scene
  30576. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30577. * @returns the new geometry object
  30578. */
  30579. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30580. }
  30581. }
  30582. declare module BABYLON {
  30583. /**
  30584. * Defines a target to use with MorphTargetManager
  30585. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30586. */
  30587. export class MorphTarget implements IAnimatable {
  30588. /** defines the name of the target */
  30589. name: string;
  30590. /**
  30591. * Gets or sets the list of animations
  30592. */
  30593. animations: Animation[];
  30594. private _scene;
  30595. private _positions;
  30596. private _normals;
  30597. private _tangents;
  30598. private _uvs;
  30599. private _influence;
  30600. private _uniqueId;
  30601. /**
  30602. * Observable raised when the influence changes
  30603. */
  30604. onInfluenceChanged: Observable<boolean>;
  30605. /** @hidden */
  30606. _onDataLayoutChanged: Observable<void>;
  30607. /**
  30608. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30609. */
  30610. get influence(): number;
  30611. set influence(influence: number);
  30612. /**
  30613. * Gets or sets the id of the morph Target
  30614. */
  30615. id: string;
  30616. private _animationPropertiesOverride;
  30617. /**
  30618. * Gets or sets the animation properties override
  30619. */
  30620. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30621. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30622. /**
  30623. * Creates a new MorphTarget
  30624. * @param name defines the name of the target
  30625. * @param influence defines the influence to use
  30626. * @param scene defines the scene the morphtarget belongs to
  30627. */
  30628. constructor(
  30629. /** defines the name of the target */
  30630. name: string, influence?: number, scene?: Nullable<Scene>);
  30631. /**
  30632. * Gets the unique ID of this manager
  30633. */
  30634. get uniqueId(): number;
  30635. /**
  30636. * Gets a boolean defining if the target contains position data
  30637. */
  30638. get hasPositions(): boolean;
  30639. /**
  30640. * Gets a boolean defining if the target contains normal data
  30641. */
  30642. get hasNormals(): boolean;
  30643. /**
  30644. * Gets a boolean defining if the target contains tangent data
  30645. */
  30646. get hasTangents(): boolean;
  30647. /**
  30648. * Gets a boolean defining if the target contains texture coordinates data
  30649. */
  30650. get hasUVs(): boolean;
  30651. /**
  30652. * Affects position data to this target
  30653. * @param data defines the position data to use
  30654. */
  30655. setPositions(data: Nullable<FloatArray>): void;
  30656. /**
  30657. * Gets the position data stored in this target
  30658. * @returns a FloatArray containing the position data (or null if not present)
  30659. */
  30660. getPositions(): Nullable<FloatArray>;
  30661. /**
  30662. * Affects normal data to this target
  30663. * @param data defines the normal data to use
  30664. */
  30665. setNormals(data: Nullable<FloatArray>): void;
  30666. /**
  30667. * Gets the normal data stored in this target
  30668. * @returns a FloatArray containing the normal data (or null if not present)
  30669. */
  30670. getNormals(): Nullable<FloatArray>;
  30671. /**
  30672. * Affects tangent data to this target
  30673. * @param data defines the tangent data to use
  30674. */
  30675. setTangents(data: Nullable<FloatArray>): void;
  30676. /**
  30677. * Gets the tangent data stored in this target
  30678. * @returns a FloatArray containing the tangent data (or null if not present)
  30679. */
  30680. getTangents(): Nullable<FloatArray>;
  30681. /**
  30682. * Affects texture coordinates data to this target
  30683. * @param data defines the texture coordinates data to use
  30684. */
  30685. setUVs(data: Nullable<FloatArray>): void;
  30686. /**
  30687. * Gets the texture coordinates data stored in this target
  30688. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30689. */
  30690. getUVs(): Nullable<FloatArray>;
  30691. /**
  30692. * Clone the current target
  30693. * @returns a new MorphTarget
  30694. */
  30695. clone(): MorphTarget;
  30696. /**
  30697. * Serializes the current target into a Serialization object
  30698. * @returns the serialized object
  30699. */
  30700. serialize(): any;
  30701. /**
  30702. * Returns the string "MorphTarget"
  30703. * @returns "MorphTarget"
  30704. */
  30705. getClassName(): string;
  30706. /**
  30707. * Creates a new target from serialized data
  30708. * @param serializationObject defines the serialized data to use
  30709. * @returns a new MorphTarget
  30710. */
  30711. static Parse(serializationObject: any): MorphTarget;
  30712. /**
  30713. * Creates a MorphTarget from mesh data
  30714. * @param mesh defines the source mesh
  30715. * @param name defines the name to use for the new target
  30716. * @param influence defines the influence to attach to the target
  30717. * @returns a new MorphTarget
  30718. */
  30719. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30720. }
  30721. }
  30722. declare module BABYLON {
  30723. /**
  30724. * This class is used to deform meshes using morphing between different targets
  30725. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30726. */
  30727. export class MorphTargetManager {
  30728. private _targets;
  30729. private _targetInfluenceChangedObservers;
  30730. private _targetDataLayoutChangedObservers;
  30731. private _activeTargets;
  30732. private _scene;
  30733. private _influences;
  30734. private _supportsNormals;
  30735. private _supportsTangents;
  30736. private _supportsUVs;
  30737. private _vertexCount;
  30738. private _uniqueId;
  30739. private _tempInfluences;
  30740. /**
  30741. * Gets or sets a boolean indicating if normals must be morphed
  30742. */
  30743. enableNormalMorphing: boolean;
  30744. /**
  30745. * Gets or sets a boolean indicating if tangents must be morphed
  30746. */
  30747. enableTangentMorphing: boolean;
  30748. /**
  30749. * Gets or sets a boolean indicating if UV must be morphed
  30750. */
  30751. enableUVMorphing: boolean;
  30752. /**
  30753. * Creates a new MorphTargetManager
  30754. * @param scene defines the current scene
  30755. */
  30756. constructor(scene?: Nullable<Scene>);
  30757. /**
  30758. * Gets the unique ID of this manager
  30759. */
  30760. get uniqueId(): number;
  30761. /**
  30762. * Gets the number of vertices handled by this manager
  30763. */
  30764. get vertexCount(): number;
  30765. /**
  30766. * Gets a boolean indicating if this manager supports morphing of normals
  30767. */
  30768. get supportsNormals(): boolean;
  30769. /**
  30770. * Gets a boolean indicating if this manager supports morphing of tangents
  30771. */
  30772. get supportsTangents(): boolean;
  30773. /**
  30774. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30775. */
  30776. get supportsUVs(): boolean;
  30777. /**
  30778. * Gets the number of targets stored in this manager
  30779. */
  30780. get numTargets(): number;
  30781. /**
  30782. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30783. */
  30784. get numInfluencers(): number;
  30785. /**
  30786. * Gets the list of influences (one per target)
  30787. */
  30788. get influences(): Float32Array;
  30789. /**
  30790. * Gets the active target at specified index. An active target is a target with an influence > 0
  30791. * @param index defines the index to check
  30792. * @returns the requested target
  30793. */
  30794. getActiveTarget(index: number): MorphTarget;
  30795. /**
  30796. * Gets the target at specified index
  30797. * @param index defines the index to check
  30798. * @returns the requested target
  30799. */
  30800. getTarget(index: number): MorphTarget;
  30801. /**
  30802. * Add a new target to this manager
  30803. * @param target defines the target to add
  30804. */
  30805. addTarget(target: MorphTarget): void;
  30806. /**
  30807. * Removes a target from the manager
  30808. * @param target defines the target to remove
  30809. */
  30810. removeTarget(target: MorphTarget): void;
  30811. /**
  30812. * Clone the current manager
  30813. * @returns a new MorphTargetManager
  30814. */
  30815. clone(): MorphTargetManager;
  30816. /**
  30817. * Serializes the current manager into a Serialization object
  30818. * @returns the serialized object
  30819. */
  30820. serialize(): any;
  30821. private _syncActiveTargets;
  30822. /**
  30823. * Syncrhonize the targets with all the meshes using this morph target manager
  30824. */
  30825. synchronize(): void;
  30826. /**
  30827. * Creates a new MorphTargetManager from serialized data
  30828. * @param serializationObject defines the serialized data
  30829. * @param scene defines the hosting scene
  30830. * @returns the new MorphTargetManager
  30831. */
  30832. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30833. }
  30834. }
  30835. declare module BABYLON {
  30836. /**
  30837. * Class used to represent a specific level of detail of a mesh
  30838. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30839. */
  30840. export class MeshLODLevel {
  30841. /** Defines the distance where this level should start being displayed */
  30842. distance: number;
  30843. /** Defines the mesh to use to render this level */
  30844. mesh: Nullable<Mesh>;
  30845. /**
  30846. * Creates a new LOD level
  30847. * @param distance defines the distance where this level should star being displayed
  30848. * @param mesh defines the mesh to use to render this level
  30849. */
  30850. constructor(
  30851. /** Defines the distance where this level should start being displayed */
  30852. distance: number,
  30853. /** Defines the mesh to use to render this level */
  30854. mesh: Nullable<Mesh>);
  30855. }
  30856. }
  30857. declare module BABYLON {
  30858. /**
  30859. * Helper class used to generate a canvas to manipulate images
  30860. */
  30861. export class CanvasGenerator {
  30862. /**
  30863. * Create a new canvas (or offscreen canvas depending on the context)
  30864. * @param width defines the expected width
  30865. * @param height defines the expected height
  30866. * @return a new canvas or offscreen canvas
  30867. */
  30868. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30869. }
  30870. }
  30871. declare module BABYLON {
  30872. /**
  30873. * Mesh representing the gorund
  30874. */
  30875. export class GroundMesh extends Mesh {
  30876. /** If octree should be generated */
  30877. generateOctree: boolean;
  30878. private _heightQuads;
  30879. /** @hidden */
  30880. _subdivisionsX: number;
  30881. /** @hidden */
  30882. _subdivisionsY: number;
  30883. /** @hidden */
  30884. _width: number;
  30885. /** @hidden */
  30886. _height: number;
  30887. /** @hidden */
  30888. _minX: number;
  30889. /** @hidden */
  30890. _maxX: number;
  30891. /** @hidden */
  30892. _minZ: number;
  30893. /** @hidden */
  30894. _maxZ: number;
  30895. constructor(name: string, scene: Scene);
  30896. /**
  30897. * "GroundMesh"
  30898. * @returns "GroundMesh"
  30899. */
  30900. getClassName(): string;
  30901. /**
  30902. * The minimum of x and y subdivisions
  30903. */
  30904. get subdivisions(): number;
  30905. /**
  30906. * X subdivisions
  30907. */
  30908. get subdivisionsX(): number;
  30909. /**
  30910. * Y subdivisions
  30911. */
  30912. get subdivisionsY(): number;
  30913. /**
  30914. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30915. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30916. * @param chunksCount the number of subdivisions for x and y
  30917. * @param octreeBlocksSize (Default: 32)
  30918. */
  30919. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30920. /**
  30921. * Returns a height (y) value in the Worl system :
  30922. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30923. * @param x x coordinate
  30924. * @param z z coordinate
  30925. * @returns the ground y position if (x, z) are outside the ground surface.
  30926. */
  30927. getHeightAtCoordinates(x: number, z: number): number;
  30928. /**
  30929. * Returns a normalized vector (Vector3) orthogonal to the ground
  30930. * at the ground coordinates (x, z) expressed in the World system.
  30931. * @param x x coordinate
  30932. * @param z z coordinate
  30933. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30934. */
  30935. getNormalAtCoordinates(x: number, z: number): Vector3;
  30936. /**
  30937. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30938. * at the ground coordinates (x, z) expressed in the World system.
  30939. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30940. * @param x x coordinate
  30941. * @param z z coordinate
  30942. * @param ref vector to store the result
  30943. * @returns the GroundMesh.
  30944. */
  30945. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  30946. /**
  30947. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  30948. * if the ground has been updated.
  30949. * This can be used in the render loop.
  30950. * @returns the GroundMesh.
  30951. */
  30952. updateCoordinateHeights(): GroundMesh;
  30953. private _getFacetAt;
  30954. private _initHeightQuads;
  30955. private _computeHeightQuads;
  30956. /**
  30957. * Serializes this ground mesh
  30958. * @param serializationObject object to write serialization to
  30959. */
  30960. serialize(serializationObject: any): void;
  30961. /**
  30962. * Parses a serialized ground mesh
  30963. * @param parsedMesh the serialized mesh
  30964. * @param scene the scene to create the ground mesh in
  30965. * @returns the created ground mesh
  30966. */
  30967. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  30968. }
  30969. }
  30970. declare module BABYLON {
  30971. /**
  30972. * Interface for Physics-Joint data
  30973. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  30974. */
  30975. export interface PhysicsJointData {
  30976. /**
  30977. * The main pivot of the joint
  30978. */
  30979. mainPivot?: Vector3;
  30980. /**
  30981. * The connected pivot of the joint
  30982. */
  30983. connectedPivot?: Vector3;
  30984. /**
  30985. * The main axis of the joint
  30986. */
  30987. mainAxis?: Vector3;
  30988. /**
  30989. * The connected axis of the joint
  30990. */
  30991. connectedAxis?: Vector3;
  30992. /**
  30993. * The collision of the joint
  30994. */
  30995. collision?: boolean;
  30996. /**
  30997. * Native Oimo/Cannon/Energy data
  30998. */
  30999. nativeParams?: any;
  31000. }
  31001. /**
  31002. * This is a holder class for the physics joint created by the physics plugin
  31003. * It holds a set of functions to control the underlying joint
  31004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31005. */
  31006. export class PhysicsJoint {
  31007. /**
  31008. * The type of the physics joint
  31009. */
  31010. type: number;
  31011. /**
  31012. * The data for the physics joint
  31013. */
  31014. jointData: PhysicsJointData;
  31015. private _physicsJoint;
  31016. protected _physicsPlugin: IPhysicsEnginePlugin;
  31017. /**
  31018. * Initializes the physics joint
  31019. * @param type The type of the physics joint
  31020. * @param jointData The data for the physics joint
  31021. */
  31022. constructor(
  31023. /**
  31024. * The type of the physics joint
  31025. */
  31026. type: number,
  31027. /**
  31028. * The data for the physics joint
  31029. */
  31030. jointData: PhysicsJointData);
  31031. /**
  31032. * Gets the physics joint
  31033. */
  31034. get physicsJoint(): any;
  31035. /**
  31036. * Sets the physics joint
  31037. */
  31038. set physicsJoint(newJoint: any);
  31039. /**
  31040. * Sets the physics plugin
  31041. */
  31042. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31043. /**
  31044. * Execute a function that is physics-plugin specific.
  31045. * @param {Function} func the function that will be executed.
  31046. * It accepts two parameters: the physics world and the physics joint
  31047. */
  31048. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31049. /**
  31050. * Distance-Joint type
  31051. */
  31052. static DistanceJoint: number;
  31053. /**
  31054. * Hinge-Joint type
  31055. */
  31056. static HingeJoint: number;
  31057. /**
  31058. * Ball-and-Socket joint type
  31059. */
  31060. static BallAndSocketJoint: number;
  31061. /**
  31062. * Wheel-Joint type
  31063. */
  31064. static WheelJoint: number;
  31065. /**
  31066. * Slider-Joint type
  31067. */
  31068. static SliderJoint: number;
  31069. /**
  31070. * Prismatic-Joint type
  31071. */
  31072. static PrismaticJoint: number;
  31073. /**
  31074. * Universal-Joint type
  31075. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31076. */
  31077. static UniversalJoint: number;
  31078. /**
  31079. * Hinge-Joint 2 type
  31080. */
  31081. static Hinge2Joint: number;
  31082. /**
  31083. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31084. */
  31085. static PointToPointJoint: number;
  31086. /**
  31087. * Spring-Joint type
  31088. */
  31089. static SpringJoint: number;
  31090. /**
  31091. * Lock-Joint type
  31092. */
  31093. static LockJoint: number;
  31094. }
  31095. /**
  31096. * A class representing a physics distance joint
  31097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31098. */
  31099. export class DistanceJoint extends PhysicsJoint {
  31100. /**
  31101. *
  31102. * @param jointData The data for the Distance-Joint
  31103. */
  31104. constructor(jointData: DistanceJointData);
  31105. /**
  31106. * Update the predefined distance.
  31107. * @param maxDistance The maximum preferred distance
  31108. * @param minDistance The minimum preferred distance
  31109. */
  31110. updateDistance(maxDistance: number, minDistance?: number): void;
  31111. }
  31112. /**
  31113. * Represents a Motor-Enabled Joint
  31114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31115. */
  31116. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31117. /**
  31118. * Initializes the Motor-Enabled Joint
  31119. * @param type The type of the joint
  31120. * @param jointData The physica joint data for the joint
  31121. */
  31122. constructor(type: number, jointData: PhysicsJointData);
  31123. /**
  31124. * Set the motor values.
  31125. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31126. * @param force the force to apply
  31127. * @param maxForce max force for this motor.
  31128. */
  31129. setMotor(force?: number, maxForce?: number): void;
  31130. /**
  31131. * Set the motor's limits.
  31132. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31133. * @param upperLimit The upper limit of the motor
  31134. * @param lowerLimit The lower limit of the motor
  31135. */
  31136. setLimit(upperLimit: number, lowerLimit?: number): void;
  31137. }
  31138. /**
  31139. * This class represents a single physics Hinge-Joint
  31140. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31141. */
  31142. export class HingeJoint extends MotorEnabledJoint {
  31143. /**
  31144. * Initializes the Hinge-Joint
  31145. * @param jointData The joint data for the Hinge-Joint
  31146. */
  31147. constructor(jointData: PhysicsJointData);
  31148. /**
  31149. * Set the motor values.
  31150. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31151. * @param {number} force the force to apply
  31152. * @param {number} maxForce max force for this motor.
  31153. */
  31154. setMotor(force?: number, maxForce?: number): void;
  31155. /**
  31156. * Set the motor's limits.
  31157. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31158. * @param upperLimit The upper limit of the motor
  31159. * @param lowerLimit The lower limit of the motor
  31160. */
  31161. setLimit(upperLimit: number, lowerLimit?: number): void;
  31162. }
  31163. /**
  31164. * This class represents a dual hinge physics joint (same as wheel joint)
  31165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31166. */
  31167. export class Hinge2Joint extends MotorEnabledJoint {
  31168. /**
  31169. * Initializes the Hinge2-Joint
  31170. * @param jointData The joint data for the Hinge2-Joint
  31171. */
  31172. constructor(jointData: PhysicsJointData);
  31173. /**
  31174. * Set the motor values.
  31175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31176. * @param {number} targetSpeed the speed the motor is to reach
  31177. * @param {number} maxForce max force for this motor.
  31178. * @param {motorIndex} the motor's index, 0 or 1.
  31179. */
  31180. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31181. /**
  31182. * Set the motor limits.
  31183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31184. * @param {number} upperLimit the upper limit
  31185. * @param {number} lowerLimit lower limit
  31186. * @param {motorIndex} the motor's index, 0 or 1.
  31187. */
  31188. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31189. }
  31190. /**
  31191. * Interface for a motor enabled joint
  31192. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31193. */
  31194. export interface IMotorEnabledJoint {
  31195. /**
  31196. * Physics joint
  31197. */
  31198. physicsJoint: any;
  31199. /**
  31200. * Sets the motor of the motor-enabled joint
  31201. * @param force The force of the motor
  31202. * @param maxForce The maximum force of the motor
  31203. * @param motorIndex The index of the motor
  31204. */
  31205. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31206. /**
  31207. * Sets the limit of the motor
  31208. * @param upperLimit The upper limit of the motor
  31209. * @param lowerLimit The lower limit of the motor
  31210. * @param motorIndex The index of the motor
  31211. */
  31212. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31213. }
  31214. /**
  31215. * Joint data for a Distance-Joint
  31216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31217. */
  31218. export interface DistanceJointData extends PhysicsJointData {
  31219. /**
  31220. * Max distance the 2 joint objects can be apart
  31221. */
  31222. maxDistance: number;
  31223. }
  31224. /**
  31225. * Joint data from a spring joint
  31226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31227. */
  31228. export interface SpringJointData extends PhysicsJointData {
  31229. /**
  31230. * Length of the spring
  31231. */
  31232. length: number;
  31233. /**
  31234. * Stiffness of the spring
  31235. */
  31236. stiffness: number;
  31237. /**
  31238. * Damping of the spring
  31239. */
  31240. damping: number;
  31241. /** this callback will be called when applying the force to the impostors. */
  31242. forceApplicationCallback: () => void;
  31243. }
  31244. }
  31245. declare module BABYLON {
  31246. /**
  31247. * Holds the data for the raycast result
  31248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31249. */
  31250. export class PhysicsRaycastResult {
  31251. private _hasHit;
  31252. private _hitDistance;
  31253. private _hitNormalWorld;
  31254. private _hitPointWorld;
  31255. private _rayFromWorld;
  31256. private _rayToWorld;
  31257. /**
  31258. * Gets if there was a hit
  31259. */
  31260. get hasHit(): boolean;
  31261. /**
  31262. * Gets the distance from the hit
  31263. */
  31264. get hitDistance(): number;
  31265. /**
  31266. * Gets the hit normal/direction in the world
  31267. */
  31268. get hitNormalWorld(): Vector3;
  31269. /**
  31270. * Gets the hit point in the world
  31271. */
  31272. get hitPointWorld(): Vector3;
  31273. /**
  31274. * Gets the ray "start point" of the ray in the world
  31275. */
  31276. get rayFromWorld(): Vector3;
  31277. /**
  31278. * Gets the ray "end point" of the ray in the world
  31279. */
  31280. get rayToWorld(): Vector3;
  31281. /**
  31282. * Sets the hit data (normal & point in world space)
  31283. * @param hitNormalWorld defines the normal in world space
  31284. * @param hitPointWorld defines the point in world space
  31285. */
  31286. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31287. /**
  31288. * Sets the distance from the start point to the hit point
  31289. * @param distance
  31290. */
  31291. setHitDistance(distance: number): void;
  31292. /**
  31293. * Calculates the distance manually
  31294. */
  31295. calculateHitDistance(): void;
  31296. /**
  31297. * Resets all the values to default
  31298. * @param from The from point on world space
  31299. * @param to The to point on world space
  31300. */
  31301. reset(from?: Vector3, to?: Vector3): void;
  31302. }
  31303. /**
  31304. * Interface for the size containing width and height
  31305. */
  31306. interface IXYZ {
  31307. /**
  31308. * X
  31309. */
  31310. x: number;
  31311. /**
  31312. * Y
  31313. */
  31314. y: number;
  31315. /**
  31316. * Z
  31317. */
  31318. z: number;
  31319. }
  31320. }
  31321. declare module BABYLON {
  31322. /**
  31323. * Interface used to describe a physics joint
  31324. */
  31325. export interface PhysicsImpostorJoint {
  31326. /** Defines the main impostor to which the joint is linked */
  31327. mainImpostor: PhysicsImpostor;
  31328. /** Defines the impostor that is connected to the main impostor using this joint */
  31329. connectedImpostor: PhysicsImpostor;
  31330. /** Defines the joint itself */
  31331. joint: PhysicsJoint;
  31332. }
  31333. /** @hidden */
  31334. export interface IPhysicsEnginePlugin {
  31335. world: any;
  31336. name: string;
  31337. setGravity(gravity: Vector3): void;
  31338. setTimeStep(timeStep: number): void;
  31339. getTimeStep(): number;
  31340. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31341. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31342. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31343. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31344. removePhysicsBody(impostor: PhysicsImpostor): void;
  31345. generateJoint(joint: PhysicsImpostorJoint): void;
  31346. removeJoint(joint: PhysicsImpostorJoint): void;
  31347. isSupported(): boolean;
  31348. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31350. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31351. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31352. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31353. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31354. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31355. getBodyMass(impostor: PhysicsImpostor): number;
  31356. getBodyFriction(impostor: PhysicsImpostor): number;
  31357. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31358. getBodyRestitution(impostor: PhysicsImpostor): number;
  31359. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31360. getBodyPressure?(impostor: PhysicsImpostor): number;
  31361. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31362. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31363. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31364. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31365. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31366. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31367. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31368. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31369. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31370. sleepBody(impostor: PhysicsImpostor): void;
  31371. wakeUpBody(impostor: PhysicsImpostor): void;
  31372. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31373. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31374. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31375. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31376. getRadius(impostor: PhysicsImpostor): number;
  31377. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31378. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31379. dispose(): void;
  31380. }
  31381. /**
  31382. * Interface used to define a physics engine
  31383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31384. */
  31385. export interface IPhysicsEngine {
  31386. /**
  31387. * Gets the gravity vector used by the simulation
  31388. */
  31389. gravity: Vector3;
  31390. /**
  31391. * Sets the gravity vector used by the simulation
  31392. * @param gravity defines the gravity vector to use
  31393. */
  31394. setGravity(gravity: Vector3): void;
  31395. /**
  31396. * Set the time step of the physics engine.
  31397. * Default is 1/60.
  31398. * To slow it down, enter 1/600 for example.
  31399. * To speed it up, 1/30
  31400. * @param newTimeStep the new timestep to apply to this world.
  31401. */
  31402. setTimeStep(newTimeStep: number): void;
  31403. /**
  31404. * Get the time step of the physics engine.
  31405. * @returns the current time step
  31406. */
  31407. getTimeStep(): number;
  31408. /**
  31409. * Set the sub time step of the physics engine.
  31410. * Default is 0 meaning there is no sub steps
  31411. * To increase physics resolution precision, set a small value (like 1 ms)
  31412. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31413. */
  31414. setSubTimeStep(subTimeStep: number): void;
  31415. /**
  31416. * Get the sub time step of the physics engine.
  31417. * @returns the current sub time step
  31418. */
  31419. getSubTimeStep(): number;
  31420. /**
  31421. * Release all resources
  31422. */
  31423. dispose(): void;
  31424. /**
  31425. * Gets the name of the current physics plugin
  31426. * @returns the name of the plugin
  31427. */
  31428. getPhysicsPluginName(): string;
  31429. /**
  31430. * Adding a new impostor for the impostor tracking.
  31431. * This will be done by the impostor itself.
  31432. * @param impostor the impostor to add
  31433. */
  31434. addImpostor(impostor: PhysicsImpostor): void;
  31435. /**
  31436. * Remove an impostor from the engine.
  31437. * This impostor and its mesh will not longer be updated by the physics engine.
  31438. * @param impostor the impostor to remove
  31439. */
  31440. removeImpostor(impostor: PhysicsImpostor): void;
  31441. /**
  31442. * Add a joint to the physics engine
  31443. * @param mainImpostor defines the main impostor to which the joint is added.
  31444. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31445. * @param joint defines the joint that will connect both impostors.
  31446. */
  31447. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31448. /**
  31449. * Removes a joint from the simulation
  31450. * @param mainImpostor defines the impostor used with the joint
  31451. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31452. * @param joint defines the joint to remove
  31453. */
  31454. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31455. /**
  31456. * Gets the current plugin used to run the simulation
  31457. * @returns current plugin
  31458. */
  31459. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31460. /**
  31461. * Gets the list of physic impostors
  31462. * @returns an array of PhysicsImpostor
  31463. */
  31464. getImpostors(): Array<PhysicsImpostor>;
  31465. /**
  31466. * Gets the impostor for a physics enabled object
  31467. * @param object defines the object impersonated by the impostor
  31468. * @returns the PhysicsImpostor or null if not found
  31469. */
  31470. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31471. /**
  31472. * Gets the impostor for a physics body object
  31473. * @param body defines physics body used by the impostor
  31474. * @returns the PhysicsImpostor or null if not found
  31475. */
  31476. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31477. /**
  31478. * Does a raycast in the physics world
  31479. * @param from when should the ray start?
  31480. * @param to when should the ray end?
  31481. * @returns PhysicsRaycastResult
  31482. */
  31483. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31484. /**
  31485. * Called by the scene. No need to call it.
  31486. * @param delta defines the timespam between frames
  31487. */
  31488. _step(delta: number): void;
  31489. }
  31490. }
  31491. declare module BABYLON {
  31492. /**
  31493. * The interface for the physics imposter parameters
  31494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31495. */
  31496. export interface PhysicsImpostorParameters {
  31497. /**
  31498. * The mass of the physics imposter
  31499. */
  31500. mass: number;
  31501. /**
  31502. * The friction of the physics imposter
  31503. */
  31504. friction?: number;
  31505. /**
  31506. * The coefficient of restitution of the physics imposter
  31507. */
  31508. restitution?: number;
  31509. /**
  31510. * The native options of the physics imposter
  31511. */
  31512. nativeOptions?: any;
  31513. /**
  31514. * Specifies if the parent should be ignored
  31515. */
  31516. ignoreParent?: boolean;
  31517. /**
  31518. * Specifies if bi-directional transformations should be disabled
  31519. */
  31520. disableBidirectionalTransformation?: boolean;
  31521. /**
  31522. * The pressure inside the physics imposter, soft object only
  31523. */
  31524. pressure?: number;
  31525. /**
  31526. * The stiffness the physics imposter, soft object only
  31527. */
  31528. stiffness?: number;
  31529. /**
  31530. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31531. */
  31532. velocityIterations?: number;
  31533. /**
  31534. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31535. */
  31536. positionIterations?: number;
  31537. /**
  31538. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31539. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31540. * Add to fix multiple points
  31541. */
  31542. fixedPoints?: number;
  31543. /**
  31544. * The collision margin around a soft object
  31545. */
  31546. margin?: number;
  31547. /**
  31548. * The collision margin around a soft object
  31549. */
  31550. damping?: number;
  31551. /**
  31552. * The path for a rope based on an extrusion
  31553. */
  31554. path?: any;
  31555. /**
  31556. * The shape of an extrusion used for a rope based on an extrusion
  31557. */
  31558. shape?: any;
  31559. }
  31560. /**
  31561. * Interface for a physics-enabled object
  31562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31563. */
  31564. export interface IPhysicsEnabledObject {
  31565. /**
  31566. * The position of the physics-enabled object
  31567. */
  31568. position: Vector3;
  31569. /**
  31570. * The rotation of the physics-enabled object
  31571. */
  31572. rotationQuaternion: Nullable<Quaternion>;
  31573. /**
  31574. * The scale of the physics-enabled object
  31575. */
  31576. scaling: Vector3;
  31577. /**
  31578. * The rotation of the physics-enabled object
  31579. */
  31580. rotation?: Vector3;
  31581. /**
  31582. * The parent of the physics-enabled object
  31583. */
  31584. parent?: any;
  31585. /**
  31586. * The bounding info of the physics-enabled object
  31587. * @returns The bounding info of the physics-enabled object
  31588. */
  31589. getBoundingInfo(): BoundingInfo;
  31590. /**
  31591. * Computes the world matrix
  31592. * @param force Specifies if the world matrix should be computed by force
  31593. * @returns A world matrix
  31594. */
  31595. computeWorldMatrix(force: boolean): Matrix;
  31596. /**
  31597. * Gets the world matrix
  31598. * @returns A world matrix
  31599. */
  31600. getWorldMatrix?(): Matrix;
  31601. /**
  31602. * Gets the child meshes
  31603. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31604. * @returns An array of abstract meshes
  31605. */
  31606. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31607. /**
  31608. * Gets the vertex data
  31609. * @param kind The type of vertex data
  31610. * @returns A nullable array of numbers, or a float32 array
  31611. */
  31612. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31613. /**
  31614. * Gets the indices from the mesh
  31615. * @returns A nullable array of index arrays
  31616. */
  31617. getIndices?(): Nullable<IndicesArray>;
  31618. /**
  31619. * Gets the scene from the mesh
  31620. * @returns the indices array or null
  31621. */
  31622. getScene?(): Scene;
  31623. /**
  31624. * Gets the absolute position from the mesh
  31625. * @returns the absolute position
  31626. */
  31627. getAbsolutePosition(): Vector3;
  31628. /**
  31629. * Gets the absolute pivot point from the mesh
  31630. * @returns the absolute pivot point
  31631. */
  31632. getAbsolutePivotPoint(): Vector3;
  31633. /**
  31634. * Rotates the mesh
  31635. * @param axis The axis of rotation
  31636. * @param amount The amount of rotation
  31637. * @param space The space of the rotation
  31638. * @returns The rotation transform node
  31639. */
  31640. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31641. /**
  31642. * Translates the mesh
  31643. * @param axis The axis of translation
  31644. * @param distance The distance of translation
  31645. * @param space The space of the translation
  31646. * @returns The transform node
  31647. */
  31648. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31649. /**
  31650. * Sets the absolute position of the mesh
  31651. * @param absolutePosition The absolute position of the mesh
  31652. * @returns The transform node
  31653. */
  31654. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31655. /**
  31656. * Gets the class name of the mesh
  31657. * @returns The class name
  31658. */
  31659. getClassName(): string;
  31660. }
  31661. /**
  31662. * Represents a physics imposter
  31663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31664. */
  31665. export class PhysicsImpostor {
  31666. /**
  31667. * The physics-enabled object used as the physics imposter
  31668. */
  31669. object: IPhysicsEnabledObject;
  31670. /**
  31671. * The type of the physics imposter
  31672. */
  31673. type: number;
  31674. private _options;
  31675. private _scene?;
  31676. /**
  31677. * The default object size of the imposter
  31678. */
  31679. static DEFAULT_OBJECT_SIZE: Vector3;
  31680. /**
  31681. * The identity quaternion of the imposter
  31682. */
  31683. static IDENTITY_QUATERNION: Quaternion;
  31684. /** @hidden */
  31685. _pluginData: any;
  31686. private _physicsEngine;
  31687. private _physicsBody;
  31688. private _bodyUpdateRequired;
  31689. private _onBeforePhysicsStepCallbacks;
  31690. private _onAfterPhysicsStepCallbacks;
  31691. /** @hidden */
  31692. _onPhysicsCollideCallbacks: Array<{
  31693. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31694. otherImpostors: Array<PhysicsImpostor>;
  31695. }>;
  31696. private _deltaPosition;
  31697. private _deltaRotation;
  31698. private _deltaRotationConjugated;
  31699. /** @hidden */
  31700. _isFromLine: boolean;
  31701. private _parent;
  31702. private _isDisposed;
  31703. private static _tmpVecs;
  31704. private static _tmpQuat;
  31705. /**
  31706. * Specifies if the physics imposter is disposed
  31707. */
  31708. get isDisposed(): boolean;
  31709. /**
  31710. * Gets the mass of the physics imposter
  31711. */
  31712. get mass(): number;
  31713. set mass(value: number);
  31714. /**
  31715. * Gets the coefficient of friction
  31716. */
  31717. get friction(): number;
  31718. /**
  31719. * Sets the coefficient of friction
  31720. */
  31721. set friction(value: number);
  31722. /**
  31723. * Gets the coefficient of restitution
  31724. */
  31725. get restitution(): number;
  31726. /**
  31727. * Sets the coefficient of restitution
  31728. */
  31729. set restitution(value: number);
  31730. /**
  31731. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31732. */
  31733. get pressure(): number;
  31734. /**
  31735. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31736. */
  31737. set pressure(value: number);
  31738. /**
  31739. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31740. */
  31741. get stiffness(): number;
  31742. /**
  31743. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31744. */
  31745. set stiffness(value: number);
  31746. /**
  31747. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31748. */
  31749. get velocityIterations(): number;
  31750. /**
  31751. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31752. */
  31753. set velocityIterations(value: number);
  31754. /**
  31755. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31756. */
  31757. get positionIterations(): number;
  31758. /**
  31759. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31760. */
  31761. set positionIterations(value: number);
  31762. /**
  31763. * The unique id of the physics imposter
  31764. * set by the physics engine when adding this impostor to the array
  31765. */
  31766. uniqueId: number;
  31767. /**
  31768. * @hidden
  31769. */
  31770. soft: boolean;
  31771. /**
  31772. * @hidden
  31773. */
  31774. segments: number;
  31775. private _joints;
  31776. /**
  31777. * Initializes the physics imposter
  31778. * @param object The physics-enabled object used as the physics imposter
  31779. * @param type The type of the physics imposter
  31780. * @param _options The options for the physics imposter
  31781. * @param _scene The Babylon scene
  31782. */
  31783. constructor(
  31784. /**
  31785. * The physics-enabled object used as the physics imposter
  31786. */
  31787. object: IPhysicsEnabledObject,
  31788. /**
  31789. * The type of the physics imposter
  31790. */
  31791. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31792. /**
  31793. * This function will completly initialize this impostor.
  31794. * It will create a new body - but only if this mesh has no parent.
  31795. * If it has, this impostor will not be used other than to define the impostor
  31796. * of the child mesh.
  31797. * @hidden
  31798. */
  31799. _init(): void;
  31800. private _getPhysicsParent;
  31801. /**
  31802. * Should a new body be generated.
  31803. * @returns boolean specifying if body initialization is required
  31804. */
  31805. isBodyInitRequired(): boolean;
  31806. /**
  31807. * Sets the updated scaling
  31808. * @param updated Specifies if the scaling is updated
  31809. */
  31810. setScalingUpdated(): void;
  31811. /**
  31812. * Force a regeneration of this or the parent's impostor's body.
  31813. * Use under cautious - This will remove all joints already implemented.
  31814. */
  31815. forceUpdate(): void;
  31816. /**
  31817. * Gets the body that holds this impostor. Either its own, or its parent.
  31818. */
  31819. get physicsBody(): any;
  31820. /**
  31821. * Get the parent of the physics imposter
  31822. * @returns Physics imposter or null
  31823. */
  31824. get parent(): Nullable<PhysicsImpostor>;
  31825. /**
  31826. * Sets the parent of the physics imposter
  31827. */
  31828. set parent(value: Nullable<PhysicsImpostor>);
  31829. /**
  31830. * Set the physics body. Used mainly by the physics engine/plugin
  31831. */
  31832. set physicsBody(physicsBody: any);
  31833. /**
  31834. * Resets the update flags
  31835. */
  31836. resetUpdateFlags(): void;
  31837. /**
  31838. * Gets the object extend size
  31839. * @returns the object extend size
  31840. */
  31841. getObjectExtendSize(): Vector3;
  31842. /**
  31843. * Gets the object center
  31844. * @returns The object center
  31845. */
  31846. getObjectCenter(): Vector3;
  31847. /**
  31848. * Get a specific parameter from the options parameters
  31849. * @param paramName The object parameter name
  31850. * @returns The object parameter
  31851. */
  31852. getParam(paramName: string): any;
  31853. /**
  31854. * Sets a specific parameter in the options given to the physics plugin
  31855. * @param paramName The parameter name
  31856. * @param value The value of the parameter
  31857. */
  31858. setParam(paramName: string, value: number): void;
  31859. /**
  31860. * Specifically change the body's mass option. Won't recreate the physics body object
  31861. * @param mass The mass of the physics imposter
  31862. */
  31863. setMass(mass: number): void;
  31864. /**
  31865. * Gets the linear velocity
  31866. * @returns linear velocity or null
  31867. */
  31868. getLinearVelocity(): Nullable<Vector3>;
  31869. /**
  31870. * Sets the linear velocity
  31871. * @param velocity linear velocity or null
  31872. */
  31873. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31874. /**
  31875. * Gets the angular velocity
  31876. * @returns angular velocity or null
  31877. */
  31878. getAngularVelocity(): Nullable<Vector3>;
  31879. /**
  31880. * Sets the angular velocity
  31881. * @param velocity The velocity or null
  31882. */
  31883. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31884. /**
  31885. * Execute a function with the physics plugin native code
  31886. * Provide a function the will have two variables - the world object and the physics body object
  31887. * @param func The function to execute with the physics plugin native code
  31888. */
  31889. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31890. /**
  31891. * Register a function that will be executed before the physics world is stepping forward
  31892. * @param func The function to execute before the physics world is stepped forward
  31893. */
  31894. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31895. /**
  31896. * Unregister a function that will be executed before the physics world is stepping forward
  31897. * @param func The function to execute before the physics world is stepped forward
  31898. */
  31899. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31900. /**
  31901. * Register a function that will be executed after the physics step
  31902. * @param func The function to execute after physics step
  31903. */
  31904. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31905. /**
  31906. * Unregisters a function that will be executed after the physics step
  31907. * @param func The function to execute after physics step
  31908. */
  31909. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31910. /**
  31911. * register a function that will be executed when this impostor collides against a different body
  31912. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31913. * @param func Callback that is executed on collision
  31914. */
  31915. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31916. /**
  31917. * Unregisters the physics imposter on contact
  31918. * @param collideAgainst The physics object to collide against
  31919. * @param func Callback to execute on collision
  31920. */
  31921. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31922. private _tmpQuat;
  31923. private _tmpQuat2;
  31924. /**
  31925. * Get the parent rotation
  31926. * @returns The parent rotation
  31927. */
  31928. getParentsRotation(): Quaternion;
  31929. /**
  31930. * this function is executed by the physics engine.
  31931. */
  31932. beforeStep: () => void;
  31933. /**
  31934. * this function is executed by the physics engine
  31935. */
  31936. afterStep: () => void;
  31937. /**
  31938. * Legacy collision detection event support
  31939. */
  31940. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31941. /**
  31942. * event and body object due to cannon's event-based architecture.
  31943. */
  31944. onCollide: (e: {
  31945. body: any;
  31946. point: Nullable<Vector3>;
  31947. }) => void;
  31948. /**
  31949. * Apply a force
  31950. * @param force The force to apply
  31951. * @param contactPoint The contact point for the force
  31952. * @returns The physics imposter
  31953. */
  31954. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31955. /**
  31956. * Apply an impulse
  31957. * @param force The impulse force
  31958. * @param contactPoint The contact point for the impulse force
  31959. * @returns The physics imposter
  31960. */
  31961. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  31962. /**
  31963. * A help function to create a joint
  31964. * @param otherImpostor A physics imposter used to create a joint
  31965. * @param jointType The type of joint
  31966. * @param jointData The data for the joint
  31967. * @returns The physics imposter
  31968. */
  31969. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  31970. /**
  31971. * Add a joint to this impostor with a different impostor
  31972. * @param otherImpostor A physics imposter used to add a joint
  31973. * @param joint The joint to add
  31974. * @returns The physics imposter
  31975. */
  31976. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  31977. /**
  31978. * Add an anchor to a cloth impostor
  31979. * @param otherImpostor rigid impostor to anchor to
  31980. * @param width ratio across width from 0 to 1
  31981. * @param height ratio up height from 0 to 1
  31982. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  31983. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  31984. * @returns impostor the soft imposter
  31985. */
  31986. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  31987. /**
  31988. * Add a hook to a rope impostor
  31989. * @param otherImpostor rigid impostor to anchor to
  31990. * @param length ratio across rope from 0 to 1
  31991. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  31992. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  31993. * @returns impostor the rope imposter
  31994. */
  31995. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  31996. /**
  31997. * Will keep this body still, in a sleep mode.
  31998. * @returns the physics imposter
  31999. */
  32000. sleep(): PhysicsImpostor;
  32001. /**
  32002. * Wake the body up.
  32003. * @returns The physics imposter
  32004. */
  32005. wakeUp(): PhysicsImpostor;
  32006. /**
  32007. * Clones the physics imposter
  32008. * @param newObject The physics imposter clones to this physics-enabled object
  32009. * @returns A nullable physics imposter
  32010. */
  32011. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32012. /**
  32013. * Disposes the physics imposter
  32014. */
  32015. dispose(): void;
  32016. /**
  32017. * Sets the delta position
  32018. * @param position The delta position amount
  32019. */
  32020. setDeltaPosition(position: Vector3): void;
  32021. /**
  32022. * Sets the delta rotation
  32023. * @param rotation The delta rotation amount
  32024. */
  32025. setDeltaRotation(rotation: Quaternion): void;
  32026. /**
  32027. * Gets the box size of the physics imposter and stores the result in the input parameter
  32028. * @param result Stores the box size
  32029. * @returns The physics imposter
  32030. */
  32031. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32032. /**
  32033. * Gets the radius of the physics imposter
  32034. * @returns Radius of the physics imposter
  32035. */
  32036. getRadius(): number;
  32037. /**
  32038. * Sync a bone with this impostor
  32039. * @param bone The bone to sync to the impostor.
  32040. * @param boneMesh The mesh that the bone is influencing.
  32041. * @param jointPivot The pivot of the joint / bone in local space.
  32042. * @param distToJoint Optional distance from the impostor to the joint.
  32043. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32044. */
  32045. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32046. /**
  32047. * Sync impostor to a bone
  32048. * @param bone The bone that the impostor will be synced to.
  32049. * @param boneMesh The mesh that the bone is influencing.
  32050. * @param jointPivot The pivot of the joint / bone in local space.
  32051. * @param distToJoint Optional distance from the impostor to the joint.
  32052. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32053. * @param boneAxis Optional vector3 axis the bone is aligned with
  32054. */
  32055. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32056. /**
  32057. * No-Imposter type
  32058. */
  32059. static NoImpostor: number;
  32060. /**
  32061. * Sphere-Imposter type
  32062. */
  32063. static SphereImpostor: number;
  32064. /**
  32065. * Box-Imposter type
  32066. */
  32067. static BoxImpostor: number;
  32068. /**
  32069. * Plane-Imposter type
  32070. */
  32071. static PlaneImpostor: number;
  32072. /**
  32073. * Mesh-imposter type
  32074. */
  32075. static MeshImpostor: number;
  32076. /**
  32077. * Capsule-Impostor type (Ammo.js plugin only)
  32078. */
  32079. static CapsuleImpostor: number;
  32080. /**
  32081. * Cylinder-Imposter type
  32082. */
  32083. static CylinderImpostor: number;
  32084. /**
  32085. * Particle-Imposter type
  32086. */
  32087. static ParticleImpostor: number;
  32088. /**
  32089. * Heightmap-Imposter type
  32090. */
  32091. static HeightmapImpostor: number;
  32092. /**
  32093. * ConvexHull-Impostor type (Ammo.js plugin only)
  32094. */
  32095. static ConvexHullImpostor: number;
  32096. /**
  32097. * Custom-Imposter type (Ammo.js plugin only)
  32098. */
  32099. static CustomImpostor: number;
  32100. /**
  32101. * Rope-Imposter type
  32102. */
  32103. static RopeImpostor: number;
  32104. /**
  32105. * Cloth-Imposter type
  32106. */
  32107. static ClothImpostor: number;
  32108. /**
  32109. * Softbody-Imposter type
  32110. */
  32111. static SoftbodyImpostor: number;
  32112. }
  32113. }
  32114. declare module BABYLON {
  32115. /**
  32116. * @hidden
  32117. **/
  32118. export class _CreationDataStorage {
  32119. closePath?: boolean;
  32120. closeArray?: boolean;
  32121. idx: number[];
  32122. dashSize: number;
  32123. gapSize: number;
  32124. path3D: Path3D;
  32125. pathArray: Vector3[][];
  32126. arc: number;
  32127. radius: number;
  32128. cap: number;
  32129. tessellation: number;
  32130. }
  32131. /**
  32132. * @hidden
  32133. **/
  32134. class _InstanceDataStorage {
  32135. visibleInstances: any;
  32136. batchCache: _InstancesBatch;
  32137. instancesBufferSize: number;
  32138. instancesBuffer: Nullable<Buffer>;
  32139. instancesData: Float32Array;
  32140. overridenInstanceCount: number;
  32141. isFrozen: boolean;
  32142. previousBatch: Nullable<_InstancesBatch>;
  32143. hardwareInstancedRendering: boolean;
  32144. sideOrientation: number;
  32145. manualUpdate: boolean;
  32146. previousRenderId: number;
  32147. }
  32148. /**
  32149. * @hidden
  32150. **/
  32151. export class _InstancesBatch {
  32152. mustReturn: boolean;
  32153. visibleInstances: Nullable<InstancedMesh[]>[];
  32154. renderSelf: boolean[];
  32155. hardwareInstancedRendering: boolean[];
  32156. }
  32157. /**
  32158. * @hidden
  32159. **/
  32160. class _ThinInstanceDataStorage {
  32161. instancesCount: number;
  32162. matrixBuffer: Nullable<Buffer>;
  32163. matrixBufferSize: number;
  32164. matrixData: Nullable<Float32Array>;
  32165. boundingVectors: Array<Vector3>;
  32166. worldMatrices: Nullable<Matrix[]>;
  32167. }
  32168. /**
  32169. * Class used to represent renderable models
  32170. */
  32171. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32172. /**
  32173. * Mesh side orientation : usually the external or front surface
  32174. */
  32175. static readonly FRONTSIDE: number;
  32176. /**
  32177. * Mesh side orientation : usually the internal or back surface
  32178. */
  32179. static readonly BACKSIDE: number;
  32180. /**
  32181. * Mesh side orientation : both internal and external or front and back surfaces
  32182. */
  32183. static readonly DOUBLESIDE: number;
  32184. /**
  32185. * Mesh side orientation : by default, `FRONTSIDE`
  32186. */
  32187. static readonly DEFAULTSIDE: number;
  32188. /**
  32189. * Mesh cap setting : no cap
  32190. */
  32191. static readonly NO_CAP: number;
  32192. /**
  32193. * Mesh cap setting : one cap at the beginning of the mesh
  32194. */
  32195. static readonly CAP_START: number;
  32196. /**
  32197. * Mesh cap setting : one cap at the end of the mesh
  32198. */
  32199. static readonly CAP_END: number;
  32200. /**
  32201. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32202. */
  32203. static readonly CAP_ALL: number;
  32204. /**
  32205. * Mesh pattern setting : no flip or rotate
  32206. */
  32207. static readonly NO_FLIP: number;
  32208. /**
  32209. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32210. */
  32211. static readonly FLIP_TILE: number;
  32212. /**
  32213. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32214. */
  32215. static readonly ROTATE_TILE: number;
  32216. /**
  32217. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32218. */
  32219. static readonly FLIP_ROW: number;
  32220. /**
  32221. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32222. */
  32223. static readonly ROTATE_ROW: number;
  32224. /**
  32225. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32226. */
  32227. static readonly FLIP_N_ROTATE_TILE: number;
  32228. /**
  32229. * Mesh pattern setting : rotate pattern and rotate
  32230. */
  32231. static readonly FLIP_N_ROTATE_ROW: number;
  32232. /**
  32233. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32234. */
  32235. static readonly CENTER: number;
  32236. /**
  32237. * Mesh tile positioning : part tiles on left
  32238. */
  32239. static readonly LEFT: number;
  32240. /**
  32241. * Mesh tile positioning : part tiles on right
  32242. */
  32243. static readonly RIGHT: number;
  32244. /**
  32245. * Mesh tile positioning : part tiles on top
  32246. */
  32247. static readonly TOP: number;
  32248. /**
  32249. * Mesh tile positioning : part tiles on bottom
  32250. */
  32251. static readonly BOTTOM: number;
  32252. /**
  32253. * Gets the default side orientation.
  32254. * @param orientation the orientation to value to attempt to get
  32255. * @returns the default orientation
  32256. * @hidden
  32257. */
  32258. static _GetDefaultSideOrientation(orientation?: number): number;
  32259. private _internalMeshDataInfo;
  32260. get computeBonesUsingShaders(): boolean;
  32261. set computeBonesUsingShaders(value: boolean);
  32262. /**
  32263. * An event triggered before rendering the mesh
  32264. */
  32265. get onBeforeRenderObservable(): Observable<Mesh>;
  32266. /**
  32267. * An event triggered before binding the mesh
  32268. */
  32269. get onBeforeBindObservable(): Observable<Mesh>;
  32270. /**
  32271. * An event triggered after rendering the mesh
  32272. */
  32273. get onAfterRenderObservable(): Observable<Mesh>;
  32274. /**
  32275. * An event triggered before drawing the mesh
  32276. */
  32277. get onBeforeDrawObservable(): Observable<Mesh>;
  32278. private _onBeforeDrawObserver;
  32279. /**
  32280. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32281. */
  32282. set onBeforeDraw(callback: () => void);
  32283. get hasInstances(): boolean;
  32284. get hasThinInstances(): boolean;
  32285. /**
  32286. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32287. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32288. */
  32289. delayLoadState: number;
  32290. /**
  32291. * Gets the list of instances created from this mesh
  32292. * it is not supposed to be modified manually.
  32293. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32294. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32295. */
  32296. instances: InstancedMesh[];
  32297. /**
  32298. * Gets the file containing delay loading data for this mesh
  32299. */
  32300. delayLoadingFile: string;
  32301. /** @hidden */
  32302. _binaryInfo: any;
  32303. /**
  32304. * User defined function used to change how LOD level selection is done
  32305. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32306. */
  32307. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32308. /**
  32309. * Gets or sets the morph target manager
  32310. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32311. */
  32312. get morphTargetManager(): Nullable<MorphTargetManager>;
  32313. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32314. /** @hidden */
  32315. _creationDataStorage: Nullable<_CreationDataStorage>;
  32316. /** @hidden */
  32317. _geometry: Nullable<Geometry>;
  32318. /** @hidden */
  32319. _delayInfo: Array<string>;
  32320. /** @hidden */
  32321. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32322. /** @hidden */
  32323. _instanceDataStorage: _InstanceDataStorage;
  32324. /** @hidden */
  32325. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32326. private _effectiveMaterial;
  32327. /** @hidden */
  32328. _shouldGenerateFlatShading: boolean;
  32329. /** @hidden */
  32330. _originalBuilderSideOrientation: number;
  32331. /**
  32332. * Use this property to change the original side orientation defined at construction time
  32333. */
  32334. overrideMaterialSideOrientation: Nullable<number>;
  32335. /**
  32336. * Gets the source mesh (the one used to clone this one from)
  32337. */
  32338. get source(): Nullable<Mesh>;
  32339. /**
  32340. * Gets the list of clones of this mesh
  32341. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32342. * Note that useClonedMeshMap=true is the default setting
  32343. */
  32344. get cloneMeshMap(): Nullable<{
  32345. [id: string]: Mesh | undefined;
  32346. }>;
  32347. /**
  32348. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32349. */
  32350. get isUnIndexed(): boolean;
  32351. set isUnIndexed(value: boolean);
  32352. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32353. get worldMatrixInstancedBuffer(): Float32Array;
  32354. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32355. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32356. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32357. /**
  32358. * @constructor
  32359. * @param name The value used by scene.getMeshByName() to do a lookup.
  32360. * @param scene The scene to add this mesh to.
  32361. * @param parent The parent of this mesh, if it has one
  32362. * @param source An optional Mesh from which geometry is shared, cloned.
  32363. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32364. * When false, achieved by calling a clone(), also passing False.
  32365. * This will make creation of children, recursive.
  32366. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32367. */
  32368. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32369. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32370. doNotInstantiate: boolean;
  32371. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32372. /**
  32373. * Gets the class name
  32374. * @returns the string "Mesh".
  32375. */
  32376. getClassName(): string;
  32377. /** @hidden */
  32378. get _isMesh(): boolean;
  32379. /**
  32380. * Returns a description of this mesh
  32381. * @param fullDetails define if full details about this mesh must be used
  32382. * @returns a descriptive string representing this mesh
  32383. */
  32384. toString(fullDetails?: boolean): string;
  32385. /** @hidden */
  32386. _unBindEffect(): void;
  32387. /**
  32388. * Gets a boolean indicating if this mesh has LOD
  32389. */
  32390. get hasLODLevels(): boolean;
  32391. /**
  32392. * Gets the list of MeshLODLevel associated with the current mesh
  32393. * @returns an array of MeshLODLevel
  32394. */
  32395. getLODLevels(): MeshLODLevel[];
  32396. private _sortLODLevels;
  32397. /**
  32398. * Add a mesh as LOD level triggered at the given distance.
  32399. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32400. * @param distance The distance from the center of the object to show this level
  32401. * @param mesh The mesh to be added as LOD level (can be null)
  32402. * @return This mesh (for chaining)
  32403. */
  32404. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32405. /**
  32406. * Returns the LOD level mesh at the passed distance or null if not found.
  32407. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32408. * @param distance The distance from the center of the object to show this level
  32409. * @returns a Mesh or `null`
  32410. */
  32411. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32412. /**
  32413. * Remove a mesh from the LOD array
  32414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32415. * @param mesh defines the mesh to be removed
  32416. * @return This mesh (for chaining)
  32417. */
  32418. removeLODLevel(mesh: Mesh): Mesh;
  32419. /**
  32420. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32422. * @param camera defines the camera to use to compute distance
  32423. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32424. * @return This mesh (for chaining)
  32425. */
  32426. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32427. /**
  32428. * Gets the mesh internal Geometry object
  32429. */
  32430. get geometry(): Nullable<Geometry>;
  32431. /**
  32432. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32433. * @returns the total number of vertices
  32434. */
  32435. getTotalVertices(): number;
  32436. /**
  32437. * Returns the content of an associated vertex buffer
  32438. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32439. * - VertexBuffer.PositionKind
  32440. * - VertexBuffer.UVKind
  32441. * - VertexBuffer.UV2Kind
  32442. * - VertexBuffer.UV3Kind
  32443. * - VertexBuffer.UV4Kind
  32444. * - VertexBuffer.UV5Kind
  32445. * - VertexBuffer.UV6Kind
  32446. * - VertexBuffer.ColorKind
  32447. * - VertexBuffer.MatricesIndicesKind
  32448. * - VertexBuffer.MatricesIndicesExtraKind
  32449. * - VertexBuffer.MatricesWeightsKind
  32450. * - VertexBuffer.MatricesWeightsExtraKind
  32451. * @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
  32452. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32453. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32454. */
  32455. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32456. /**
  32457. * Returns the mesh VertexBuffer object from the requested `kind`
  32458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32459. * - VertexBuffer.PositionKind
  32460. * - VertexBuffer.NormalKind
  32461. * - VertexBuffer.UVKind
  32462. * - VertexBuffer.UV2Kind
  32463. * - VertexBuffer.UV3Kind
  32464. * - VertexBuffer.UV4Kind
  32465. * - VertexBuffer.UV5Kind
  32466. * - VertexBuffer.UV6Kind
  32467. * - VertexBuffer.ColorKind
  32468. * - VertexBuffer.MatricesIndicesKind
  32469. * - VertexBuffer.MatricesIndicesExtraKind
  32470. * - VertexBuffer.MatricesWeightsKind
  32471. * - VertexBuffer.MatricesWeightsExtraKind
  32472. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32473. */
  32474. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32475. /**
  32476. * Tests if a specific vertex buffer is associated with this mesh
  32477. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32478. * - VertexBuffer.PositionKind
  32479. * - VertexBuffer.NormalKind
  32480. * - VertexBuffer.UVKind
  32481. * - VertexBuffer.UV2Kind
  32482. * - VertexBuffer.UV3Kind
  32483. * - VertexBuffer.UV4Kind
  32484. * - VertexBuffer.UV5Kind
  32485. * - VertexBuffer.UV6Kind
  32486. * - VertexBuffer.ColorKind
  32487. * - VertexBuffer.MatricesIndicesKind
  32488. * - VertexBuffer.MatricesIndicesExtraKind
  32489. * - VertexBuffer.MatricesWeightsKind
  32490. * - VertexBuffer.MatricesWeightsExtraKind
  32491. * @returns a boolean
  32492. */
  32493. isVerticesDataPresent(kind: string): boolean;
  32494. /**
  32495. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32496. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32497. * - VertexBuffer.PositionKind
  32498. * - VertexBuffer.UVKind
  32499. * - VertexBuffer.UV2Kind
  32500. * - VertexBuffer.UV3Kind
  32501. * - VertexBuffer.UV4Kind
  32502. * - VertexBuffer.UV5Kind
  32503. * - VertexBuffer.UV6Kind
  32504. * - VertexBuffer.ColorKind
  32505. * - VertexBuffer.MatricesIndicesKind
  32506. * - VertexBuffer.MatricesIndicesExtraKind
  32507. * - VertexBuffer.MatricesWeightsKind
  32508. * - VertexBuffer.MatricesWeightsExtraKind
  32509. * @returns a boolean
  32510. */
  32511. isVertexBufferUpdatable(kind: string): boolean;
  32512. /**
  32513. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32514. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32515. * - VertexBuffer.PositionKind
  32516. * - VertexBuffer.NormalKind
  32517. * - VertexBuffer.UVKind
  32518. * - VertexBuffer.UV2Kind
  32519. * - VertexBuffer.UV3Kind
  32520. * - VertexBuffer.UV4Kind
  32521. * - VertexBuffer.UV5Kind
  32522. * - VertexBuffer.UV6Kind
  32523. * - VertexBuffer.ColorKind
  32524. * - VertexBuffer.MatricesIndicesKind
  32525. * - VertexBuffer.MatricesIndicesExtraKind
  32526. * - VertexBuffer.MatricesWeightsKind
  32527. * - VertexBuffer.MatricesWeightsExtraKind
  32528. * @returns an array of strings
  32529. */
  32530. getVerticesDataKinds(): string[];
  32531. /**
  32532. * Returns a positive integer : the total number of indices in this mesh geometry.
  32533. * @returns the numner of indices or zero if the mesh has no geometry.
  32534. */
  32535. getTotalIndices(): number;
  32536. /**
  32537. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32538. * @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.
  32539. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32540. * @returns the indices array or an empty array if the mesh has no geometry
  32541. */
  32542. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32543. get isBlocked(): boolean;
  32544. /**
  32545. * Determine if the current mesh is ready to be rendered
  32546. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32547. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32548. * @returns true if all associated assets are ready (material, textures, shaders)
  32549. */
  32550. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32551. /**
  32552. * 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.
  32553. */
  32554. get areNormalsFrozen(): boolean;
  32555. /**
  32556. * 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.
  32557. * @returns the current mesh
  32558. */
  32559. freezeNormals(): Mesh;
  32560. /**
  32561. * 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
  32562. * @returns the current mesh
  32563. */
  32564. unfreezeNormals(): Mesh;
  32565. /**
  32566. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32567. */
  32568. set overridenInstanceCount(count: number);
  32569. /** @hidden */
  32570. _preActivate(): Mesh;
  32571. /** @hidden */
  32572. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32573. /** @hidden */
  32574. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32575. protected _afterComputeWorldMatrix(): void;
  32576. /** @hidden */
  32577. _postActivate(): void;
  32578. /**
  32579. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32580. * This means the mesh underlying bounding box and sphere are recomputed.
  32581. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32582. * @returns the current mesh
  32583. */
  32584. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32585. /** @hidden */
  32586. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32587. /**
  32588. * This function will subdivide the mesh into multiple submeshes
  32589. * @param count defines the expected number of submeshes
  32590. */
  32591. subdivide(count: number): void;
  32592. /**
  32593. * Copy a FloatArray into a specific associated vertex buffer
  32594. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32595. * - VertexBuffer.PositionKind
  32596. * - VertexBuffer.UVKind
  32597. * - VertexBuffer.UV2Kind
  32598. * - VertexBuffer.UV3Kind
  32599. * - VertexBuffer.UV4Kind
  32600. * - VertexBuffer.UV5Kind
  32601. * - VertexBuffer.UV6Kind
  32602. * - VertexBuffer.ColorKind
  32603. * - VertexBuffer.MatricesIndicesKind
  32604. * - VertexBuffer.MatricesIndicesExtraKind
  32605. * - VertexBuffer.MatricesWeightsKind
  32606. * - VertexBuffer.MatricesWeightsExtraKind
  32607. * @param data defines the data source
  32608. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32609. * @param stride defines the data stride size (can be null)
  32610. * @returns the current mesh
  32611. */
  32612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32613. /**
  32614. * Delete a vertex buffer associated with this mesh
  32615. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32616. * - VertexBuffer.PositionKind
  32617. * - VertexBuffer.UVKind
  32618. * - VertexBuffer.UV2Kind
  32619. * - VertexBuffer.UV3Kind
  32620. * - VertexBuffer.UV4Kind
  32621. * - VertexBuffer.UV5Kind
  32622. * - VertexBuffer.UV6Kind
  32623. * - VertexBuffer.ColorKind
  32624. * - VertexBuffer.MatricesIndicesKind
  32625. * - VertexBuffer.MatricesIndicesExtraKind
  32626. * - VertexBuffer.MatricesWeightsKind
  32627. * - VertexBuffer.MatricesWeightsExtraKind
  32628. */
  32629. removeVerticesData(kind: string): void;
  32630. /**
  32631. * Flags an associated vertex buffer as updatable
  32632. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32633. * - VertexBuffer.PositionKind
  32634. * - VertexBuffer.UVKind
  32635. * - VertexBuffer.UV2Kind
  32636. * - VertexBuffer.UV3Kind
  32637. * - VertexBuffer.UV4Kind
  32638. * - VertexBuffer.UV5Kind
  32639. * - VertexBuffer.UV6Kind
  32640. * - VertexBuffer.ColorKind
  32641. * - VertexBuffer.MatricesIndicesKind
  32642. * - VertexBuffer.MatricesIndicesExtraKind
  32643. * - VertexBuffer.MatricesWeightsKind
  32644. * - VertexBuffer.MatricesWeightsExtraKind
  32645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32646. */
  32647. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32648. /**
  32649. * Sets the mesh global Vertex Buffer
  32650. * @param buffer defines the buffer to use
  32651. * @returns the current mesh
  32652. */
  32653. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32654. /**
  32655. * Update a specific associated vertex buffer
  32656. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32657. * - VertexBuffer.PositionKind
  32658. * - VertexBuffer.UVKind
  32659. * - VertexBuffer.UV2Kind
  32660. * - VertexBuffer.UV3Kind
  32661. * - VertexBuffer.UV4Kind
  32662. * - VertexBuffer.UV5Kind
  32663. * - VertexBuffer.UV6Kind
  32664. * - VertexBuffer.ColorKind
  32665. * - VertexBuffer.MatricesIndicesKind
  32666. * - VertexBuffer.MatricesIndicesExtraKind
  32667. * - VertexBuffer.MatricesWeightsKind
  32668. * - VertexBuffer.MatricesWeightsExtraKind
  32669. * @param data defines the data source
  32670. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32671. * @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)
  32672. * @returns the current mesh
  32673. */
  32674. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32675. /**
  32676. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32677. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32678. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32679. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32680. * @returns the current mesh
  32681. */
  32682. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32683. /**
  32684. * Creates a un-shared specific occurence of the geometry for the mesh.
  32685. * @returns the current mesh
  32686. */
  32687. makeGeometryUnique(): Mesh;
  32688. /**
  32689. * Set the index buffer of this mesh
  32690. * @param indices defines the source data
  32691. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32692. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32693. * @returns the current mesh
  32694. */
  32695. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32696. /**
  32697. * Update the current index buffer
  32698. * @param indices defines the source data
  32699. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32700. * @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)
  32701. * @returns the current mesh
  32702. */
  32703. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32704. /**
  32705. * Invert the geometry to move from a right handed system to a left handed one.
  32706. * @returns the current mesh
  32707. */
  32708. toLeftHanded(): Mesh;
  32709. /** @hidden */
  32710. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32711. /** @hidden */
  32712. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32713. /**
  32714. * Registers for this mesh a javascript function called just before the rendering process
  32715. * @param func defines the function to call before rendering this mesh
  32716. * @returns the current mesh
  32717. */
  32718. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32719. /**
  32720. * Disposes a previously registered javascript function called before the rendering
  32721. * @param func defines the function to remove
  32722. * @returns the current mesh
  32723. */
  32724. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32725. /**
  32726. * Registers for this mesh a javascript function called just after the rendering is complete
  32727. * @param func defines the function to call after rendering this mesh
  32728. * @returns the current mesh
  32729. */
  32730. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32731. /**
  32732. * Disposes a previously registered javascript function called after the rendering.
  32733. * @param func defines the function to remove
  32734. * @returns the current mesh
  32735. */
  32736. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32737. /** @hidden */
  32738. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32739. /** @hidden */
  32740. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32741. /** @hidden */
  32742. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32743. /** @hidden */
  32744. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32745. /** @hidden */
  32746. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32747. /** @hidden */
  32748. _rebuild(): void;
  32749. /** @hidden */
  32750. _freeze(): void;
  32751. /** @hidden */
  32752. _unFreeze(): void;
  32753. /**
  32754. * 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
  32755. * @param subMesh defines the subMesh to render
  32756. * @param enableAlphaMode defines if alpha mode can be changed
  32757. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32758. * @returns the current mesh
  32759. */
  32760. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32761. private _onBeforeDraw;
  32762. /**
  32763. * Renormalize the mesh and patch it up if there are no weights
  32764. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32765. * However in the case of zero weights then we set just a single influence to 1.
  32766. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32767. */
  32768. cleanMatrixWeights(): void;
  32769. private normalizeSkinFourWeights;
  32770. private normalizeSkinWeightsAndExtra;
  32771. /**
  32772. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32773. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32774. * the user know there was an issue with importing the mesh
  32775. * @returns a validation object with skinned, valid and report string
  32776. */
  32777. validateSkinning(): {
  32778. skinned: boolean;
  32779. valid: boolean;
  32780. report: string;
  32781. };
  32782. /** @hidden */
  32783. _checkDelayState(): Mesh;
  32784. private _queueLoad;
  32785. /**
  32786. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32787. * A mesh is in the frustum if its bounding box intersects the frustum
  32788. * @param frustumPlanes defines the frustum to test
  32789. * @returns true if the mesh is in the frustum planes
  32790. */
  32791. isInFrustum(frustumPlanes: Plane[]): boolean;
  32792. /**
  32793. * Sets the mesh material by the material or multiMaterial `id` property
  32794. * @param id is a string identifying the material or the multiMaterial
  32795. * @returns the current mesh
  32796. */
  32797. setMaterialByID(id: string): Mesh;
  32798. /**
  32799. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32800. * @returns an array of IAnimatable
  32801. */
  32802. getAnimatables(): IAnimatable[];
  32803. /**
  32804. * Modifies the mesh geometry according to the passed transformation matrix.
  32805. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32806. * The mesh normals are modified using the same transformation.
  32807. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32808. * @param transform defines the transform matrix to use
  32809. * @see https://doc.babylonjs.com/resources/baking_transformations
  32810. * @returns the current mesh
  32811. */
  32812. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32813. /**
  32814. * Modifies the mesh geometry according to its own current World Matrix.
  32815. * The mesh World Matrix is then reset.
  32816. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32817. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32818. * @see https://doc.babylonjs.com/resources/baking_transformations
  32819. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32820. * @returns the current mesh
  32821. */
  32822. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32823. /** @hidden */
  32824. get _positions(): Nullable<Vector3[]>;
  32825. /** @hidden */
  32826. _resetPointsArrayCache(): Mesh;
  32827. /** @hidden */
  32828. _generatePointsArray(): boolean;
  32829. /**
  32830. * Returns a new Mesh object generated from the current mesh properties.
  32831. * This method must not get confused with createInstance()
  32832. * @param name is a string, the name given to the new mesh
  32833. * @param newParent can be any Node object (default `null`)
  32834. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32835. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32836. * @returns a new mesh
  32837. */
  32838. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32839. /**
  32840. * Releases resources associated with this mesh.
  32841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32843. */
  32844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32845. /** @hidden */
  32846. _disposeInstanceSpecificData(): void;
  32847. /** @hidden */
  32848. _disposeThinInstanceSpecificData(): void;
  32849. /**
  32850. * Modifies the mesh geometry according to a displacement map.
  32851. * 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.
  32852. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32853. * @param url is a string, the URL from the image file is to be downloaded.
  32854. * @param minHeight is the lower limit of the displacement.
  32855. * @param maxHeight is the upper limit of the displacement.
  32856. * @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.
  32857. * @param uvOffset is an optional vector2 used to offset UV.
  32858. * @param uvScale is an optional vector2 used to scale UV.
  32859. * @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.
  32860. * @returns the Mesh.
  32861. */
  32862. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32863. /**
  32864. * Modifies the mesh geometry according to a displacementMap buffer.
  32865. * 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.
  32866. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32867. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32868. * @param heightMapWidth is the width of the buffer image.
  32869. * @param heightMapHeight is the height of the buffer image.
  32870. * @param minHeight is the lower limit of the displacement.
  32871. * @param maxHeight is the upper limit of the displacement.
  32872. * @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.
  32873. * @param uvOffset is an optional vector2 used to offset UV.
  32874. * @param uvScale is an optional vector2 used to scale UV.
  32875. * @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.
  32876. * @returns the Mesh.
  32877. */
  32878. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32879. /**
  32880. * Modify the mesh to get a flat shading rendering.
  32881. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32882. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32883. * @returns current mesh
  32884. */
  32885. convertToFlatShadedMesh(): Mesh;
  32886. /**
  32887. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32888. * In other words, more vertices, no more indices and a single bigger VBO.
  32889. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32890. * @returns current mesh
  32891. */
  32892. convertToUnIndexedMesh(): Mesh;
  32893. /**
  32894. * Inverses facet orientations.
  32895. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32896. * @param flipNormals will also inverts the normals
  32897. * @returns current mesh
  32898. */
  32899. flipFaces(flipNormals?: boolean): Mesh;
  32900. /**
  32901. * Increase the number of facets and hence vertices in a mesh
  32902. * Vertex normals are interpolated from existing vertex normals
  32903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32904. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32905. */
  32906. increaseVertices(numberPerEdge: number): void;
  32907. /**
  32908. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32909. * This will undo any application of covertToFlatShadedMesh
  32910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32911. */
  32912. forceSharedVertices(): void;
  32913. /** @hidden */
  32914. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32915. /** @hidden */
  32916. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32917. /**
  32918. * Creates a new InstancedMesh object from the mesh model.
  32919. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32920. * @param name defines the name of the new instance
  32921. * @returns a new InstancedMesh
  32922. */
  32923. createInstance(name: string): InstancedMesh;
  32924. /**
  32925. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32926. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32927. * @returns the current mesh
  32928. */
  32929. synchronizeInstances(): Mesh;
  32930. /**
  32931. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32932. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32933. * This should be used together with the simplification to avoid disappearing triangles.
  32934. * @param successCallback an optional success callback to be called after the optimization finished.
  32935. * @returns the current mesh
  32936. */
  32937. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32938. /**
  32939. * Serialize current mesh
  32940. * @param serializationObject defines the object which will receive the serialization data
  32941. */
  32942. serialize(serializationObject: any): void;
  32943. /** @hidden */
  32944. _syncGeometryWithMorphTargetManager(): void;
  32945. /** @hidden */
  32946. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  32947. /**
  32948. * Returns a new Mesh object parsed from the source provided.
  32949. * @param parsedMesh is the source
  32950. * @param scene defines the hosting scene
  32951. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  32952. * @returns a new Mesh
  32953. */
  32954. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  32955. /**
  32956. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  32957. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  32958. * @param name defines the name of the mesh to create
  32959. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  32960. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  32961. * @param closePath creates a seam between the first and the last points of each path of the path array
  32962. * @param offset is taken in account only if the `pathArray` is containing a single path
  32963. * @param scene defines the hosting scene
  32964. * @param updatable defines if the mesh must be flagged as updatable
  32965. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32966. * @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)
  32967. * @returns a new Mesh
  32968. */
  32969. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  32970. /**
  32971. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  32972. * @param name defines the name of the mesh to create
  32973. * @param radius sets the radius size (float) of the polygon (default 0.5)
  32974. * @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
  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. * @returns a new Mesh
  32979. */
  32980. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  32981. /**
  32982. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  32983. * @param name defines the name of the mesh to create
  32984. * @param size sets the size (float) of each box side (default 1)
  32985. * @param scene defines the hosting scene
  32986. * @param updatable defines if the mesh must be flagged as updatable
  32987. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32988. * @returns a new Mesh
  32989. */
  32990. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  32991. /**
  32992. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  32993. * @param name defines the name of the mesh to create
  32994. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  32995. * @param diameter sets the diameter size (float) of the sphere (default 1)
  32996. * @param scene defines the hosting scene
  32997. * @param updatable defines if the mesh must be flagged as updatable
  32998. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  32999. * @returns a new Mesh
  33000. */
  33001. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33002. /**
  33003. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33004. * @param name defines the name of the mesh to create
  33005. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33006. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33007. * @param scene defines the hosting scene
  33008. * @returns a new Mesh
  33009. */
  33010. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33011. /**
  33012. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33013. * @param name defines the name of the mesh to create
  33014. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33015. * @param diameterTop set the top cap diameter (floats, default 1)
  33016. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33017. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33018. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33019. * @param scene defines the hosting scene
  33020. * @param updatable defines if the mesh must be flagged as updatable
  33021. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33022. * @returns a new Mesh
  33023. */
  33024. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33025. /**
  33026. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33027. * @param name defines the name of the mesh to create
  33028. * @param diameter sets the diameter size (float) of the torus (default 1)
  33029. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33030. * @param tessellation sets the number of torus sides (postive integer, default 16)
  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 CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33037. /**
  33038. * Creates a torus knot 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 radius sets the global radius size (float) of the torus knot (default 2)
  33041. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33042. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33043. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33044. * @param p the number of windings on X axis (positive integers, default 2)
  33045. * @param q the number of windings on Y axis (positive integers, default 3)
  33046. * @param scene defines the hosting scene
  33047. * @param updatable defines if the mesh must be flagged as updatable
  33048. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33049. * @returns a new Mesh
  33050. */
  33051. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33052. /**
  33053. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33054. * @param name defines the name of the mesh to create
  33055. * @param points is an array successive Vector3
  33056. * @param scene defines the hosting scene
  33057. * @param updatable defines if the mesh must be flagged as updatable
  33058. * @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).
  33059. * @returns a new Mesh
  33060. */
  33061. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33062. /**
  33063. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33064. * @param name defines the name of the mesh to create
  33065. * @param points is an array successive Vector3
  33066. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33067. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33068. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33069. * @param scene defines the hosting scene
  33070. * @param updatable defines if the mesh must be flagged as updatable
  33071. * @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)
  33072. * @returns a new Mesh
  33073. */
  33074. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33075. /**
  33076. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33077. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33078. * 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.
  33079. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33080. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33081. * Remember you can only change the shape positions, not their number when updating a polygon.
  33082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33083. * @param name defines the name of the mesh to create
  33084. * @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
  33085. * @param scene defines the hosting scene
  33086. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33087. * @param updatable defines if the mesh must be flagged as updatable
  33088. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33089. * @param earcutInjection can be used to inject your own earcut reference
  33090. * @returns a new Mesh
  33091. */
  33092. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33093. /**
  33094. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33096. * @param name defines the name of the mesh to create
  33097. * @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
  33098. * @param depth defines the height of extrusion
  33099. * @param scene defines the hosting scene
  33100. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33101. * @param updatable defines if the mesh must be flagged as updatable
  33102. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33103. * @param earcutInjection can be used to inject your own earcut reference
  33104. * @returns a new Mesh
  33105. */
  33106. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33107. /**
  33108. * Creates an extruded shape mesh.
  33109. * 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
  33110. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33112. * @param name defines the name of the mesh to create
  33113. * @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
  33114. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33115. * @param scale is the value to scale the shape
  33116. * @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
  33117. * @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
  33118. * @param scene defines the hosting scene
  33119. * @param updatable defines if the mesh must be flagged as updatable
  33120. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33121. * @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)
  33122. * @returns a new Mesh
  33123. */
  33124. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33125. /**
  33126. * Creates an custom extruded shape mesh.
  33127. * The custom extrusion is a parametric shape.
  33128. * It has no predefined shape. Its final shape will depend on the input parameters.
  33129. * Please consider using the same method from the MeshBuilder class instead
  33130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33131. * @param name defines the name of the mesh to create
  33132. * @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
  33133. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33134. * @param scaleFunction is a custom Javascript function called on each path point
  33135. * @param rotationFunction is a custom Javascript function called on each path point
  33136. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33137. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33138. * @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
  33139. * @param scene defines the hosting scene
  33140. * @param updatable defines if the mesh must be flagged as updatable
  33141. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33142. * @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)
  33143. * @returns a new Mesh
  33144. */
  33145. 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;
  33146. /**
  33147. * Creates lathe mesh.
  33148. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33149. * Please consider using the same method from the MeshBuilder class instead
  33150. * @param name defines the name of the mesh to create
  33151. * @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
  33152. * @param radius is the radius value of the lathe
  33153. * @param tessellation is the side number of the lathe.
  33154. * @param scene defines the hosting scene
  33155. * @param updatable defines if the mesh must be flagged as updatable
  33156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33157. * @returns a new Mesh
  33158. */
  33159. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33160. /**
  33161. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33162. * @param name defines the name of the mesh to create
  33163. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33164. * @param scene defines the hosting scene
  33165. * @param updatable defines if the mesh must be flagged as updatable
  33166. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33167. * @returns a new Mesh
  33168. */
  33169. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33170. /**
  33171. * Creates a ground mesh.
  33172. * Please consider using the same method from the MeshBuilder class instead
  33173. * @param name defines the name of the mesh to create
  33174. * @param width set the width of the ground
  33175. * @param height set the height of the ground
  33176. * @param subdivisions sets the number of subdivisions per side
  33177. * @param scene defines the hosting scene
  33178. * @param updatable defines if the mesh must be flagged as updatable
  33179. * @returns a new Mesh
  33180. */
  33181. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33182. /**
  33183. * Creates a tiled 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 xmin set the ground minimum X coordinate
  33187. * @param zmin set the ground minimum Y coordinate
  33188. * @param xmax set the ground maximum X coordinate
  33189. * @param zmax set the ground maximum Z coordinate
  33190. * @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
  33191. * @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
  33192. * @param scene defines the hosting scene
  33193. * @param updatable defines if the mesh must be flagged as updatable
  33194. * @returns a new Mesh
  33195. */
  33196. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33197. w: number;
  33198. h: number;
  33199. }, precision: {
  33200. w: number;
  33201. h: number;
  33202. }, scene: Scene, updatable?: boolean): Mesh;
  33203. /**
  33204. * Creates a ground mesh from a height map.
  33205. * Please consider using the same method from the MeshBuilder class instead
  33206. * @see https://doc.babylonjs.com/babylon101/height_map
  33207. * @param name defines the name of the mesh to create
  33208. * @param url sets the URL of the height map image resource
  33209. * @param width set the ground width size
  33210. * @param height set the ground height size
  33211. * @param subdivisions sets the number of subdivision per side
  33212. * @param minHeight is the minimum altitude on the ground
  33213. * @param maxHeight is the maximum altitude on the ground
  33214. * @param scene defines the hosting scene
  33215. * @param updatable defines if the mesh must be flagged as updatable
  33216. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33217. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33218. * @returns a new Mesh
  33219. */
  33220. 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;
  33221. /**
  33222. * Creates a tube mesh.
  33223. * The tube is a parametric shape.
  33224. * It has no predefined shape. Its final shape will depend on the input parameters.
  33225. * Please consider using the same method from the MeshBuilder class instead
  33226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33227. * @param name defines the name of the mesh to create
  33228. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33229. * @param radius sets the tube radius size
  33230. * @param tessellation is the number of sides on the tubular surface
  33231. * @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
  33232. * @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
  33233. * @param scene defines the hosting scene
  33234. * @param updatable defines if the mesh must be flagged as updatable
  33235. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33236. * @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)
  33237. * @returns a new Mesh
  33238. */
  33239. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33240. (i: number, distance: number): number;
  33241. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33242. /**
  33243. * Creates a polyhedron mesh.
  33244. * Please consider using the same method from the MeshBuilder class instead.
  33245. * * 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
  33246. * * The parameter `size` (positive float, default 1) sets the polygon size
  33247. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33248. * * 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`
  33249. * * 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
  33250. * * 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)`)
  33251. * * 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
  33252. * * 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
  33253. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33254. * * 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
  33255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33256. * @param name defines the name of the mesh to create
  33257. * @param options defines the options used to create the mesh
  33258. * @param scene defines the hosting scene
  33259. * @returns a new Mesh
  33260. */
  33261. static CreatePolyhedron(name: string, options: {
  33262. type?: number;
  33263. size?: number;
  33264. sizeX?: number;
  33265. sizeY?: number;
  33266. sizeZ?: number;
  33267. custom?: any;
  33268. faceUV?: Vector4[];
  33269. faceColors?: Color4[];
  33270. updatable?: boolean;
  33271. sideOrientation?: number;
  33272. }, scene: Scene): Mesh;
  33273. /**
  33274. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33275. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33276. * * 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`)
  33277. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33278. * * 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
  33279. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33280. * * 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
  33281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33282. * @param name defines the name of the mesh
  33283. * @param options defines the options used to create the mesh
  33284. * @param scene defines the hosting scene
  33285. * @returns a new Mesh
  33286. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33287. */
  33288. static CreateIcoSphere(name: string, options: {
  33289. radius?: number;
  33290. flat?: boolean;
  33291. subdivisions?: number;
  33292. sideOrientation?: number;
  33293. updatable?: boolean;
  33294. }, scene: Scene): Mesh;
  33295. /**
  33296. * Creates a decal mesh.
  33297. * Please consider using the same method from the MeshBuilder class instead.
  33298. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33299. * @param name defines the name of the mesh
  33300. * @param sourceMesh defines the mesh receiving the decal
  33301. * @param position sets the position of the decal in world coordinates
  33302. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33303. * @param size sets the decal scaling
  33304. * @param angle sets the angle to rotate the decal
  33305. * @returns a new Mesh
  33306. */
  33307. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33308. /** Creates a Capsule Mesh
  33309. * @param name defines the name of the mesh.
  33310. * @param options the constructors options used to shape the mesh.
  33311. * @param scene defines the scene the mesh is scoped to.
  33312. * @returns the capsule mesh
  33313. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33314. */
  33315. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33316. /**
  33317. * Prepare internal position array for software CPU skinning
  33318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33319. */
  33320. setPositionsForCPUSkinning(): Float32Array;
  33321. /**
  33322. * Prepare internal normal array for software CPU skinning
  33323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33324. */
  33325. setNormalsForCPUSkinning(): Float32Array;
  33326. /**
  33327. * Updates the vertex buffer by applying transformation from the bones
  33328. * @param skeleton defines the skeleton to apply to current mesh
  33329. * @returns the current mesh
  33330. */
  33331. applySkeleton(skeleton: Skeleton): Mesh;
  33332. /**
  33333. * 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
  33334. * @param meshes defines the list of meshes to scan
  33335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33336. */
  33337. static MinMax(meshes: AbstractMesh[]): {
  33338. min: Vector3;
  33339. max: Vector3;
  33340. };
  33341. /**
  33342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33344. * @returns a vector3
  33345. */
  33346. static Center(meshesOrMinMaxVector: {
  33347. min: Vector3;
  33348. max: Vector3;
  33349. } | AbstractMesh[]): Vector3;
  33350. /**
  33351. * Merge the array of meshes into a single mesh for performance reasons.
  33352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33358. * @returns a new mesh
  33359. */
  33360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33361. /** @hidden */
  33362. addInstance(instance: InstancedMesh): void;
  33363. /** @hidden */
  33364. removeInstance(instance: InstancedMesh): void;
  33365. }
  33366. }
  33367. declare module BABYLON {
  33368. /**
  33369. * The options Interface for creating a Capsule Mesh
  33370. */
  33371. export interface ICreateCapsuleOptions {
  33372. /** The Orientation of the capsule. Default : Vector3.Up() */
  33373. orientation?: Vector3;
  33374. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33375. subdivisions: number;
  33376. /** Number of cylindrical segments on the capsule. */
  33377. tessellation: number;
  33378. /** Height or Length of the capsule. */
  33379. height: number;
  33380. /** Radius of the capsule. */
  33381. radius: number;
  33382. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33383. capSubdivisions: number;
  33384. /** Overwrite for the top radius. */
  33385. radiusTop?: number;
  33386. /** Overwrite for the bottom radius. */
  33387. radiusBottom?: number;
  33388. /** Overwrite for the top capSubdivisions. */
  33389. topCapSubdivisions?: number;
  33390. /** Overwrite for the bottom capSubdivisions. */
  33391. bottomCapSubdivisions?: number;
  33392. }
  33393. /**
  33394. * Class containing static functions to help procedurally build meshes
  33395. */
  33396. export class CapsuleBuilder {
  33397. /**
  33398. * Creates a capsule or a pill mesh
  33399. * @param name defines the name of the mesh
  33400. * @param options The constructors options.
  33401. * @param scene The scene the mesh is scoped to.
  33402. * @returns Capsule Mesh
  33403. */
  33404. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33405. }
  33406. }
  33407. declare module BABYLON {
  33408. /**
  33409. * Define an interface for all classes that will get and set the data on vertices
  33410. */
  33411. export interface IGetSetVerticesData {
  33412. /**
  33413. * Gets a boolean indicating if specific vertex data is present
  33414. * @param kind defines the vertex data kind to use
  33415. * @returns true is data kind is present
  33416. */
  33417. isVerticesDataPresent(kind: string): boolean;
  33418. /**
  33419. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33420. * @param kind defines the data kind (Position, normal, etc...)
  33421. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33422. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33423. * @returns a float array containing vertex data
  33424. */
  33425. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33426. /**
  33427. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33428. * @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.
  33429. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33430. * @returns the indices array or an empty array if the mesh has no geometry
  33431. */
  33432. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33433. /**
  33434. * Set specific vertex data
  33435. * @param kind defines the data kind (Position, normal, etc...)
  33436. * @param data defines the vertex data to use
  33437. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33438. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33439. */
  33440. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33441. /**
  33442. * Update a specific associated vertex buffer
  33443. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33444. * - VertexBuffer.PositionKind
  33445. * - VertexBuffer.UVKind
  33446. * - VertexBuffer.UV2Kind
  33447. * - VertexBuffer.UV3Kind
  33448. * - VertexBuffer.UV4Kind
  33449. * - VertexBuffer.UV5Kind
  33450. * - VertexBuffer.UV6Kind
  33451. * - VertexBuffer.ColorKind
  33452. * - VertexBuffer.MatricesIndicesKind
  33453. * - VertexBuffer.MatricesIndicesExtraKind
  33454. * - VertexBuffer.MatricesWeightsKind
  33455. * - VertexBuffer.MatricesWeightsExtraKind
  33456. * @param data defines the data source
  33457. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33458. * @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)
  33459. */
  33460. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33461. /**
  33462. * Creates a new index buffer
  33463. * @param indices defines the indices to store in the index buffer
  33464. * @param totalVertices defines the total number of vertices (could be null)
  33465. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33466. */
  33467. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33468. }
  33469. /**
  33470. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33471. */
  33472. export class VertexData {
  33473. /**
  33474. * Mesh side orientation : usually the external or front surface
  33475. */
  33476. static readonly FRONTSIDE: number;
  33477. /**
  33478. * Mesh side orientation : usually the internal or back surface
  33479. */
  33480. static readonly BACKSIDE: number;
  33481. /**
  33482. * Mesh side orientation : both internal and external or front and back surfaces
  33483. */
  33484. static readonly DOUBLESIDE: number;
  33485. /**
  33486. * Mesh side orientation : by default, `FRONTSIDE`
  33487. */
  33488. static readonly DEFAULTSIDE: number;
  33489. /**
  33490. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33491. */
  33492. positions: Nullable<FloatArray>;
  33493. /**
  33494. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33495. */
  33496. normals: Nullable<FloatArray>;
  33497. /**
  33498. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33499. */
  33500. tangents: Nullable<FloatArray>;
  33501. /**
  33502. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33503. */
  33504. uvs: Nullable<FloatArray>;
  33505. /**
  33506. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33507. */
  33508. uvs2: Nullable<FloatArray>;
  33509. /**
  33510. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33511. */
  33512. uvs3: Nullable<FloatArray>;
  33513. /**
  33514. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33515. */
  33516. uvs4: Nullable<FloatArray>;
  33517. /**
  33518. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33519. */
  33520. uvs5: Nullable<FloatArray>;
  33521. /**
  33522. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33523. */
  33524. uvs6: Nullable<FloatArray>;
  33525. /**
  33526. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33527. */
  33528. colors: Nullable<FloatArray>;
  33529. /**
  33530. * 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).
  33531. */
  33532. matricesIndices: Nullable<FloatArray>;
  33533. /**
  33534. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33535. */
  33536. matricesWeights: Nullable<FloatArray>;
  33537. /**
  33538. * An array extending the number of possible indices
  33539. */
  33540. matricesIndicesExtra: Nullable<FloatArray>;
  33541. /**
  33542. * An array extending the number of possible weights when the number of indices is extended
  33543. */
  33544. matricesWeightsExtra: Nullable<FloatArray>;
  33545. /**
  33546. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33547. */
  33548. indices: Nullable<IndicesArray>;
  33549. /**
  33550. * Uses the passed data array to set the set the values for the specified kind of data
  33551. * @param data a linear array of floating numbers
  33552. * @param kind the type of data that is being set, eg positions, colors etc
  33553. */
  33554. set(data: FloatArray, kind: string): void;
  33555. /**
  33556. * Associates the vertexData to the passed Mesh.
  33557. * Sets it as updatable or not (default `false`)
  33558. * @param mesh the mesh the vertexData is applied to
  33559. * @param updatable when used and having the value true allows new data to update the vertexData
  33560. * @returns the VertexData
  33561. */
  33562. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33563. /**
  33564. * Associates the vertexData to the passed Geometry.
  33565. * Sets it as updatable or not (default `false`)
  33566. * @param geometry the geometry the vertexData is applied to
  33567. * @param updatable when used and having the value true allows new data to update the vertexData
  33568. * @returns VertexData
  33569. */
  33570. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33571. /**
  33572. * Updates the associated mesh
  33573. * @param mesh the mesh to be updated
  33574. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33575. * @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
  33576. * @returns VertexData
  33577. */
  33578. updateMesh(mesh: Mesh): VertexData;
  33579. /**
  33580. * Updates the associated geometry
  33581. * @param geometry the geometry to be updated
  33582. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33583. * @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
  33584. * @returns VertexData.
  33585. */
  33586. updateGeometry(geometry: Geometry): VertexData;
  33587. private _applyTo;
  33588. private _update;
  33589. /**
  33590. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33591. * @param matrix the transforming matrix
  33592. * @returns the VertexData
  33593. */
  33594. transform(matrix: Matrix): VertexData;
  33595. /**
  33596. * Merges the passed VertexData into the current one
  33597. * @param other the VertexData to be merged into the current one
  33598. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33599. * @returns the modified VertexData
  33600. */
  33601. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33602. private _mergeElement;
  33603. private _validate;
  33604. /**
  33605. * Serializes the VertexData
  33606. * @returns a serialized object
  33607. */
  33608. serialize(): any;
  33609. /**
  33610. * Extracts the vertexData from a mesh
  33611. * @param mesh the mesh from which to extract the VertexData
  33612. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33613. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33614. * @returns the object VertexData associated to the passed mesh
  33615. */
  33616. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33617. /**
  33618. * Extracts the vertexData from the geometry
  33619. * @param geometry the geometry from which to extract the VertexData
  33620. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33621. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33622. * @returns the object VertexData associated to the passed mesh
  33623. */
  33624. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33625. private static _ExtractFrom;
  33626. /**
  33627. * Creates the VertexData for a Ribbon
  33628. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33629. * * pathArray array of paths, each of which an array of successive Vector3
  33630. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33631. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33632. * * 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
  33633. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33634. * * 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)
  33635. * * 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)
  33636. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33637. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33638. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33639. * @returns the VertexData of the ribbon
  33640. */
  33641. static CreateRibbon(options: {
  33642. pathArray: Vector3[][];
  33643. closeArray?: boolean;
  33644. closePath?: boolean;
  33645. offset?: number;
  33646. sideOrientation?: number;
  33647. frontUVs?: Vector4;
  33648. backUVs?: Vector4;
  33649. invertUV?: boolean;
  33650. uvs?: Vector2[];
  33651. colors?: Color4[];
  33652. }): VertexData;
  33653. /**
  33654. * Creates the VertexData for a box
  33655. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33656. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33657. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33658. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33659. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33660. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33661. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33662. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33663. * * 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)
  33664. * * 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)
  33665. * @returns the VertexData of the box
  33666. */
  33667. static CreateBox(options: {
  33668. size?: number;
  33669. width?: number;
  33670. height?: number;
  33671. depth?: number;
  33672. faceUV?: Vector4[];
  33673. faceColors?: Color4[];
  33674. sideOrientation?: number;
  33675. frontUVs?: Vector4;
  33676. backUVs?: Vector4;
  33677. }): VertexData;
  33678. /**
  33679. * Creates the VertexData for a tiled box
  33680. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33681. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33682. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33683. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33684. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33685. * @returns the VertexData of the box
  33686. */
  33687. static CreateTiledBox(options: {
  33688. pattern?: number;
  33689. width?: number;
  33690. height?: number;
  33691. depth?: number;
  33692. tileSize?: number;
  33693. tileWidth?: number;
  33694. tileHeight?: number;
  33695. alignHorizontal?: number;
  33696. alignVertical?: number;
  33697. faceUV?: Vector4[];
  33698. faceColors?: Color4[];
  33699. sideOrientation?: number;
  33700. }): VertexData;
  33701. /**
  33702. * Creates the VertexData for a tiled plane
  33703. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33704. * * pattern a limited pattern arrangement depending on the number
  33705. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33706. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33707. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33708. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33709. * * 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)
  33710. * * 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)
  33711. * @returns the VertexData of the tiled plane
  33712. */
  33713. static CreateTiledPlane(options: {
  33714. pattern?: number;
  33715. tileSize?: number;
  33716. tileWidth?: number;
  33717. tileHeight?: number;
  33718. size?: number;
  33719. width?: number;
  33720. height?: number;
  33721. alignHorizontal?: number;
  33722. alignVertical?: number;
  33723. sideOrientation?: number;
  33724. frontUVs?: Vector4;
  33725. backUVs?: Vector4;
  33726. }): VertexData;
  33727. /**
  33728. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33729. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33730. * * segments sets the number of horizontal strips optional, default 32
  33731. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33732. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33733. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33734. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33735. * * 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
  33736. * * 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
  33737. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33738. * * 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)
  33739. * * 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)
  33740. * @returns the VertexData of the ellipsoid
  33741. */
  33742. static CreateSphere(options: {
  33743. segments?: number;
  33744. diameter?: number;
  33745. diameterX?: number;
  33746. diameterY?: number;
  33747. diameterZ?: number;
  33748. arc?: number;
  33749. slice?: number;
  33750. sideOrientation?: number;
  33751. frontUVs?: Vector4;
  33752. backUVs?: Vector4;
  33753. }): VertexData;
  33754. /**
  33755. * Creates the VertexData for a cylinder, cone or prism
  33756. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33757. * * height sets the height (y direction) of the cylinder, optional, default 2
  33758. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33759. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33760. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33761. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33762. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33763. * * 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
  33764. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33765. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33766. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33767. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33768. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33769. * * 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)
  33770. * * 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)
  33771. * @returns the VertexData of the cylinder, cone or prism
  33772. */
  33773. static CreateCylinder(options: {
  33774. height?: number;
  33775. diameterTop?: number;
  33776. diameterBottom?: number;
  33777. diameter?: number;
  33778. tessellation?: number;
  33779. subdivisions?: number;
  33780. arc?: number;
  33781. faceColors?: Color4[];
  33782. faceUV?: Vector4[];
  33783. hasRings?: boolean;
  33784. enclose?: boolean;
  33785. sideOrientation?: number;
  33786. frontUVs?: Vector4;
  33787. backUVs?: Vector4;
  33788. }): VertexData;
  33789. /**
  33790. * Creates the VertexData for a torus
  33791. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33792. * * diameter the diameter of the torus, optional default 1
  33793. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33794. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33796. * * 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)
  33797. * * 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)
  33798. * @returns the VertexData of the torus
  33799. */
  33800. static CreateTorus(options: {
  33801. diameter?: number;
  33802. thickness?: number;
  33803. tessellation?: number;
  33804. sideOrientation?: number;
  33805. frontUVs?: Vector4;
  33806. backUVs?: Vector4;
  33807. }): VertexData;
  33808. /**
  33809. * Creates the VertexData of the LineSystem
  33810. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33811. * - lines an array of lines, each line being an array of successive Vector3
  33812. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33813. * @returns the VertexData of the LineSystem
  33814. */
  33815. static CreateLineSystem(options: {
  33816. lines: Vector3[][];
  33817. colors?: Nullable<Color4[][]>;
  33818. }): VertexData;
  33819. /**
  33820. * Create the VertexData for a DashedLines
  33821. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33822. * - points an array successive Vector3
  33823. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33824. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33825. * - dashNb the intended total number of dashes, optional, default 200
  33826. * @returns the VertexData for the DashedLines
  33827. */
  33828. static CreateDashedLines(options: {
  33829. points: Vector3[];
  33830. dashSize?: number;
  33831. gapSize?: number;
  33832. dashNb?: number;
  33833. }): VertexData;
  33834. /**
  33835. * Creates the VertexData for a Ground
  33836. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33837. * - width the width (x direction) of the ground, optional, default 1
  33838. * - height the height (z direction) of the ground, optional, default 1
  33839. * - subdivisions the number of subdivisions per side, optional, default 1
  33840. * @returns the VertexData of the Ground
  33841. */
  33842. static CreateGround(options: {
  33843. width?: number;
  33844. height?: number;
  33845. subdivisions?: number;
  33846. subdivisionsX?: number;
  33847. subdivisionsY?: number;
  33848. }): VertexData;
  33849. /**
  33850. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33851. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33852. * * xmin the ground minimum X coordinate, optional, default -1
  33853. * * zmin the ground minimum Z coordinate, optional, default -1
  33854. * * xmax the ground maximum X coordinate, optional, default 1
  33855. * * zmax the ground maximum Z coordinate, optional, default 1
  33856. * * 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}
  33857. * * 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}
  33858. * @returns the VertexData of the TiledGround
  33859. */
  33860. static CreateTiledGround(options: {
  33861. xmin: number;
  33862. zmin: number;
  33863. xmax: number;
  33864. zmax: number;
  33865. subdivisions?: {
  33866. w: number;
  33867. h: number;
  33868. };
  33869. precision?: {
  33870. w: number;
  33871. h: number;
  33872. };
  33873. }): VertexData;
  33874. /**
  33875. * Creates the VertexData of the Ground designed from a heightmap
  33876. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33877. * * width the width (x direction) of the ground
  33878. * * height the height (z direction) of the ground
  33879. * * subdivisions the number of subdivisions per side
  33880. * * minHeight the minimum altitude on the ground, optional, default 0
  33881. * * maxHeight the maximum altitude on the ground, optional default 1
  33882. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33883. * * buffer the array holding the image color data
  33884. * * bufferWidth the width of image
  33885. * * bufferHeight the height of image
  33886. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33887. * @returns the VertexData of the Ground designed from a heightmap
  33888. */
  33889. static CreateGroundFromHeightMap(options: {
  33890. width: number;
  33891. height: number;
  33892. subdivisions: number;
  33893. minHeight: number;
  33894. maxHeight: number;
  33895. colorFilter: Color3;
  33896. buffer: Uint8Array;
  33897. bufferWidth: number;
  33898. bufferHeight: number;
  33899. alphaFilter: number;
  33900. }): VertexData;
  33901. /**
  33902. * Creates the VertexData for a Plane
  33903. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33904. * * size sets the width and height of the plane to the value of size, optional default 1
  33905. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33906. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33908. * * 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)
  33909. * * 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)
  33910. * @returns the VertexData of the box
  33911. */
  33912. static CreatePlane(options: {
  33913. size?: number;
  33914. width?: number;
  33915. height?: number;
  33916. sideOrientation?: number;
  33917. frontUVs?: Vector4;
  33918. backUVs?: Vector4;
  33919. }): VertexData;
  33920. /**
  33921. * Creates the VertexData of the Disc or regular Polygon
  33922. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33923. * * radius the radius of the disc, optional default 0.5
  33924. * * tessellation the number of polygon sides, optional, default 64
  33925. * * 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
  33926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33927. * * 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)
  33928. * * 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)
  33929. * @returns the VertexData of the box
  33930. */
  33931. static CreateDisc(options: {
  33932. radius?: number;
  33933. tessellation?: number;
  33934. arc?: number;
  33935. sideOrientation?: number;
  33936. frontUVs?: Vector4;
  33937. backUVs?: Vector4;
  33938. }): VertexData;
  33939. /**
  33940. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33941. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  33942. * @param polygon a mesh built from polygonTriangulation.build()
  33943. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33944. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33945. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33946. * @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)
  33947. * @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)
  33948. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  33949. * @returns the VertexData of the Polygon
  33950. */
  33951. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  33952. /**
  33953. * Creates the VertexData of the IcoSphere
  33954. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  33955. * * radius the radius of the IcoSphere, optional default 1
  33956. * * radiusX allows stretching in the x direction, optional, default radius
  33957. * * radiusY allows stretching in the y direction, optional, default radius
  33958. * * radiusZ allows stretching in the z direction, optional, default radius
  33959. * * flat when true creates a flat shaded mesh, optional, default true
  33960. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  33961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33962. * * 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)
  33963. * * 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)
  33964. * @returns the VertexData of the IcoSphere
  33965. */
  33966. static CreateIcoSphere(options: {
  33967. radius?: number;
  33968. radiusX?: number;
  33969. radiusY?: number;
  33970. radiusZ?: number;
  33971. flat?: boolean;
  33972. subdivisions?: number;
  33973. sideOrientation?: number;
  33974. frontUVs?: Vector4;
  33975. backUVs?: Vector4;
  33976. }): VertexData;
  33977. /**
  33978. * Creates the VertexData for a Polyhedron
  33979. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  33980. * * type provided types are:
  33981. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  33982. * * 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)
  33983. * * size the size of the IcoSphere, optional default 1
  33984. * * sizeX allows stretching in the x direction, optional, default size
  33985. * * sizeY allows stretching in the y direction, optional, default size
  33986. * * sizeZ allows stretching in the z direction, optional, default size
  33987. * * 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
  33988. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33989. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33990. * * flat when true creates a flat shaded mesh, optional, default true
  33991. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  33992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33993. * * 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)
  33994. * * 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)
  33995. * @returns the VertexData of the Polyhedron
  33996. */
  33997. static CreatePolyhedron(options: {
  33998. type?: number;
  33999. size?: number;
  34000. sizeX?: number;
  34001. sizeY?: number;
  34002. sizeZ?: number;
  34003. custom?: any;
  34004. faceUV?: Vector4[];
  34005. faceColors?: Color4[];
  34006. flat?: boolean;
  34007. sideOrientation?: number;
  34008. frontUVs?: Vector4;
  34009. backUVs?: Vector4;
  34010. }): VertexData;
  34011. /**
  34012. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34013. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34014. * @returns the VertexData of the Capsule
  34015. */
  34016. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34017. /**
  34018. * Creates the VertexData for a TorusKnot
  34019. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34020. * * radius the radius of the torus knot, optional, default 2
  34021. * * tube the thickness of the tube, optional, default 0.5
  34022. * * radialSegments the number of sides on each tube segments, optional, default 32
  34023. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34024. * * p the number of windings around the z axis, optional, default 2
  34025. * * q the number of windings around the x axis, optional, default 3
  34026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34027. * * 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)
  34028. * * 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)
  34029. * @returns the VertexData of the Torus Knot
  34030. */
  34031. static CreateTorusKnot(options: {
  34032. radius?: number;
  34033. tube?: number;
  34034. radialSegments?: number;
  34035. tubularSegments?: number;
  34036. p?: number;
  34037. q?: number;
  34038. sideOrientation?: number;
  34039. frontUVs?: Vector4;
  34040. backUVs?: Vector4;
  34041. }): VertexData;
  34042. /**
  34043. * Compute normals for given positions and indices
  34044. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34045. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34046. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34047. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34048. * * facetNormals : optional array of facet normals (vector3)
  34049. * * facetPositions : optional array of facet positions (vector3)
  34050. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34051. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34052. * * bInfo : optional bounding info, required for facetPartitioning computation
  34053. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34054. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34055. * * useRightHandedSystem: optional boolean to for right handed system computation
  34056. * * depthSort : optional boolean to enable the facet depth sort computation
  34057. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34058. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34059. */
  34060. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34061. facetNormals?: any;
  34062. facetPositions?: any;
  34063. facetPartitioning?: any;
  34064. ratio?: number;
  34065. bInfo?: any;
  34066. bbSize?: Vector3;
  34067. subDiv?: any;
  34068. useRightHandedSystem?: boolean;
  34069. depthSort?: boolean;
  34070. distanceTo?: Vector3;
  34071. depthSortedFacets?: any;
  34072. }): void;
  34073. /** @hidden */
  34074. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34075. /**
  34076. * Applies VertexData created from the imported parameters to the geometry
  34077. * @param parsedVertexData the parsed data from an imported file
  34078. * @param geometry the geometry to apply the VertexData to
  34079. */
  34080. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34081. }
  34082. }
  34083. declare module BABYLON {
  34084. /**
  34085. * Class containing static functions to help procedurally build meshes
  34086. */
  34087. export class DiscBuilder {
  34088. /**
  34089. * Creates a plane polygonal mesh. By default, this is a disc
  34090. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34091. * * 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
  34092. * * 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
  34093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34094. * * 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
  34095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34096. * @param name defines the name of the mesh
  34097. * @param options defines the options used to create the mesh
  34098. * @param scene defines the hosting scene
  34099. * @returns the plane polygonal mesh
  34100. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34101. */
  34102. static CreateDisc(name: string, options: {
  34103. radius?: number;
  34104. tessellation?: number;
  34105. arc?: number;
  34106. updatable?: boolean;
  34107. sideOrientation?: number;
  34108. frontUVs?: Vector4;
  34109. backUVs?: Vector4;
  34110. }, scene?: Nullable<Scene>): Mesh;
  34111. }
  34112. }
  34113. declare module BABYLON {
  34114. /**
  34115. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34116. *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.
  34117. * The SPS is also a particle system. It provides some methods to manage the particles.
  34118. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34119. *
  34120. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34121. */
  34122. export class SolidParticleSystem implements IDisposable {
  34123. /**
  34124. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34125. * Example : var p = SPS.particles[i];
  34126. */
  34127. particles: SolidParticle[];
  34128. /**
  34129. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34130. */
  34131. nbParticles: number;
  34132. /**
  34133. * If the particles must ever face the camera (default false). Useful for planar particles.
  34134. */
  34135. billboard: boolean;
  34136. /**
  34137. * Recompute normals when adding a shape
  34138. */
  34139. recomputeNormals: boolean;
  34140. /**
  34141. * This a counter ofr your own usage. It's not set by any SPS functions.
  34142. */
  34143. counter: number;
  34144. /**
  34145. * The SPS name. This name is also given to the underlying mesh.
  34146. */
  34147. name: string;
  34148. /**
  34149. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34150. */
  34151. mesh: Mesh;
  34152. /**
  34153. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34154. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34155. */
  34156. vars: any;
  34157. /**
  34158. * This array is populated when the SPS is set as 'pickable'.
  34159. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34160. * Each element of this array is an object `{idx: int, faceId: int}`.
  34161. * `idx` is the picked particle index in the `SPS.particles` array
  34162. * `faceId` is the picked face index counted within this particle.
  34163. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34164. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34165. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34166. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34167. */
  34168. pickedParticles: {
  34169. idx: number;
  34170. faceId: number;
  34171. }[];
  34172. /**
  34173. * This array is populated when the SPS is set as 'pickable'
  34174. * Each key of this array is a submesh index.
  34175. * Each element of this array is a second array defined like this :
  34176. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34177. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34178. * `idx` is the picked particle index in the `SPS.particles` array
  34179. * `faceId` is the picked face index counted within this particle.
  34180. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34181. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34182. */
  34183. pickedBySubMesh: {
  34184. idx: number;
  34185. faceId: number;
  34186. }[][];
  34187. /**
  34188. * This array is populated when `enableDepthSort` is set to true.
  34189. * Each element of this array is an instance of the class DepthSortedParticle.
  34190. */
  34191. depthSortedParticles: DepthSortedParticle[];
  34192. /**
  34193. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34194. * @hidden
  34195. */
  34196. _bSphereOnly: boolean;
  34197. /**
  34198. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34199. * @hidden
  34200. */
  34201. _bSphereRadiusFactor: number;
  34202. private _scene;
  34203. private _positions;
  34204. private _indices;
  34205. private _normals;
  34206. private _colors;
  34207. private _uvs;
  34208. private _indices32;
  34209. private _positions32;
  34210. private _normals32;
  34211. private _fixedNormal32;
  34212. private _colors32;
  34213. private _uvs32;
  34214. private _index;
  34215. private _updatable;
  34216. private _pickable;
  34217. private _isVisibilityBoxLocked;
  34218. private _alwaysVisible;
  34219. private _depthSort;
  34220. private _expandable;
  34221. private _shapeCounter;
  34222. private _copy;
  34223. private _color;
  34224. private _computeParticleColor;
  34225. private _computeParticleTexture;
  34226. private _computeParticleRotation;
  34227. private _computeParticleVertex;
  34228. private _computeBoundingBox;
  34229. private _depthSortParticles;
  34230. private _camera;
  34231. private _mustUnrotateFixedNormals;
  34232. private _particlesIntersect;
  34233. private _needs32Bits;
  34234. private _isNotBuilt;
  34235. private _lastParticleId;
  34236. private _idxOfId;
  34237. private _multimaterialEnabled;
  34238. private _useModelMaterial;
  34239. private _indicesByMaterial;
  34240. private _materialIndexes;
  34241. private _depthSortFunction;
  34242. private _materialSortFunction;
  34243. private _materials;
  34244. private _multimaterial;
  34245. private _materialIndexesById;
  34246. private _defaultMaterial;
  34247. private _autoUpdateSubMeshes;
  34248. private _tmpVertex;
  34249. /**
  34250. * Creates a SPS (Solid Particle System) object.
  34251. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34252. * @param scene (Scene) is the scene in which the SPS is added.
  34253. * @param options defines the options of the sps e.g.
  34254. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34255. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34256. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34257. * * 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.
  34258. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34259. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34260. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34261. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34262. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34263. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34264. */
  34265. constructor(name: string, scene: Scene, options?: {
  34266. updatable?: boolean;
  34267. isPickable?: boolean;
  34268. enableDepthSort?: boolean;
  34269. particleIntersection?: boolean;
  34270. boundingSphereOnly?: boolean;
  34271. bSphereRadiusFactor?: number;
  34272. expandable?: boolean;
  34273. useModelMaterial?: boolean;
  34274. enableMultiMaterial?: boolean;
  34275. });
  34276. /**
  34277. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34278. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34279. * @returns the created mesh
  34280. */
  34281. buildMesh(): Mesh;
  34282. /**
  34283. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34284. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34285. * Thus the particles generated from `digest()` have their property `position` set yet.
  34286. * @param mesh ( Mesh ) is the mesh to be digested
  34287. * @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
  34288. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34289. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34290. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34291. * @returns the current SPS
  34292. */
  34293. digest(mesh: Mesh, options?: {
  34294. facetNb?: number;
  34295. number?: number;
  34296. delta?: number;
  34297. storage?: [];
  34298. }): SolidParticleSystem;
  34299. /**
  34300. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34301. * @hidden
  34302. */
  34303. private _unrotateFixedNormals;
  34304. /**
  34305. * Resets the temporary working copy particle
  34306. * @hidden
  34307. */
  34308. private _resetCopy;
  34309. /**
  34310. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34311. * @param p the current index in the positions array to be updated
  34312. * @param ind the current index in the indices array
  34313. * @param shape a Vector3 array, the shape geometry
  34314. * @param positions the positions array to be updated
  34315. * @param meshInd the shape indices array
  34316. * @param indices the indices array to be updated
  34317. * @param meshUV the shape uv array
  34318. * @param uvs the uv array to be updated
  34319. * @param meshCol the shape color array
  34320. * @param colors the color array to be updated
  34321. * @param meshNor the shape normals array
  34322. * @param normals the normals array to be updated
  34323. * @param idx the particle index
  34324. * @param idxInShape the particle index in its shape
  34325. * @param options the addShape() method passed options
  34326. * @model the particle model
  34327. * @hidden
  34328. */
  34329. private _meshBuilder;
  34330. /**
  34331. * Returns a shape Vector3 array from positions float array
  34332. * @param positions float array
  34333. * @returns a vector3 array
  34334. * @hidden
  34335. */
  34336. private _posToShape;
  34337. /**
  34338. * Returns a shapeUV array from a float uvs (array deep copy)
  34339. * @param uvs as a float array
  34340. * @returns a shapeUV array
  34341. * @hidden
  34342. */
  34343. private _uvsToShapeUV;
  34344. /**
  34345. * Adds a new particle object in the particles array
  34346. * @param idx particle index in particles array
  34347. * @param id particle id
  34348. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34349. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34350. * @param model particle ModelShape object
  34351. * @param shapeId model shape identifier
  34352. * @param idxInShape index of the particle in the current model
  34353. * @param bInfo model bounding info object
  34354. * @param storage target storage array, if any
  34355. * @hidden
  34356. */
  34357. private _addParticle;
  34358. /**
  34359. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34360. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34361. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34362. * @param nb (positive integer) the number of particles to be created from this model
  34363. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34364. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34365. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34366. * @returns the number of shapes in the system
  34367. */
  34368. addShape(mesh: Mesh, nb: number, options?: {
  34369. positionFunction?: any;
  34370. vertexFunction?: any;
  34371. storage?: [];
  34372. }): number;
  34373. /**
  34374. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34375. * @hidden
  34376. */
  34377. private _rebuildParticle;
  34378. /**
  34379. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34380. * @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.
  34381. * @returns the SPS.
  34382. */
  34383. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34384. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34385. * Returns an array with the removed particles.
  34386. * 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.
  34387. * The SPS can't be empty so at least one particle needs to remain in place.
  34388. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34389. * @param start index of the first particle to remove
  34390. * @param end index of the last particle to remove (included)
  34391. * @returns an array populated with the removed particles
  34392. */
  34393. removeParticles(start: number, end: number): SolidParticle[];
  34394. /**
  34395. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34396. * @param solidParticleArray an array populated with Solid Particles objects
  34397. * @returns the SPS
  34398. */
  34399. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34400. /**
  34401. * Creates a new particle and modifies the SPS mesh geometry :
  34402. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34403. * - calls _addParticle() to populate the particle array
  34404. * factorized code from addShape() and insertParticlesFromArray()
  34405. * @param idx particle index in the particles array
  34406. * @param i particle index in its shape
  34407. * @param modelShape particle ModelShape object
  34408. * @param shape shape vertex array
  34409. * @param meshInd shape indices array
  34410. * @param meshUV shape uv array
  34411. * @param meshCol shape color array
  34412. * @param meshNor shape normals array
  34413. * @param bbInfo shape bounding info
  34414. * @param storage target particle storage
  34415. * @options addShape() passed options
  34416. * @hidden
  34417. */
  34418. private _insertNewParticle;
  34419. /**
  34420. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34421. * This method calls `updateParticle()` for each particle of the SPS.
  34422. * For an animated SPS, it is usually called within the render loop.
  34423. * 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.
  34424. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34425. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34426. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34427. * @returns the SPS.
  34428. */
  34429. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34430. /**
  34431. * Disposes the SPS.
  34432. */
  34433. dispose(): void;
  34434. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34435. * idx is the particle index in the SPS
  34436. * faceId is the picked face index counted within this particle.
  34437. * Returns null if the pickInfo can't identify a picked particle.
  34438. * @param pickingInfo (PickingInfo object)
  34439. * @returns {idx: number, faceId: number} or null
  34440. */
  34441. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34442. idx: number;
  34443. faceId: number;
  34444. }>;
  34445. /**
  34446. * Returns a SolidParticle object from its identifier : particle.id
  34447. * @param id (integer) the particle Id
  34448. * @returns the searched particle or null if not found in the SPS.
  34449. */
  34450. getParticleById(id: number): Nullable<SolidParticle>;
  34451. /**
  34452. * Returns a new array populated with the particles having the passed shapeId.
  34453. * @param shapeId (integer) the shape identifier
  34454. * @returns a new solid particle array
  34455. */
  34456. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34457. /**
  34458. * Populates the passed array "ref" with the particles having the passed shapeId.
  34459. * @param shapeId the shape identifier
  34460. * @returns the SPS
  34461. * @param ref
  34462. */
  34463. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34464. /**
  34465. * Computes the required SubMeshes according the materials assigned to the particles.
  34466. * @returns the solid particle system.
  34467. * Does nothing if called before the SPS mesh is built.
  34468. */
  34469. computeSubMeshes(): SolidParticleSystem;
  34470. /**
  34471. * Sorts the solid particles by material when MultiMaterial is enabled.
  34472. * Updates the indices32 array.
  34473. * Updates the indicesByMaterial array.
  34474. * Updates the mesh indices array.
  34475. * @returns the SPS
  34476. * @hidden
  34477. */
  34478. private _sortParticlesByMaterial;
  34479. /**
  34480. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34481. * @hidden
  34482. */
  34483. private _setMaterialIndexesById;
  34484. /**
  34485. * Returns an array with unique values of Materials from the passed array
  34486. * @param array the material array to be checked and filtered
  34487. * @hidden
  34488. */
  34489. private _filterUniqueMaterialId;
  34490. /**
  34491. * Sets a new Standard Material as _defaultMaterial if not already set.
  34492. * @hidden
  34493. */
  34494. private _setDefaultMaterial;
  34495. /**
  34496. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34497. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34498. * @returns the SPS.
  34499. */
  34500. refreshVisibleSize(): SolidParticleSystem;
  34501. /**
  34502. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34503. * @param size the size (float) of the visibility box
  34504. * note : this doesn't lock the SPS mesh bounding box.
  34505. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34506. */
  34507. setVisibilityBox(size: number): void;
  34508. /**
  34509. * Gets whether the SPS as always visible or not
  34510. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34511. */
  34512. get isAlwaysVisible(): boolean;
  34513. /**
  34514. * Sets the SPS as always visible or not
  34515. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34516. */
  34517. set isAlwaysVisible(val: boolean);
  34518. /**
  34519. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34520. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34521. */
  34522. set isVisibilityBoxLocked(val: boolean);
  34523. /**
  34524. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34525. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34526. */
  34527. get isVisibilityBoxLocked(): boolean;
  34528. /**
  34529. * Tells to `setParticles()` to compute the particle rotations or not.
  34530. * Default value : true. The SPS is faster when it's set to false.
  34531. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34532. */
  34533. set computeParticleRotation(val: boolean);
  34534. /**
  34535. * Tells to `setParticles()` to compute the particle colors or not.
  34536. * Default value : true. The SPS is faster when it's set to false.
  34537. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34538. */
  34539. set computeParticleColor(val: boolean);
  34540. set computeParticleTexture(val: boolean);
  34541. /**
  34542. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34543. * Default value : false. The SPS is faster when it's set to false.
  34544. * Note : the particle custom vertex positions aren't stored values.
  34545. */
  34546. set computeParticleVertex(val: boolean);
  34547. /**
  34548. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34549. */
  34550. set computeBoundingBox(val: boolean);
  34551. /**
  34552. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34553. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34554. * Default : `true`
  34555. */
  34556. set depthSortParticles(val: boolean);
  34557. /**
  34558. * Gets if `setParticles()` computes the particle rotations or not.
  34559. * Default value : true. The SPS is faster when it's set to false.
  34560. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34561. */
  34562. get computeParticleRotation(): boolean;
  34563. /**
  34564. * Gets if `setParticles()` computes the particle colors or not.
  34565. * Default value : true. The SPS is faster when it's set to false.
  34566. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34567. */
  34568. get computeParticleColor(): boolean;
  34569. /**
  34570. * Gets if `setParticles()` computes the particle textures or not.
  34571. * Default value : true. The SPS is faster when it's set to false.
  34572. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34573. */
  34574. get computeParticleTexture(): boolean;
  34575. /**
  34576. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34577. * Default value : false. The SPS is faster when it's set to false.
  34578. * Note : the particle custom vertex positions aren't stored values.
  34579. */
  34580. get computeParticleVertex(): boolean;
  34581. /**
  34582. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34583. */
  34584. get computeBoundingBox(): boolean;
  34585. /**
  34586. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34587. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34588. * Default : `true`
  34589. */
  34590. get depthSortParticles(): boolean;
  34591. /**
  34592. * Gets if the SPS is created as expandable at construction time.
  34593. * Default : `false`
  34594. */
  34595. get expandable(): boolean;
  34596. /**
  34597. * Gets if the SPS supports the Multi Materials
  34598. */
  34599. get multimaterialEnabled(): boolean;
  34600. /**
  34601. * Gets if the SPS uses the model materials for its own multimaterial.
  34602. */
  34603. get useModelMaterial(): boolean;
  34604. /**
  34605. * The SPS used material array.
  34606. */
  34607. get materials(): Material[];
  34608. /**
  34609. * Sets the SPS MultiMaterial from the passed materials.
  34610. * Note : the passed array is internally copied and not used then by reference.
  34611. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34612. */
  34613. setMultiMaterial(materials: Material[]): void;
  34614. /**
  34615. * The SPS computed multimaterial object
  34616. */
  34617. get multimaterial(): MultiMaterial;
  34618. set multimaterial(mm: MultiMaterial);
  34619. /**
  34620. * If the subMeshes must be updated on the next call to setParticles()
  34621. */
  34622. get autoUpdateSubMeshes(): boolean;
  34623. set autoUpdateSubMeshes(val: boolean);
  34624. /**
  34625. * This function does nothing. It may be overwritten to set all the particle first values.
  34626. * The SPS doesn't call this function, you may have to call it by your own.
  34627. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34628. */
  34629. initParticles(): void;
  34630. /**
  34631. * This function does nothing. It may be overwritten to recycle a particle.
  34632. * The SPS doesn't call this function, you may have to call it by your own.
  34633. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34634. * @param particle The particle to recycle
  34635. * @returns the recycled particle
  34636. */
  34637. recycleParticle(particle: SolidParticle): SolidParticle;
  34638. /**
  34639. * Updates a particle : this function should be overwritten by the user.
  34640. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34641. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34642. * @example : just set a particle position or velocity and recycle conditions
  34643. * @param particle The particle to update
  34644. * @returns the updated particle
  34645. */
  34646. updateParticle(particle: SolidParticle): SolidParticle;
  34647. /**
  34648. * Updates a vertex of a particle : it can be overwritten by the user.
  34649. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34650. * @param particle the current particle
  34651. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34652. * @param pt the index of the current vertex in the particle shape
  34653. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34654. * @example : just set a vertex particle position or color
  34655. * @returns the sps
  34656. */
  34657. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34658. /**
  34659. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34660. * This does nothing and may be overwritten by the user.
  34661. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34662. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34663. * @param update the boolean update value actually passed to setParticles()
  34664. */
  34665. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34666. /**
  34667. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34668. * This will be passed three parameters.
  34669. * This does nothing and may be overwritten by the user.
  34670. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34671. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34672. * @param update the boolean update value actually passed to setParticles()
  34673. */
  34674. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34675. }
  34676. }
  34677. declare module BABYLON {
  34678. /**
  34679. * Represents one particle of a solid particle system.
  34680. */
  34681. export class SolidParticle {
  34682. /**
  34683. * particle global index
  34684. */
  34685. idx: number;
  34686. /**
  34687. * particle identifier
  34688. */
  34689. id: number;
  34690. /**
  34691. * The color of the particle
  34692. */
  34693. color: Nullable<Color4>;
  34694. /**
  34695. * The world space position of the particle.
  34696. */
  34697. position: Vector3;
  34698. /**
  34699. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34700. */
  34701. rotation: Vector3;
  34702. /**
  34703. * The world space rotation quaternion of the particle.
  34704. */
  34705. rotationQuaternion: Nullable<Quaternion>;
  34706. /**
  34707. * The scaling of the particle.
  34708. */
  34709. scaling: Vector3;
  34710. /**
  34711. * The uvs of the particle.
  34712. */
  34713. uvs: Vector4;
  34714. /**
  34715. * The current speed of the particle.
  34716. */
  34717. velocity: Vector3;
  34718. /**
  34719. * The pivot point in the particle local space.
  34720. */
  34721. pivot: Vector3;
  34722. /**
  34723. * Must the particle be translated from its pivot point in its local space ?
  34724. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34725. * Default : false
  34726. */
  34727. translateFromPivot: boolean;
  34728. /**
  34729. * Is the particle active or not ?
  34730. */
  34731. alive: boolean;
  34732. /**
  34733. * Is the particle visible or not ?
  34734. */
  34735. isVisible: boolean;
  34736. /**
  34737. * Index of this particle in the global "positions" array (Internal use)
  34738. * @hidden
  34739. */
  34740. _pos: number;
  34741. /**
  34742. * @hidden Index of this particle in the global "indices" array (Internal use)
  34743. */
  34744. _ind: number;
  34745. /**
  34746. * @hidden ModelShape of this particle (Internal use)
  34747. */
  34748. _model: ModelShape;
  34749. /**
  34750. * ModelShape id of this particle
  34751. */
  34752. shapeId: number;
  34753. /**
  34754. * Index of the particle in its shape id
  34755. */
  34756. idxInShape: number;
  34757. /**
  34758. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34759. */
  34760. _modelBoundingInfo: BoundingInfo;
  34761. /**
  34762. * @hidden Particle BoundingInfo object (Internal use)
  34763. */
  34764. _boundingInfo: BoundingInfo;
  34765. /**
  34766. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34767. */
  34768. _sps: SolidParticleSystem;
  34769. /**
  34770. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34771. */
  34772. _stillInvisible: boolean;
  34773. /**
  34774. * @hidden Last computed particle rotation matrix
  34775. */
  34776. _rotationMatrix: number[];
  34777. /**
  34778. * Parent particle Id, if any.
  34779. * Default null.
  34780. */
  34781. parentId: Nullable<number>;
  34782. /**
  34783. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34784. */
  34785. materialIndex: Nullable<number>;
  34786. /**
  34787. * Custom object or properties.
  34788. */
  34789. props: Nullable<any>;
  34790. /**
  34791. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34792. * The possible values are :
  34793. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34794. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34795. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34796. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34797. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34798. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34799. * */
  34800. cullingStrategy: number;
  34801. /**
  34802. * @hidden Internal global position in the SPS.
  34803. */
  34804. _globalPosition: Vector3;
  34805. /**
  34806. * Creates a Solid Particle object.
  34807. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34808. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34809. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34810. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34811. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34812. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34813. * @param shapeId (integer) is the model shape identifier in the SPS.
  34814. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34815. * @param sps defines the sps it is associated to
  34816. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34817. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34818. */
  34819. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34820. /**
  34821. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34822. * @param target the particle target
  34823. * @returns the current particle
  34824. */
  34825. copyToRef(target: SolidParticle): SolidParticle;
  34826. /**
  34827. * Legacy support, changed scale to scaling
  34828. */
  34829. get scale(): Vector3;
  34830. /**
  34831. * Legacy support, changed scale to scaling
  34832. */
  34833. set scale(scale: Vector3);
  34834. /**
  34835. * Legacy support, changed quaternion to rotationQuaternion
  34836. */
  34837. get quaternion(): Nullable<Quaternion>;
  34838. /**
  34839. * Legacy support, changed quaternion to rotationQuaternion
  34840. */
  34841. set quaternion(q: Nullable<Quaternion>);
  34842. /**
  34843. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34844. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34845. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34846. * @returns true if it intersects
  34847. */
  34848. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34849. /**
  34850. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34851. * A particle is in the frustum if its bounding box intersects the frustum
  34852. * @param frustumPlanes defines the frustum to test
  34853. * @returns true if the particle is in the frustum planes
  34854. */
  34855. isInFrustum(frustumPlanes: Plane[]): boolean;
  34856. /**
  34857. * get the rotation matrix of the particle
  34858. * @hidden
  34859. */
  34860. getRotationMatrix(m: Matrix): void;
  34861. }
  34862. /**
  34863. * Represents the shape of the model used by one particle of a solid particle system.
  34864. * SPS internal tool, don't use it manually.
  34865. */
  34866. export class ModelShape {
  34867. /**
  34868. * The shape id
  34869. * @hidden
  34870. */
  34871. shapeID: number;
  34872. /**
  34873. * flat array of model positions (internal use)
  34874. * @hidden
  34875. */
  34876. _shape: Vector3[];
  34877. /**
  34878. * flat array of model UVs (internal use)
  34879. * @hidden
  34880. */
  34881. _shapeUV: number[];
  34882. /**
  34883. * color array of the model
  34884. * @hidden
  34885. */
  34886. _shapeColors: number[];
  34887. /**
  34888. * indices array of the model
  34889. * @hidden
  34890. */
  34891. _indices: number[];
  34892. /**
  34893. * normals array of the model
  34894. * @hidden
  34895. */
  34896. _normals: number[];
  34897. /**
  34898. * length of the shape in the model indices array (internal use)
  34899. * @hidden
  34900. */
  34901. _indicesLength: number;
  34902. /**
  34903. * Custom position function (internal use)
  34904. * @hidden
  34905. */
  34906. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34907. /**
  34908. * Custom vertex function (internal use)
  34909. * @hidden
  34910. */
  34911. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34912. /**
  34913. * Model material (internal use)
  34914. * @hidden
  34915. */
  34916. _material: Nullable<Material>;
  34917. /**
  34918. * 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.
  34919. * SPS internal tool, don't use it manually.
  34920. * @hidden
  34921. */
  34922. 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>);
  34923. }
  34924. /**
  34925. * Represents a Depth Sorted Particle in the solid particle system.
  34926. * @hidden
  34927. */
  34928. export class DepthSortedParticle {
  34929. /**
  34930. * Particle index
  34931. */
  34932. idx: number;
  34933. /**
  34934. * Index of the particle in the "indices" array
  34935. */
  34936. ind: number;
  34937. /**
  34938. * Length of the particle shape in the "indices" array
  34939. */
  34940. indicesLength: number;
  34941. /**
  34942. * Squared distance from the particle to the camera
  34943. */
  34944. sqDistance: number;
  34945. /**
  34946. * Material index when used with MultiMaterials
  34947. */
  34948. materialIndex: number;
  34949. /**
  34950. * Creates a new sorted particle
  34951. * @param materialIndex
  34952. */
  34953. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34954. }
  34955. /**
  34956. * Represents a solid particle vertex
  34957. */
  34958. export class SolidParticleVertex {
  34959. /**
  34960. * Vertex position
  34961. */
  34962. position: Vector3;
  34963. /**
  34964. * Vertex color
  34965. */
  34966. color: Color4;
  34967. /**
  34968. * Vertex UV
  34969. */
  34970. uv: Vector2;
  34971. /**
  34972. * Creates a new solid particle vertex
  34973. */
  34974. constructor();
  34975. /** Vertex x coordinate */
  34976. get x(): number;
  34977. set x(val: number);
  34978. /** Vertex y coordinate */
  34979. get y(): number;
  34980. set y(val: number);
  34981. /** Vertex z coordinate */
  34982. get z(): number;
  34983. set z(val: number);
  34984. }
  34985. }
  34986. declare module BABYLON {
  34987. /**
  34988. * @hidden
  34989. */
  34990. export class _MeshCollisionData {
  34991. _checkCollisions: boolean;
  34992. _collisionMask: number;
  34993. _collisionGroup: number;
  34994. _surroundingMeshes: Nullable<AbstractMesh[]>;
  34995. _collider: Nullable<Collider>;
  34996. _oldPositionForCollisions: Vector3;
  34997. _diffPositionForCollisions: Vector3;
  34998. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  34999. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35000. _collisionResponse: boolean;
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /** @hidden */
  35005. class _FacetDataStorage {
  35006. facetPositions: Vector3[];
  35007. facetNormals: Vector3[];
  35008. facetPartitioning: number[][];
  35009. facetNb: number;
  35010. partitioningSubdivisions: number;
  35011. partitioningBBoxRatio: number;
  35012. facetDataEnabled: boolean;
  35013. facetParameters: any;
  35014. bbSize: Vector3;
  35015. subDiv: {
  35016. max: number;
  35017. X: number;
  35018. Y: number;
  35019. Z: number;
  35020. };
  35021. facetDepthSort: boolean;
  35022. facetDepthSortEnabled: boolean;
  35023. depthSortedIndices: IndicesArray;
  35024. depthSortedFacets: {
  35025. ind: number;
  35026. sqDistance: number;
  35027. }[];
  35028. facetDepthSortFunction: (f1: {
  35029. ind: number;
  35030. sqDistance: number;
  35031. }, f2: {
  35032. ind: number;
  35033. sqDistance: number;
  35034. }) => number;
  35035. facetDepthSortFrom: Vector3;
  35036. facetDepthSortOrigin: Vector3;
  35037. invertedMatrix: Matrix;
  35038. }
  35039. /**
  35040. * @hidden
  35041. **/
  35042. class _InternalAbstractMeshDataInfo {
  35043. _hasVertexAlpha: boolean;
  35044. _useVertexColors: boolean;
  35045. _numBoneInfluencers: number;
  35046. _applyFog: boolean;
  35047. _receiveShadows: boolean;
  35048. _facetData: _FacetDataStorage;
  35049. _visibility: number;
  35050. _skeleton: Nullable<Skeleton>;
  35051. _layerMask: number;
  35052. _computeBonesUsingShaders: boolean;
  35053. _isActive: boolean;
  35054. _onlyForInstances: boolean;
  35055. _isActiveIntermediate: boolean;
  35056. _onlyForInstancesIntermediate: boolean;
  35057. _actAsRegularMesh: boolean;
  35058. _currentLOD: Nullable<AbstractMesh>;
  35059. }
  35060. /**
  35061. * Class used to store all common mesh properties
  35062. */
  35063. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35064. /** No occlusion */
  35065. static OCCLUSION_TYPE_NONE: number;
  35066. /** Occlusion set to optimisitic */
  35067. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35068. /** Occlusion set to strict */
  35069. static OCCLUSION_TYPE_STRICT: number;
  35070. /** Use an accurante occlusion algorithm */
  35071. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35072. /** Use a conservative occlusion algorithm */
  35073. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35074. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35075. * Test order :
  35076. * Is the bounding sphere outside the frustum ?
  35077. * If not, are the bounding box vertices outside the frustum ?
  35078. * It not, then the cullable object is in the frustum.
  35079. */
  35080. static readonly CULLINGSTRATEGY_STANDARD: number;
  35081. /** Culling strategy : Bounding Sphere Only.
  35082. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35083. * It's also less accurate than the standard because some not visible objects can still be selected.
  35084. * Test : is the bounding sphere outside the frustum ?
  35085. * If not, then the cullable object is in the frustum.
  35086. */
  35087. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35088. /** Culling strategy : Optimistic Inclusion.
  35089. * This in an inclusion test first, then the standard exclusion test.
  35090. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35091. * 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.
  35092. * Anyway, it's as accurate as the standard strategy.
  35093. * Test :
  35094. * Is the cullable object bounding sphere center in the frustum ?
  35095. * If not, apply the default culling strategy.
  35096. */
  35097. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35098. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35099. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35100. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35101. * 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.
  35102. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35103. * Test :
  35104. * Is the cullable object bounding sphere center in the frustum ?
  35105. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35106. */
  35107. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35108. /**
  35109. * No billboard
  35110. */
  35111. static get BILLBOARDMODE_NONE(): number;
  35112. /** Billboard on X axis */
  35113. static get BILLBOARDMODE_X(): number;
  35114. /** Billboard on Y axis */
  35115. static get BILLBOARDMODE_Y(): number;
  35116. /** Billboard on Z axis */
  35117. static get BILLBOARDMODE_Z(): number;
  35118. /** Billboard on all axes */
  35119. static get BILLBOARDMODE_ALL(): number;
  35120. /** Billboard on using position instead of orientation */
  35121. static get BILLBOARDMODE_USE_POSITION(): number;
  35122. /** @hidden */
  35123. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35124. /**
  35125. * The culling strategy to use to check whether the mesh must be rendered or not.
  35126. * This value can be changed at any time and will be used on the next render mesh selection.
  35127. * The possible values are :
  35128. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35129. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35130. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35131. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35132. * Please read each static variable documentation to get details about the culling process.
  35133. * */
  35134. cullingStrategy: number;
  35135. /**
  35136. * Gets the number of facets in the mesh
  35137. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35138. */
  35139. get facetNb(): number;
  35140. /**
  35141. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35142. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35143. */
  35144. get partitioningSubdivisions(): number;
  35145. set partitioningSubdivisions(nb: number);
  35146. /**
  35147. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35148. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35149. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35150. */
  35151. get partitioningBBoxRatio(): number;
  35152. set partitioningBBoxRatio(ratio: number);
  35153. /**
  35154. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35155. * Works only for updatable meshes.
  35156. * Doesn't work with multi-materials
  35157. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35158. */
  35159. get mustDepthSortFacets(): boolean;
  35160. set mustDepthSortFacets(sort: boolean);
  35161. /**
  35162. * The location (Vector3) where the facet depth sort must be computed from.
  35163. * By default, the active camera position.
  35164. * Used only when facet depth sort is enabled
  35165. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35166. */
  35167. get facetDepthSortFrom(): Vector3;
  35168. set facetDepthSortFrom(location: Vector3);
  35169. /**
  35170. * gets a boolean indicating if facetData is enabled
  35171. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35172. */
  35173. get isFacetDataEnabled(): boolean;
  35174. /** @hidden */
  35175. _updateNonUniformScalingState(value: boolean): boolean;
  35176. /**
  35177. * An event triggered when this mesh collides with another one
  35178. */
  35179. onCollideObservable: Observable<AbstractMesh>;
  35180. /** Set a function to call when this mesh collides with another one */
  35181. set onCollide(callback: () => void);
  35182. /**
  35183. * An event triggered when the collision's position changes
  35184. */
  35185. onCollisionPositionChangeObservable: Observable<Vector3>;
  35186. /** Set a function to call when the collision's position changes */
  35187. set onCollisionPositionChange(callback: () => void);
  35188. /**
  35189. * An event triggered when material is changed
  35190. */
  35191. onMaterialChangedObservable: Observable<AbstractMesh>;
  35192. /**
  35193. * Gets or sets the orientation for POV movement & rotation
  35194. */
  35195. definedFacingForward: boolean;
  35196. /** @hidden */
  35197. _occlusionQuery: Nullable<WebGLQuery>;
  35198. /** @hidden */
  35199. _renderingGroup: Nullable<RenderingGroup>;
  35200. /**
  35201. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35202. */
  35203. get visibility(): number;
  35204. /**
  35205. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35206. */
  35207. set visibility(value: number);
  35208. /** Gets or sets the alpha index used to sort transparent meshes
  35209. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35210. */
  35211. alphaIndex: number;
  35212. /**
  35213. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35214. */
  35215. isVisible: boolean;
  35216. /**
  35217. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35218. */
  35219. isPickable: boolean;
  35220. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35221. showSubMeshesBoundingBox: boolean;
  35222. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35223. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35224. */
  35225. isBlocker: boolean;
  35226. /**
  35227. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35228. */
  35229. enablePointerMoveEvents: boolean;
  35230. private _renderingGroupId;
  35231. /**
  35232. * Specifies the rendering group id for this mesh (0 by default)
  35233. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35234. */
  35235. get renderingGroupId(): number;
  35236. set renderingGroupId(value: number);
  35237. private _material;
  35238. /** Gets or sets current material */
  35239. get material(): Nullable<Material>;
  35240. set material(value: Nullable<Material>);
  35241. /**
  35242. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35243. * @see https://doc.babylonjs.com/babylon101/shadows
  35244. */
  35245. get receiveShadows(): boolean;
  35246. set receiveShadows(value: boolean);
  35247. /** Defines color to use when rendering outline */
  35248. outlineColor: Color3;
  35249. /** Define width to use when rendering outline */
  35250. outlineWidth: number;
  35251. /** Defines color to use when rendering overlay */
  35252. overlayColor: Color3;
  35253. /** Defines alpha to use when rendering overlay */
  35254. overlayAlpha: number;
  35255. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35256. get hasVertexAlpha(): boolean;
  35257. set hasVertexAlpha(value: boolean);
  35258. /** 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) */
  35259. get useVertexColors(): boolean;
  35260. set useVertexColors(value: boolean);
  35261. /**
  35262. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35263. */
  35264. get computeBonesUsingShaders(): boolean;
  35265. set computeBonesUsingShaders(value: boolean);
  35266. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35267. get numBoneInfluencers(): number;
  35268. set numBoneInfluencers(value: number);
  35269. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35270. get applyFog(): boolean;
  35271. set applyFog(value: boolean);
  35272. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35273. useOctreeForRenderingSelection: boolean;
  35274. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35275. useOctreeForPicking: boolean;
  35276. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35277. useOctreeForCollisions: boolean;
  35278. /**
  35279. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35280. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35281. */
  35282. get layerMask(): number;
  35283. set layerMask(value: number);
  35284. /**
  35285. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35286. */
  35287. alwaysSelectAsActiveMesh: boolean;
  35288. /**
  35289. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35290. */
  35291. doNotSyncBoundingInfo: boolean;
  35292. /**
  35293. * Gets or sets the current action manager
  35294. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35295. */
  35296. actionManager: Nullable<AbstractActionManager>;
  35297. private _meshCollisionData;
  35298. /**
  35299. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35300. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35301. */
  35302. ellipsoid: Vector3;
  35303. /**
  35304. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35305. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35306. */
  35307. ellipsoidOffset: Vector3;
  35308. /**
  35309. * Gets or sets a collision mask used to mask collisions (default is -1).
  35310. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35311. */
  35312. get collisionMask(): number;
  35313. set collisionMask(mask: number);
  35314. /**
  35315. * Gets or sets a collision response flag (default is true).
  35316. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35317. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35318. * to respond to the collision.
  35319. */
  35320. get collisionResponse(): boolean;
  35321. set collisionResponse(response: boolean);
  35322. /**
  35323. * Gets or sets the current collision group mask (-1 by default).
  35324. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35325. */
  35326. get collisionGroup(): number;
  35327. set collisionGroup(mask: number);
  35328. /**
  35329. * Gets or sets current surrounding meshes (null by default).
  35330. *
  35331. * By default collision detection is tested against every mesh in the scene.
  35332. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35333. * meshes will be tested for the collision.
  35334. *
  35335. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35336. */
  35337. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35338. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35339. /**
  35340. * Defines edge width used when edgesRenderer is enabled
  35341. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35342. */
  35343. edgesWidth: number;
  35344. /**
  35345. * Defines edge color used when edgesRenderer is enabled
  35346. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35347. */
  35348. edgesColor: Color4;
  35349. /** @hidden */
  35350. _edgesRenderer: Nullable<IEdgesRenderer>;
  35351. /** @hidden */
  35352. _masterMesh: Nullable<AbstractMesh>;
  35353. /** @hidden */
  35354. _boundingInfo: Nullable<BoundingInfo>;
  35355. /** @hidden */
  35356. _renderId: number;
  35357. /**
  35358. * Gets or sets the list of subMeshes
  35359. * @see https://doc.babylonjs.com/how_to/multi_materials
  35360. */
  35361. subMeshes: SubMesh[];
  35362. /** @hidden */
  35363. _intersectionsInProgress: AbstractMesh[];
  35364. /** @hidden */
  35365. _unIndexed: boolean;
  35366. /** @hidden */
  35367. _lightSources: Light[];
  35368. /** Gets the list of lights affecting that mesh */
  35369. get lightSources(): Light[];
  35370. /** @hidden */
  35371. get _positions(): Nullable<Vector3[]>;
  35372. /** @hidden */
  35373. _waitingData: {
  35374. lods: Nullable<any>;
  35375. actions: Nullable<any>;
  35376. freezeWorldMatrix: Nullable<boolean>;
  35377. };
  35378. /** @hidden */
  35379. _bonesTransformMatrices: Nullable<Float32Array>;
  35380. /** @hidden */
  35381. _transformMatrixTexture: Nullable<RawTexture>;
  35382. /**
  35383. * Gets or sets a skeleton to apply skining transformations
  35384. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35385. */
  35386. set skeleton(value: Nullable<Skeleton>);
  35387. get skeleton(): Nullable<Skeleton>;
  35388. /**
  35389. * An event triggered when the mesh is rebuilt.
  35390. */
  35391. onRebuildObservable: Observable<AbstractMesh>;
  35392. /**
  35393. * Creates a new AbstractMesh
  35394. * @param name defines the name of the mesh
  35395. * @param scene defines the hosting scene
  35396. */
  35397. constructor(name: string, scene?: Nullable<Scene>);
  35398. /**
  35399. * Returns the string "AbstractMesh"
  35400. * @returns "AbstractMesh"
  35401. */
  35402. getClassName(): string;
  35403. /**
  35404. * Gets a string representation of the current mesh
  35405. * @param fullDetails defines a boolean indicating if full details must be included
  35406. * @returns a string representation of the current mesh
  35407. */
  35408. toString(fullDetails?: boolean): string;
  35409. /**
  35410. * @hidden
  35411. */
  35412. protected _getEffectiveParent(): Nullable<Node>;
  35413. /** @hidden */
  35414. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35415. /** @hidden */
  35416. _rebuild(): void;
  35417. /** @hidden */
  35418. _resyncLightSources(): void;
  35419. /** @hidden */
  35420. _resyncLightSource(light: Light): void;
  35421. /** @hidden */
  35422. _unBindEffect(): void;
  35423. /** @hidden */
  35424. _removeLightSource(light: Light, dispose: boolean): void;
  35425. private _markSubMeshesAsDirty;
  35426. /** @hidden */
  35427. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35428. /** @hidden */
  35429. _markSubMeshesAsAttributesDirty(): void;
  35430. /** @hidden */
  35431. _markSubMeshesAsMiscDirty(): void;
  35432. /**
  35433. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35434. */
  35435. get scaling(): Vector3;
  35436. set scaling(newScaling: Vector3);
  35437. /**
  35438. * Returns true if the mesh is blocked. Implemented by child classes
  35439. */
  35440. get isBlocked(): boolean;
  35441. /**
  35442. * Returns the mesh itself by default. Implemented by child classes
  35443. * @param camera defines the camera to use to pick the right LOD level
  35444. * @returns the currentAbstractMesh
  35445. */
  35446. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35447. /**
  35448. * Returns 0 by default. Implemented by child classes
  35449. * @returns an integer
  35450. */
  35451. getTotalVertices(): number;
  35452. /**
  35453. * Returns a positive integer : the total number of indices in this mesh geometry.
  35454. * @returns the numner of indices or zero if the mesh has no geometry.
  35455. */
  35456. getTotalIndices(): number;
  35457. /**
  35458. * Returns null by default. Implemented by child classes
  35459. * @returns null
  35460. */
  35461. getIndices(): Nullable<IndicesArray>;
  35462. /**
  35463. * Returns the array of the requested vertex data kind. Implemented by child classes
  35464. * @param kind defines the vertex data kind to use
  35465. * @returns null
  35466. */
  35467. getVerticesData(kind: string): Nullable<FloatArray>;
  35468. /**
  35469. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35470. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35471. * Note that a new underlying VertexBuffer object is created each call.
  35472. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35473. * @param kind defines vertex data kind:
  35474. * * VertexBuffer.PositionKind
  35475. * * VertexBuffer.UVKind
  35476. * * VertexBuffer.UV2Kind
  35477. * * VertexBuffer.UV3Kind
  35478. * * VertexBuffer.UV4Kind
  35479. * * VertexBuffer.UV5Kind
  35480. * * VertexBuffer.UV6Kind
  35481. * * VertexBuffer.ColorKind
  35482. * * VertexBuffer.MatricesIndicesKind
  35483. * * VertexBuffer.MatricesIndicesExtraKind
  35484. * * VertexBuffer.MatricesWeightsKind
  35485. * * VertexBuffer.MatricesWeightsExtraKind
  35486. * @param data defines the data source
  35487. * @param updatable defines if the data must be flagged as updatable (or static)
  35488. * @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
  35489. * @returns the current mesh
  35490. */
  35491. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35492. /**
  35493. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35494. * If the mesh has no geometry, it is simply returned as it is.
  35495. * @param kind defines vertex data kind:
  35496. * * VertexBuffer.PositionKind
  35497. * * VertexBuffer.UVKind
  35498. * * VertexBuffer.UV2Kind
  35499. * * VertexBuffer.UV3Kind
  35500. * * VertexBuffer.UV4Kind
  35501. * * VertexBuffer.UV5Kind
  35502. * * VertexBuffer.UV6Kind
  35503. * * VertexBuffer.ColorKind
  35504. * * VertexBuffer.MatricesIndicesKind
  35505. * * VertexBuffer.MatricesIndicesExtraKind
  35506. * * VertexBuffer.MatricesWeightsKind
  35507. * * VertexBuffer.MatricesWeightsExtraKind
  35508. * @param data defines the data source
  35509. * @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
  35510. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35511. * @returns the current mesh
  35512. */
  35513. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35514. /**
  35515. * Sets the mesh indices,
  35516. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35517. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35518. * @param totalVertices Defines the total number of vertices
  35519. * @returns the current mesh
  35520. */
  35521. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35522. /**
  35523. * Gets a boolean indicating if specific vertex data is present
  35524. * @param kind defines the vertex data kind to use
  35525. * @returns true is data kind is present
  35526. */
  35527. isVerticesDataPresent(kind: string): boolean;
  35528. /**
  35529. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35530. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35531. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35532. * @returns a BoundingInfo
  35533. */
  35534. getBoundingInfo(): BoundingInfo;
  35535. /**
  35536. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35537. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35538. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35539. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35540. * @returns the current mesh
  35541. */
  35542. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35543. /**
  35544. * Overwrite the current bounding info
  35545. * @param boundingInfo defines the new bounding info
  35546. * @returns the current mesh
  35547. */
  35548. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35549. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35550. get useBones(): boolean;
  35551. /** @hidden */
  35552. _preActivate(): void;
  35553. /** @hidden */
  35554. _preActivateForIntermediateRendering(renderId: number): void;
  35555. /** @hidden */
  35556. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35557. /** @hidden */
  35558. _postActivate(): void;
  35559. /** @hidden */
  35560. _freeze(): void;
  35561. /** @hidden */
  35562. _unFreeze(): void;
  35563. /**
  35564. * Gets the current world matrix
  35565. * @returns a Matrix
  35566. */
  35567. getWorldMatrix(): Matrix;
  35568. /** @hidden */
  35569. _getWorldMatrixDeterminant(): number;
  35570. /**
  35571. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35572. */
  35573. get isAnInstance(): boolean;
  35574. /**
  35575. * Gets a boolean indicating if this mesh has instances
  35576. */
  35577. get hasInstances(): boolean;
  35578. /**
  35579. * Gets a boolean indicating if this mesh has thin instances
  35580. */
  35581. get hasThinInstances(): boolean;
  35582. /**
  35583. * Perform relative position change from the point of view of behind the front of the mesh.
  35584. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35585. * Supports definition of mesh facing forward or backward
  35586. * @param amountRight defines the distance on the right axis
  35587. * @param amountUp defines the distance on the up axis
  35588. * @param amountForward defines the distance on the forward axis
  35589. * @returns the current mesh
  35590. */
  35591. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35592. /**
  35593. * Calculate relative position change from the point of view of behind the front of the mesh.
  35594. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35595. * Supports definition of mesh facing forward or backward
  35596. * @param amountRight defines the distance on the right axis
  35597. * @param amountUp defines the distance on the up axis
  35598. * @param amountForward defines the distance on the forward axis
  35599. * @returns the new displacement vector
  35600. */
  35601. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35602. /**
  35603. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35604. * Supports definition of mesh facing forward or backward
  35605. * @param flipBack defines the flip
  35606. * @param twirlClockwise defines the twirl
  35607. * @param tiltRight defines the tilt
  35608. * @returns the current mesh
  35609. */
  35610. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35611. /**
  35612. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35613. * Supports definition of mesh facing forward or backward.
  35614. * @param flipBack defines the flip
  35615. * @param twirlClockwise defines the twirl
  35616. * @param tiltRight defines the tilt
  35617. * @returns the new rotation vector
  35618. */
  35619. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35620. /**
  35621. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35622. * This means the mesh underlying bounding box and sphere are recomputed.
  35623. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35624. * @returns the current mesh
  35625. */
  35626. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35627. /** @hidden */
  35628. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35629. /** @hidden */
  35630. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35631. /** @hidden */
  35632. _updateBoundingInfo(): AbstractMesh;
  35633. /** @hidden */
  35634. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35635. /** @hidden */
  35636. protected _afterComputeWorldMatrix(): void;
  35637. /** @hidden */
  35638. get _effectiveMesh(): AbstractMesh;
  35639. /**
  35640. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35641. * A mesh is in the frustum if its bounding box intersects the frustum
  35642. * @param frustumPlanes defines the frustum to test
  35643. * @returns true if the mesh is in the frustum planes
  35644. */
  35645. isInFrustum(frustumPlanes: Plane[]): boolean;
  35646. /**
  35647. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35648. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35649. * @param frustumPlanes defines the frustum to test
  35650. * @returns true if the mesh is completely in the frustum planes
  35651. */
  35652. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35653. /**
  35654. * True if the mesh intersects another mesh or a SolidParticle object
  35655. * @param mesh defines a target mesh or SolidParticle to test
  35656. * @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)
  35657. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35658. * @returns true if there is an intersection
  35659. */
  35660. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35661. /**
  35662. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35663. * @param point defines the point to test
  35664. * @returns true if there is an intersection
  35665. */
  35666. intersectsPoint(point: Vector3): boolean;
  35667. /**
  35668. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35669. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35670. */
  35671. get checkCollisions(): boolean;
  35672. set checkCollisions(collisionEnabled: boolean);
  35673. /**
  35674. * Gets Collider object used to compute collisions (not physics)
  35675. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35676. */
  35677. get collider(): Nullable<Collider>;
  35678. /**
  35679. * Move the mesh using collision engine
  35680. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35681. * @param displacement defines the requested displacement vector
  35682. * @returns the current mesh
  35683. */
  35684. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35685. private _onCollisionPositionChange;
  35686. /** @hidden */
  35687. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35688. /** @hidden */
  35689. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35690. /** @hidden */
  35691. _checkCollision(collider: Collider): AbstractMesh;
  35692. /** @hidden */
  35693. _generatePointsArray(): boolean;
  35694. /**
  35695. * Checks if the passed Ray intersects with the mesh
  35696. * @param ray defines the ray to use
  35697. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35698. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35699. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35700. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35701. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35702. * @returns the picking info
  35703. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35704. */
  35705. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35706. /**
  35707. * Clones the current mesh
  35708. * @param name defines the mesh name
  35709. * @param newParent defines the new mesh parent
  35710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35711. * @returns the new mesh
  35712. */
  35713. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35714. /**
  35715. * Disposes all the submeshes of the current meshnp
  35716. * @returns the current mesh
  35717. */
  35718. releaseSubMeshes(): AbstractMesh;
  35719. /**
  35720. * Releases resources associated with this abstract mesh.
  35721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35723. */
  35724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35725. /**
  35726. * Adds the passed mesh as a child to the current mesh
  35727. * @param mesh defines the child mesh
  35728. * @returns the current mesh
  35729. */
  35730. addChild(mesh: AbstractMesh): AbstractMesh;
  35731. /**
  35732. * Removes the passed mesh from the current mesh children list
  35733. * @param mesh defines the child mesh
  35734. * @returns the current mesh
  35735. */
  35736. removeChild(mesh: AbstractMesh): AbstractMesh;
  35737. /** @hidden */
  35738. private _initFacetData;
  35739. /**
  35740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35741. * This method can be called within the render loop.
  35742. * 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
  35743. * @returns the current mesh
  35744. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35745. */
  35746. updateFacetData(): AbstractMesh;
  35747. /**
  35748. * Returns the facetLocalNormals array.
  35749. * The normals are expressed in the mesh local spac
  35750. * @returns an array of Vector3
  35751. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35752. */
  35753. getFacetLocalNormals(): Vector3[];
  35754. /**
  35755. * Returns the facetLocalPositions array.
  35756. * The facet positions are expressed in the mesh local space
  35757. * @returns an array of Vector3
  35758. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35759. */
  35760. getFacetLocalPositions(): Vector3[];
  35761. /**
  35762. * Returns the facetLocalPartioning array
  35763. * @returns an array of array of numbers
  35764. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35765. */
  35766. getFacetLocalPartitioning(): number[][];
  35767. /**
  35768. * Returns the i-th facet position in the world system.
  35769. * This method allocates a new Vector3 per call
  35770. * @param i defines the facet index
  35771. * @returns a new Vector3
  35772. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35773. */
  35774. getFacetPosition(i: number): Vector3;
  35775. /**
  35776. * Sets the reference Vector3 with the i-th facet position in the world system
  35777. * @param i defines the facet index
  35778. * @param ref defines the target vector
  35779. * @returns the current mesh
  35780. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35781. */
  35782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35783. /**
  35784. * Returns the i-th facet normal in the world system.
  35785. * This method allocates a new Vector3 per call
  35786. * @param i defines the facet index
  35787. * @returns a new Vector3
  35788. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35789. */
  35790. getFacetNormal(i: number): Vector3;
  35791. /**
  35792. * Sets the reference Vector3 with the i-th facet normal in the world system
  35793. * @param i defines the facet index
  35794. * @param ref defines the target vector
  35795. * @returns the current mesh
  35796. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35797. */
  35798. getFacetNormalToRef(i: number, ref: Vector3): this;
  35799. /**
  35800. * 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)
  35801. * @param x defines x coordinate
  35802. * @param y defines y coordinate
  35803. * @param z defines z coordinate
  35804. * @returns the array of facet indexes
  35805. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35806. */
  35807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35808. /**
  35809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35810. * @param projected sets as the (x,y,z) world projection on the facet
  35811. * @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
  35812. * @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
  35813. * @param x defines x coordinate
  35814. * @param y defines y coordinate
  35815. * @param z defines z coordinate
  35816. * @returns the face index if found (or null instead)
  35817. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35818. */
  35819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35820. /**
  35821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35822. * @param projected sets as the (x,y,z) local 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. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35832. /**
  35833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35834. * @returns the parameters
  35835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35836. */
  35837. getFacetDataParameters(): any;
  35838. /**
  35839. * Disables the feature FacetData and frees the related memory
  35840. * @returns the current mesh
  35841. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35842. */
  35843. disableFacetData(): AbstractMesh;
  35844. /**
  35845. * Updates the AbstractMesh indices array
  35846. * @param indices defines the data source
  35847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35848. * @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)
  35849. * @returns the current mesh
  35850. */
  35851. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35852. /**
  35853. * Creates new normals data for the mesh
  35854. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35855. * @returns the current mesh
  35856. */
  35857. createNormals(updatable: boolean): AbstractMesh;
  35858. /**
  35859. * Align the mesh with a normal
  35860. * @param normal defines the normal to use
  35861. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35862. * @returns the current mesh
  35863. */
  35864. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35865. /** @hidden */
  35866. _checkOcclusionQuery(): boolean;
  35867. /**
  35868. * Disables the mesh edge rendering mode
  35869. * @returns the currentAbstractMesh
  35870. */
  35871. disableEdgesRendering(): AbstractMesh;
  35872. /**
  35873. * Enables the edge rendering mode on the mesh.
  35874. * This mode makes the mesh edges visible
  35875. * @param epsilon defines the maximal distance between two angles to detect a face
  35876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35877. * @param options options to the edge renderer
  35878. * @returns the currentAbstractMesh
  35879. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35880. */
  35881. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35882. /**
  35883. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35884. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35885. */
  35886. getConnectedParticleSystems(): IParticleSystem[];
  35887. }
  35888. }
  35889. declare module BABYLON {
  35890. /**
  35891. * Interface used to define ActionEvent
  35892. */
  35893. export interface IActionEvent {
  35894. /** The mesh or sprite that triggered the action */
  35895. source: any;
  35896. /** The X mouse cursor position at the time of the event */
  35897. pointerX: number;
  35898. /** The Y mouse cursor position at the time of the event */
  35899. pointerY: number;
  35900. /** The mesh that is currently pointed at (can be null) */
  35901. meshUnderPointer: Nullable<AbstractMesh>;
  35902. /** the original (browser) event that triggered the ActionEvent */
  35903. sourceEvent?: any;
  35904. /** additional data for the event */
  35905. additionalData?: any;
  35906. }
  35907. /**
  35908. * ActionEvent is the event being sent when an action is triggered.
  35909. */
  35910. export class ActionEvent implements IActionEvent {
  35911. /** The mesh or sprite that triggered the action */
  35912. source: any;
  35913. /** The X mouse cursor position at the time of the event */
  35914. pointerX: number;
  35915. /** The Y mouse cursor position at the time of the event */
  35916. pointerY: number;
  35917. /** The mesh that is currently pointed at (can be null) */
  35918. meshUnderPointer: Nullable<AbstractMesh>;
  35919. /** the original (browser) event that triggered the ActionEvent */
  35920. sourceEvent?: any;
  35921. /** additional data for the event */
  35922. additionalData?: any;
  35923. /**
  35924. * Creates a new ActionEvent
  35925. * @param source The mesh or sprite that triggered the action
  35926. * @param pointerX The X mouse cursor position at the time of the event
  35927. * @param pointerY The Y mouse cursor position at the time of the event
  35928. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35929. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35930. * @param additionalData additional data for the event
  35931. */
  35932. constructor(
  35933. /** The mesh or sprite that triggered the action */
  35934. source: any,
  35935. /** The X mouse cursor position at the time of the event */
  35936. pointerX: number,
  35937. /** The Y mouse cursor position at the time of the event */
  35938. pointerY: number,
  35939. /** The mesh that is currently pointed at (can be null) */
  35940. meshUnderPointer: Nullable<AbstractMesh>,
  35941. /** the original (browser) event that triggered the ActionEvent */
  35942. sourceEvent?: any,
  35943. /** additional data for the event */
  35944. additionalData?: any);
  35945. /**
  35946. * Helper function to auto-create an ActionEvent from a source mesh.
  35947. * @param source The source mesh that triggered the event
  35948. * @param evt The original (browser) event
  35949. * @param additionalData additional data for the event
  35950. * @returns the new ActionEvent
  35951. */
  35952. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35953. /**
  35954. * Helper function to auto-create an ActionEvent from a source sprite
  35955. * @param source The source sprite that triggered the event
  35956. * @param scene Scene associated with the sprite
  35957. * @param evt The original (browser) event
  35958. * @param additionalData additional data for the event
  35959. * @returns the new ActionEvent
  35960. */
  35961. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  35962. /**
  35963. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  35964. * @param scene the scene where the event occurred
  35965. * @param evt The original (browser) event
  35966. * @returns the new ActionEvent
  35967. */
  35968. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  35969. /**
  35970. * Helper function to auto-create an ActionEvent from a primitive
  35971. * @param prim defines the target primitive
  35972. * @param pointerPos defines the pointer position
  35973. * @param evt The original (browser) event
  35974. * @param additionalData additional data for the event
  35975. * @returns the new ActionEvent
  35976. */
  35977. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  35978. }
  35979. }
  35980. declare module BABYLON {
  35981. /**
  35982. * Abstract class used to decouple action Manager from scene and meshes.
  35983. * Do not instantiate.
  35984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35985. */
  35986. export abstract class AbstractActionManager implements IDisposable {
  35987. /** Gets the list of active triggers */
  35988. static Triggers: {
  35989. [key: string]: number;
  35990. };
  35991. /** Gets the cursor to use when hovering items */
  35992. hoverCursor: string;
  35993. /** Gets the list of actions */
  35994. actions: IAction[];
  35995. /**
  35996. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  35997. */
  35998. isRecursive: boolean;
  35999. /**
  36000. * Releases all associated resources
  36001. */
  36002. abstract dispose(): void;
  36003. /**
  36004. * Does this action manager has pointer triggers
  36005. */
  36006. abstract get hasPointerTriggers(): boolean;
  36007. /**
  36008. * Does this action manager has pick triggers
  36009. */
  36010. abstract get hasPickTriggers(): boolean;
  36011. /**
  36012. * Process a specific trigger
  36013. * @param trigger defines the trigger to process
  36014. * @param evt defines the event details to be processed
  36015. */
  36016. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36017. /**
  36018. * Does this action manager handles actions of any of the given triggers
  36019. * @param triggers defines the triggers to be tested
  36020. * @return a boolean indicating whether one (or more) of the triggers is handled
  36021. */
  36022. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36023. /**
  36024. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36025. * speed.
  36026. * @param triggerA defines the trigger to be tested
  36027. * @param triggerB defines the trigger to be tested
  36028. * @return a boolean indicating whether one (or more) of the triggers is handled
  36029. */
  36030. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36031. /**
  36032. * Does this action manager handles actions of a given trigger
  36033. * @param trigger defines the trigger to be tested
  36034. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36035. * @return whether the trigger is handled
  36036. */
  36037. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36038. /**
  36039. * Serialize this manager to a JSON object
  36040. * @param name defines the property name to store this manager
  36041. * @returns a JSON representation of this manager
  36042. */
  36043. abstract serialize(name: string): any;
  36044. /**
  36045. * Registers an action to this action manager
  36046. * @param action defines the action to be registered
  36047. * @return the action amended (prepared) after registration
  36048. */
  36049. abstract registerAction(action: IAction): Nullable<IAction>;
  36050. /**
  36051. * Unregisters an action to this action manager
  36052. * @param action defines the action to be unregistered
  36053. * @return a boolean indicating whether the action has been unregistered
  36054. */
  36055. abstract unregisterAction(action: IAction): Boolean;
  36056. /**
  36057. * Does exist one action manager with at least one trigger
  36058. **/
  36059. static get HasTriggers(): boolean;
  36060. /**
  36061. * Does exist one action manager with at least one pick trigger
  36062. **/
  36063. static get HasPickTriggers(): boolean;
  36064. /**
  36065. * Does exist one action manager that handles actions of a given trigger
  36066. * @param trigger defines the trigger to be tested
  36067. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36068. **/
  36069. static HasSpecificTrigger(trigger: number): boolean;
  36070. }
  36071. }
  36072. declare module BABYLON {
  36073. /**
  36074. * Defines how a node can be built from a string name.
  36075. */
  36076. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36077. /**
  36078. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36079. */
  36080. export class Node implements IBehaviorAware<Node> {
  36081. /** @hidden */
  36082. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36083. private static _NodeConstructors;
  36084. /**
  36085. * Add a new node constructor
  36086. * @param type defines the type name of the node to construct
  36087. * @param constructorFunc defines the constructor function
  36088. */
  36089. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36090. /**
  36091. * Returns a node constructor based on type name
  36092. * @param type defines the type name
  36093. * @param name defines the new node name
  36094. * @param scene defines the hosting scene
  36095. * @param options defines optional options to transmit to constructors
  36096. * @returns the new constructor or null
  36097. */
  36098. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36099. /**
  36100. * Gets or sets the name of the node
  36101. */
  36102. name: string;
  36103. /**
  36104. * Gets or sets the id of the node
  36105. */
  36106. id: string;
  36107. /**
  36108. * Gets or sets the unique id of the node
  36109. */
  36110. uniqueId: number;
  36111. /**
  36112. * Gets or sets a string used to store user defined state for the node
  36113. */
  36114. state: string;
  36115. /**
  36116. * Gets or sets an object used to store user defined information for the node
  36117. */
  36118. metadata: any;
  36119. /**
  36120. * For internal use only. Please do not use.
  36121. */
  36122. reservedDataStore: any;
  36123. /**
  36124. * List of inspectable custom properties (used by the Inspector)
  36125. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36126. */
  36127. inspectableCustomProperties: IInspectable[];
  36128. private _doNotSerialize;
  36129. /**
  36130. * Gets or sets a boolean used to define if the node must be serialized
  36131. */
  36132. get doNotSerialize(): boolean;
  36133. set doNotSerialize(value: boolean);
  36134. /** @hidden */
  36135. _isDisposed: boolean;
  36136. /**
  36137. * Gets a list of Animations associated with the node
  36138. */
  36139. animations: Animation[];
  36140. protected _ranges: {
  36141. [name: string]: Nullable<AnimationRange>;
  36142. };
  36143. /**
  36144. * Callback raised when the node is ready to be used
  36145. */
  36146. onReady: Nullable<(node: Node) => void>;
  36147. private _isEnabled;
  36148. private _isParentEnabled;
  36149. private _isReady;
  36150. /** @hidden */
  36151. _currentRenderId: number;
  36152. private _parentUpdateId;
  36153. /** @hidden */
  36154. _childUpdateId: number;
  36155. /** @hidden */
  36156. _waitingParentId: Nullable<string>;
  36157. /** @hidden */
  36158. _scene: Scene;
  36159. /** @hidden */
  36160. _cache: any;
  36161. private _parentNode;
  36162. private _children;
  36163. /** @hidden */
  36164. _worldMatrix: Matrix;
  36165. /** @hidden */
  36166. _worldMatrixDeterminant: number;
  36167. /** @hidden */
  36168. _worldMatrixDeterminantIsDirty: boolean;
  36169. /** @hidden */
  36170. private _sceneRootNodesIndex;
  36171. /**
  36172. * Gets a boolean indicating if the node has been disposed
  36173. * @returns true if the node was disposed
  36174. */
  36175. isDisposed(): boolean;
  36176. /**
  36177. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36178. * @see https://doc.babylonjs.com/how_to/parenting
  36179. */
  36180. set parent(parent: Nullable<Node>);
  36181. get parent(): Nullable<Node>;
  36182. /** @hidden */
  36183. _addToSceneRootNodes(): void;
  36184. /** @hidden */
  36185. _removeFromSceneRootNodes(): void;
  36186. private _animationPropertiesOverride;
  36187. /**
  36188. * Gets or sets the animation properties override
  36189. */
  36190. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36191. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36192. /**
  36193. * Gets a string identifying the name of the class
  36194. * @returns "Node" string
  36195. */
  36196. getClassName(): string;
  36197. /** @hidden */
  36198. readonly _isNode: boolean;
  36199. /**
  36200. * An event triggered when the mesh is disposed
  36201. */
  36202. onDisposeObservable: Observable<Node>;
  36203. private _onDisposeObserver;
  36204. /**
  36205. * Sets a callback that will be raised when the node will be disposed
  36206. */
  36207. set onDispose(callback: () => void);
  36208. /**
  36209. * Creates a new Node
  36210. * @param name the name and id to be given to this node
  36211. * @param scene the scene this node will be added to
  36212. */
  36213. constructor(name: string, scene?: Nullable<Scene>);
  36214. /**
  36215. * Gets the scene of the node
  36216. * @returns a scene
  36217. */
  36218. getScene(): Scene;
  36219. /**
  36220. * Gets the engine of the node
  36221. * @returns a Engine
  36222. */
  36223. getEngine(): Engine;
  36224. private _behaviors;
  36225. /**
  36226. * Attach a behavior to the node
  36227. * @see https://doc.babylonjs.com/features/behaviour
  36228. * @param behavior defines the behavior to attach
  36229. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36230. * @returns the current Node
  36231. */
  36232. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36233. /**
  36234. * Remove an attached behavior
  36235. * @see https://doc.babylonjs.com/features/behaviour
  36236. * @param behavior defines the behavior to attach
  36237. * @returns the current Node
  36238. */
  36239. removeBehavior(behavior: Behavior<Node>): Node;
  36240. /**
  36241. * Gets the list of attached behaviors
  36242. * @see https://doc.babylonjs.com/features/behaviour
  36243. */
  36244. get behaviors(): Behavior<Node>[];
  36245. /**
  36246. * Gets an attached behavior by name
  36247. * @param name defines the name of the behavior to look for
  36248. * @see https://doc.babylonjs.com/features/behaviour
  36249. * @returns null if behavior was not found else the requested behavior
  36250. */
  36251. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36252. /**
  36253. * Returns the latest update of the World matrix
  36254. * @returns a Matrix
  36255. */
  36256. getWorldMatrix(): Matrix;
  36257. /** @hidden */
  36258. _getWorldMatrixDeterminant(): number;
  36259. /**
  36260. * Returns directly the latest state of the mesh World matrix.
  36261. * A Matrix is returned.
  36262. */
  36263. get worldMatrixFromCache(): Matrix;
  36264. /** @hidden */
  36265. _initCache(): void;
  36266. /** @hidden */
  36267. updateCache(force?: boolean): void;
  36268. /** @hidden */
  36269. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36270. /** @hidden */
  36271. _updateCache(ignoreParentClass?: boolean): void;
  36272. /** @hidden */
  36273. _isSynchronized(): boolean;
  36274. /** @hidden */
  36275. _markSyncedWithParent(): void;
  36276. /** @hidden */
  36277. isSynchronizedWithParent(): boolean;
  36278. /** @hidden */
  36279. isSynchronized(): boolean;
  36280. /**
  36281. * Is this node ready to be used/rendered
  36282. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36283. * @return true if the node is ready
  36284. */
  36285. isReady(completeCheck?: boolean): boolean;
  36286. /**
  36287. * Is this node enabled?
  36288. * 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
  36289. * @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
  36290. * @return whether this node (and its parent) is enabled
  36291. */
  36292. isEnabled(checkAncestors?: boolean): boolean;
  36293. /** @hidden */
  36294. protected _syncParentEnabledState(): void;
  36295. /**
  36296. * Set the enabled state of this node
  36297. * @param value defines the new enabled state
  36298. */
  36299. setEnabled(value: boolean): void;
  36300. /**
  36301. * Is this node a descendant of the given node?
  36302. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36303. * @param ancestor defines the parent node to inspect
  36304. * @returns a boolean indicating if this node is a descendant of the given node
  36305. */
  36306. isDescendantOf(ancestor: Node): boolean;
  36307. /** @hidden */
  36308. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36309. /**
  36310. * Will return all nodes that have this node as ascendant
  36311. * @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
  36312. * @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
  36313. * @return all children nodes of all types
  36314. */
  36315. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36316. /**
  36317. * Get all child-meshes of this node
  36318. * @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)
  36319. * @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
  36320. * @returns an array of AbstractMesh
  36321. */
  36322. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36323. /**
  36324. * Get all direct children of this node
  36325. * @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
  36326. * @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)
  36327. * @returns an array of Node
  36328. */
  36329. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36330. /** @hidden */
  36331. _setReady(state: boolean): void;
  36332. /**
  36333. * Get an animation by name
  36334. * @param name defines the name of the animation to look for
  36335. * @returns null if not found else the requested animation
  36336. */
  36337. getAnimationByName(name: string): Nullable<Animation>;
  36338. /**
  36339. * Creates an animation range for this node
  36340. * @param name defines the name of the range
  36341. * @param from defines the starting key
  36342. * @param to defines the end key
  36343. */
  36344. createAnimationRange(name: string, from: number, to: number): void;
  36345. /**
  36346. * Delete a specific animation range
  36347. * @param name defines the name of the range to delete
  36348. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36349. */
  36350. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36351. /**
  36352. * Get an animation range by name
  36353. * @param name defines the name of the animation range to look for
  36354. * @returns null if not found else the requested animation range
  36355. */
  36356. getAnimationRange(name: string): Nullable<AnimationRange>;
  36357. /**
  36358. * Gets the list of all animation ranges defined on this node
  36359. * @returns an array
  36360. */
  36361. getAnimationRanges(): Nullable<AnimationRange>[];
  36362. /**
  36363. * Will start the animation sequence
  36364. * @param name defines the range frames for animation sequence
  36365. * @param loop defines if the animation should loop (false by default)
  36366. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36367. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36368. * @returns the object created for this animation. If range does not exist, it will return null
  36369. */
  36370. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36371. /**
  36372. * Serialize animation ranges into a JSON compatible object
  36373. * @returns serialization object
  36374. */
  36375. serializeAnimationRanges(): any;
  36376. /**
  36377. * Computes the world matrix of the node
  36378. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36379. * @returns the world matrix
  36380. */
  36381. computeWorldMatrix(force?: boolean): Matrix;
  36382. /**
  36383. * Releases resources associated with this node.
  36384. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36385. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36386. */
  36387. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36388. /**
  36389. * Parse animation range data from a serialization object and store them into a given node
  36390. * @param node defines where to store the animation ranges
  36391. * @param parsedNode defines the serialization object to read data from
  36392. * @param scene defines the hosting scene
  36393. */
  36394. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36395. /**
  36396. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36397. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36398. * @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
  36399. * @returns the new bounding vectors
  36400. */
  36401. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36402. min: Vector3;
  36403. max: Vector3;
  36404. };
  36405. }
  36406. }
  36407. declare module BABYLON {
  36408. /**
  36409. * @hidden
  36410. */
  36411. export class _IAnimationState {
  36412. key: number;
  36413. repeatCount: number;
  36414. workValue?: any;
  36415. loopMode?: number;
  36416. offsetValue?: any;
  36417. highLimitValue?: any;
  36418. }
  36419. /**
  36420. * Class used to store any kind of animation
  36421. */
  36422. export class Animation {
  36423. /**Name of the animation */
  36424. name: string;
  36425. /**Property to animate */
  36426. targetProperty: string;
  36427. /**The frames per second of the animation */
  36428. framePerSecond: number;
  36429. /**The data type of the animation */
  36430. dataType: number;
  36431. /**The loop mode of the animation */
  36432. loopMode?: number | undefined;
  36433. /**Specifies if blending should be enabled */
  36434. enableBlending?: boolean | undefined;
  36435. /**
  36436. * Use matrix interpolation instead of using direct key value when animating matrices
  36437. */
  36438. static AllowMatricesInterpolation: boolean;
  36439. /**
  36440. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36441. */
  36442. static AllowMatrixDecomposeForInterpolation: boolean;
  36443. /** Define the Url to load snippets */
  36444. static SnippetUrl: string;
  36445. /** Snippet ID if the animation was created from the snippet server */
  36446. snippetId: string;
  36447. /**
  36448. * Stores the key frames of the animation
  36449. */
  36450. private _keys;
  36451. /**
  36452. * Stores the easing function of the animation
  36453. */
  36454. private _easingFunction;
  36455. /**
  36456. * @hidden Internal use only
  36457. */
  36458. _runtimeAnimations: RuntimeAnimation[];
  36459. /**
  36460. * The set of event that will be linked to this animation
  36461. */
  36462. private _events;
  36463. /**
  36464. * Stores an array of target property paths
  36465. */
  36466. targetPropertyPath: string[];
  36467. /**
  36468. * Stores the blending speed of the animation
  36469. */
  36470. blendingSpeed: number;
  36471. /**
  36472. * Stores the animation ranges for the animation
  36473. */
  36474. private _ranges;
  36475. /**
  36476. * @hidden Internal use
  36477. */
  36478. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36479. /**
  36480. * Sets up an animation
  36481. * @param property The property to animate
  36482. * @param animationType The animation type to apply
  36483. * @param framePerSecond The frames per second of the animation
  36484. * @param easingFunction The easing function used in the animation
  36485. * @returns The created animation
  36486. */
  36487. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36488. /**
  36489. * Create and start an animation on a node
  36490. * @param name defines the name of the global animation that will be run on all nodes
  36491. * @param node defines the root node where the animation will take place
  36492. * @param targetProperty defines property to animate
  36493. * @param framePerSecond defines the number of frame per second yo use
  36494. * @param totalFrame defines the number of frames in total
  36495. * @param from defines the initial value
  36496. * @param to defines the final value
  36497. * @param loopMode defines which loop mode you want to use (off by default)
  36498. * @param easingFunction defines the easing function to use (linear by default)
  36499. * @param onAnimationEnd defines the callback to call when animation end
  36500. * @returns the animatable created for this animation
  36501. */
  36502. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36503. /**
  36504. * Create and start an animation on a node and its descendants
  36505. * @param name defines the name of the global animation that will be run on all nodes
  36506. * @param node defines the root node where the animation will take place
  36507. * @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
  36508. * @param targetProperty defines property to animate
  36509. * @param framePerSecond defines the number of frame per second to use
  36510. * @param totalFrame defines the number of frames in total
  36511. * @param from defines the initial value
  36512. * @param to defines the final value
  36513. * @param loopMode defines which loop mode you want to use (off by default)
  36514. * @param easingFunction defines the easing function to use (linear by default)
  36515. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36516. * @returns the list of animatables created for all nodes
  36517. * @example https://www.babylonjs-playground.com/#MH0VLI
  36518. */
  36519. 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[]>;
  36520. /**
  36521. * Creates a new animation, merges it with the existing animations and starts it
  36522. * @param name Name of the animation
  36523. * @param node Node which contains the scene that begins the animations
  36524. * @param targetProperty Specifies which property to animate
  36525. * @param framePerSecond The frames per second of the animation
  36526. * @param totalFrame The total number of frames
  36527. * @param from The frame at the beginning of the animation
  36528. * @param to The frame at the end of the animation
  36529. * @param loopMode Specifies the loop mode of the animation
  36530. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36531. * @param onAnimationEnd Callback to run once the animation is complete
  36532. * @returns Nullable animation
  36533. */
  36534. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36535. /**
  36536. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36537. * @param sourceAnimation defines the Animation containing keyframes to convert
  36538. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36539. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36540. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36541. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36542. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36543. */
  36544. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36545. /**
  36546. * Transition property of an host to the target Value
  36547. * @param property The property to transition
  36548. * @param targetValue The target Value of the property
  36549. * @param host The object where the property to animate belongs
  36550. * @param scene Scene used to run the animation
  36551. * @param frameRate Framerate (in frame/s) to use
  36552. * @param transition The transition type we want to use
  36553. * @param duration The duration of the animation, in milliseconds
  36554. * @param onAnimationEnd Callback trigger at the end of the animation
  36555. * @returns Nullable animation
  36556. */
  36557. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36558. /**
  36559. * Return the array of runtime animations currently using this animation
  36560. */
  36561. get runtimeAnimations(): RuntimeAnimation[];
  36562. /**
  36563. * Specifies if any of the runtime animations are currently running
  36564. */
  36565. get hasRunningRuntimeAnimations(): boolean;
  36566. /**
  36567. * Initializes the animation
  36568. * @param name Name of the animation
  36569. * @param targetProperty Property to animate
  36570. * @param framePerSecond The frames per second of the animation
  36571. * @param dataType The data type of the animation
  36572. * @param loopMode The loop mode of the animation
  36573. * @param enableBlending Specifies if blending should be enabled
  36574. */
  36575. constructor(
  36576. /**Name of the animation */
  36577. name: string,
  36578. /**Property to animate */
  36579. targetProperty: string,
  36580. /**The frames per second of the animation */
  36581. framePerSecond: number,
  36582. /**The data type of the animation */
  36583. dataType: number,
  36584. /**The loop mode of the animation */
  36585. loopMode?: number | undefined,
  36586. /**Specifies if blending should be enabled */
  36587. enableBlending?: boolean | undefined);
  36588. /**
  36589. * Converts the animation to a string
  36590. * @param fullDetails support for multiple levels of logging within scene loading
  36591. * @returns String form of the animation
  36592. */
  36593. toString(fullDetails?: boolean): string;
  36594. /**
  36595. * Add an event to this animation
  36596. * @param event Event to add
  36597. */
  36598. addEvent(event: AnimationEvent): void;
  36599. /**
  36600. * Remove all events found at the given frame
  36601. * @param frame The frame to remove events from
  36602. */
  36603. removeEvents(frame: number): void;
  36604. /**
  36605. * Retrieves all the events from the animation
  36606. * @returns Events from the animation
  36607. */
  36608. getEvents(): AnimationEvent[];
  36609. /**
  36610. * Creates an animation range
  36611. * @param name Name of the animation range
  36612. * @param from Starting frame of the animation range
  36613. * @param to Ending frame of the animation
  36614. */
  36615. createRange(name: string, from: number, to: number): void;
  36616. /**
  36617. * Deletes an animation range by name
  36618. * @param name Name of the animation range to delete
  36619. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36620. */
  36621. deleteRange(name: string, deleteFrames?: boolean): void;
  36622. /**
  36623. * Gets the animation range by name, or null if not defined
  36624. * @param name Name of the animation range
  36625. * @returns Nullable animation range
  36626. */
  36627. getRange(name: string): Nullable<AnimationRange>;
  36628. /**
  36629. * Gets the key frames from the animation
  36630. * @returns The key frames of the animation
  36631. */
  36632. getKeys(): Array<IAnimationKey>;
  36633. /**
  36634. * Gets the highest frame rate of the animation
  36635. * @returns Highest frame rate of the animation
  36636. */
  36637. getHighestFrame(): number;
  36638. /**
  36639. * Gets the easing function of the animation
  36640. * @returns Easing function of the animation
  36641. */
  36642. getEasingFunction(): IEasingFunction;
  36643. /**
  36644. * Sets the easing function of the animation
  36645. * @param easingFunction A custom mathematical formula for animation
  36646. */
  36647. setEasingFunction(easingFunction: EasingFunction): void;
  36648. /**
  36649. * Interpolates a scalar linearly
  36650. * @param startValue Start value of the animation curve
  36651. * @param endValue End value of the animation curve
  36652. * @param gradient Scalar amount to interpolate
  36653. * @returns Interpolated scalar value
  36654. */
  36655. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36656. /**
  36657. * Interpolates a scalar cubically
  36658. * @param startValue Start value of the animation curve
  36659. * @param outTangent End tangent of the animation
  36660. * @param endValue End value of the animation curve
  36661. * @param inTangent Start tangent of the animation curve
  36662. * @param gradient Scalar amount to interpolate
  36663. * @returns Interpolated scalar value
  36664. */
  36665. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36666. /**
  36667. * Interpolates a quaternion using a spherical linear interpolation
  36668. * @param startValue Start value of the animation curve
  36669. * @param endValue End value of the animation curve
  36670. * @param gradient Scalar amount to interpolate
  36671. * @returns Interpolated quaternion value
  36672. */
  36673. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36674. /**
  36675. * Interpolates a quaternion cubically
  36676. * @param startValue Start value of the animation curve
  36677. * @param outTangent End tangent of the animation curve
  36678. * @param endValue End value of the animation curve
  36679. * @param inTangent Start tangent of the animation curve
  36680. * @param gradient Scalar amount to interpolate
  36681. * @returns Interpolated quaternion value
  36682. */
  36683. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36684. /**
  36685. * Interpolates a Vector3 linearl
  36686. * @param startValue Start value of the animation curve
  36687. * @param endValue End value of the animation curve
  36688. * @param gradient Scalar amount to interpolate
  36689. * @returns Interpolated scalar value
  36690. */
  36691. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36692. /**
  36693. * Interpolates a Vector3 cubically
  36694. * @param startValue Start value of the animation curve
  36695. * @param outTangent End tangent of the animation
  36696. * @param endValue End value of the animation curve
  36697. * @param inTangent Start tangent of the animation curve
  36698. * @param gradient Scalar amount to interpolate
  36699. * @returns InterpolatedVector3 value
  36700. */
  36701. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36702. /**
  36703. * Interpolates a Vector2 linearly
  36704. * @param startValue Start value of the animation curve
  36705. * @param endValue End value of the animation curve
  36706. * @param gradient Scalar amount to interpolate
  36707. * @returns Interpolated Vector2 value
  36708. */
  36709. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36710. /**
  36711. * Interpolates a Vector2 cubically
  36712. * @param startValue Start value of the animation curve
  36713. * @param outTangent End tangent of the animation
  36714. * @param endValue End value of the animation curve
  36715. * @param inTangent Start tangent of the animation curve
  36716. * @param gradient Scalar amount to interpolate
  36717. * @returns Interpolated Vector2 value
  36718. */
  36719. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36720. /**
  36721. * Interpolates a size linearly
  36722. * @param startValue Start value of the animation curve
  36723. * @param endValue End value of the animation curve
  36724. * @param gradient Scalar amount to interpolate
  36725. * @returns Interpolated Size value
  36726. */
  36727. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36728. /**
  36729. * Interpolates a Color3 linearly
  36730. * @param startValue Start value of the animation curve
  36731. * @param endValue End value of the animation curve
  36732. * @param gradient Scalar amount to interpolate
  36733. * @returns Interpolated Color3 value
  36734. */
  36735. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36736. /**
  36737. * Interpolates a Color4 linearly
  36738. * @param startValue Start value of the animation curve
  36739. * @param endValue End value of the animation curve
  36740. * @param gradient Scalar amount to interpolate
  36741. * @returns Interpolated Color3 value
  36742. */
  36743. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36744. /**
  36745. * @hidden Internal use only
  36746. */
  36747. _getKeyValue(value: any): any;
  36748. /**
  36749. * @hidden Internal use only
  36750. */
  36751. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36752. /**
  36753. * Defines the function to use to interpolate matrices
  36754. * @param startValue defines the start matrix
  36755. * @param endValue defines the end matrix
  36756. * @param gradient defines the gradient between both matrices
  36757. * @param result defines an optional target matrix where to store the interpolation
  36758. * @returns the interpolated matrix
  36759. */
  36760. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36761. /**
  36762. * Makes a copy of the animation
  36763. * @returns Cloned animation
  36764. */
  36765. clone(): Animation;
  36766. /**
  36767. * Sets the key frames of the animation
  36768. * @param values The animation key frames to set
  36769. */
  36770. setKeys(values: Array<IAnimationKey>): void;
  36771. /**
  36772. * Serializes the animation to an object
  36773. * @returns Serialized object
  36774. */
  36775. serialize(): any;
  36776. /**
  36777. * Float animation type
  36778. */
  36779. static readonly ANIMATIONTYPE_FLOAT: number;
  36780. /**
  36781. * Vector3 animation type
  36782. */
  36783. static readonly ANIMATIONTYPE_VECTOR3: number;
  36784. /**
  36785. * Quaternion animation type
  36786. */
  36787. static readonly ANIMATIONTYPE_QUATERNION: number;
  36788. /**
  36789. * Matrix animation type
  36790. */
  36791. static readonly ANIMATIONTYPE_MATRIX: number;
  36792. /**
  36793. * Color3 animation type
  36794. */
  36795. static readonly ANIMATIONTYPE_COLOR3: number;
  36796. /**
  36797. * Color3 animation type
  36798. */
  36799. static readonly ANIMATIONTYPE_COLOR4: number;
  36800. /**
  36801. * Vector2 animation type
  36802. */
  36803. static readonly ANIMATIONTYPE_VECTOR2: number;
  36804. /**
  36805. * Size animation type
  36806. */
  36807. static readonly ANIMATIONTYPE_SIZE: number;
  36808. /**
  36809. * Relative Loop Mode
  36810. */
  36811. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36812. /**
  36813. * Cycle Loop Mode
  36814. */
  36815. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36816. /**
  36817. * Constant Loop Mode
  36818. */
  36819. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36820. /** @hidden */
  36821. static _UniversalLerp(left: any, right: any, amount: number): any;
  36822. /**
  36823. * Parses an animation object and creates an animation
  36824. * @param parsedAnimation Parsed animation object
  36825. * @returns Animation object
  36826. */
  36827. static Parse(parsedAnimation: any): Animation;
  36828. /**
  36829. * Appends the serialized animations from the source animations
  36830. * @param source Source containing the animations
  36831. * @param destination Target to store the animations
  36832. */
  36833. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36834. /**
  36835. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36836. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36837. * @param url defines the url to load from
  36838. * @returns a promise that will resolve to the new animation or an array of animations
  36839. */
  36840. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36841. /**
  36842. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36843. * @param snippetId defines the snippet to load
  36844. * @returns a promise that will resolve to the new animation or a new array of animations
  36845. */
  36846. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36847. }
  36848. }
  36849. declare module BABYLON {
  36850. /**
  36851. * Interface containing an array of animations
  36852. */
  36853. export interface IAnimatable {
  36854. /**
  36855. * Array of animations
  36856. */
  36857. animations: Nullable<Array<Animation>>;
  36858. }
  36859. }
  36860. declare module BABYLON {
  36861. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36862. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36863. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36864. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36865. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36866. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36867. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36868. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36869. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36870. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36871. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36872. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36873. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36874. /**
  36875. * Decorator used to define property that can be serialized as reference to a camera
  36876. * @param sourceName defines the name of the property to decorate
  36877. */
  36878. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36879. /**
  36880. * Class used to help serialization objects
  36881. */
  36882. export class SerializationHelper {
  36883. /** @hidden */
  36884. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36885. /** @hidden */
  36886. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36887. /** @hidden */
  36888. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36889. /** @hidden */
  36890. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36891. /**
  36892. * Appends the serialized animations from the source animations
  36893. * @param source Source containing the animations
  36894. * @param destination Target to store the animations
  36895. */
  36896. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36897. /**
  36898. * Static function used to serialized a specific entity
  36899. * @param entity defines the entity to serialize
  36900. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36901. * @returns a JSON compatible object representing the serialization of the entity
  36902. */
  36903. static Serialize<T>(entity: T, serializationObject?: any): any;
  36904. /**
  36905. * Creates a new entity from a serialization data object
  36906. * @param creationFunction defines a function used to instanciated the new entity
  36907. * @param source defines the source serialization data
  36908. * @param scene defines the hosting scene
  36909. * @param rootUrl defines the root url for resources
  36910. * @returns a new entity
  36911. */
  36912. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36913. /**
  36914. * Clones an object
  36915. * @param creationFunction defines the function used to instanciate the new object
  36916. * @param source defines the source object
  36917. * @returns the cloned object
  36918. */
  36919. static Clone<T>(creationFunction: () => T, source: T): T;
  36920. /**
  36921. * Instanciates a new object based on a source one (some data will be shared between both object)
  36922. * @param creationFunction defines the function used to instanciate the new object
  36923. * @param source defines the source object
  36924. * @returns the new object
  36925. */
  36926. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36927. }
  36928. }
  36929. declare module BABYLON {
  36930. /**
  36931. * This is the base class of all the camera used in the application.
  36932. * @see https://doc.babylonjs.com/features/cameras
  36933. */
  36934. export class Camera extends Node {
  36935. /** @hidden */
  36936. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36937. /**
  36938. * This is the default projection mode used by the cameras.
  36939. * It helps recreating a feeling of perspective and better appreciate depth.
  36940. * This is the best way to simulate real life cameras.
  36941. */
  36942. static readonly PERSPECTIVE_CAMERA: number;
  36943. /**
  36944. * This helps creating camera with an orthographic mode.
  36945. * 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.
  36946. */
  36947. static readonly ORTHOGRAPHIC_CAMERA: number;
  36948. /**
  36949. * This is the default FOV mode for perspective cameras.
  36950. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  36951. */
  36952. static readonly FOVMODE_VERTICAL_FIXED: number;
  36953. /**
  36954. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  36955. */
  36956. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  36957. /**
  36958. * This specifies ther is no need for a camera rig.
  36959. * Basically only one eye is rendered corresponding to the camera.
  36960. */
  36961. static readonly RIG_MODE_NONE: number;
  36962. /**
  36963. * Simulates a camera Rig with one blue eye and one red eye.
  36964. * This can be use with 3d blue and red glasses.
  36965. */
  36966. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  36967. /**
  36968. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  36969. */
  36970. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  36971. /**
  36972. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  36973. */
  36974. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  36975. /**
  36976. * Defines that both eyes of the camera will be rendered over under each other.
  36977. */
  36978. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  36979. /**
  36980. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  36981. */
  36982. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  36983. /**
  36984. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  36985. */
  36986. static readonly RIG_MODE_VR: number;
  36987. /**
  36988. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  36989. */
  36990. static readonly RIG_MODE_WEBVR: number;
  36991. /**
  36992. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  36993. */
  36994. static readonly RIG_MODE_CUSTOM: number;
  36995. /**
  36996. * Defines if by default attaching controls should prevent the default javascript event to continue.
  36997. */
  36998. static ForceAttachControlToAlwaysPreventDefault: boolean;
  36999. /**
  37000. * Define the input manager associated with the camera.
  37001. */
  37002. inputs: CameraInputsManager<Camera>;
  37003. /** @hidden */
  37004. _position: Vector3;
  37005. /**
  37006. * Define the current local position of the camera in the scene
  37007. */
  37008. get position(): Vector3;
  37009. set position(newPosition: Vector3);
  37010. protected _upVector: Vector3;
  37011. /**
  37012. * The vector the camera should consider as up.
  37013. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37014. */
  37015. set upVector(vec: Vector3);
  37016. get upVector(): Vector3;
  37017. /**
  37018. * Define the current limit on the left side for an orthographic camera
  37019. * In scene unit
  37020. */
  37021. orthoLeft: Nullable<number>;
  37022. /**
  37023. * Define the current limit on the right side for an orthographic camera
  37024. * In scene unit
  37025. */
  37026. orthoRight: Nullable<number>;
  37027. /**
  37028. * Define the current limit on the bottom side for an orthographic camera
  37029. * In scene unit
  37030. */
  37031. orthoBottom: Nullable<number>;
  37032. /**
  37033. * Define the current limit on the top side for an orthographic camera
  37034. * In scene unit
  37035. */
  37036. orthoTop: Nullable<number>;
  37037. /**
  37038. * Field Of View is set in Radians. (default is 0.8)
  37039. */
  37040. fov: number;
  37041. /**
  37042. * Define the minimum distance the camera can see from.
  37043. * This is important to note that the depth buffer are not infinite and the closer it starts
  37044. * the more your scene might encounter depth fighting issue.
  37045. */
  37046. minZ: number;
  37047. /**
  37048. * Define the maximum distance the camera can see to.
  37049. * This is important to note that the depth buffer are not infinite and the further it end
  37050. * the more your scene might encounter depth fighting issue.
  37051. */
  37052. maxZ: number;
  37053. /**
  37054. * Define the default inertia of the camera.
  37055. * This helps giving a smooth feeling to the camera movement.
  37056. */
  37057. inertia: number;
  37058. /**
  37059. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37060. */
  37061. mode: number;
  37062. /**
  37063. * Define whether the camera is intermediate.
  37064. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37065. */
  37066. isIntermediate: boolean;
  37067. /**
  37068. * Define the viewport of the camera.
  37069. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37070. */
  37071. viewport: Viewport;
  37072. /**
  37073. * Restricts the camera to viewing objects with the same layerMask.
  37074. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37075. */
  37076. layerMask: number;
  37077. /**
  37078. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37079. */
  37080. fovMode: number;
  37081. /**
  37082. * Rig mode of the camera.
  37083. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37084. * This is normally controlled byt the camera themselves as internal use.
  37085. */
  37086. cameraRigMode: number;
  37087. /**
  37088. * Defines the distance between both "eyes" in case of a RIG
  37089. */
  37090. interaxialDistance: number;
  37091. /**
  37092. * Defines if stereoscopic rendering is done side by side or over under.
  37093. */
  37094. isStereoscopicSideBySide: boolean;
  37095. /**
  37096. * 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
  37097. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37098. * else in the scene. (Eg. security camera)
  37099. *
  37100. * 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)
  37101. */
  37102. customRenderTargets: RenderTargetTexture[];
  37103. /**
  37104. * When set, the camera will render to this render target instead of the default canvas
  37105. *
  37106. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37107. */
  37108. outputRenderTarget: Nullable<RenderTargetTexture>;
  37109. /**
  37110. * Observable triggered when the camera view matrix has changed.
  37111. */
  37112. onViewMatrixChangedObservable: Observable<Camera>;
  37113. /**
  37114. * Observable triggered when the camera Projection matrix has changed.
  37115. */
  37116. onProjectionMatrixChangedObservable: Observable<Camera>;
  37117. /**
  37118. * Observable triggered when the inputs have been processed.
  37119. */
  37120. onAfterCheckInputsObservable: Observable<Camera>;
  37121. /**
  37122. * Observable triggered when reset has been called and applied to the camera.
  37123. */
  37124. onRestoreStateObservable: Observable<Camera>;
  37125. /**
  37126. * Is this camera a part of a rig system?
  37127. */
  37128. isRigCamera: boolean;
  37129. /**
  37130. * If isRigCamera set to true this will be set with the parent camera.
  37131. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37132. */
  37133. rigParent?: Camera;
  37134. /** @hidden */
  37135. _cameraRigParams: any;
  37136. /** @hidden */
  37137. _rigCameras: Camera[];
  37138. /** @hidden */
  37139. _rigPostProcess: Nullable<PostProcess>;
  37140. protected _webvrViewMatrix: Matrix;
  37141. /** @hidden */
  37142. _skipRendering: boolean;
  37143. /** @hidden */
  37144. _projectionMatrix: Matrix;
  37145. /** @hidden */
  37146. _postProcesses: Nullable<PostProcess>[];
  37147. /** @hidden */
  37148. _activeMeshes: SmartArray<AbstractMesh>;
  37149. protected _globalPosition: Vector3;
  37150. /** @hidden */
  37151. _computedViewMatrix: Matrix;
  37152. private _doNotComputeProjectionMatrix;
  37153. private _transformMatrix;
  37154. private _frustumPlanes;
  37155. private _refreshFrustumPlanes;
  37156. private _storedFov;
  37157. private _stateStored;
  37158. /**
  37159. * Instantiates a new camera object.
  37160. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37161. * @see https://doc.babylonjs.com/features/cameras
  37162. * @param name Defines the name of the camera in the scene
  37163. * @param position Defines the position of the camera
  37164. * @param scene Defines the scene the camera belongs too
  37165. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37166. */
  37167. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37168. /**
  37169. * Store current camera state (fov, position, etc..)
  37170. * @returns the camera
  37171. */
  37172. storeState(): Camera;
  37173. /**
  37174. * Restores the camera state values if it has been stored. You must call storeState() first
  37175. */
  37176. protected _restoreStateValues(): boolean;
  37177. /**
  37178. * Restored camera state. You must call storeState() first.
  37179. * @returns true if restored and false otherwise
  37180. */
  37181. restoreState(): boolean;
  37182. /**
  37183. * Gets the class name of the camera.
  37184. * @returns the class name
  37185. */
  37186. getClassName(): string;
  37187. /** @hidden */
  37188. readonly _isCamera: boolean;
  37189. /**
  37190. * Gets a string representation of the camera useful for debug purpose.
  37191. * @param fullDetails Defines that a more verboe level of logging is required
  37192. * @returns the string representation
  37193. */
  37194. toString(fullDetails?: boolean): string;
  37195. /**
  37196. * Gets the current world space position of the camera.
  37197. */
  37198. get globalPosition(): Vector3;
  37199. /**
  37200. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37201. * @returns the active meshe list
  37202. */
  37203. getActiveMeshes(): SmartArray<AbstractMesh>;
  37204. /**
  37205. * Check whether a mesh is part of the current active mesh list of the camera
  37206. * @param mesh Defines the mesh to check
  37207. * @returns true if active, false otherwise
  37208. */
  37209. isActiveMesh(mesh: Mesh): boolean;
  37210. /**
  37211. * Is this camera ready to be used/rendered
  37212. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37213. * @return true if the camera is ready
  37214. */
  37215. isReady(completeCheck?: boolean): boolean;
  37216. /** @hidden */
  37217. _initCache(): void;
  37218. /** @hidden */
  37219. _updateCache(ignoreParentClass?: boolean): void;
  37220. /** @hidden */
  37221. _isSynchronized(): boolean;
  37222. /** @hidden */
  37223. _isSynchronizedViewMatrix(): boolean;
  37224. /** @hidden */
  37225. _isSynchronizedProjectionMatrix(): boolean;
  37226. /**
  37227. * Attach the input controls to a specific dom element to get the input from.
  37228. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37229. */
  37230. attachControl(noPreventDefault?: boolean): void;
  37231. /**
  37232. * Detach the current controls from the specified dom element.
  37233. */
  37234. detachControl(): void;
  37235. /**
  37236. * Update the camera state according to the different inputs gathered during the frame.
  37237. */
  37238. update(): void;
  37239. /** @hidden */
  37240. _checkInputs(): void;
  37241. /** @hidden */
  37242. get rigCameras(): Camera[];
  37243. /**
  37244. * Gets the post process used by the rig cameras
  37245. */
  37246. get rigPostProcess(): Nullable<PostProcess>;
  37247. /**
  37248. * Internal, gets the first post proces.
  37249. * @returns the first post process to be run on this camera.
  37250. */
  37251. _getFirstPostProcess(): Nullable<PostProcess>;
  37252. private _cascadePostProcessesToRigCams;
  37253. /**
  37254. * Attach a post process to the camera.
  37255. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37256. * @param postProcess The post process to attach to the camera
  37257. * @param insertAt The position of the post process in case several of them are in use in the scene
  37258. * @returns the position the post process has been inserted at
  37259. */
  37260. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37261. /**
  37262. * Detach a post process to the camera.
  37263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37264. * @param postProcess The post process to detach from the camera
  37265. */
  37266. detachPostProcess(postProcess: PostProcess): void;
  37267. /**
  37268. * Gets the current world matrix of the camera
  37269. */
  37270. getWorldMatrix(): Matrix;
  37271. /** @hidden */
  37272. _getViewMatrix(): Matrix;
  37273. /**
  37274. * Gets the current view matrix of the camera.
  37275. * @param force forces the camera to recompute the matrix without looking at the cached state
  37276. * @returns the view matrix
  37277. */
  37278. getViewMatrix(force?: boolean): Matrix;
  37279. /**
  37280. * Freeze the projection matrix.
  37281. * It will prevent the cache check of the camera projection compute and can speed up perf
  37282. * if no parameter of the camera are meant to change
  37283. * @param projection Defines manually a projection if necessary
  37284. */
  37285. freezeProjectionMatrix(projection?: Matrix): void;
  37286. /**
  37287. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37288. */
  37289. unfreezeProjectionMatrix(): void;
  37290. /**
  37291. * Gets the current projection matrix of the camera.
  37292. * @param force forces the camera to recompute the matrix without looking at the cached state
  37293. * @returns the projection matrix
  37294. */
  37295. getProjectionMatrix(force?: boolean): Matrix;
  37296. /**
  37297. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37298. * @returns a Matrix
  37299. */
  37300. getTransformationMatrix(): Matrix;
  37301. private _updateFrustumPlanes;
  37302. /**
  37303. * Checks if a cullable object (mesh...) is in the camera frustum
  37304. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37305. * @param target The object to check
  37306. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37307. * @returns true if the object is in frustum otherwise false
  37308. */
  37309. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37310. /**
  37311. * Checks if a cullable object (mesh...) is in the camera frustum
  37312. * Unlike isInFrustum this cheks the full bounding box
  37313. * @param target The object to check
  37314. * @returns true if the object is in frustum otherwise false
  37315. */
  37316. isCompletelyInFrustum(target: ICullable): boolean;
  37317. /**
  37318. * Gets a ray in the forward direction from the camera.
  37319. * @param length Defines the length of the ray to create
  37320. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37321. * @param origin Defines the start point of the ray which defaults to the camera position
  37322. * @returns the forward ray
  37323. */
  37324. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37325. /**
  37326. * Gets a ray in the forward direction from the camera.
  37327. * @param refRay the ray to (re)use when setting the values
  37328. * @param length Defines the length of the ray to create
  37329. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37330. * @param origin Defines the start point of the ray which defaults to the camera position
  37331. * @returns the forward ray
  37332. */
  37333. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37334. /**
  37335. * Releases resources associated with this node.
  37336. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37337. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37338. */
  37339. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37340. /** @hidden */
  37341. _isLeftCamera: boolean;
  37342. /**
  37343. * Gets the left camera of a rig setup in case of Rigged Camera
  37344. */
  37345. get isLeftCamera(): boolean;
  37346. /** @hidden */
  37347. _isRightCamera: boolean;
  37348. /**
  37349. * Gets the right camera of a rig setup in case of Rigged Camera
  37350. */
  37351. get isRightCamera(): boolean;
  37352. /**
  37353. * Gets the left camera of a rig setup in case of Rigged Camera
  37354. */
  37355. get leftCamera(): Nullable<FreeCamera>;
  37356. /**
  37357. * Gets the right camera of a rig setup in case of Rigged Camera
  37358. */
  37359. get rightCamera(): Nullable<FreeCamera>;
  37360. /**
  37361. * Gets the left camera target of a rig setup in case of Rigged Camera
  37362. * @returns the target position
  37363. */
  37364. getLeftTarget(): Nullable<Vector3>;
  37365. /**
  37366. * Gets the right camera target of a rig setup in case of Rigged Camera
  37367. * @returns the target position
  37368. */
  37369. getRightTarget(): Nullable<Vector3>;
  37370. /**
  37371. * @hidden
  37372. */
  37373. setCameraRigMode(mode: number, rigParams: any): void;
  37374. /** @hidden */
  37375. static _setStereoscopicRigMode(camera: Camera): void;
  37376. /** @hidden */
  37377. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37378. /** @hidden */
  37379. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37380. /** @hidden */
  37381. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37382. /** @hidden */
  37383. _getVRProjectionMatrix(): Matrix;
  37384. protected _updateCameraRotationMatrix(): void;
  37385. protected _updateWebVRCameraRotationMatrix(): void;
  37386. /**
  37387. * This function MUST be overwritten by the different WebVR cameras available.
  37388. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37389. * @hidden
  37390. */
  37391. _getWebVRProjectionMatrix(): Matrix;
  37392. /**
  37393. * This function MUST be overwritten by the different WebVR cameras available.
  37394. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37395. * @hidden
  37396. */
  37397. _getWebVRViewMatrix(): Matrix;
  37398. /** @hidden */
  37399. setCameraRigParameter(name: string, value: any): void;
  37400. /**
  37401. * needs to be overridden by children so sub has required properties to be copied
  37402. * @hidden
  37403. */
  37404. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37405. /**
  37406. * May need to be overridden by children
  37407. * @hidden
  37408. */
  37409. _updateRigCameras(): void;
  37410. /** @hidden */
  37411. _setupInputs(): void;
  37412. /**
  37413. * Serialiaze the camera setup to a json represention
  37414. * @returns the JSON representation
  37415. */
  37416. serialize(): any;
  37417. /**
  37418. * Clones the current camera.
  37419. * @param name The cloned camera name
  37420. * @returns the cloned camera
  37421. */
  37422. clone(name: string): Camera;
  37423. /**
  37424. * Gets the direction of the camera relative to a given local axis.
  37425. * @param localAxis Defines the reference axis to provide a relative direction.
  37426. * @return the direction
  37427. */
  37428. getDirection(localAxis: Vector3): Vector3;
  37429. /**
  37430. * Returns the current camera absolute rotation
  37431. */
  37432. get absoluteRotation(): Quaternion;
  37433. /**
  37434. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37435. * @param localAxis Defines the reference axis to provide a relative direction.
  37436. * @param result Defines the vector to store the result in
  37437. */
  37438. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37439. /**
  37440. * Gets a camera constructor for a given camera type
  37441. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37442. * @param name The name of the camera the result will be able to instantiate
  37443. * @param scene The scene the result will construct the camera in
  37444. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37445. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37446. * @returns a factory method to construc the camera
  37447. */
  37448. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37449. /**
  37450. * Compute the world matrix of the camera.
  37451. * @returns the camera world matrix
  37452. */
  37453. computeWorldMatrix(): Matrix;
  37454. /**
  37455. * Parse a JSON and creates the camera from the parsed information
  37456. * @param parsedCamera The JSON to parse
  37457. * @param scene The scene to instantiate the camera in
  37458. * @returns the newly constructed camera
  37459. */
  37460. static Parse(parsedCamera: any, scene: Scene): Camera;
  37461. }
  37462. }
  37463. declare module BABYLON {
  37464. /**
  37465. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37466. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37467. */
  37468. export class PostProcessManager {
  37469. private _scene;
  37470. private _indexBuffer;
  37471. private _vertexBuffers;
  37472. /**
  37473. * Creates a new instance PostProcess
  37474. * @param scene The scene that the post process is associated with.
  37475. */
  37476. constructor(scene: Scene);
  37477. private _prepareBuffers;
  37478. private _buildIndexBuffer;
  37479. /**
  37480. * Rebuilds the vertex buffers of the manager.
  37481. * @hidden
  37482. */
  37483. _rebuild(): void;
  37484. /**
  37485. * Prepares a frame to be run through a post process.
  37486. * @param sourceTexture The input texture to the post procesess. (default: null)
  37487. * @param postProcesses An array of post processes to be run. (default: null)
  37488. * @returns True if the post processes were able to be run.
  37489. * @hidden
  37490. */
  37491. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37492. /**
  37493. * Manually render a set of post processes to a texture.
  37494. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37495. * @param postProcesses An array of post processes to be run.
  37496. * @param targetTexture The target texture to render to.
  37497. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37498. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37499. * @param lodLevel defines which lod of the texture to render to
  37500. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37501. */
  37502. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37503. /**
  37504. * Finalize the result of the output of the postprocesses.
  37505. * @param doNotPresent If true the result will not be displayed to the screen.
  37506. * @param targetTexture The target texture to render to.
  37507. * @param faceIndex The index of the face to bind the target texture to.
  37508. * @param postProcesses The array of post processes to render.
  37509. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37510. * @hidden
  37511. */
  37512. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37513. /**
  37514. * Disposes of the post process manager.
  37515. */
  37516. dispose(): void;
  37517. }
  37518. }
  37519. declare module BABYLON {
  37520. /**
  37521. * This Helps creating a texture that will be created from a camera in your scene.
  37522. * It is basically a dynamic texture that could be used to create special effects for instance.
  37523. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37524. */
  37525. export class RenderTargetTexture extends Texture {
  37526. /**
  37527. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37528. */
  37529. static readonly REFRESHRATE_RENDER_ONCE: number;
  37530. /**
  37531. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37532. */
  37533. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37534. /**
  37535. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37536. * the central point of your effect and can save a lot of performances.
  37537. */
  37538. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37539. /**
  37540. * Use this predicate to dynamically define the list of mesh you want to render.
  37541. * If set, the renderList property will be overwritten.
  37542. */
  37543. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37544. private _renderList;
  37545. /**
  37546. * Use this list to define the list of mesh you want to render.
  37547. */
  37548. get renderList(): Nullable<Array<AbstractMesh>>;
  37549. set renderList(value: Nullable<Array<AbstractMesh>>);
  37550. /**
  37551. * Use this function to overload the renderList array at rendering time.
  37552. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37553. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37554. * the cube (if the RTT is a cube, else layerOrFace=0).
  37555. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37556. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37557. * hold dummy elements!
  37558. */
  37559. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37560. private _hookArray;
  37561. /**
  37562. * Define if particles should be rendered in your texture.
  37563. */
  37564. renderParticles: boolean;
  37565. /**
  37566. * Define if sprites should be rendered in your texture.
  37567. */
  37568. renderSprites: boolean;
  37569. /**
  37570. * Define the camera used to render the texture.
  37571. */
  37572. activeCamera: Nullable<Camera>;
  37573. /**
  37574. * Override the mesh isReady function with your own one.
  37575. */
  37576. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37577. /**
  37578. * Override the render function of the texture with your own one.
  37579. */
  37580. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37581. /**
  37582. * Define if camera post processes should be use while rendering the texture.
  37583. */
  37584. useCameraPostProcesses: boolean;
  37585. /**
  37586. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37587. */
  37588. ignoreCameraViewport: boolean;
  37589. private _postProcessManager;
  37590. private _postProcesses;
  37591. private _resizeObserver;
  37592. /**
  37593. * An event triggered when the texture is unbind.
  37594. */
  37595. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37596. /**
  37597. * An event triggered when the texture is unbind.
  37598. */
  37599. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37600. private _onAfterUnbindObserver;
  37601. /**
  37602. * Set a after unbind callback in the texture.
  37603. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37604. */
  37605. set onAfterUnbind(callback: () => void);
  37606. /**
  37607. * An event triggered before rendering the texture
  37608. */
  37609. onBeforeRenderObservable: Observable<number>;
  37610. private _onBeforeRenderObserver;
  37611. /**
  37612. * Set a before render callback in the texture.
  37613. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37614. */
  37615. set onBeforeRender(callback: (faceIndex: number) => void);
  37616. /**
  37617. * An event triggered after rendering the texture
  37618. */
  37619. onAfterRenderObservable: Observable<number>;
  37620. private _onAfterRenderObserver;
  37621. /**
  37622. * Set a after render callback in the texture.
  37623. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37624. */
  37625. set onAfterRender(callback: (faceIndex: number) => void);
  37626. /**
  37627. * An event triggered after the texture clear
  37628. */
  37629. onClearObservable: Observable<Engine>;
  37630. private _onClearObserver;
  37631. /**
  37632. * Set a clear callback in the texture.
  37633. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37634. */
  37635. set onClear(callback: (Engine: Engine) => void);
  37636. /**
  37637. * An event triggered when the texture is resized.
  37638. */
  37639. onResizeObservable: Observable<RenderTargetTexture>;
  37640. /**
  37641. * Define the clear color of the Render Target if it should be different from the scene.
  37642. */
  37643. clearColor: Color4;
  37644. protected _size: number | {
  37645. width: number;
  37646. height: number;
  37647. layers?: number;
  37648. };
  37649. protected _initialSizeParameter: number | {
  37650. width: number;
  37651. height: number;
  37652. } | {
  37653. ratio: number;
  37654. };
  37655. protected _sizeRatio: Nullable<number>;
  37656. /** @hidden */
  37657. _generateMipMaps: boolean;
  37658. protected _renderingManager: RenderingManager;
  37659. /** @hidden */
  37660. _waitingRenderList?: string[];
  37661. protected _doNotChangeAspectRatio: boolean;
  37662. protected _currentRefreshId: number;
  37663. protected _refreshRate: number;
  37664. protected _textureMatrix: Matrix;
  37665. protected _samples: number;
  37666. protected _renderTargetOptions: RenderTargetCreationOptions;
  37667. /**
  37668. * Gets render target creation options that were used.
  37669. */
  37670. get renderTargetOptions(): RenderTargetCreationOptions;
  37671. protected _onRatioRescale(): void;
  37672. /**
  37673. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37674. * It must define where the camera used to render the texture is set
  37675. */
  37676. boundingBoxPosition: Vector3;
  37677. private _boundingBoxSize;
  37678. /**
  37679. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37680. * When defined, the cubemap will switch to local mode
  37681. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37682. * @example https://www.babylonjs-playground.com/#RNASML
  37683. */
  37684. set boundingBoxSize(value: Vector3);
  37685. get boundingBoxSize(): Vector3;
  37686. /**
  37687. * In case the RTT has been created with a depth texture, get the associated
  37688. * depth texture.
  37689. * Otherwise, return null.
  37690. */
  37691. get depthStencilTexture(): Nullable<InternalTexture>;
  37692. /**
  37693. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37694. * or used a shadow, depth texture...
  37695. * @param name The friendly name of the texture
  37696. * @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)
  37697. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37698. * @param generateMipMaps True if mip maps need to be generated after render.
  37699. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37700. * @param type The type of the buffer in the RTT (int, half float, float...)
  37701. * @param isCube True if a cube texture needs to be created
  37702. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37703. * @param generateDepthBuffer True to generate a depth buffer
  37704. * @param generateStencilBuffer True to generate a stencil buffer
  37705. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37706. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37707. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37708. */
  37709. constructor(name: string, size: number | {
  37710. width: number;
  37711. height: number;
  37712. layers?: number;
  37713. } | {
  37714. ratio: number;
  37715. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37716. /**
  37717. * Creates a depth stencil texture.
  37718. * This is only available in WebGL 2 or with the depth texture extension available.
  37719. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37720. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37721. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37722. */
  37723. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37724. private _processSizeParameter;
  37725. /**
  37726. * Define the number of samples to use in case of MSAA.
  37727. * It defaults to one meaning no MSAA has been enabled.
  37728. */
  37729. get samples(): number;
  37730. set samples(value: number);
  37731. /**
  37732. * Resets the refresh counter of the texture and start bak from scratch.
  37733. * Could be useful to regenerate the texture if it is setup to render only once.
  37734. */
  37735. resetRefreshCounter(): void;
  37736. /**
  37737. * Define the refresh rate of the texture or the rendering frequency.
  37738. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37739. */
  37740. get refreshRate(): number;
  37741. set refreshRate(value: number);
  37742. /**
  37743. * Adds a post process to the render target rendering passes.
  37744. * @param postProcess define the post process to add
  37745. */
  37746. addPostProcess(postProcess: PostProcess): void;
  37747. /**
  37748. * Clear all the post processes attached to the render target
  37749. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37750. */
  37751. clearPostProcesses(dispose?: boolean): void;
  37752. /**
  37753. * Remove one of the post process from the list of attached post processes to the texture
  37754. * @param postProcess define the post process to remove from the list
  37755. */
  37756. removePostProcess(postProcess: PostProcess): void;
  37757. /** @hidden */
  37758. _shouldRender(): boolean;
  37759. /**
  37760. * Gets the actual render size of the texture.
  37761. * @returns the width of the render size
  37762. */
  37763. getRenderSize(): number;
  37764. /**
  37765. * Gets the actual render width of the texture.
  37766. * @returns the width of the render size
  37767. */
  37768. getRenderWidth(): number;
  37769. /**
  37770. * Gets the actual render height of the texture.
  37771. * @returns the height of the render size
  37772. */
  37773. getRenderHeight(): number;
  37774. /**
  37775. * Gets the actual number of layers of the texture.
  37776. * @returns the number of layers
  37777. */
  37778. getRenderLayers(): number;
  37779. /**
  37780. * Get if the texture can be rescaled or not.
  37781. */
  37782. get canRescale(): boolean;
  37783. /**
  37784. * Resize the texture using a ratio.
  37785. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37786. */
  37787. scale(ratio: number): void;
  37788. /**
  37789. * Get the texture reflection matrix used to rotate/transform the reflection.
  37790. * @returns the reflection matrix
  37791. */
  37792. getReflectionTextureMatrix(): Matrix;
  37793. /**
  37794. * Resize the texture to a new desired size.
  37795. * Be carrefull as it will recreate all the data in the new texture.
  37796. * @param size Define the new size. It can be:
  37797. * - a number for squared texture,
  37798. * - an object containing { width: number, height: number }
  37799. * - or an object containing a ratio { ratio: number }
  37800. */
  37801. resize(size: number | {
  37802. width: number;
  37803. height: number;
  37804. } | {
  37805. ratio: number;
  37806. }): void;
  37807. private _defaultRenderListPrepared;
  37808. /**
  37809. * Renders all the objects from the render list into the texture.
  37810. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37811. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37812. */
  37813. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37814. private _bestReflectionRenderTargetDimension;
  37815. private _prepareRenderingManager;
  37816. /**
  37817. * @hidden
  37818. * @param faceIndex face index to bind to if this is a cubetexture
  37819. * @param layer defines the index of the texture to bind in the array
  37820. */
  37821. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37822. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37823. private renderToTarget;
  37824. /**
  37825. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37826. * This allowed control for front to back rendering or reversly depending of the special needs.
  37827. *
  37828. * @param renderingGroupId The rendering group id corresponding to its index
  37829. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37830. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37831. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37832. */
  37833. 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;
  37834. /**
  37835. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37836. *
  37837. * @param renderingGroupId The rendering group id corresponding to its index
  37838. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37839. */
  37840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37841. /**
  37842. * Clones the texture.
  37843. * @returns the cloned texture
  37844. */
  37845. clone(): RenderTargetTexture;
  37846. /**
  37847. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37848. * @returns The JSON representation of the texture
  37849. */
  37850. serialize(): any;
  37851. /**
  37852. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37853. */
  37854. disposeFramebufferObjects(): void;
  37855. /**
  37856. * Dispose the texture and release its associated resources.
  37857. */
  37858. dispose(): void;
  37859. /** @hidden */
  37860. _rebuild(): void;
  37861. /**
  37862. * Clear the info related to rendering groups preventing retention point in material dispose.
  37863. */
  37864. freeRenderingGroups(): void;
  37865. /**
  37866. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37867. * @returns the view count
  37868. */
  37869. getViewCount(): number;
  37870. }
  37871. }
  37872. declare module BABYLON {
  37873. /**
  37874. * Options to be used when creating an effect.
  37875. */
  37876. export interface IEffectCreationOptions {
  37877. /**
  37878. * Atrributes that will be used in the shader.
  37879. */
  37880. attributes: string[];
  37881. /**
  37882. * Uniform varible names that will be set in the shader.
  37883. */
  37884. uniformsNames: string[];
  37885. /**
  37886. * Uniform buffer variable names that will be set in the shader.
  37887. */
  37888. uniformBuffersNames: string[];
  37889. /**
  37890. * Sampler texture variable names that will be set in the shader.
  37891. */
  37892. samplers: string[];
  37893. /**
  37894. * Define statements that will be set in the shader.
  37895. */
  37896. defines: any;
  37897. /**
  37898. * Possible fallbacks for this effect to improve performance when needed.
  37899. */
  37900. fallbacks: Nullable<IEffectFallbacks>;
  37901. /**
  37902. * Callback that will be called when the shader is compiled.
  37903. */
  37904. onCompiled: Nullable<(effect: Effect) => void>;
  37905. /**
  37906. * Callback that will be called if an error occurs during shader compilation.
  37907. */
  37908. onError: Nullable<(effect: Effect, errors: string) => void>;
  37909. /**
  37910. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37911. */
  37912. indexParameters?: any;
  37913. /**
  37914. * Max number of lights that can be used in the shader.
  37915. */
  37916. maxSimultaneousLights?: number;
  37917. /**
  37918. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37919. */
  37920. transformFeedbackVaryings?: Nullable<string[]>;
  37921. /**
  37922. * 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
  37923. */
  37924. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37925. /**
  37926. * Is this effect rendering to several color attachments ?
  37927. */
  37928. multiTarget?: boolean;
  37929. }
  37930. /**
  37931. * Effect containing vertex and fragment shader that can be executed on an object.
  37932. */
  37933. export class Effect implements IDisposable {
  37934. /**
  37935. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37936. */
  37937. static ShadersRepository: string;
  37938. /**
  37939. * Enable logging of the shader code when a compilation error occurs
  37940. */
  37941. static LogShaderCodeOnCompilationError: boolean;
  37942. /**
  37943. * Name of the effect.
  37944. */
  37945. name: any;
  37946. /**
  37947. * String container all the define statements that should be set on the shader.
  37948. */
  37949. defines: string;
  37950. /**
  37951. * Callback that will be called when the shader is compiled.
  37952. */
  37953. onCompiled: Nullable<(effect: Effect) => void>;
  37954. /**
  37955. * Callback that will be called if an error occurs during shader compilation.
  37956. */
  37957. onError: Nullable<(effect: Effect, errors: string) => void>;
  37958. /**
  37959. * Callback that will be called when effect is bound.
  37960. */
  37961. onBind: Nullable<(effect: Effect) => void>;
  37962. /**
  37963. * Unique ID of the effect.
  37964. */
  37965. uniqueId: number;
  37966. /**
  37967. * Observable that will be called when the shader is compiled.
  37968. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37969. */
  37970. onCompileObservable: Observable<Effect>;
  37971. /**
  37972. * Observable that will be called if an error occurs during shader compilation.
  37973. */
  37974. onErrorObservable: Observable<Effect>;
  37975. /** @hidden */
  37976. _onBindObservable: Nullable<Observable<Effect>>;
  37977. /**
  37978. * @hidden
  37979. * Specifies if the effect was previously ready
  37980. */
  37981. _wasPreviouslyReady: boolean;
  37982. /**
  37983. * Observable that will be called when effect is bound.
  37984. */
  37985. get onBindObservable(): Observable<Effect>;
  37986. /** @hidden */
  37987. _bonesComputationForcedToCPU: boolean;
  37988. /** @hidden */
  37989. _multiTarget: boolean;
  37990. private static _uniqueIdSeed;
  37991. private _engine;
  37992. private _uniformBuffersNames;
  37993. private _uniformBuffersNamesList;
  37994. private _uniformsNames;
  37995. private _samplerList;
  37996. private _samplers;
  37997. private _isReady;
  37998. private _compilationError;
  37999. private _allFallbacksProcessed;
  38000. private _attributesNames;
  38001. private _attributes;
  38002. private _attributeLocationByName;
  38003. private _uniforms;
  38004. /**
  38005. * Key for the effect.
  38006. * @hidden
  38007. */
  38008. _key: string;
  38009. private _indexParameters;
  38010. private _fallbacks;
  38011. private _vertexSourceCode;
  38012. private _fragmentSourceCode;
  38013. private _vertexSourceCodeOverride;
  38014. private _fragmentSourceCodeOverride;
  38015. private _transformFeedbackVaryings;
  38016. private _rawVertexSourceCode;
  38017. private _rawFragmentSourceCode;
  38018. /**
  38019. * Compiled shader to webGL program.
  38020. * @hidden
  38021. */
  38022. _pipelineContext: Nullable<IPipelineContext>;
  38023. private _valueCache;
  38024. private static _baseCache;
  38025. /**
  38026. * Instantiates an effect.
  38027. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38028. * @param baseName Name of the effect.
  38029. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38030. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38031. * @param samplers List of sampler variables that will be passed to the shader.
  38032. * @param engine Engine to be used to render the effect
  38033. * @param defines Define statements to be added to the shader.
  38034. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38035. * @param onCompiled Callback that will be called when the shader is compiled.
  38036. * @param onError Callback that will be called if an error occurs during shader compilation.
  38037. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38038. */
  38039. 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);
  38040. private _useFinalCode;
  38041. /**
  38042. * Unique key for this effect
  38043. */
  38044. get key(): string;
  38045. /**
  38046. * If the effect has been compiled and prepared.
  38047. * @returns if the effect is compiled and prepared.
  38048. */
  38049. isReady(): boolean;
  38050. private _isReadyInternal;
  38051. /**
  38052. * The engine the effect was initialized with.
  38053. * @returns the engine.
  38054. */
  38055. getEngine(): Engine;
  38056. /**
  38057. * The pipeline context for this effect
  38058. * @returns the associated pipeline context
  38059. */
  38060. getPipelineContext(): Nullable<IPipelineContext>;
  38061. /**
  38062. * The set of names of attribute variables for the shader.
  38063. * @returns An array of attribute names.
  38064. */
  38065. getAttributesNames(): string[];
  38066. /**
  38067. * Returns the attribute at the given index.
  38068. * @param index The index of the attribute.
  38069. * @returns The location of the attribute.
  38070. */
  38071. getAttributeLocation(index: number): number;
  38072. /**
  38073. * Returns the attribute based on the name of the variable.
  38074. * @param name of the attribute to look up.
  38075. * @returns the attribute location.
  38076. */
  38077. getAttributeLocationByName(name: string): number;
  38078. /**
  38079. * The number of attributes.
  38080. * @returns the numnber of attributes.
  38081. */
  38082. getAttributesCount(): number;
  38083. /**
  38084. * Gets the index of a uniform variable.
  38085. * @param uniformName of the uniform to look up.
  38086. * @returns the index.
  38087. */
  38088. getUniformIndex(uniformName: string): number;
  38089. /**
  38090. * Returns the attribute based on the name of the variable.
  38091. * @param uniformName of the uniform to look up.
  38092. * @returns the location of the uniform.
  38093. */
  38094. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38095. /**
  38096. * Returns an array of sampler variable names
  38097. * @returns The array of sampler variable names.
  38098. */
  38099. getSamplers(): string[];
  38100. /**
  38101. * Returns an array of uniform variable names
  38102. * @returns The array of uniform variable names.
  38103. */
  38104. getUniformNames(): string[];
  38105. /**
  38106. * Returns an array of uniform buffer variable names
  38107. * @returns The array of uniform buffer variable names.
  38108. */
  38109. getUniformBuffersNames(): string[];
  38110. /**
  38111. * Returns the index parameters used to create the effect
  38112. * @returns The index parameters object
  38113. */
  38114. getIndexParameters(): any;
  38115. /**
  38116. * The error from the last compilation.
  38117. * @returns the error string.
  38118. */
  38119. getCompilationError(): string;
  38120. /**
  38121. * Gets a boolean indicating that all fallbacks were used during compilation
  38122. * @returns true if all fallbacks were used
  38123. */
  38124. allFallbacksProcessed(): boolean;
  38125. /**
  38126. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38127. * @param func The callback to be used.
  38128. */
  38129. executeWhenCompiled(func: (effect: Effect) => void): void;
  38130. private _checkIsReady;
  38131. private _loadShader;
  38132. /**
  38133. * Gets the vertex shader source code of this effect
  38134. */
  38135. get vertexSourceCode(): string;
  38136. /**
  38137. * Gets the fragment shader source code of this effect
  38138. */
  38139. get fragmentSourceCode(): string;
  38140. /**
  38141. * Gets the vertex shader source code before it has been processed by the preprocessor
  38142. */
  38143. get rawVertexSourceCode(): string;
  38144. /**
  38145. * Gets the fragment shader source code before it has been processed by the preprocessor
  38146. */
  38147. get rawFragmentSourceCode(): string;
  38148. /**
  38149. * Recompiles the webGL program
  38150. * @param vertexSourceCode The source code for the vertex shader.
  38151. * @param fragmentSourceCode The source code for the fragment shader.
  38152. * @param onCompiled Callback called when completed.
  38153. * @param onError Callback called on error.
  38154. * @hidden
  38155. */
  38156. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38157. /**
  38158. * Prepares the effect
  38159. * @hidden
  38160. */
  38161. _prepareEffect(): void;
  38162. private _getShaderCodeAndErrorLine;
  38163. private _processCompilationErrors;
  38164. /**
  38165. * Checks if the effect is supported. (Must be called after compilation)
  38166. */
  38167. get isSupported(): boolean;
  38168. /**
  38169. * Binds a texture to the engine to be used as output of the shader.
  38170. * @param channel Name of the output variable.
  38171. * @param texture Texture to bind.
  38172. * @hidden
  38173. */
  38174. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38175. /**
  38176. * Sets a texture on the engine to be used in the shader.
  38177. * @param channel Name of the sampler variable.
  38178. * @param texture Texture to set.
  38179. */
  38180. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38181. /**
  38182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38183. * @param channel Name of the sampler variable.
  38184. * @param texture Texture to set.
  38185. */
  38186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38187. /**
  38188. * Sets an array of textures on the engine to be used in the shader.
  38189. * @param channel Name of the variable.
  38190. * @param textures Textures to set.
  38191. */
  38192. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38193. /**
  38194. * 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)
  38195. * @param channel Name of the sampler variable.
  38196. * @param postProcess Post process to get the input texture from.
  38197. */
  38198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38199. /**
  38200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38201. * 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)
  38202. * @param channel Name of the sampler variable.
  38203. * @param postProcess Post process to get the output texture from.
  38204. */
  38205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38206. /** @hidden */
  38207. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38208. /** @hidden */
  38209. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38210. /** @hidden */
  38211. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38212. /** @hidden */
  38213. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38214. /**
  38215. * Binds a buffer to a uniform.
  38216. * @param buffer Buffer to bind.
  38217. * @param name Name of the uniform variable to bind to.
  38218. */
  38219. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38220. /**
  38221. * Binds block to a uniform.
  38222. * @param blockName Name of the block to bind.
  38223. * @param index Index to bind.
  38224. */
  38225. bindUniformBlock(blockName: string, index: number): void;
  38226. /**
  38227. * Sets an interger value on a uniform variable.
  38228. * @param uniformName Name of the variable.
  38229. * @param value Value to be set.
  38230. * @returns this effect.
  38231. */
  38232. setInt(uniformName: string, value: number): Effect;
  38233. /**
  38234. * Sets an int array on a uniform variable.
  38235. * @param uniformName Name of the variable.
  38236. * @param array array to be set.
  38237. * @returns this effect.
  38238. */
  38239. setIntArray(uniformName: string, array: Int32Array): Effect;
  38240. /**
  38241. * 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)
  38242. * @param uniformName Name of the variable.
  38243. * @param array array to be set.
  38244. * @returns this effect.
  38245. */
  38246. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38247. /**
  38248. * 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)
  38249. * @param uniformName Name of the variable.
  38250. * @param array array to be set.
  38251. * @returns this effect.
  38252. */
  38253. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38254. /**
  38255. * 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)
  38256. * @param uniformName Name of the variable.
  38257. * @param array array to be set.
  38258. * @returns this effect.
  38259. */
  38260. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38261. /**
  38262. * Sets an float array on a uniform variable.
  38263. * @param uniformName Name of the variable.
  38264. * @param array array to be set.
  38265. * @returns this effect.
  38266. */
  38267. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38268. /**
  38269. * 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)
  38270. * @param uniformName Name of the variable.
  38271. * @param array array to be set.
  38272. * @returns this effect.
  38273. */
  38274. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38275. /**
  38276. * 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)
  38277. * @param uniformName Name of the variable.
  38278. * @param array array to be set.
  38279. * @returns this effect.
  38280. */
  38281. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38282. /**
  38283. * 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)
  38284. * @param uniformName Name of the variable.
  38285. * @param array array to be set.
  38286. * @returns this effect.
  38287. */
  38288. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38289. /**
  38290. * Sets an array on a uniform variable.
  38291. * @param uniformName Name of the variable.
  38292. * @param array array to be set.
  38293. * @returns this effect.
  38294. */
  38295. setArray(uniformName: string, array: number[]): Effect;
  38296. /**
  38297. * 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)
  38298. * @param uniformName Name of the variable.
  38299. * @param array array to be set.
  38300. * @returns this effect.
  38301. */
  38302. setArray2(uniformName: string, array: number[]): Effect;
  38303. /**
  38304. * 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)
  38305. * @param uniformName Name of the variable.
  38306. * @param array array to be set.
  38307. * @returns this effect.
  38308. */
  38309. setArray3(uniformName: string, array: number[]): Effect;
  38310. /**
  38311. * 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)
  38312. * @param uniformName Name of the variable.
  38313. * @param array array to be set.
  38314. * @returns this effect.
  38315. */
  38316. setArray4(uniformName: string, array: number[]): Effect;
  38317. /**
  38318. * Sets matrices on a uniform variable.
  38319. * @param uniformName Name of the variable.
  38320. * @param matrices matrices to be set.
  38321. * @returns this effect.
  38322. */
  38323. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38324. /**
  38325. * Sets matrix on a uniform variable.
  38326. * @param uniformName Name of the variable.
  38327. * @param matrix matrix to be set.
  38328. * @returns this effect.
  38329. */
  38330. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38331. /**
  38332. * 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)
  38333. * @param uniformName Name of the variable.
  38334. * @param matrix matrix to be set.
  38335. * @returns this effect.
  38336. */
  38337. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38338. /**
  38339. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38340. * @param uniformName Name of the variable.
  38341. * @param matrix matrix to be set.
  38342. * @returns this effect.
  38343. */
  38344. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38345. /**
  38346. * Sets a float on a uniform variable.
  38347. * @param uniformName Name of the variable.
  38348. * @param value value to be set.
  38349. * @returns this effect.
  38350. */
  38351. setFloat(uniformName: string, value: number): Effect;
  38352. /**
  38353. * Sets a boolean on a uniform variable.
  38354. * @param uniformName Name of the variable.
  38355. * @param bool value to be set.
  38356. * @returns this effect.
  38357. */
  38358. setBool(uniformName: string, bool: boolean): Effect;
  38359. /**
  38360. * Sets a Vector2 on a uniform variable.
  38361. * @param uniformName Name of the variable.
  38362. * @param vector2 vector2 to be set.
  38363. * @returns this effect.
  38364. */
  38365. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38366. /**
  38367. * Sets a float2 on a uniform variable.
  38368. * @param uniformName Name of the variable.
  38369. * @param x First float in float2.
  38370. * @param y Second float in float2.
  38371. * @returns this effect.
  38372. */
  38373. setFloat2(uniformName: string, x: number, y: number): Effect;
  38374. /**
  38375. * Sets a Vector3 on a uniform variable.
  38376. * @param uniformName Name of the variable.
  38377. * @param vector3 Value to be set.
  38378. * @returns this effect.
  38379. */
  38380. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38381. /**
  38382. * Sets a float3 on a uniform variable.
  38383. * @param uniformName Name of the variable.
  38384. * @param x First float in float3.
  38385. * @param y Second float in float3.
  38386. * @param z Third float in float3.
  38387. * @returns this effect.
  38388. */
  38389. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38390. /**
  38391. * Sets a Vector4 on a uniform variable.
  38392. * @param uniformName Name of the variable.
  38393. * @param vector4 Value to be set.
  38394. * @returns this effect.
  38395. */
  38396. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38397. /**
  38398. * Sets a float4 on a uniform variable.
  38399. * @param uniformName Name of the variable.
  38400. * @param x First float in float4.
  38401. * @param y Second float in float4.
  38402. * @param z Third float in float4.
  38403. * @param w Fourth float in float4.
  38404. * @returns this effect.
  38405. */
  38406. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38407. /**
  38408. * Sets a Color3 on a uniform variable.
  38409. * @param uniformName Name of the variable.
  38410. * @param color3 Value to be set.
  38411. * @returns this effect.
  38412. */
  38413. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38414. /**
  38415. * Sets a Color4 on a uniform variable.
  38416. * @param uniformName Name of the variable.
  38417. * @param color3 Value to be set.
  38418. * @param alpha Alpha value to be set.
  38419. * @returns this effect.
  38420. */
  38421. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38422. /**
  38423. * Sets a Color4 on a uniform variable
  38424. * @param uniformName defines the name of the variable
  38425. * @param color4 defines the value to be set
  38426. * @returns this effect.
  38427. */
  38428. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38429. /** Release all associated resources */
  38430. dispose(): void;
  38431. /**
  38432. * This function will add a new shader to the shader store
  38433. * @param name the name of the shader
  38434. * @param pixelShader optional pixel shader content
  38435. * @param vertexShader optional vertex shader content
  38436. */
  38437. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38438. /**
  38439. * Store of each shader (The can be looked up using effect.key)
  38440. */
  38441. static ShadersStore: {
  38442. [key: string]: string;
  38443. };
  38444. /**
  38445. * Store of each included file for a shader (The can be looked up using effect.key)
  38446. */
  38447. static IncludesShadersStore: {
  38448. [key: string]: string;
  38449. };
  38450. /**
  38451. * Resets the cache of effects.
  38452. */
  38453. static ResetCache(): void;
  38454. }
  38455. }
  38456. declare module BABYLON {
  38457. /**
  38458. * Interface used to describe the capabilities of the engine relatively to the current browser
  38459. */
  38460. export interface EngineCapabilities {
  38461. /** Maximum textures units per fragment shader */
  38462. maxTexturesImageUnits: number;
  38463. /** Maximum texture units per vertex shader */
  38464. maxVertexTextureImageUnits: number;
  38465. /** Maximum textures units in the entire pipeline */
  38466. maxCombinedTexturesImageUnits: number;
  38467. /** Maximum texture size */
  38468. maxTextureSize: number;
  38469. /** Maximum texture samples */
  38470. maxSamples?: number;
  38471. /** Maximum cube texture size */
  38472. maxCubemapTextureSize: number;
  38473. /** Maximum render texture size */
  38474. maxRenderTextureSize: number;
  38475. /** Maximum number of vertex attributes */
  38476. maxVertexAttribs: number;
  38477. /** Maximum number of varyings */
  38478. maxVaryingVectors: number;
  38479. /** Maximum number of uniforms per vertex shader */
  38480. maxVertexUniformVectors: number;
  38481. /** Maximum number of uniforms per fragment shader */
  38482. maxFragmentUniformVectors: number;
  38483. /** Defines if standard derivates (dx/dy) are supported */
  38484. standardDerivatives: boolean;
  38485. /** Defines if s3tc texture compression is supported */
  38486. s3tc?: WEBGL_compressed_texture_s3tc;
  38487. /** Defines if pvrtc texture compression is supported */
  38488. pvrtc: any;
  38489. /** Defines if etc1 texture compression is supported */
  38490. etc1: any;
  38491. /** Defines if etc2 texture compression is supported */
  38492. etc2: any;
  38493. /** Defines if astc texture compression is supported */
  38494. astc: any;
  38495. /** Defines if bptc texture compression is supported */
  38496. bptc: any;
  38497. /** Defines if float textures are supported */
  38498. textureFloat: boolean;
  38499. /** Defines if vertex array objects are supported */
  38500. vertexArrayObject: boolean;
  38501. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38502. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38503. /** Gets the maximum level of anisotropy supported */
  38504. maxAnisotropy: number;
  38505. /** Defines if instancing is supported */
  38506. instancedArrays: boolean;
  38507. /** Defines if 32 bits indices are supported */
  38508. uintIndices: boolean;
  38509. /** Defines if high precision shaders are supported */
  38510. highPrecisionShaderSupported: boolean;
  38511. /** Defines if depth reading in the fragment shader is supported */
  38512. fragmentDepthSupported: boolean;
  38513. /** Defines if float texture linear filtering is supported*/
  38514. textureFloatLinearFiltering: boolean;
  38515. /** Defines if rendering to float textures is supported */
  38516. textureFloatRender: boolean;
  38517. /** Defines if half float textures are supported*/
  38518. textureHalfFloat: boolean;
  38519. /** Defines if half float texture linear filtering is supported*/
  38520. textureHalfFloatLinearFiltering: boolean;
  38521. /** Defines if rendering to half float textures is supported */
  38522. textureHalfFloatRender: boolean;
  38523. /** Defines if textureLOD shader command is supported */
  38524. textureLOD: boolean;
  38525. /** Defines if draw buffers extension is supported */
  38526. drawBuffersExtension: boolean;
  38527. /** Defines if depth textures are supported */
  38528. depthTextureExtension: boolean;
  38529. /** Defines if float color buffer are supported */
  38530. colorBufferFloat: boolean;
  38531. /** Gets disjoint timer query extension (null if not supported) */
  38532. timerQuery?: EXT_disjoint_timer_query;
  38533. /** Defines if timestamp can be used with timer query */
  38534. canUseTimestampForTimerQuery: boolean;
  38535. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38536. multiview?: any;
  38537. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38538. oculusMultiview?: any;
  38539. /** Function used to let the system compiles shaders in background */
  38540. parallelShaderCompile?: {
  38541. COMPLETION_STATUS_KHR: number;
  38542. };
  38543. /** Max number of texture samples for MSAA */
  38544. maxMSAASamples: number;
  38545. /** Defines if the blend min max extension is supported */
  38546. blendMinMax: boolean;
  38547. }
  38548. }
  38549. declare module BABYLON {
  38550. /**
  38551. * @hidden
  38552. **/
  38553. export class DepthCullingState {
  38554. private _isDepthTestDirty;
  38555. private _isDepthMaskDirty;
  38556. private _isDepthFuncDirty;
  38557. private _isCullFaceDirty;
  38558. private _isCullDirty;
  38559. private _isZOffsetDirty;
  38560. private _isFrontFaceDirty;
  38561. private _depthTest;
  38562. private _depthMask;
  38563. private _depthFunc;
  38564. private _cull;
  38565. private _cullFace;
  38566. private _zOffset;
  38567. private _frontFace;
  38568. /**
  38569. * Initializes the state.
  38570. */
  38571. constructor();
  38572. get isDirty(): boolean;
  38573. get zOffset(): number;
  38574. set zOffset(value: number);
  38575. get cullFace(): Nullable<number>;
  38576. set cullFace(value: Nullable<number>);
  38577. get cull(): Nullable<boolean>;
  38578. set cull(value: Nullable<boolean>);
  38579. get depthFunc(): Nullable<number>;
  38580. set depthFunc(value: Nullable<number>);
  38581. get depthMask(): boolean;
  38582. set depthMask(value: boolean);
  38583. get depthTest(): boolean;
  38584. set depthTest(value: boolean);
  38585. get frontFace(): Nullable<number>;
  38586. set frontFace(value: Nullable<number>);
  38587. reset(): void;
  38588. apply(gl: WebGLRenderingContext): void;
  38589. }
  38590. }
  38591. declare module BABYLON {
  38592. /**
  38593. * @hidden
  38594. **/
  38595. export class StencilState {
  38596. /** 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 */
  38597. static readonly ALWAYS: number;
  38598. /** Passed to stencilOperation to specify that stencil value must be kept */
  38599. static readonly KEEP: number;
  38600. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38601. static readonly REPLACE: number;
  38602. private _isStencilTestDirty;
  38603. private _isStencilMaskDirty;
  38604. private _isStencilFuncDirty;
  38605. private _isStencilOpDirty;
  38606. private _stencilTest;
  38607. private _stencilMask;
  38608. private _stencilFunc;
  38609. private _stencilFuncRef;
  38610. private _stencilFuncMask;
  38611. private _stencilOpStencilFail;
  38612. private _stencilOpDepthFail;
  38613. private _stencilOpStencilDepthPass;
  38614. get isDirty(): boolean;
  38615. get stencilFunc(): number;
  38616. set stencilFunc(value: number);
  38617. get stencilFuncRef(): number;
  38618. set stencilFuncRef(value: number);
  38619. get stencilFuncMask(): number;
  38620. set stencilFuncMask(value: number);
  38621. get stencilOpStencilFail(): number;
  38622. set stencilOpStencilFail(value: number);
  38623. get stencilOpDepthFail(): number;
  38624. set stencilOpDepthFail(value: number);
  38625. get stencilOpStencilDepthPass(): number;
  38626. set stencilOpStencilDepthPass(value: number);
  38627. get stencilMask(): number;
  38628. set stencilMask(value: number);
  38629. get stencilTest(): boolean;
  38630. set stencilTest(value: boolean);
  38631. constructor();
  38632. reset(): void;
  38633. apply(gl: WebGLRenderingContext): void;
  38634. }
  38635. }
  38636. declare module BABYLON {
  38637. /**
  38638. * @hidden
  38639. **/
  38640. export class AlphaState {
  38641. private _isAlphaBlendDirty;
  38642. private _isBlendFunctionParametersDirty;
  38643. private _isBlendEquationParametersDirty;
  38644. private _isBlendConstantsDirty;
  38645. private _alphaBlend;
  38646. private _blendFunctionParameters;
  38647. private _blendEquationParameters;
  38648. private _blendConstants;
  38649. /**
  38650. * Initializes the state.
  38651. */
  38652. constructor();
  38653. get isDirty(): boolean;
  38654. get alphaBlend(): boolean;
  38655. set alphaBlend(value: boolean);
  38656. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38657. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38658. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38659. reset(): void;
  38660. apply(gl: WebGLRenderingContext): void;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /** @hidden */
  38665. export class WebGLShaderProcessor implements IShaderProcessor {
  38666. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38667. }
  38668. }
  38669. declare module BABYLON {
  38670. /** @hidden */
  38671. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38672. attributeProcessor(attribute: string): string;
  38673. varyingProcessor(varying: string, isFragment: boolean): string;
  38674. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38675. }
  38676. }
  38677. declare module BABYLON {
  38678. /**
  38679. * Interface for attribute information associated with buffer instanciation
  38680. */
  38681. export interface InstancingAttributeInfo {
  38682. /**
  38683. * Name of the GLSL attribute
  38684. * if attribute index is not specified, this is used to retrieve the index from the effect
  38685. */
  38686. attributeName: string;
  38687. /**
  38688. * Index/offset of the attribute in the vertex shader
  38689. * if not specified, this will be computes from the name.
  38690. */
  38691. index?: number;
  38692. /**
  38693. * size of the attribute, 1, 2, 3 or 4
  38694. */
  38695. attributeSize: number;
  38696. /**
  38697. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38698. */
  38699. offset: number;
  38700. /**
  38701. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38702. * default to 1
  38703. */
  38704. divisor?: number;
  38705. /**
  38706. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38707. * default is FLOAT
  38708. */
  38709. attributeType?: number;
  38710. /**
  38711. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38712. */
  38713. normalized?: boolean;
  38714. }
  38715. }
  38716. declare module BABYLON {
  38717. interface ThinEngine {
  38718. /**
  38719. * Update a video texture
  38720. * @param texture defines the texture to update
  38721. * @param video defines the video element to use
  38722. * @param invertY defines if data must be stored with Y axis inverted
  38723. */
  38724. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38725. }
  38726. }
  38727. declare module BABYLON {
  38728. interface ThinEngine {
  38729. /**
  38730. * Creates a dynamic texture
  38731. * @param width defines the width of the texture
  38732. * @param height defines the height of the texture
  38733. * @param generateMipMaps defines if the engine should generate the mip levels
  38734. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38735. * @returns the dynamic texture inside an InternalTexture
  38736. */
  38737. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38738. /**
  38739. * Update the content of a dynamic texture
  38740. * @param texture defines the texture to update
  38741. * @param canvas defines the canvas containing the source
  38742. * @param invertY defines if data must be stored with Y axis inverted
  38743. * @param premulAlpha defines if alpha is stored as premultiplied
  38744. * @param format defines the format of the data
  38745. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38746. */
  38747. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38748. }
  38749. }
  38750. declare module BABYLON {
  38751. /**
  38752. * Settings for finer control over video usage
  38753. */
  38754. export interface VideoTextureSettings {
  38755. /**
  38756. * Applies `autoplay` to video, if specified
  38757. */
  38758. autoPlay?: boolean;
  38759. /**
  38760. * Applies `muted` to video, if specified
  38761. */
  38762. muted?: boolean;
  38763. /**
  38764. * Applies `loop` to video, if specified
  38765. */
  38766. loop?: boolean;
  38767. /**
  38768. * Automatically updates internal texture from video at every frame in the render loop
  38769. */
  38770. autoUpdateTexture: boolean;
  38771. /**
  38772. * Image src displayed during the video loading or until the user interacts with the video.
  38773. */
  38774. poster?: string;
  38775. }
  38776. /**
  38777. * If you want to display a video in your scene, this is the special texture for that.
  38778. * This special texture works similar to other textures, with the exception of a few parameters.
  38779. * @see https://doc.babylonjs.com/how_to/video_texture
  38780. */
  38781. export class VideoTexture extends Texture {
  38782. /**
  38783. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38784. */
  38785. readonly autoUpdateTexture: boolean;
  38786. /**
  38787. * The video instance used by the texture internally
  38788. */
  38789. readonly video: HTMLVideoElement;
  38790. private _onUserActionRequestedObservable;
  38791. /**
  38792. * Event triggerd when a dom action is required by the user to play the video.
  38793. * This happens due to recent changes in browser policies preventing video to auto start.
  38794. */
  38795. get onUserActionRequestedObservable(): Observable<Texture>;
  38796. private _generateMipMaps;
  38797. private _stillImageCaptured;
  38798. private _displayingPosterTexture;
  38799. private _settings;
  38800. private _createInternalTextureOnEvent;
  38801. private _frameId;
  38802. private _currentSrc;
  38803. /**
  38804. * Creates a video texture.
  38805. * If you want to display a video in your scene, this is the special texture for that.
  38806. * This special texture works similar to other textures, with the exception of a few parameters.
  38807. * @see https://doc.babylonjs.com/how_to/video_texture
  38808. * @param name optional name, will detect from video source, if not defined
  38809. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38810. * @param scene is obviously the current scene.
  38811. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38812. * @param invertY is false by default but can be used to invert video on Y axis
  38813. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38814. * @param settings allows finer control over video usage
  38815. */
  38816. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38817. private _getName;
  38818. private _getVideo;
  38819. private _createInternalTexture;
  38820. private reset;
  38821. /**
  38822. * @hidden Internal method to initiate `update`.
  38823. */
  38824. _rebuild(): void;
  38825. /**
  38826. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38827. */
  38828. update(): void;
  38829. /**
  38830. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38831. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38832. */
  38833. updateTexture(isVisible: boolean): void;
  38834. protected _updateInternalTexture: () => void;
  38835. /**
  38836. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38837. * @param url New url.
  38838. */
  38839. updateURL(url: string): void;
  38840. /**
  38841. * Clones the texture.
  38842. * @returns the cloned texture
  38843. */
  38844. clone(): VideoTexture;
  38845. /**
  38846. * Dispose the texture and release its associated resources.
  38847. */
  38848. dispose(): void;
  38849. /**
  38850. * Creates a video texture straight from a stream.
  38851. * @param scene Define the scene the texture should be created in
  38852. * @param stream Define the stream the texture should be created from
  38853. * @returns The created video texture as a promise
  38854. */
  38855. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38856. /**
  38857. * Creates a video texture straight from your WebCam video feed.
  38858. * @param scene Define the scene the texture should be created in
  38859. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38860. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38861. * @returns The created video texture as a promise
  38862. */
  38863. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38864. minWidth: number;
  38865. maxWidth: number;
  38866. minHeight: number;
  38867. maxHeight: number;
  38868. deviceId: string;
  38869. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38870. /**
  38871. * Creates a video texture straight from your WebCam video feed.
  38872. * @param scene Define the scene the texture should be created in
  38873. * @param onReady Define a callback to triggered once the texture will be ready
  38874. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38875. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38876. */
  38877. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38878. minWidth: number;
  38879. maxWidth: number;
  38880. minHeight: number;
  38881. maxHeight: number;
  38882. deviceId: string;
  38883. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38884. }
  38885. }
  38886. declare module BABYLON {
  38887. /**
  38888. * Defines the interface used by objects working like Scene
  38889. * @hidden
  38890. */
  38891. export interface ISceneLike {
  38892. _addPendingData(data: any): void;
  38893. _removePendingData(data: any): void;
  38894. offlineProvider: IOfflineProvider;
  38895. }
  38896. /**
  38897. * Information about the current host
  38898. */
  38899. export interface HostInformation {
  38900. /**
  38901. * Defines if the current host is a mobile
  38902. */
  38903. isMobile: boolean;
  38904. }
  38905. /** Interface defining initialization parameters for Engine class */
  38906. export interface EngineOptions extends WebGLContextAttributes {
  38907. /**
  38908. * Defines if the engine should no exceed a specified device ratio
  38909. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38910. */
  38911. limitDeviceRatio?: number;
  38912. /**
  38913. * Defines if webvr should be enabled automatically
  38914. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38915. */
  38916. autoEnableWebVR?: boolean;
  38917. /**
  38918. * Defines if webgl2 should be turned off even if supported
  38919. * @see https://doc.babylonjs.com/features/webgl2
  38920. */
  38921. disableWebGL2Support?: boolean;
  38922. /**
  38923. * Defines if webaudio should be initialized as well
  38924. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38925. */
  38926. audioEngine?: boolean;
  38927. /**
  38928. * Defines if animations should run using a deterministic lock step
  38929. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38930. */
  38931. deterministicLockstep?: boolean;
  38932. /** Defines the maximum steps to use with deterministic lock step mode */
  38933. lockstepMaxSteps?: number;
  38934. /** Defines the seconds between each deterministic lock step */
  38935. timeStep?: number;
  38936. /**
  38937. * Defines that engine should ignore context lost events
  38938. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38939. */
  38940. doNotHandleContextLost?: boolean;
  38941. /**
  38942. * Defines that engine should ignore modifying touch action attribute and style
  38943. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38944. */
  38945. doNotHandleTouchAction?: boolean;
  38946. /**
  38947. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38948. */
  38949. useHighPrecisionFloats?: boolean;
  38950. /**
  38951. * Make the canvas XR Compatible for XR sessions
  38952. */
  38953. xrCompatible?: boolean;
  38954. /**
  38955. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38956. */
  38957. useHighPrecisionMatrix?: boolean;
  38958. /**
  38959. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38960. */
  38961. failIfMajorPerformanceCaveat?: boolean;
  38962. }
  38963. /**
  38964. * The base engine class (root of all engines)
  38965. */
  38966. export class ThinEngine {
  38967. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38968. static ExceptionList: ({
  38969. key: string;
  38970. capture: string;
  38971. captureConstraint: number;
  38972. targets: string[];
  38973. } | {
  38974. key: string;
  38975. capture: null;
  38976. captureConstraint: null;
  38977. targets: string[];
  38978. })[];
  38979. /** @hidden */
  38980. static _TextureLoaders: IInternalTextureLoader[];
  38981. /**
  38982. * Returns the current npm package of the sdk
  38983. */
  38984. static get NpmPackage(): string;
  38985. /**
  38986. * Returns the current version of the framework
  38987. */
  38988. static get Version(): string;
  38989. /**
  38990. * Returns a string describing the current engine
  38991. */
  38992. get description(): string;
  38993. /**
  38994. * Gets or sets the epsilon value used by collision engine
  38995. */
  38996. static CollisionsEpsilon: number;
  38997. /**
  38998. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38999. */
  39000. static get ShadersRepository(): string;
  39001. static set ShadersRepository(value: string);
  39002. /** @hidden */
  39003. _shaderProcessor: IShaderProcessor;
  39004. /**
  39005. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39006. */
  39007. forcePOTTextures: boolean;
  39008. /**
  39009. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39010. */
  39011. isFullscreen: boolean;
  39012. /**
  39013. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39014. */
  39015. cullBackFaces: boolean;
  39016. /**
  39017. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39018. */
  39019. renderEvenInBackground: boolean;
  39020. /**
  39021. * Gets or sets a boolean indicating that cache can be kept between frames
  39022. */
  39023. preventCacheWipeBetweenFrames: boolean;
  39024. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39025. validateShaderPrograms: boolean;
  39026. /**
  39027. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39028. * This can provide greater z depth for distant objects.
  39029. */
  39030. useReverseDepthBuffer: boolean;
  39031. /**
  39032. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39033. */
  39034. disableUniformBuffers: boolean;
  39035. /** @hidden */
  39036. _uniformBuffers: UniformBuffer[];
  39037. /**
  39038. * Gets a boolean indicating that the engine supports uniform buffers
  39039. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39040. */
  39041. get supportsUniformBuffers(): boolean;
  39042. /** @hidden */
  39043. _gl: WebGLRenderingContext;
  39044. /** @hidden */
  39045. _webGLVersion: number;
  39046. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39047. protected _windowIsBackground: boolean;
  39048. protected _creationOptions: EngineOptions;
  39049. protected _highPrecisionShadersAllowed: boolean;
  39050. /** @hidden */
  39051. get _shouldUseHighPrecisionShader(): boolean;
  39052. /**
  39053. * Gets a boolean indicating that only power of 2 textures are supported
  39054. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39055. */
  39056. get needPOTTextures(): boolean;
  39057. /** @hidden */
  39058. _badOS: boolean;
  39059. /** @hidden */
  39060. _badDesktopOS: boolean;
  39061. private _hardwareScalingLevel;
  39062. /** @hidden */
  39063. _caps: EngineCapabilities;
  39064. private _isStencilEnable;
  39065. private _glVersion;
  39066. private _glRenderer;
  39067. private _glVendor;
  39068. /** @hidden */
  39069. _videoTextureSupported: boolean;
  39070. protected _renderingQueueLaunched: boolean;
  39071. protected _activeRenderLoops: (() => void)[];
  39072. /**
  39073. * Observable signaled when a context lost event is raised
  39074. */
  39075. onContextLostObservable: Observable<ThinEngine>;
  39076. /**
  39077. * Observable signaled when a context restored event is raised
  39078. */
  39079. onContextRestoredObservable: Observable<ThinEngine>;
  39080. private _onContextLost;
  39081. private _onContextRestored;
  39082. protected _contextWasLost: boolean;
  39083. /** @hidden */
  39084. _doNotHandleContextLost: boolean;
  39085. /**
  39086. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39088. */
  39089. get doNotHandleContextLost(): boolean;
  39090. set doNotHandleContextLost(value: boolean);
  39091. /**
  39092. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39093. */
  39094. disableVertexArrayObjects: boolean;
  39095. /** @hidden */
  39096. protected _colorWrite: boolean;
  39097. /** @hidden */
  39098. protected _colorWriteChanged: boolean;
  39099. /** @hidden */
  39100. protected _depthCullingState: DepthCullingState;
  39101. /** @hidden */
  39102. protected _stencilState: StencilState;
  39103. /** @hidden */
  39104. _alphaState: AlphaState;
  39105. /** @hidden */
  39106. _alphaMode: number;
  39107. /** @hidden */
  39108. _alphaEquation: number;
  39109. /** @hidden */
  39110. _internalTexturesCache: InternalTexture[];
  39111. /** @hidden */
  39112. protected _activeChannel: number;
  39113. private _currentTextureChannel;
  39114. /** @hidden */
  39115. protected _boundTexturesCache: {
  39116. [key: string]: Nullable<InternalTexture>;
  39117. };
  39118. /** @hidden */
  39119. protected _currentEffect: Nullable<Effect>;
  39120. /** @hidden */
  39121. protected _currentProgram: Nullable<WebGLProgram>;
  39122. private _compiledEffects;
  39123. private _vertexAttribArraysEnabled;
  39124. /** @hidden */
  39125. protected _cachedViewport: Nullable<IViewportLike>;
  39126. private _cachedVertexArrayObject;
  39127. /** @hidden */
  39128. protected _cachedVertexBuffers: any;
  39129. /** @hidden */
  39130. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39131. /** @hidden */
  39132. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39133. /** @hidden */
  39134. _currentRenderTarget: Nullable<InternalTexture>;
  39135. private _uintIndicesCurrentlySet;
  39136. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39137. /** @hidden */
  39138. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39139. /** @hidden */
  39140. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39141. private _currentBufferPointers;
  39142. private _currentInstanceLocations;
  39143. private _currentInstanceBuffers;
  39144. private _textureUnits;
  39145. /** @hidden */
  39146. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39147. /** @hidden */
  39148. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39149. /** @hidden */
  39150. _boundRenderFunction: any;
  39151. private _vaoRecordInProgress;
  39152. private _mustWipeVertexAttributes;
  39153. private _emptyTexture;
  39154. private _emptyCubeTexture;
  39155. private _emptyTexture3D;
  39156. private _emptyTexture2DArray;
  39157. /** @hidden */
  39158. _frameHandler: number;
  39159. private _nextFreeTextureSlots;
  39160. private _maxSimultaneousTextures;
  39161. private _activeRequests;
  39162. /** @hidden */
  39163. _transformTextureUrl: Nullable<(url: string) => string>;
  39164. /**
  39165. * Gets information about the current host
  39166. */
  39167. hostInformation: HostInformation;
  39168. protected get _supportsHardwareTextureRescaling(): boolean;
  39169. private _framebufferDimensionsObject;
  39170. /**
  39171. * sets the object from which width and height will be taken from when getting render width and height
  39172. * Will fallback to the gl object
  39173. * @param dimensions the framebuffer width and height that will be used.
  39174. */
  39175. set framebufferDimensionsObject(dimensions: Nullable<{
  39176. framebufferWidth: number;
  39177. framebufferHeight: number;
  39178. }>);
  39179. /**
  39180. * Gets the current viewport
  39181. */
  39182. get currentViewport(): Nullable<IViewportLike>;
  39183. /**
  39184. * Gets the default empty texture
  39185. */
  39186. get emptyTexture(): InternalTexture;
  39187. /**
  39188. * Gets the default empty 3D texture
  39189. */
  39190. get emptyTexture3D(): InternalTexture;
  39191. /**
  39192. * Gets the default empty 2D array texture
  39193. */
  39194. get emptyTexture2DArray(): InternalTexture;
  39195. /**
  39196. * Gets the default empty cube texture
  39197. */
  39198. get emptyCubeTexture(): InternalTexture;
  39199. /**
  39200. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39201. */
  39202. readonly premultipliedAlpha: boolean;
  39203. /**
  39204. * Observable event triggered before each texture is initialized
  39205. */
  39206. onBeforeTextureInitObservable: Observable<Texture>;
  39207. /**
  39208. * Creates a new engine
  39209. * @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
  39210. * @param antialias defines enable antialiasing (default: false)
  39211. * @param options defines further options to be sent to the getContext() function
  39212. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39213. */
  39214. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39215. private _rebuildInternalTextures;
  39216. private _rebuildEffects;
  39217. /**
  39218. * Gets a boolean indicating if all created effects are ready
  39219. * @returns true if all effects are ready
  39220. */
  39221. areAllEffectsReady(): boolean;
  39222. protected _rebuildBuffers(): void;
  39223. protected _initGLContext(): void;
  39224. /**
  39225. * Gets version of the current webGL context
  39226. */
  39227. get webGLVersion(): number;
  39228. /**
  39229. * Gets a string identifying the name of the class
  39230. * @returns "Engine" string
  39231. */
  39232. getClassName(): string;
  39233. /**
  39234. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39235. */
  39236. get isStencilEnable(): boolean;
  39237. /** @hidden */
  39238. _prepareWorkingCanvas(): void;
  39239. /**
  39240. * Reset the texture cache to empty state
  39241. */
  39242. resetTextureCache(): void;
  39243. /**
  39244. * Gets an object containing information about the current webGL context
  39245. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39246. */
  39247. getGlInfo(): {
  39248. vendor: string;
  39249. renderer: string;
  39250. version: string;
  39251. };
  39252. /**
  39253. * Defines the hardware scaling level.
  39254. * By default the hardware scaling level is computed from the window device ratio.
  39255. * 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.
  39256. * @param level defines the level to use
  39257. */
  39258. setHardwareScalingLevel(level: number): void;
  39259. /**
  39260. * Gets the current hardware scaling level.
  39261. * By default the hardware scaling level is computed from the window device ratio.
  39262. * 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.
  39263. * @returns a number indicating the current hardware scaling level
  39264. */
  39265. getHardwareScalingLevel(): number;
  39266. /**
  39267. * Gets the list of loaded textures
  39268. * @returns an array containing all loaded textures
  39269. */
  39270. getLoadedTexturesCache(): InternalTexture[];
  39271. /**
  39272. * Gets the object containing all engine capabilities
  39273. * @returns the EngineCapabilities object
  39274. */
  39275. getCaps(): EngineCapabilities;
  39276. /**
  39277. * stop executing a render loop function and remove it from the execution array
  39278. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39279. */
  39280. stopRenderLoop(renderFunction?: () => void): void;
  39281. /** @hidden */
  39282. _renderLoop(): void;
  39283. /**
  39284. * Gets the HTML canvas attached with the current webGL context
  39285. * @returns a HTML canvas
  39286. */
  39287. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39288. /**
  39289. * Gets host window
  39290. * @returns the host window object
  39291. */
  39292. getHostWindow(): Nullable<Window>;
  39293. /**
  39294. * Gets the current render width
  39295. * @param useScreen defines if screen size must be used (or the current render target if any)
  39296. * @returns a number defining the current render width
  39297. */
  39298. getRenderWidth(useScreen?: boolean): number;
  39299. /**
  39300. * Gets the current render height
  39301. * @param useScreen defines if screen size must be used (or the current render target if any)
  39302. * @returns a number defining the current render height
  39303. */
  39304. getRenderHeight(useScreen?: boolean): number;
  39305. /**
  39306. * Can be used to override the current requestAnimationFrame requester.
  39307. * @hidden
  39308. */
  39309. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39310. /**
  39311. * Register and execute a render loop. The engine can have more than one render function
  39312. * @param renderFunction defines the function to continuously execute
  39313. */
  39314. runRenderLoop(renderFunction: () => void): void;
  39315. /**
  39316. * Clear the current render buffer or the current render target (if any is set up)
  39317. * @param color defines the color to use
  39318. * @param backBuffer defines if the back buffer must be cleared
  39319. * @param depth defines if the depth buffer must be cleared
  39320. * @param stencil defines if the stencil buffer must be cleared
  39321. */
  39322. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39323. private _viewportCached;
  39324. /** @hidden */
  39325. _viewport(x: number, y: number, width: number, height: number): void;
  39326. /**
  39327. * Set the WebGL's viewport
  39328. * @param viewport defines the viewport element to be used
  39329. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39330. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39331. */
  39332. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39333. /**
  39334. * Begin a new frame
  39335. */
  39336. beginFrame(): void;
  39337. /**
  39338. * Enf the current frame
  39339. */
  39340. endFrame(): void;
  39341. /**
  39342. * Resize the view according to the canvas' size
  39343. */
  39344. resize(): void;
  39345. /**
  39346. * Force a specific size of the canvas
  39347. * @param width defines the new canvas' width
  39348. * @param height defines the new canvas' height
  39349. * @returns true if the size was changed
  39350. */
  39351. setSize(width: number, height: number): boolean;
  39352. /**
  39353. * Binds the frame buffer to the specified texture.
  39354. * @param texture The texture to render to or null for the default canvas
  39355. * @param faceIndex The face of the texture to render to in case of cube texture
  39356. * @param requiredWidth The width of the target to render to
  39357. * @param requiredHeight The height of the target to render to
  39358. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39359. * @param lodLevel defines the lod level to bind to the frame buffer
  39360. * @param layer defines the 2d array index to bind to frame buffer to
  39361. */
  39362. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39363. /** @hidden */
  39364. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39365. /**
  39366. * Unbind the current render target texture from the webGL context
  39367. * @param texture defines the render target texture to unbind
  39368. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39369. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39370. */
  39371. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39372. /**
  39373. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39374. */
  39375. flushFramebuffer(): void;
  39376. /**
  39377. * Unbind the current render target and bind the default framebuffer
  39378. */
  39379. restoreDefaultFramebuffer(): void;
  39380. /** @hidden */
  39381. protected _resetVertexBufferBinding(): void;
  39382. /**
  39383. * Creates a vertex buffer
  39384. * @param data the data for the vertex buffer
  39385. * @returns the new WebGL static buffer
  39386. */
  39387. createVertexBuffer(data: DataArray): DataBuffer;
  39388. private _createVertexBuffer;
  39389. /**
  39390. * Creates a dynamic vertex buffer
  39391. * @param data the data for the dynamic vertex buffer
  39392. * @returns the new WebGL dynamic buffer
  39393. */
  39394. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39395. protected _resetIndexBufferBinding(): void;
  39396. /**
  39397. * Creates a new index buffer
  39398. * @param indices defines the content of the index buffer
  39399. * @param updatable defines if the index buffer must be updatable
  39400. * @returns a new webGL buffer
  39401. */
  39402. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39403. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39404. /**
  39405. * Bind a webGL buffer to the webGL context
  39406. * @param buffer defines the buffer to bind
  39407. */
  39408. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39409. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39410. private bindBuffer;
  39411. /**
  39412. * update the bound buffer with the given data
  39413. * @param data defines the data to update
  39414. */
  39415. updateArrayBuffer(data: Float32Array): void;
  39416. private _vertexAttribPointer;
  39417. /** @hidden */
  39418. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39419. private _bindVertexBuffersAttributes;
  39420. /**
  39421. * Records a vertex array object
  39422. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39423. * @param vertexBuffers defines the list of vertex buffers to store
  39424. * @param indexBuffer defines the index buffer to store
  39425. * @param effect defines the effect to store
  39426. * @returns the new vertex array object
  39427. */
  39428. recordVertexArrayObject(vertexBuffers: {
  39429. [key: string]: VertexBuffer;
  39430. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39431. /**
  39432. * Bind a specific vertex array object
  39433. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39434. * @param vertexArrayObject defines the vertex array object to bind
  39435. * @param indexBuffer defines the index buffer to bind
  39436. */
  39437. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39438. /**
  39439. * Bind webGl buffers directly to the webGL context
  39440. * @param vertexBuffer defines the vertex buffer to bind
  39441. * @param indexBuffer defines the index buffer to bind
  39442. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39443. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39444. * @param effect defines the effect associated with the vertex buffer
  39445. */
  39446. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39447. private _unbindVertexArrayObject;
  39448. /**
  39449. * Bind a list of vertex buffers to the webGL context
  39450. * @param vertexBuffers defines the list of vertex buffers to bind
  39451. * @param indexBuffer defines the index buffer to bind
  39452. * @param effect defines the effect associated with the vertex buffers
  39453. */
  39454. bindBuffers(vertexBuffers: {
  39455. [key: string]: Nullable<VertexBuffer>;
  39456. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39457. /**
  39458. * Unbind all instance attributes
  39459. */
  39460. unbindInstanceAttributes(): void;
  39461. /**
  39462. * Release and free the memory of a vertex array object
  39463. * @param vao defines the vertex array object to delete
  39464. */
  39465. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39466. /** @hidden */
  39467. _releaseBuffer(buffer: DataBuffer): boolean;
  39468. protected _deleteBuffer(buffer: DataBuffer): void;
  39469. /**
  39470. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39471. * @param instancesBuffer defines the webGL buffer to update and bind
  39472. * @param data defines the data to store in the buffer
  39473. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39474. */
  39475. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39476. /**
  39477. * Bind the content of a webGL buffer used with instantiation
  39478. * @param instancesBuffer defines the webGL buffer to bind
  39479. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39480. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39481. */
  39482. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39483. /**
  39484. * Disable the instance attribute corresponding to the name in parameter
  39485. * @param name defines the name of the attribute to disable
  39486. */
  39487. disableInstanceAttributeByName(name: string): void;
  39488. /**
  39489. * Disable the instance attribute corresponding to the location in parameter
  39490. * @param attributeLocation defines the attribute location of the attribute to disable
  39491. */
  39492. disableInstanceAttribute(attributeLocation: number): void;
  39493. /**
  39494. * Disable the attribute corresponding to the location in parameter
  39495. * @param attributeLocation defines the attribute location of the attribute to disable
  39496. */
  39497. disableAttributeByIndex(attributeLocation: number): void;
  39498. /**
  39499. * Send a draw order
  39500. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39501. * @param indexStart defines the starting index
  39502. * @param indexCount defines the number of index to draw
  39503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39504. */
  39505. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39506. /**
  39507. * Draw a list of points
  39508. * @param verticesStart defines the index of first vertex to draw
  39509. * @param verticesCount defines the count of vertices to draw
  39510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39511. */
  39512. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39513. /**
  39514. * Draw a list of unindexed primitives
  39515. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39516. * @param verticesStart defines the index of first vertex to draw
  39517. * @param verticesCount defines the count of vertices to draw
  39518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39519. */
  39520. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39521. /**
  39522. * Draw a list of indexed primitives
  39523. * @param fillMode defines the primitive to use
  39524. * @param indexStart defines the starting index
  39525. * @param indexCount defines the number of index to draw
  39526. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39527. */
  39528. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39529. /**
  39530. * Draw a list of unindexed primitives
  39531. * @param fillMode defines the primitive to use
  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. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39537. private _drawMode;
  39538. /** @hidden */
  39539. protected _reportDrawCall(): void;
  39540. /** @hidden */
  39541. _releaseEffect(effect: Effect): void;
  39542. /** @hidden */
  39543. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39544. /**
  39545. * Create a new effect (used to store vertex/fragment shaders)
  39546. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39547. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39548. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39549. * @param samplers defines an array of string used to represent textures
  39550. * @param defines defines the string containing the defines to use to compile the shaders
  39551. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39552. * @param onCompiled defines a function to call when the effect creation is successful
  39553. * @param onError defines a function to call when the effect creation has failed
  39554. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39555. * @returns the new Effect
  39556. */
  39557. 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;
  39558. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39559. private _compileShader;
  39560. private _compileRawShader;
  39561. /** @hidden */
  39562. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39563. /**
  39564. * Directly creates a webGL program
  39565. * @param pipelineContext defines the pipeline context to attach to
  39566. * @param vertexCode defines the vertex shader code to use
  39567. * @param fragmentCode defines the fragment shader code to use
  39568. * @param context defines the webGL context to use (if not set, the current one will be used)
  39569. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39570. * @returns the new webGL program
  39571. */
  39572. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39573. /**
  39574. * Creates a webGL program
  39575. * @param pipelineContext defines the pipeline context to attach to
  39576. * @param vertexCode defines the vertex shader code to use
  39577. * @param fragmentCode defines the fragment shader code to use
  39578. * @param defines defines the string containing the defines to use to compile the shaders
  39579. * @param context defines the webGL context to use (if not set, the current one will be used)
  39580. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39581. * @returns the new webGL program
  39582. */
  39583. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39584. /**
  39585. * Creates a new pipeline context
  39586. * @returns the new pipeline
  39587. */
  39588. createPipelineContext(): IPipelineContext;
  39589. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39590. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39591. /** @hidden */
  39592. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39593. /** @hidden */
  39594. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39595. /** @hidden */
  39596. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39597. /**
  39598. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39599. * @param pipelineContext defines the pipeline context to use
  39600. * @param uniformsNames defines the list of uniform names
  39601. * @returns an array of webGL uniform locations
  39602. */
  39603. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39604. /**
  39605. * Gets the lsit of active attributes for a given webGL program
  39606. * @param pipelineContext defines the pipeline context to use
  39607. * @param attributesNames defines the list of attribute names to get
  39608. * @returns an array of indices indicating the offset of each attribute
  39609. */
  39610. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39611. /**
  39612. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39613. * @param effect defines the effect to activate
  39614. */
  39615. enableEffect(effect: Nullable<Effect>): void;
  39616. /**
  39617. * Set the value of an uniform to a number (int)
  39618. * @param uniform defines the webGL uniform location where to store the value
  39619. * @param value defines the int number to store
  39620. * @returns true if the value was set
  39621. */
  39622. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39623. /**
  39624. * Set the value of an uniform to an array of int32
  39625. * @param uniform defines the webGL uniform location where to store the value
  39626. * @param array defines the array of int32 to store
  39627. * @returns true if the value was set
  39628. */
  39629. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39630. /**
  39631. * Set the value of an uniform to an array of int32 (stored as vec2)
  39632. * @param uniform defines the webGL uniform location where to store the value
  39633. * @param array defines the array of int32 to store
  39634. * @returns true if the value was set
  39635. */
  39636. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39637. /**
  39638. * Set the value of an uniform to an array of int32 (stored as vec3)
  39639. * @param uniform defines the webGL uniform location where to store the value
  39640. * @param array defines the array of int32 to store
  39641. * @returns true if the value was set
  39642. */
  39643. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39644. /**
  39645. * Set the value of an uniform to an array of int32 (stored as vec4)
  39646. * @param uniform defines the webGL uniform location where to store the value
  39647. * @param array defines the array of int32 to store
  39648. * @returns true if the value was set
  39649. */
  39650. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39651. /**
  39652. * Set the value of an uniform to an array of number
  39653. * @param uniform defines the webGL uniform location where to store the value
  39654. * @param array defines the array of number to store
  39655. * @returns true if the value was set
  39656. */
  39657. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39658. /**
  39659. * Set the value of an uniform to an array of number (stored as vec2)
  39660. * @param uniform defines the webGL uniform location where to store the value
  39661. * @param array defines the array of number to store
  39662. * @returns true if the value was set
  39663. */
  39664. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39665. /**
  39666. * Set the value of an uniform to an array of number (stored as vec3)
  39667. * @param uniform defines the webGL uniform location where to store the value
  39668. * @param array defines the array of number to store
  39669. * @returns true if the value was set
  39670. */
  39671. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39672. /**
  39673. * Set the value of an uniform to an array of number (stored as vec4)
  39674. * @param uniform defines the webGL uniform location where to store the value
  39675. * @param array defines the array of number to store
  39676. * @returns true if the value was set
  39677. */
  39678. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39679. /**
  39680. * Set the value of an uniform to an array of float32 (stored as matrices)
  39681. * @param uniform defines the webGL uniform location where to store the value
  39682. * @param matrices defines the array of float32 to store
  39683. * @returns true if the value was set
  39684. */
  39685. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39686. /**
  39687. * Set the value of an uniform to a matrix (3x3)
  39688. * @param uniform defines the webGL uniform location where to store the value
  39689. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39690. * @returns true if the value was set
  39691. */
  39692. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39693. /**
  39694. * Set the value of an uniform to a matrix (2x2)
  39695. * @param uniform defines the webGL uniform location where to store the value
  39696. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39697. * @returns true if the value was set
  39698. */
  39699. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39700. /**
  39701. * Set the value of an uniform to a number (float)
  39702. * @param uniform defines the webGL uniform location where to store the value
  39703. * @param value defines the float number to store
  39704. * @returns true if the value was transfered
  39705. */
  39706. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39707. /**
  39708. * Set the value of an uniform to a vec2
  39709. * @param uniform defines the webGL uniform location where to store the value
  39710. * @param x defines the 1st component of the value
  39711. * @param y defines the 2nd component of the value
  39712. * @returns true if the value was set
  39713. */
  39714. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39715. /**
  39716. * Set the value of an uniform to a vec3
  39717. * @param uniform defines the webGL uniform location where to store the value
  39718. * @param x defines the 1st component of the value
  39719. * @param y defines the 2nd component of the value
  39720. * @param z defines the 3rd component of the value
  39721. * @returns true if the value was set
  39722. */
  39723. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39724. /**
  39725. * Set the value of an uniform to a vec4
  39726. * @param uniform defines the webGL uniform location where to store the value
  39727. * @param x defines the 1st component of the value
  39728. * @param y defines the 2nd component of the value
  39729. * @param z defines the 3rd component of the value
  39730. * @param w defines the 4th component of the value
  39731. * @returns true if the value was set
  39732. */
  39733. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39734. /**
  39735. * Apply all cached states (depth, culling, stencil and alpha)
  39736. */
  39737. applyStates(): void;
  39738. /**
  39739. * Enable or disable color writing
  39740. * @param enable defines the state to set
  39741. */
  39742. setColorWrite(enable: boolean): void;
  39743. /**
  39744. * Gets a boolean indicating if color writing is enabled
  39745. * @returns the current color writing state
  39746. */
  39747. getColorWrite(): boolean;
  39748. /**
  39749. * Gets the depth culling state manager
  39750. */
  39751. get depthCullingState(): DepthCullingState;
  39752. /**
  39753. * Gets the alpha state manager
  39754. */
  39755. get alphaState(): AlphaState;
  39756. /**
  39757. * Gets the stencil state manager
  39758. */
  39759. get stencilState(): StencilState;
  39760. /**
  39761. * Clears the list of texture accessible through engine.
  39762. * This can help preventing texture load conflict due to name collision.
  39763. */
  39764. clearInternalTexturesCache(): void;
  39765. /**
  39766. * Force the entire cache to be cleared
  39767. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39768. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39769. */
  39770. wipeCaches(bruteForce?: boolean): void;
  39771. /** @hidden */
  39772. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39773. min: number;
  39774. mag: number;
  39775. };
  39776. /** @hidden */
  39777. _createTexture(): WebGLTexture;
  39778. /**
  39779. * Usually called from Texture.ts.
  39780. * Passed information to create a WebGLTexture
  39781. * @param url defines a value which contains one of the following:
  39782. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39783. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39784. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39785. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39786. * @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)
  39787. * @param scene needed for loading to the correct scene
  39788. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39789. * @param onLoad optional callback to be called upon successful completion
  39790. * @param onError optional callback to be called upon failure
  39791. * @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
  39792. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39793. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39794. * @param forcedExtension defines the extension to use to pick the right loader
  39795. * @param mimeType defines an optional mime type
  39796. * @param loaderOptions options to be passed to the loader
  39797. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39798. */
  39799. 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;
  39800. /**
  39801. * Loads an image as an HTMLImageElement.
  39802. * @param input url string, ArrayBuffer, or Blob to load
  39803. * @param onLoad callback called when the image successfully loads
  39804. * @param onError callback called when the image fails to load
  39805. * @param offlineProvider offline provider for caching
  39806. * @param mimeType optional mime type
  39807. * @returns the HTMLImageElement of the loaded image
  39808. * @hidden
  39809. */
  39810. 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>;
  39811. /**
  39812. * @hidden
  39813. */
  39814. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39815. private _unpackFlipYCached;
  39816. /**
  39817. * In case you are sharing the context with other applications, it might
  39818. * be interested to not cache the unpack flip y state to ensure a consistent
  39819. * value would be set.
  39820. */
  39821. enableUnpackFlipYCached: boolean;
  39822. /** @hidden */
  39823. _unpackFlipY(value: boolean): void;
  39824. /** @hidden */
  39825. _getUnpackAlignement(): number;
  39826. private _getTextureTarget;
  39827. /**
  39828. * Update the sampling mode of a given texture
  39829. * @param samplingMode defines the required sampling mode
  39830. * @param texture defines the texture to update
  39831. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39832. */
  39833. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39834. /**
  39835. * Update the sampling mode of a given texture
  39836. * @param texture defines the texture to update
  39837. * @param wrapU defines the texture wrap mode of the u coordinates
  39838. * @param wrapV defines the texture wrap mode of the v coordinates
  39839. * @param wrapR defines the texture wrap mode of the r coordinates
  39840. */
  39841. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39842. /** @hidden */
  39843. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39844. width: number;
  39845. height: number;
  39846. layers?: number;
  39847. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39848. /** @hidden */
  39849. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39850. /** @hidden */
  39851. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39852. /**
  39853. * Update a portion of an internal texture
  39854. * @param texture defines the texture to update
  39855. * @param imageData defines the data to store into the texture
  39856. * @param xOffset defines the x coordinates of the update rectangle
  39857. * @param yOffset defines the y coordinates of the update rectangle
  39858. * @param width defines the width of the update rectangle
  39859. * @param height defines the height of the update rectangle
  39860. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39861. * @param lod defines the lod level to update (0 by default)
  39862. */
  39863. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39864. /** @hidden */
  39865. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39866. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39867. private _prepareWebGLTexture;
  39868. /** @hidden */
  39869. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39870. private _getDepthStencilBuffer;
  39871. /** @hidden */
  39872. _releaseFramebufferObjects(texture: InternalTexture): void;
  39873. /** @hidden */
  39874. _releaseTexture(texture: InternalTexture): void;
  39875. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39876. protected _setProgram(program: WebGLProgram): void;
  39877. protected _boundUniforms: {
  39878. [key: number]: WebGLUniformLocation;
  39879. };
  39880. /**
  39881. * Binds an effect to the webGL context
  39882. * @param effect defines the effect to bind
  39883. */
  39884. bindSamplers(effect: Effect): void;
  39885. private _activateCurrentTexture;
  39886. /** @hidden */
  39887. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39888. /** @hidden */
  39889. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39890. /**
  39891. * Unbind all textures from the webGL context
  39892. */
  39893. unbindAllTextures(): void;
  39894. /**
  39895. * Sets a texture to the according uniform.
  39896. * @param channel The texture channel
  39897. * @param uniform The uniform to set
  39898. * @param texture The texture to apply
  39899. */
  39900. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39901. private _bindSamplerUniformToChannel;
  39902. private _getTextureWrapMode;
  39903. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39904. /**
  39905. * Sets an array of texture to the webGL context
  39906. * @param channel defines the channel where the texture array must be set
  39907. * @param uniform defines the associated uniform location
  39908. * @param textures defines the array of textures to bind
  39909. */
  39910. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39911. /** @hidden */
  39912. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39913. private _setTextureParameterFloat;
  39914. private _setTextureParameterInteger;
  39915. /**
  39916. * Unbind all vertex attributes from the webGL context
  39917. */
  39918. unbindAllAttributes(): void;
  39919. /**
  39920. * 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
  39921. */
  39922. releaseEffects(): void;
  39923. /**
  39924. * Dispose and release all associated resources
  39925. */
  39926. dispose(): void;
  39927. /**
  39928. * Attach a new callback raised when context lost event is fired
  39929. * @param callback defines the callback to call
  39930. */
  39931. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39932. /**
  39933. * Attach a new callback raised when context restored event is fired
  39934. * @param callback defines the callback to call
  39935. */
  39936. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39937. /**
  39938. * Get the current error code of the webGL context
  39939. * @returns the error code
  39940. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39941. */
  39942. getError(): number;
  39943. private _canRenderToFloatFramebuffer;
  39944. private _canRenderToHalfFloatFramebuffer;
  39945. private _canRenderToFramebuffer;
  39946. /** @hidden */
  39947. _getWebGLTextureType(type: number): number;
  39948. /** @hidden */
  39949. _getInternalFormat(format: number): number;
  39950. /** @hidden */
  39951. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39952. /** @hidden */
  39953. _getRGBAMultiSampleBufferFormat(type: number): number;
  39954. /** @hidden */
  39955. _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;
  39956. /**
  39957. * Loads a file from a url
  39958. * @param url url to load
  39959. * @param onSuccess callback called when the file successfully loads
  39960. * @param onProgress callback called while file is loading (if the server supports this mode)
  39961. * @param offlineProvider defines the offline provider for caching
  39962. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39963. * @param onError callback called when the file fails to load
  39964. * @returns a file request object
  39965. * @hidden
  39966. */
  39967. 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;
  39968. /**
  39969. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39970. * @param x defines the x coordinate of the rectangle where pixels must be read
  39971. * @param y defines the y coordinate of the rectangle where pixels must be read
  39972. * @param width defines the width of the rectangle where pixels must be read
  39973. * @param height defines the height of the rectangle where pixels must be read
  39974. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39975. * @returns a Uint8Array containing RGBA colors
  39976. */
  39977. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39978. private static _IsSupported;
  39979. private static _HasMajorPerformanceCaveat;
  39980. /**
  39981. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39982. */
  39983. static get IsSupported(): boolean;
  39984. /**
  39985. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39986. * @returns true if the engine can be created
  39987. * @ignorenaming
  39988. */
  39989. static isSupported(): boolean;
  39990. /**
  39991. * 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)
  39992. */
  39993. static get HasMajorPerformanceCaveat(): boolean;
  39994. /**
  39995. * Find the next highest power of two.
  39996. * @param x Number to start search from.
  39997. * @return Next highest power of two.
  39998. */
  39999. static CeilingPOT(x: number): number;
  40000. /**
  40001. * Find the next lowest power of two.
  40002. * @param x Number to start search from.
  40003. * @return Next lowest power of two.
  40004. */
  40005. static FloorPOT(x: number): number;
  40006. /**
  40007. * Find the nearest power of two.
  40008. * @param x Number to start search from.
  40009. * @return Next nearest power of two.
  40010. */
  40011. static NearestPOT(x: number): number;
  40012. /**
  40013. * Get the closest exponent of two
  40014. * @param value defines the value to approximate
  40015. * @param max defines the maximum value to return
  40016. * @param mode defines how to define the closest value
  40017. * @returns closest exponent of two of the given value
  40018. */
  40019. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40020. /**
  40021. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40022. * @param func - the function to be called
  40023. * @param requester - the object that will request the next frame. Falls back to window.
  40024. * @returns frame number
  40025. */
  40026. static QueueNewFrame(func: () => void, requester?: any): number;
  40027. /**
  40028. * Gets host document
  40029. * @returns the host document object
  40030. */
  40031. getHostDocument(): Nullable<Document>;
  40032. }
  40033. }
  40034. declare module BABYLON {
  40035. /**
  40036. * Defines the source of the internal texture
  40037. */
  40038. export enum InternalTextureSource {
  40039. /**
  40040. * The source of the texture data is unknown
  40041. */
  40042. Unknown = 0,
  40043. /**
  40044. * Texture data comes from an URL
  40045. */
  40046. Url = 1,
  40047. /**
  40048. * Texture data is only used for temporary storage
  40049. */
  40050. Temp = 2,
  40051. /**
  40052. * Texture data comes from raw data (ArrayBuffer)
  40053. */
  40054. Raw = 3,
  40055. /**
  40056. * Texture content is dynamic (video or dynamic texture)
  40057. */
  40058. Dynamic = 4,
  40059. /**
  40060. * Texture content is generated by rendering to it
  40061. */
  40062. RenderTarget = 5,
  40063. /**
  40064. * Texture content is part of a multi render target process
  40065. */
  40066. MultiRenderTarget = 6,
  40067. /**
  40068. * Texture data comes from a cube data file
  40069. */
  40070. Cube = 7,
  40071. /**
  40072. * Texture data comes from a raw cube data
  40073. */
  40074. CubeRaw = 8,
  40075. /**
  40076. * Texture data come from a prefiltered cube data file
  40077. */
  40078. CubePrefiltered = 9,
  40079. /**
  40080. * Texture content is raw 3D data
  40081. */
  40082. Raw3D = 10,
  40083. /**
  40084. * Texture content is raw 2D array data
  40085. */
  40086. Raw2DArray = 11,
  40087. /**
  40088. * Texture content is a depth texture
  40089. */
  40090. Depth = 12,
  40091. /**
  40092. * Texture data comes from a raw cube data encoded with RGBD
  40093. */
  40094. CubeRawRGBD = 13
  40095. }
  40096. /**
  40097. * Class used to store data associated with WebGL texture data for the engine
  40098. * This class should not be used directly
  40099. */
  40100. export class InternalTexture {
  40101. /** @hidden */
  40102. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40103. /**
  40104. * Defines if the texture is ready
  40105. */
  40106. isReady: boolean;
  40107. /**
  40108. * Defines if the texture is a cube texture
  40109. */
  40110. isCube: boolean;
  40111. /**
  40112. * Defines if the texture contains 3D data
  40113. */
  40114. is3D: boolean;
  40115. /**
  40116. * Defines if the texture contains 2D array data
  40117. */
  40118. is2DArray: boolean;
  40119. /**
  40120. * Defines if the texture contains multiview data
  40121. */
  40122. isMultiview: boolean;
  40123. /**
  40124. * Gets the URL used to load this texture
  40125. */
  40126. url: string;
  40127. /**
  40128. * Gets the sampling mode of the texture
  40129. */
  40130. samplingMode: number;
  40131. /**
  40132. * Gets a boolean indicating if the texture needs mipmaps generation
  40133. */
  40134. generateMipMaps: boolean;
  40135. /**
  40136. * Gets the number of samples used by the texture (WebGL2+ only)
  40137. */
  40138. samples: number;
  40139. /**
  40140. * Gets the type of the texture (int, float...)
  40141. */
  40142. type: number;
  40143. /**
  40144. * Gets the format of the texture (RGB, RGBA...)
  40145. */
  40146. format: number;
  40147. /**
  40148. * Observable called when the texture is loaded
  40149. */
  40150. onLoadedObservable: Observable<InternalTexture>;
  40151. /**
  40152. * Gets the width of the texture
  40153. */
  40154. width: number;
  40155. /**
  40156. * Gets the height of the texture
  40157. */
  40158. height: number;
  40159. /**
  40160. * Gets the depth of the texture
  40161. */
  40162. depth: number;
  40163. /**
  40164. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40165. */
  40166. baseWidth: number;
  40167. /**
  40168. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40169. */
  40170. baseHeight: number;
  40171. /**
  40172. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40173. */
  40174. baseDepth: number;
  40175. /**
  40176. * Gets a boolean indicating if the texture is inverted on Y axis
  40177. */
  40178. invertY: boolean;
  40179. /** @hidden */
  40180. _invertVScale: boolean;
  40181. /** @hidden */
  40182. _associatedChannel: number;
  40183. /** @hidden */
  40184. _source: InternalTextureSource;
  40185. /** @hidden */
  40186. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40187. /** @hidden */
  40188. _bufferView: Nullable<ArrayBufferView>;
  40189. /** @hidden */
  40190. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40191. /** @hidden */
  40192. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40193. /** @hidden */
  40194. _size: number;
  40195. /** @hidden */
  40196. _extension: string;
  40197. /** @hidden */
  40198. _files: Nullable<string[]>;
  40199. /** @hidden */
  40200. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40201. /** @hidden */
  40202. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40203. /** @hidden */
  40204. _framebuffer: Nullable<WebGLFramebuffer>;
  40205. /** @hidden */
  40206. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40207. /** @hidden */
  40208. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40209. /** @hidden */
  40210. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40211. /** @hidden */
  40212. _attachments: Nullable<number[]>;
  40213. /** @hidden */
  40214. _textureArray: Nullable<InternalTexture[]>;
  40215. /** @hidden */
  40216. _cachedCoordinatesMode: Nullable<number>;
  40217. /** @hidden */
  40218. _cachedWrapU: Nullable<number>;
  40219. /** @hidden */
  40220. _cachedWrapV: Nullable<number>;
  40221. /** @hidden */
  40222. _cachedWrapR: Nullable<number>;
  40223. /** @hidden */
  40224. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40225. /** @hidden */
  40226. _isDisabled: boolean;
  40227. /** @hidden */
  40228. _compression: Nullable<string>;
  40229. /** @hidden */
  40230. _generateStencilBuffer: boolean;
  40231. /** @hidden */
  40232. _generateDepthBuffer: boolean;
  40233. /** @hidden */
  40234. _comparisonFunction: number;
  40235. /** @hidden */
  40236. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40237. /** @hidden */
  40238. _lodGenerationScale: number;
  40239. /** @hidden */
  40240. _lodGenerationOffset: number;
  40241. /** @hidden */
  40242. _depthStencilTexture: Nullable<InternalTexture>;
  40243. /** @hidden */
  40244. _colorTextureArray: Nullable<WebGLTexture>;
  40245. /** @hidden */
  40246. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40247. /** @hidden */
  40248. _lodTextureHigh: Nullable<BaseTexture>;
  40249. /** @hidden */
  40250. _lodTextureMid: Nullable<BaseTexture>;
  40251. /** @hidden */
  40252. _lodTextureLow: Nullable<BaseTexture>;
  40253. /** @hidden */
  40254. _isRGBD: boolean;
  40255. /** @hidden */
  40256. _linearSpecularLOD: boolean;
  40257. /** @hidden */
  40258. _irradianceTexture: Nullable<BaseTexture>;
  40259. /** @hidden */
  40260. _webGLTexture: Nullable<WebGLTexture>;
  40261. /** @hidden */
  40262. _references: number;
  40263. /** @hidden */
  40264. _gammaSpace: Nullable<boolean>;
  40265. private _engine;
  40266. /**
  40267. * Gets the Engine the texture belongs to.
  40268. * @returns The babylon engine
  40269. */
  40270. getEngine(): ThinEngine;
  40271. /**
  40272. * Gets the data source type of the texture
  40273. */
  40274. get source(): InternalTextureSource;
  40275. /**
  40276. * Creates a new InternalTexture
  40277. * @param engine defines the engine to use
  40278. * @param source defines the type of data that will be used
  40279. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40280. */
  40281. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40282. /**
  40283. * Increments the number of references (ie. the number of Texture that point to it)
  40284. */
  40285. incrementReferences(): void;
  40286. /**
  40287. * Change the size of the texture (not the size of the content)
  40288. * @param width defines the new width
  40289. * @param height defines the new height
  40290. * @param depth defines the new depth (1 by default)
  40291. */
  40292. updateSize(width: int, height: int, depth?: int): void;
  40293. /** @hidden */
  40294. _rebuild(): void;
  40295. /** @hidden */
  40296. _swapAndDie(target: InternalTexture): void;
  40297. /**
  40298. * Dispose the current allocated resources
  40299. */
  40300. dispose(): void;
  40301. }
  40302. }
  40303. declare module BABYLON {
  40304. /**
  40305. * Interface used to present a loading screen while loading a scene
  40306. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40307. */
  40308. export interface ILoadingScreen {
  40309. /**
  40310. * Function called to display the loading screen
  40311. */
  40312. displayLoadingUI: () => void;
  40313. /**
  40314. * Function called to hide the loading screen
  40315. */
  40316. hideLoadingUI: () => void;
  40317. /**
  40318. * Gets or sets the color to use for the background
  40319. */
  40320. loadingUIBackgroundColor: string;
  40321. /**
  40322. * Gets or sets the text to display while loading
  40323. */
  40324. loadingUIText: string;
  40325. }
  40326. /**
  40327. * Class used for the default loading screen
  40328. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40329. */
  40330. export class DefaultLoadingScreen implements ILoadingScreen {
  40331. private _renderingCanvas;
  40332. private _loadingText;
  40333. private _loadingDivBackgroundColor;
  40334. private _loadingDiv;
  40335. private _loadingTextDiv;
  40336. /** Gets or sets the logo url to use for the default loading screen */
  40337. static DefaultLogoUrl: string;
  40338. /** Gets or sets the spinner url to use for the default loading screen */
  40339. static DefaultSpinnerUrl: string;
  40340. /**
  40341. * Creates a new default loading screen
  40342. * @param _renderingCanvas defines the canvas used to render the scene
  40343. * @param _loadingText defines the default text to display
  40344. * @param _loadingDivBackgroundColor defines the default background color
  40345. */
  40346. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40347. /**
  40348. * Function called to display the loading screen
  40349. */
  40350. displayLoadingUI(): void;
  40351. /**
  40352. * Function called to hide the loading screen
  40353. */
  40354. hideLoadingUI(): void;
  40355. /**
  40356. * Gets or sets the text to display while loading
  40357. */
  40358. set loadingUIText(text: string);
  40359. get loadingUIText(): string;
  40360. /**
  40361. * Gets or sets the color to use for the background
  40362. */
  40363. get loadingUIBackgroundColor(): string;
  40364. set loadingUIBackgroundColor(color: string);
  40365. private _resizeLoadingUI;
  40366. }
  40367. }
  40368. declare module BABYLON {
  40369. /**
  40370. * Interface for any object that can request an animation frame
  40371. */
  40372. export interface ICustomAnimationFrameRequester {
  40373. /**
  40374. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40375. */
  40376. renderFunction?: Function;
  40377. /**
  40378. * Called to request the next frame to render to
  40379. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40380. */
  40381. requestAnimationFrame: Function;
  40382. /**
  40383. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40384. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40385. */
  40386. requestID?: number;
  40387. }
  40388. }
  40389. declare module BABYLON {
  40390. /**
  40391. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40392. */
  40393. export class PerformanceMonitor {
  40394. private _enabled;
  40395. private _rollingFrameTime;
  40396. private _lastFrameTimeMs;
  40397. /**
  40398. * constructor
  40399. * @param frameSampleSize The number of samples required to saturate the sliding window
  40400. */
  40401. constructor(frameSampleSize?: number);
  40402. /**
  40403. * Samples current frame
  40404. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40405. */
  40406. sampleFrame(timeMs?: number): void;
  40407. /**
  40408. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40409. */
  40410. get averageFrameTime(): number;
  40411. /**
  40412. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40413. */
  40414. get averageFrameTimeVariance(): number;
  40415. /**
  40416. * Returns the frame time of the most recent frame
  40417. */
  40418. get instantaneousFrameTime(): number;
  40419. /**
  40420. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40421. */
  40422. get averageFPS(): number;
  40423. /**
  40424. * Returns the average framerate in frames per second using the most recent frame time
  40425. */
  40426. get instantaneousFPS(): number;
  40427. /**
  40428. * Returns true if enough samples have been taken to completely fill the sliding window
  40429. */
  40430. get isSaturated(): boolean;
  40431. /**
  40432. * Enables contributions to the sliding window sample set
  40433. */
  40434. enable(): void;
  40435. /**
  40436. * Disables contributions to the sliding window sample set
  40437. * Samples will not be interpolated over the disabled period
  40438. */
  40439. disable(): void;
  40440. /**
  40441. * Returns true if sampling is enabled
  40442. */
  40443. get isEnabled(): boolean;
  40444. /**
  40445. * Resets performance monitor
  40446. */
  40447. reset(): void;
  40448. }
  40449. /**
  40450. * RollingAverage
  40451. *
  40452. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40453. */
  40454. export class RollingAverage {
  40455. /**
  40456. * Current average
  40457. */
  40458. average: number;
  40459. /**
  40460. * Current variance
  40461. */
  40462. variance: number;
  40463. protected _samples: Array<number>;
  40464. protected _sampleCount: number;
  40465. protected _pos: number;
  40466. protected _m2: number;
  40467. /**
  40468. * constructor
  40469. * @param length The number of samples required to saturate the sliding window
  40470. */
  40471. constructor(length: number);
  40472. /**
  40473. * Adds a sample to the sample set
  40474. * @param v The sample value
  40475. */
  40476. add(v: number): void;
  40477. /**
  40478. * Returns previously added values or null if outside of history or outside the sliding window domain
  40479. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40480. * @return Value previously recorded with add() or null if outside of range
  40481. */
  40482. history(i: number): number;
  40483. /**
  40484. * Returns true if enough samples have been taken to completely fill the sliding window
  40485. * @return true if sample-set saturated
  40486. */
  40487. isSaturated(): boolean;
  40488. /**
  40489. * Resets the rolling average (equivalent to 0 samples taken so far)
  40490. */
  40491. reset(): void;
  40492. /**
  40493. * Wraps a value around the sample range boundaries
  40494. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40495. * @return Wrapped position in sample range
  40496. */
  40497. protected _wrapPosition(i: number): number;
  40498. }
  40499. }
  40500. declare module BABYLON {
  40501. /**
  40502. * This class is used to track a performance counter which is number based.
  40503. * The user has access to many properties which give statistics of different nature.
  40504. *
  40505. * The implementer can track two kinds of Performance Counter: time and count.
  40506. * 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.
  40507. * 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.
  40508. */
  40509. export class PerfCounter {
  40510. /**
  40511. * Gets or sets a global boolean to turn on and off all the counters
  40512. */
  40513. static Enabled: boolean;
  40514. /**
  40515. * Returns the smallest value ever
  40516. */
  40517. get min(): number;
  40518. /**
  40519. * Returns the biggest value ever
  40520. */
  40521. get max(): number;
  40522. /**
  40523. * Returns the average value since the performance counter is running
  40524. */
  40525. get average(): number;
  40526. /**
  40527. * Returns the average value of the last second the counter was monitored
  40528. */
  40529. get lastSecAverage(): number;
  40530. /**
  40531. * Returns the current value
  40532. */
  40533. get current(): number;
  40534. /**
  40535. * Gets the accumulated total
  40536. */
  40537. get total(): number;
  40538. /**
  40539. * Gets the total value count
  40540. */
  40541. get count(): number;
  40542. /**
  40543. * Creates a new counter
  40544. */
  40545. constructor();
  40546. /**
  40547. * Call this method to start monitoring a new frame.
  40548. * 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.
  40549. */
  40550. fetchNewFrame(): void;
  40551. /**
  40552. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40553. * @param newCount the count value to add to the monitored count
  40554. * @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.
  40555. */
  40556. addCount(newCount: number, fetchResult: boolean): void;
  40557. /**
  40558. * Start monitoring this performance counter
  40559. */
  40560. beginMonitoring(): void;
  40561. /**
  40562. * Compute the time lapsed since the previous beginMonitoring() call.
  40563. * @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
  40564. */
  40565. endMonitoring(newFrame?: boolean): void;
  40566. private _fetchResult;
  40567. private _startMonitoringTime;
  40568. private _min;
  40569. private _max;
  40570. private _average;
  40571. private _current;
  40572. private _totalValueCount;
  40573. private _totalAccumulated;
  40574. private _lastSecAverage;
  40575. private _lastSecAccumulated;
  40576. private _lastSecTime;
  40577. private _lastSecValueCount;
  40578. }
  40579. }
  40580. declare module BABYLON {
  40581. interface ThinEngine {
  40582. /** @hidden */
  40583. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40584. }
  40585. }
  40586. declare module BABYLON {
  40587. /**
  40588. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40590. */
  40591. export class Analyser {
  40592. /**
  40593. * Gets or sets the smoothing
  40594. * @ignorenaming
  40595. */
  40596. SMOOTHING: number;
  40597. /**
  40598. * Gets or sets the FFT table size
  40599. * @ignorenaming
  40600. */
  40601. FFT_SIZE: number;
  40602. /**
  40603. * Gets or sets the bar graph amplitude
  40604. * @ignorenaming
  40605. */
  40606. BARGRAPHAMPLITUDE: number;
  40607. /**
  40608. * Gets or sets the position of the debug canvas
  40609. * @ignorenaming
  40610. */
  40611. DEBUGCANVASPOS: {
  40612. x: number;
  40613. y: number;
  40614. };
  40615. /**
  40616. * Gets or sets the debug canvas size
  40617. * @ignorenaming
  40618. */
  40619. DEBUGCANVASSIZE: {
  40620. width: number;
  40621. height: number;
  40622. };
  40623. private _byteFreqs;
  40624. private _byteTime;
  40625. private _floatFreqs;
  40626. private _webAudioAnalyser;
  40627. private _debugCanvas;
  40628. private _debugCanvasContext;
  40629. private _scene;
  40630. private _registerFunc;
  40631. private _audioEngine;
  40632. /**
  40633. * Creates a new analyser
  40634. * @param scene defines hosting scene
  40635. */
  40636. constructor(scene: Scene);
  40637. /**
  40638. * Get the number of data values you will have to play with for the visualization
  40639. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40640. * @returns a number
  40641. */
  40642. getFrequencyBinCount(): number;
  40643. /**
  40644. * Gets the current frequency data as a byte array
  40645. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40646. * @returns a Uint8Array
  40647. */
  40648. getByteFrequencyData(): Uint8Array;
  40649. /**
  40650. * Gets the current waveform as a byte array
  40651. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40652. * @returns a Uint8Array
  40653. */
  40654. getByteTimeDomainData(): Uint8Array;
  40655. /**
  40656. * Gets the current frequency data as a float array
  40657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40658. * @returns a Float32Array
  40659. */
  40660. getFloatFrequencyData(): Float32Array;
  40661. /**
  40662. * Renders the debug canvas
  40663. */
  40664. drawDebugCanvas(): void;
  40665. /**
  40666. * Stops rendering the debug canvas and removes it
  40667. */
  40668. stopDebugCanvas(): void;
  40669. /**
  40670. * Connects two audio nodes
  40671. * @param inputAudioNode defines first node to connect
  40672. * @param outputAudioNode defines second node to connect
  40673. */
  40674. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40675. /**
  40676. * Releases all associated resources
  40677. */
  40678. dispose(): void;
  40679. }
  40680. }
  40681. declare module BABYLON {
  40682. /**
  40683. * This represents an audio engine and it is responsible
  40684. * to play, synchronize and analyse sounds throughout the application.
  40685. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40686. */
  40687. export interface IAudioEngine extends IDisposable {
  40688. /**
  40689. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40690. */
  40691. readonly canUseWebAudio: boolean;
  40692. /**
  40693. * Gets the current AudioContext if available.
  40694. */
  40695. readonly audioContext: Nullable<AudioContext>;
  40696. /**
  40697. * The master gain node defines the global audio volume of your audio engine.
  40698. */
  40699. readonly masterGain: GainNode;
  40700. /**
  40701. * Gets whether or not mp3 are supported by your browser.
  40702. */
  40703. readonly isMP3supported: boolean;
  40704. /**
  40705. * Gets whether or not ogg are supported by your browser.
  40706. */
  40707. readonly isOGGsupported: boolean;
  40708. /**
  40709. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40710. * @ignoreNaming
  40711. */
  40712. WarnedWebAudioUnsupported: boolean;
  40713. /**
  40714. * Defines if the audio engine relies on a custom unlocked button.
  40715. * In this case, the embedded button will not be displayed.
  40716. */
  40717. useCustomUnlockedButton: boolean;
  40718. /**
  40719. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40720. */
  40721. readonly unlocked: boolean;
  40722. /**
  40723. * Event raised when audio has been unlocked on the browser.
  40724. */
  40725. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40726. /**
  40727. * Event raised when audio has been locked on the browser.
  40728. */
  40729. onAudioLockedObservable: Observable<IAudioEngine>;
  40730. /**
  40731. * Flags the audio engine in Locked state.
  40732. * This happens due to new browser policies preventing audio to autoplay.
  40733. */
  40734. lock(): void;
  40735. /**
  40736. * Unlocks the audio engine once a user action has been done on the dom.
  40737. * This is helpful to resume play once browser policies have been satisfied.
  40738. */
  40739. unlock(): void;
  40740. /**
  40741. * Gets the global volume sets on the master gain.
  40742. * @returns the global volume if set or -1 otherwise
  40743. */
  40744. getGlobalVolume(): number;
  40745. /**
  40746. * Sets the global volume of your experience (sets on the master gain).
  40747. * @param newVolume Defines the new global volume of the application
  40748. */
  40749. setGlobalVolume(newVolume: number): void;
  40750. /**
  40751. * Connect the audio engine to an audio analyser allowing some amazing
  40752. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40754. * @param analyser The analyser to connect to the engine
  40755. */
  40756. connectToAnalyser(analyser: Analyser): void;
  40757. }
  40758. }
  40759. declare module BABYLON {
  40760. /**
  40761. * Defines the interface used by display changed events
  40762. */
  40763. export interface IDisplayChangedEventArgs {
  40764. /** Gets the vrDisplay object (if any) */
  40765. vrDisplay: Nullable<any>;
  40766. /** Gets a boolean indicating if webVR is supported */
  40767. vrSupported: boolean;
  40768. }
  40769. /**
  40770. * Defines the interface used by objects containing a viewport (like a camera)
  40771. */
  40772. interface IViewportOwnerLike {
  40773. /**
  40774. * Gets or sets the viewport
  40775. */
  40776. viewport: IViewportLike;
  40777. }
  40778. /**
  40779. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40780. */
  40781. export class Engine extends ThinEngine {
  40782. /** Defines that alpha blending is disabled */
  40783. static readonly ALPHA_DISABLE: number;
  40784. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40785. static readonly ALPHA_ADD: number;
  40786. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40787. static readonly ALPHA_COMBINE: number;
  40788. /** Defines that alpha blending to DEST - SRC * DEST */
  40789. static readonly ALPHA_SUBTRACT: number;
  40790. /** Defines that alpha blending to SRC * DEST */
  40791. static readonly ALPHA_MULTIPLY: number;
  40792. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40793. static readonly ALPHA_MAXIMIZED: number;
  40794. /** Defines that alpha blending to SRC + DEST */
  40795. static readonly ALPHA_ONEONE: number;
  40796. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40797. static readonly ALPHA_PREMULTIPLIED: number;
  40798. /**
  40799. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40800. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40801. */
  40802. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40803. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40804. static readonly ALPHA_INTERPOLATE: number;
  40805. /**
  40806. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40807. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40808. */
  40809. static readonly ALPHA_SCREENMODE: number;
  40810. /** Defines that the ressource is not delayed*/
  40811. static readonly DELAYLOADSTATE_NONE: number;
  40812. /** Defines that the ressource was successfully delay loaded */
  40813. static readonly DELAYLOADSTATE_LOADED: number;
  40814. /** Defines that the ressource is currently delay loading */
  40815. static readonly DELAYLOADSTATE_LOADING: number;
  40816. /** Defines that the ressource is delayed and has not started loading */
  40817. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40818. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40819. static readonly NEVER: number;
  40820. /** 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 */
  40821. static readonly ALWAYS: number;
  40822. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40823. static readonly LESS: number;
  40824. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40825. static readonly EQUAL: number;
  40826. /** 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 */
  40827. static readonly LEQUAL: number;
  40828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40829. static readonly GREATER: number;
  40830. /** 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 */
  40831. static readonly GEQUAL: number;
  40832. /** 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 */
  40833. static readonly NOTEQUAL: number;
  40834. /** Passed to stencilOperation to specify that stencil value must be kept */
  40835. static readonly KEEP: number;
  40836. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40837. static readonly REPLACE: number;
  40838. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40839. static readonly INCR: number;
  40840. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40841. static readonly DECR: number;
  40842. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40843. static readonly INVERT: number;
  40844. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40845. static readonly INCR_WRAP: number;
  40846. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40847. static readonly DECR_WRAP: number;
  40848. /** Texture is not repeating outside of 0..1 UVs */
  40849. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40850. /** Texture is repeating outside of 0..1 UVs */
  40851. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40852. /** Texture is repeating and mirrored */
  40853. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40854. /** ALPHA */
  40855. static readonly TEXTUREFORMAT_ALPHA: number;
  40856. /** LUMINANCE */
  40857. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40858. /** LUMINANCE_ALPHA */
  40859. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40860. /** RGB */
  40861. static readonly TEXTUREFORMAT_RGB: number;
  40862. /** RGBA */
  40863. static readonly TEXTUREFORMAT_RGBA: number;
  40864. /** RED */
  40865. static readonly TEXTUREFORMAT_RED: number;
  40866. /** RED (2nd reference) */
  40867. static readonly TEXTUREFORMAT_R: number;
  40868. /** RG */
  40869. static readonly TEXTUREFORMAT_RG: number;
  40870. /** RED_INTEGER */
  40871. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40872. /** RED_INTEGER (2nd reference) */
  40873. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40874. /** RG_INTEGER */
  40875. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40876. /** RGB_INTEGER */
  40877. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40878. /** RGBA_INTEGER */
  40879. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40880. /** UNSIGNED_BYTE */
  40881. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40882. /** UNSIGNED_BYTE (2nd reference) */
  40883. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40884. /** FLOAT */
  40885. static readonly TEXTURETYPE_FLOAT: number;
  40886. /** HALF_FLOAT */
  40887. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40888. /** BYTE */
  40889. static readonly TEXTURETYPE_BYTE: number;
  40890. /** SHORT */
  40891. static readonly TEXTURETYPE_SHORT: number;
  40892. /** UNSIGNED_SHORT */
  40893. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40894. /** INT */
  40895. static readonly TEXTURETYPE_INT: number;
  40896. /** UNSIGNED_INT */
  40897. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40898. /** UNSIGNED_SHORT_4_4_4_4 */
  40899. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40900. /** UNSIGNED_SHORT_5_5_5_1 */
  40901. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40902. /** UNSIGNED_SHORT_5_6_5 */
  40903. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40904. /** UNSIGNED_INT_2_10_10_10_REV */
  40905. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40906. /** UNSIGNED_INT_24_8 */
  40907. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40908. /** UNSIGNED_INT_10F_11F_11F_REV */
  40909. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40910. /** UNSIGNED_INT_5_9_9_9_REV */
  40911. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40912. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40913. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40914. /** nearest is mag = nearest and min = nearest and mip = linear */
  40915. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40916. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40917. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40918. /** Trilinear is mag = linear and min = linear and mip = linear */
  40919. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40920. /** nearest is mag = nearest and min = nearest and mip = linear */
  40921. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40922. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40923. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40924. /** Trilinear is mag = linear and min = linear and mip = linear */
  40925. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40926. /** mag = nearest and min = nearest and mip = nearest */
  40927. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40928. /** mag = nearest and min = linear and mip = nearest */
  40929. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40930. /** mag = nearest and min = linear and mip = linear */
  40931. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40932. /** mag = nearest and min = linear and mip = none */
  40933. static readonly TEXTURE_NEAREST_LINEAR: number;
  40934. /** mag = nearest and min = nearest and mip = none */
  40935. static readonly TEXTURE_NEAREST_NEAREST: number;
  40936. /** mag = linear and min = nearest and mip = nearest */
  40937. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40938. /** mag = linear and min = nearest and mip = linear */
  40939. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40940. /** mag = linear and min = linear and mip = none */
  40941. static readonly TEXTURE_LINEAR_LINEAR: number;
  40942. /** mag = linear and min = nearest and mip = none */
  40943. static readonly TEXTURE_LINEAR_NEAREST: number;
  40944. /** Explicit coordinates mode */
  40945. static readonly TEXTURE_EXPLICIT_MODE: number;
  40946. /** Spherical coordinates mode */
  40947. static readonly TEXTURE_SPHERICAL_MODE: number;
  40948. /** Planar coordinates mode */
  40949. static readonly TEXTURE_PLANAR_MODE: number;
  40950. /** Cubic coordinates mode */
  40951. static readonly TEXTURE_CUBIC_MODE: number;
  40952. /** Projection coordinates mode */
  40953. static readonly TEXTURE_PROJECTION_MODE: number;
  40954. /** Skybox coordinates mode */
  40955. static readonly TEXTURE_SKYBOX_MODE: number;
  40956. /** Inverse Cubic coordinates mode */
  40957. static readonly TEXTURE_INVCUBIC_MODE: number;
  40958. /** Equirectangular coordinates mode */
  40959. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40960. /** Equirectangular Fixed coordinates mode */
  40961. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40962. /** Equirectangular Fixed Mirrored coordinates mode */
  40963. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40964. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40965. static readonly SCALEMODE_FLOOR: number;
  40966. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40967. static readonly SCALEMODE_NEAREST: number;
  40968. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40969. static readonly SCALEMODE_CEILING: number;
  40970. /**
  40971. * Returns the current npm package of the sdk
  40972. */
  40973. static get NpmPackage(): string;
  40974. /**
  40975. * Returns the current version of the framework
  40976. */
  40977. static get Version(): string;
  40978. /** Gets the list of created engines */
  40979. static get Instances(): Engine[];
  40980. /**
  40981. * Gets the latest created engine
  40982. */
  40983. static get LastCreatedEngine(): Nullable<Engine>;
  40984. /**
  40985. * Gets the latest created scene
  40986. */
  40987. static get LastCreatedScene(): Nullable<Scene>;
  40988. /**
  40989. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40990. * @param flag defines which part of the materials must be marked as dirty
  40991. * @param predicate defines a predicate used to filter which materials should be affected
  40992. */
  40993. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40994. /**
  40995. * Method called to create the default loading screen.
  40996. * This can be overriden in your own app.
  40997. * @param canvas The rendering canvas element
  40998. * @returns The loading screen
  40999. */
  41000. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41001. /**
  41002. * Method called to create the default rescale post process on each engine.
  41003. */
  41004. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41005. /**
  41006. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41007. **/
  41008. enableOfflineSupport: boolean;
  41009. /**
  41010. * 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)
  41011. **/
  41012. disableManifestCheck: boolean;
  41013. /**
  41014. * Gets the list of created scenes
  41015. */
  41016. scenes: Scene[];
  41017. /**
  41018. * Event raised when a new scene is created
  41019. */
  41020. onNewSceneAddedObservable: Observable<Scene>;
  41021. /**
  41022. * Gets the list of created postprocesses
  41023. */
  41024. postProcesses: PostProcess[];
  41025. /**
  41026. * Gets a boolean indicating if the pointer is currently locked
  41027. */
  41028. isPointerLock: boolean;
  41029. /**
  41030. * Observable event triggered each time the rendering canvas is resized
  41031. */
  41032. onResizeObservable: Observable<Engine>;
  41033. /**
  41034. * Observable event triggered each time the canvas loses focus
  41035. */
  41036. onCanvasBlurObservable: Observable<Engine>;
  41037. /**
  41038. * Observable event triggered each time the canvas gains focus
  41039. */
  41040. onCanvasFocusObservable: Observable<Engine>;
  41041. /**
  41042. * Observable event triggered each time the canvas receives pointerout event
  41043. */
  41044. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41045. /**
  41046. * Observable raised when the engine begins a new frame
  41047. */
  41048. onBeginFrameObservable: Observable<Engine>;
  41049. /**
  41050. * If set, will be used to request the next animation frame for the render loop
  41051. */
  41052. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41053. /**
  41054. * Observable raised when the engine ends the current frame
  41055. */
  41056. onEndFrameObservable: Observable<Engine>;
  41057. /**
  41058. * Observable raised when the engine is about to compile a shader
  41059. */
  41060. onBeforeShaderCompilationObservable: Observable<Engine>;
  41061. /**
  41062. * Observable raised when the engine has jsut compiled a shader
  41063. */
  41064. onAfterShaderCompilationObservable: Observable<Engine>;
  41065. /**
  41066. * Gets the audio engine
  41067. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41068. * @ignorenaming
  41069. */
  41070. static audioEngine: IAudioEngine;
  41071. /**
  41072. * Default AudioEngine factory responsible of creating the Audio Engine.
  41073. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41074. */
  41075. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41076. /**
  41077. * Default offline support factory responsible of creating a tool used to store data locally.
  41078. * By default, this will create a Database object if the workload has been embedded.
  41079. */
  41080. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41081. private _loadingScreen;
  41082. private _pointerLockRequested;
  41083. private _rescalePostProcess;
  41084. private _deterministicLockstep;
  41085. private _lockstepMaxSteps;
  41086. private _timeStep;
  41087. protected get _supportsHardwareTextureRescaling(): boolean;
  41088. private _fps;
  41089. private _deltaTime;
  41090. /** @hidden */
  41091. _drawCalls: PerfCounter;
  41092. /** 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 */
  41093. canvasTabIndex: number;
  41094. /**
  41095. * Turn this value on if you want to pause FPS computation when in background
  41096. */
  41097. disablePerformanceMonitorInBackground: boolean;
  41098. private _performanceMonitor;
  41099. /**
  41100. * Gets the performance monitor attached to this engine
  41101. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41102. */
  41103. get performanceMonitor(): PerformanceMonitor;
  41104. private _onFocus;
  41105. private _onBlur;
  41106. private _onCanvasPointerOut;
  41107. private _onCanvasBlur;
  41108. private _onCanvasFocus;
  41109. private _onFullscreenChange;
  41110. private _onPointerLockChange;
  41111. /**
  41112. * Gets the HTML element used to attach event listeners
  41113. * @returns a HTML element
  41114. */
  41115. getInputElement(): Nullable<HTMLElement>;
  41116. /**
  41117. * Creates a new engine
  41118. * @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
  41119. * @param antialias defines enable antialiasing (default: false)
  41120. * @param options defines further options to be sent to the getContext() function
  41121. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41122. */
  41123. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41124. /**
  41125. * Gets current aspect ratio
  41126. * @param viewportOwner defines the camera to use to get the aspect ratio
  41127. * @param useScreen defines if screen size must be used (or the current render target if any)
  41128. * @returns a number defining the aspect ratio
  41129. */
  41130. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41131. /**
  41132. * Gets current screen aspect ratio
  41133. * @returns a number defining the aspect ratio
  41134. */
  41135. getScreenAspectRatio(): number;
  41136. /**
  41137. * Gets the client rect of the HTML canvas attached with the current webGL context
  41138. * @returns a client rectanglee
  41139. */
  41140. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41141. /**
  41142. * Gets the client rect of the HTML element used for events
  41143. * @returns a client rectanglee
  41144. */
  41145. getInputElementClientRect(): Nullable<ClientRect>;
  41146. /**
  41147. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41149. * @returns true if engine is in deterministic lock step mode
  41150. */
  41151. isDeterministicLockStep(): boolean;
  41152. /**
  41153. * Gets the max steps when engine is running in deterministic lock step
  41154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41155. * @returns the max steps
  41156. */
  41157. getLockstepMaxSteps(): number;
  41158. /**
  41159. * Returns the time in ms between steps when using deterministic lock step.
  41160. * @returns time step in (ms)
  41161. */
  41162. getTimeStep(): number;
  41163. /**
  41164. * Force the mipmap generation for the given render target texture
  41165. * @param texture defines the render target texture to use
  41166. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41167. */
  41168. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41169. /** States */
  41170. /**
  41171. * Set various states to the webGL context
  41172. * @param culling defines backface culling state
  41173. * @param zOffset defines the value to apply to zOffset (0 by default)
  41174. * @param force defines if states must be applied even if cache is up to date
  41175. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41176. */
  41177. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41178. /**
  41179. * Set the z offset to apply to current rendering
  41180. * @param value defines the offset to apply
  41181. */
  41182. setZOffset(value: number): void;
  41183. /**
  41184. * Gets the current value of the zOffset
  41185. * @returns the current zOffset state
  41186. */
  41187. getZOffset(): number;
  41188. /**
  41189. * Enable or disable depth buffering
  41190. * @param enable defines the state to set
  41191. */
  41192. setDepthBuffer(enable: boolean): void;
  41193. /**
  41194. * Gets a boolean indicating if depth writing is enabled
  41195. * @returns the current depth writing state
  41196. */
  41197. getDepthWrite(): boolean;
  41198. /**
  41199. * Enable or disable depth writing
  41200. * @param enable defines the state to set
  41201. */
  41202. setDepthWrite(enable: boolean): void;
  41203. /**
  41204. * Gets a boolean indicating if stencil buffer is enabled
  41205. * @returns the current stencil buffer state
  41206. */
  41207. getStencilBuffer(): boolean;
  41208. /**
  41209. * Enable or disable the stencil buffer
  41210. * @param enable defines if the stencil buffer must be enabled or disabled
  41211. */
  41212. setStencilBuffer(enable: boolean): void;
  41213. /**
  41214. * Gets the current stencil mask
  41215. * @returns a number defining the new stencil mask to use
  41216. */
  41217. getStencilMask(): number;
  41218. /**
  41219. * Sets the current stencil mask
  41220. * @param mask defines the new stencil mask to use
  41221. */
  41222. setStencilMask(mask: number): void;
  41223. /**
  41224. * Gets the current stencil function
  41225. * @returns a number defining the stencil function to use
  41226. */
  41227. getStencilFunction(): number;
  41228. /**
  41229. * Gets the current stencil reference value
  41230. * @returns a number defining the stencil reference value to use
  41231. */
  41232. getStencilFunctionReference(): number;
  41233. /**
  41234. * Gets the current stencil mask
  41235. * @returns a number defining the stencil mask to use
  41236. */
  41237. getStencilFunctionMask(): number;
  41238. /**
  41239. * Sets the current stencil function
  41240. * @param stencilFunc defines the new stencil function to use
  41241. */
  41242. setStencilFunction(stencilFunc: number): void;
  41243. /**
  41244. * Sets the current stencil reference
  41245. * @param reference defines the new stencil reference to use
  41246. */
  41247. setStencilFunctionReference(reference: number): void;
  41248. /**
  41249. * Sets the current stencil mask
  41250. * @param mask defines the new stencil mask to use
  41251. */
  41252. setStencilFunctionMask(mask: number): void;
  41253. /**
  41254. * Gets the current stencil operation when stencil fails
  41255. * @returns a number defining stencil operation to use when stencil fails
  41256. */
  41257. getStencilOperationFail(): number;
  41258. /**
  41259. * Gets the current stencil operation when depth fails
  41260. * @returns a number defining stencil operation to use when depth fails
  41261. */
  41262. getStencilOperationDepthFail(): number;
  41263. /**
  41264. * Gets the current stencil operation when stencil passes
  41265. * @returns a number defining stencil operation to use when stencil passes
  41266. */
  41267. getStencilOperationPass(): number;
  41268. /**
  41269. * Sets the stencil operation to use when stencil fails
  41270. * @param operation defines the stencil operation to use when stencil fails
  41271. */
  41272. setStencilOperationFail(operation: number): void;
  41273. /**
  41274. * Sets the stencil operation to use when depth fails
  41275. * @param operation defines the stencil operation to use when depth fails
  41276. */
  41277. setStencilOperationDepthFail(operation: number): void;
  41278. /**
  41279. * Sets the stencil operation to use when stencil passes
  41280. * @param operation defines the stencil operation to use when stencil passes
  41281. */
  41282. setStencilOperationPass(operation: number): void;
  41283. /**
  41284. * Sets a boolean indicating if the dithering state is enabled or disabled
  41285. * @param value defines the dithering state
  41286. */
  41287. setDitheringState(value: boolean): void;
  41288. /**
  41289. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41290. * @param value defines the rasterizer state
  41291. */
  41292. setRasterizerState(value: boolean): void;
  41293. /**
  41294. * Gets the current depth function
  41295. * @returns a number defining the depth function
  41296. */
  41297. getDepthFunction(): Nullable<number>;
  41298. /**
  41299. * Sets the current depth function
  41300. * @param depthFunc defines the function to use
  41301. */
  41302. setDepthFunction(depthFunc: number): void;
  41303. /**
  41304. * Sets the current depth function to GREATER
  41305. */
  41306. setDepthFunctionToGreater(): void;
  41307. /**
  41308. * Sets the current depth function to GEQUAL
  41309. */
  41310. setDepthFunctionToGreaterOrEqual(): void;
  41311. /**
  41312. * Sets the current depth function to LESS
  41313. */
  41314. setDepthFunctionToLess(): void;
  41315. /**
  41316. * Sets the current depth function to LEQUAL
  41317. */
  41318. setDepthFunctionToLessOrEqual(): void;
  41319. private _cachedStencilBuffer;
  41320. private _cachedStencilFunction;
  41321. private _cachedStencilMask;
  41322. private _cachedStencilOperationPass;
  41323. private _cachedStencilOperationFail;
  41324. private _cachedStencilOperationDepthFail;
  41325. private _cachedStencilReference;
  41326. /**
  41327. * Caches the the state of the stencil buffer
  41328. */
  41329. cacheStencilState(): void;
  41330. /**
  41331. * Restores the state of the stencil buffer
  41332. */
  41333. restoreStencilState(): void;
  41334. /**
  41335. * Directly set the WebGL Viewport
  41336. * @param x defines the x coordinate of the viewport (in screen space)
  41337. * @param y defines the y coordinate of the viewport (in screen space)
  41338. * @param width defines the width of the viewport (in screen space)
  41339. * @param height defines the height of the viewport (in screen space)
  41340. * @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
  41341. */
  41342. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41343. /**
  41344. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41345. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41346. * @param y defines the y-coordinate of the corner of the clear rectangle
  41347. * @param width defines the width of the clear rectangle
  41348. * @param height defines the height of the clear rectangle
  41349. * @param clearColor defines the clear color
  41350. */
  41351. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41352. /**
  41353. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41354. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41355. * @param y defines the y-coordinate of the corner of the clear rectangle
  41356. * @param width defines the width of the clear rectangle
  41357. * @param height defines the height of the clear rectangle
  41358. */
  41359. enableScissor(x: number, y: number, width: number, height: number): void;
  41360. /**
  41361. * Disable previously set scissor test rectangle
  41362. */
  41363. disableScissor(): void;
  41364. protected _reportDrawCall(): void;
  41365. /**
  41366. * Initializes a webVR display and starts listening to display change events
  41367. * The onVRDisplayChangedObservable will be notified upon these changes
  41368. * @returns The onVRDisplayChangedObservable
  41369. */
  41370. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41371. /** @hidden */
  41372. _prepareVRComponent(): void;
  41373. /** @hidden */
  41374. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41375. /** @hidden */
  41376. _submitVRFrame(): void;
  41377. /**
  41378. * Call this function to leave webVR mode
  41379. * Will do nothing if webVR is not supported or if there is no webVR device
  41380. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41381. */
  41382. disableVR(): void;
  41383. /**
  41384. * Gets a boolean indicating that the system is in VR mode and is presenting
  41385. * @returns true if VR mode is engaged
  41386. */
  41387. isVRPresenting(): boolean;
  41388. /** @hidden */
  41389. _requestVRFrame(): void;
  41390. /** @hidden */
  41391. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41392. /**
  41393. * Gets the source code of the vertex shader associated with a specific webGL program
  41394. * @param program defines the program to use
  41395. * @returns a string containing the source code of the vertex shader associated with the program
  41396. */
  41397. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41398. /**
  41399. * Gets the source code of the fragment shader associated with a specific webGL program
  41400. * @param program defines the program to use
  41401. * @returns a string containing the source code of the fragment shader associated with the program
  41402. */
  41403. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41404. /**
  41405. * Sets a depth stencil texture from a render target to the according uniform.
  41406. * @param channel The texture channel
  41407. * @param uniform The uniform to set
  41408. * @param texture The render target texture containing the depth stencil texture to apply
  41409. */
  41410. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41411. /**
  41412. * Sets a texture to the webGL context from a postprocess
  41413. * @param channel defines the channel to use
  41414. * @param postProcess defines the source postprocess
  41415. */
  41416. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41417. /**
  41418. * Binds the output of the passed in post process to the texture channel specified
  41419. * @param channel The channel the texture should be bound to
  41420. * @param postProcess The post process which's output should be bound
  41421. */
  41422. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41423. protected _rebuildBuffers(): void;
  41424. /** @hidden */
  41425. _renderFrame(): void;
  41426. _renderLoop(): void;
  41427. /** @hidden */
  41428. _renderViews(): boolean;
  41429. /**
  41430. * Toggle full screen mode
  41431. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41432. */
  41433. switchFullscreen(requestPointerLock: boolean): void;
  41434. /**
  41435. * Enters full screen mode
  41436. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41437. */
  41438. enterFullscreen(requestPointerLock: boolean): void;
  41439. /**
  41440. * Exits full screen mode
  41441. */
  41442. exitFullscreen(): void;
  41443. /**
  41444. * Enters Pointerlock mode
  41445. */
  41446. enterPointerlock(): void;
  41447. /**
  41448. * Exits Pointerlock mode
  41449. */
  41450. exitPointerlock(): void;
  41451. /**
  41452. * Begin a new frame
  41453. */
  41454. beginFrame(): void;
  41455. /**
  41456. * Enf the current frame
  41457. */
  41458. endFrame(): void;
  41459. resize(): void;
  41460. /**
  41461. * Force a specific size of the canvas
  41462. * @param width defines the new canvas' width
  41463. * @param height defines the new canvas' height
  41464. * @returns true if the size was changed
  41465. */
  41466. setSize(width: number, height: number): boolean;
  41467. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41468. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41469. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41470. _releaseTexture(texture: InternalTexture): void;
  41471. /**
  41472. * @hidden
  41473. * Rescales a texture
  41474. * @param source input texutre
  41475. * @param destination destination texture
  41476. * @param scene scene to use to render the resize
  41477. * @param internalFormat format to use when resizing
  41478. * @param onComplete callback to be called when resize has completed
  41479. */
  41480. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41481. /**
  41482. * Gets the current framerate
  41483. * @returns a number representing the framerate
  41484. */
  41485. getFps(): number;
  41486. /**
  41487. * Gets the time spent between current and previous frame
  41488. * @returns a number representing the delta time in ms
  41489. */
  41490. getDeltaTime(): number;
  41491. private _measureFps;
  41492. /** @hidden */
  41493. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41494. /**
  41495. * Updates the sample count of a render target texture
  41496. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41497. * @param texture defines the texture to update
  41498. * @param samples defines the sample count to set
  41499. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41500. */
  41501. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41502. /**
  41503. * Updates a depth texture Comparison Mode and Function.
  41504. * If the comparison Function is equal to 0, the mode will be set to none.
  41505. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41506. * @param texture The texture to set the comparison function for
  41507. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41508. */
  41509. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41510. /**
  41511. * Creates a webGL buffer to use with instanciation
  41512. * @param capacity defines the size of the buffer
  41513. * @returns the webGL buffer
  41514. */
  41515. createInstancesBuffer(capacity: number): DataBuffer;
  41516. /**
  41517. * Delete a webGL buffer used with instanciation
  41518. * @param buffer defines the webGL buffer to delete
  41519. */
  41520. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41521. private _clientWaitAsync;
  41522. /** @hidden */
  41523. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41524. dispose(): void;
  41525. private _disableTouchAction;
  41526. /**
  41527. * Display the loading screen
  41528. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41529. */
  41530. displayLoadingUI(): void;
  41531. /**
  41532. * Hide the loading screen
  41533. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41534. */
  41535. hideLoadingUI(): void;
  41536. /**
  41537. * Gets the current loading screen object
  41538. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41539. */
  41540. get loadingScreen(): ILoadingScreen;
  41541. /**
  41542. * Sets the current loading screen object
  41543. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41544. */
  41545. set loadingScreen(loadingScreen: ILoadingScreen);
  41546. /**
  41547. * Sets the current loading screen text
  41548. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41549. */
  41550. set loadingUIText(text: string);
  41551. /**
  41552. * Sets the current loading screen background color
  41553. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41554. */
  41555. set loadingUIBackgroundColor(color: string);
  41556. /** Pointerlock and fullscreen */
  41557. /**
  41558. * Ask the browser to promote the current element to pointerlock mode
  41559. * @param element defines the DOM element to promote
  41560. */
  41561. static _RequestPointerlock(element: HTMLElement): void;
  41562. /**
  41563. * Asks the browser to exit pointerlock mode
  41564. */
  41565. static _ExitPointerlock(): void;
  41566. /**
  41567. * Ask the browser to promote the current element to fullscreen rendering mode
  41568. * @param element defines the DOM element to promote
  41569. */
  41570. static _RequestFullscreen(element: HTMLElement): void;
  41571. /**
  41572. * Asks the browser to exit fullscreen mode
  41573. */
  41574. static _ExitFullscreen(): void;
  41575. }
  41576. }
  41577. declare module BABYLON {
  41578. /**
  41579. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41580. * during the life time of the application.
  41581. */
  41582. export class EngineStore {
  41583. /** Gets the list of created engines */
  41584. static Instances: Engine[];
  41585. /** @hidden */
  41586. static _LastCreatedScene: Nullable<Scene>;
  41587. /**
  41588. * Gets the latest created engine
  41589. */
  41590. static get LastCreatedEngine(): Nullable<Engine>;
  41591. /**
  41592. * Gets the latest created scene
  41593. */
  41594. static get LastCreatedScene(): Nullable<Scene>;
  41595. /**
  41596. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41597. * @ignorenaming
  41598. */
  41599. static UseFallbackTexture: boolean;
  41600. /**
  41601. * Texture content used if a texture cannot loaded
  41602. * @ignorenaming
  41603. */
  41604. static FallbackTexture: string;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Helper class that provides a small promise polyfill
  41610. */
  41611. export class PromisePolyfill {
  41612. /**
  41613. * Static function used to check if the polyfill is required
  41614. * If this is the case then the function will inject the polyfill to window.Promise
  41615. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41616. */
  41617. static Apply(force?: boolean): void;
  41618. }
  41619. }
  41620. declare module BABYLON {
  41621. /**
  41622. * Interface for screenshot methods with describe argument called `size` as object with options
  41623. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41624. */
  41625. export interface IScreenshotSize {
  41626. /**
  41627. * number in pixels for canvas height
  41628. */
  41629. height?: number;
  41630. /**
  41631. * multiplier allowing render at a higher or lower resolution
  41632. * If value is defined then height and width will be ignored and taken from camera
  41633. */
  41634. precision?: number;
  41635. /**
  41636. * number in pixels for canvas width
  41637. */
  41638. width?: number;
  41639. }
  41640. }
  41641. declare module BABYLON {
  41642. interface IColor4Like {
  41643. r: float;
  41644. g: float;
  41645. b: float;
  41646. a: float;
  41647. }
  41648. /**
  41649. * Class containing a set of static utilities functions
  41650. */
  41651. export class Tools {
  41652. /**
  41653. * Gets or sets the base URL to use to load assets
  41654. */
  41655. static get BaseUrl(): string;
  41656. static set BaseUrl(value: string);
  41657. /**
  41658. * Enable/Disable Custom HTTP Request Headers globally.
  41659. * default = false
  41660. * @see CustomRequestHeaders
  41661. */
  41662. static UseCustomRequestHeaders: boolean;
  41663. /**
  41664. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41665. * i.e. when loading files, where the server/service expects an Authorization header
  41666. */
  41667. static CustomRequestHeaders: {
  41668. [key: string]: string;
  41669. };
  41670. /**
  41671. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41672. */
  41673. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41674. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41675. /**
  41676. * Default behaviour for cors in the application.
  41677. * It can be a string if the expected behavior is identical in the entire app.
  41678. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41679. */
  41680. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41681. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41682. /**
  41683. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41684. * @ignorenaming
  41685. */
  41686. static get UseFallbackTexture(): boolean;
  41687. static set UseFallbackTexture(value: boolean);
  41688. /**
  41689. * Use this object to register external classes like custom textures or material
  41690. * to allow the laoders to instantiate them
  41691. */
  41692. static get RegisteredExternalClasses(): {
  41693. [key: string]: Object;
  41694. };
  41695. static set RegisteredExternalClasses(classes: {
  41696. [key: string]: Object;
  41697. });
  41698. /**
  41699. * Texture content used if a texture cannot loaded
  41700. * @ignorenaming
  41701. */
  41702. static get fallbackTexture(): string;
  41703. static set fallbackTexture(value: string);
  41704. /**
  41705. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41706. * @param u defines the coordinate on X axis
  41707. * @param v defines the coordinate on Y axis
  41708. * @param width defines the width of the source data
  41709. * @param height defines the height of the source data
  41710. * @param pixels defines the source byte array
  41711. * @param color defines the output color
  41712. */
  41713. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41714. /**
  41715. * Interpolates between a and b via alpha
  41716. * @param a The lower value (returned when alpha = 0)
  41717. * @param b The upper value (returned when alpha = 1)
  41718. * @param alpha The interpolation-factor
  41719. * @return The mixed value
  41720. */
  41721. static Mix(a: number, b: number, alpha: number): number;
  41722. /**
  41723. * Tries to instantiate a new object from a given class name
  41724. * @param className defines the class name to instantiate
  41725. * @returns the new object or null if the system was not able to do the instantiation
  41726. */
  41727. static Instantiate(className: string): any;
  41728. /**
  41729. * Provides a slice function that will work even on IE
  41730. * @param data defines the array to slice
  41731. * @param start defines the start of the data (optional)
  41732. * @param end defines the end of the data (optional)
  41733. * @returns the new sliced array
  41734. */
  41735. static Slice<T>(data: T, start?: number, end?: number): T;
  41736. /**
  41737. * Provides a slice function that will work even on IE
  41738. * The difference between this and Slice is that this will force-convert to array
  41739. * @param data defines the array to slice
  41740. * @param start defines the start of the data (optional)
  41741. * @param end defines the end of the data (optional)
  41742. * @returns the new sliced array
  41743. */
  41744. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41745. /**
  41746. * Polyfill for setImmediate
  41747. * @param action defines the action to execute after the current execution block
  41748. */
  41749. static SetImmediate(action: () => void): void;
  41750. /**
  41751. * Function indicating if a number is an exponent of 2
  41752. * @param value defines the value to test
  41753. * @returns true if the value is an exponent of 2
  41754. */
  41755. static IsExponentOfTwo(value: number): boolean;
  41756. private static _tmpFloatArray;
  41757. /**
  41758. * Returns the nearest 32-bit single precision float representation of a Number
  41759. * @param value A Number. If the parameter is of a different type, it will get converted
  41760. * to a number or to NaN if it cannot be converted
  41761. * @returns number
  41762. */
  41763. static FloatRound(value: number): number;
  41764. /**
  41765. * Extracts the filename from a path
  41766. * @param path defines the path to use
  41767. * @returns the filename
  41768. */
  41769. static GetFilename(path: string): string;
  41770. /**
  41771. * Extracts the "folder" part of a path (everything before the filename).
  41772. * @param uri The URI to extract the info from
  41773. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41774. * @returns The "folder" part of the path
  41775. */
  41776. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41777. /**
  41778. * Extracts text content from a DOM element hierarchy
  41779. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41780. */
  41781. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41782. /**
  41783. * Convert an angle in radians to degrees
  41784. * @param angle defines the angle to convert
  41785. * @returns the angle in degrees
  41786. */
  41787. static ToDegrees(angle: number): number;
  41788. /**
  41789. * Convert an angle in degrees to radians
  41790. * @param angle defines the angle to convert
  41791. * @returns the angle in radians
  41792. */
  41793. static ToRadians(angle: number): number;
  41794. /**
  41795. * Returns an array if obj is not an array
  41796. * @param obj defines the object to evaluate as an array
  41797. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41798. * @returns either obj directly if obj is an array or a new array containing obj
  41799. */
  41800. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41801. /**
  41802. * Gets the pointer prefix to use
  41803. * @param engine defines the engine we are finding the prefix for
  41804. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41805. */
  41806. static GetPointerPrefix(engine: Engine): string;
  41807. /**
  41808. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41809. * @param url define the url we are trying
  41810. * @param element define the dom element where to configure the cors policy
  41811. */
  41812. static SetCorsBehavior(url: string | string[], element: {
  41813. crossOrigin: string | null;
  41814. }): void;
  41815. /**
  41816. * Removes unwanted characters from an url
  41817. * @param url defines the url to clean
  41818. * @returns the cleaned url
  41819. */
  41820. static CleanUrl(url: string): string;
  41821. /**
  41822. * Gets or sets a function used to pre-process url before using them to load assets
  41823. */
  41824. static get PreprocessUrl(): (url: string) => string;
  41825. static set PreprocessUrl(processor: (url: string) => string);
  41826. /**
  41827. * Loads an image as an HTMLImageElement.
  41828. * @param input url string, ArrayBuffer, or Blob to load
  41829. * @param onLoad callback called when the image successfully loads
  41830. * @param onError callback called when the image fails to load
  41831. * @param offlineProvider offline provider for caching
  41832. * @param mimeType optional mime type
  41833. * @returns the HTMLImageElement of the loaded image
  41834. */
  41835. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41836. /**
  41837. * Loads a file from a url
  41838. * @param url url string, ArrayBuffer, or Blob to load
  41839. * @param onSuccess callback called when the file successfully loads
  41840. * @param onProgress callback called while file is loading (if the server supports this mode)
  41841. * @param offlineProvider defines the offline provider for caching
  41842. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41843. * @param onError callback called when the file fails to load
  41844. * @returns a file request object
  41845. */
  41846. 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;
  41847. /**
  41848. * Loads a file from a url
  41849. * @param url the file url to load
  41850. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41851. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41852. */
  41853. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41854. /**
  41855. * Load a script (identified by an url). When the url returns, the
  41856. * content of this file is added into a new script element, attached to the DOM (body element)
  41857. * @param scriptUrl defines the url of the script to laod
  41858. * @param onSuccess defines the callback called when the script is loaded
  41859. * @param onError defines the callback to call if an error occurs
  41860. * @param scriptId defines the id of the script element
  41861. */
  41862. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41863. /**
  41864. * Load an asynchronous script (identified by an url). When the url returns, the
  41865. * content of this file is added into a new script element, attached to the DOM (body element)
  41866. * @param scriptUrl defines the url of the script to laod
  41867. * @param scriptId defines the id of the script element
  41868. * @returns a promise request object
  41869. */
  41870. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41871. /**
  41872. * Loads a file from a blob
  41873. * @param fileToLoad defines the blob to use
  41874. * @param callback defines the callback to call when data is loaded
  41875. * @param progressCallback defines the callback to call during loading process
  41876. * @returns a file request object
  41877. */
  41878. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41879. /**
  41880. * Reads a file from a File object
  41881. * @param file defines the file to load
  41882. * @param onSuccess defines the callback to call when data is loaded
  41883. * @param onProgress defines the callback to call during loading process
  41884. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41885. * @param onError defines the callback to call when an error occurs
  41886. * @returns a file request object
  41887. */
  41888. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41889. /**
  41890. * Creates a data url from a given string content
  41891. * @param content defines the content to convert
  41892. * @returns the new data url link
  41893. */
  41894. static FileAsURL(content: string): string;
  41895. /**
  41896. * Format the given number to a specific decimal format
  41897. * @param value defines the number to format
  41898. * @param decimals defines the number of decimals to use
  41899. * @returns the formatted string
  41900. */
  41901. static Format(value: number, decimals?: number): string;
  41902. /**
  41903. * Tries to copy an object by duplicating every property
  41904. * @param source defines the source object
  41905. * @param destination defines the target object
  41906. * @param doNotCopyList defines a list of properties to avoid
  41907. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41908. */
  41909. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41910. /**
  41911. * Gets a boolean indicating if the given object has no own property
  41912. * @param obj defines the object to test
  41913. * @returns true if object has no own property
  41914. */
  41915. static IsEmpty(obj: any): boolean;
  41916. /**
  41917. * Function used to register events at window level
  41918. * @param windowElement defines the Window object to use
  41919. * @param events defines the events to register
  41920. */
  41921. static RegisterTopRootEvents(windowElement: Window, events: {
  41922. name: string;
  41923. handler: Nullable<(e: FocusEvent) => any>;
  41924. }[]): void;
  41925. /**
  41926. * Function used to unregister events from window level
  41927. * @param windowElement defines the Window object to use
  41928. * @param events defines the events to unregister
  41929. */
  41930. static UnregisterTopRootEvents(windowElement: Window, events: {
  41931. name: string;
  41932. handler: Nullable<(e: FocusEvent) => any>;
  41933. }[]): void;
  41934. /**
  41935. * @ignore
  41936. */
  41937. static _ScreenshotCanvas: HTMLCanvasElement;
  41938. /**
  41939. * Dumps the current bound framebuffer
  41940. * @param width defines the rendering width
  41941. * @param height defines the rendering height
  41942. * @param engine defines the hosting engine
  41943. * @param successCallback defines the callback triggered once the data are available
  41944. * @param mimeType defines the mime type of the result
  41945. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41946. */
  41947. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41948. /**
  41949. * Converts the canvas data to blob.
  41950. * This acts as a polyfill for browsers not supporting the to blob function.
  41951. * @param canvas Defines the canvas to extract the data from
  41952. * @param successCallback Defines the callback triggered once the data are available
  41953. * @param mimeType Defines the mime type of the result
  41954. */
  41955. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41956. /**
  41957. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41958. * @param successCallback defines the callback triggered once the data are available
  41959. * @param mimeType defines the mime type of the result
  41960. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41961. */
  41962. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41963. /**
  41964. * Downloads a blob in the browser
  41965. * @param blob defines the blob to download
  41966. * @param fileName defines the name of the downloaded file
  41967. */
  41968. static Download(blob: Blob, fileName: string): void;
  41969. /**
  41970. * Will return the right value of the noPreventDefault variable
  41971. * Needed to keep backwards compatibility to the old API.
  41972. *
  41973. * @param args arguments passed to the attachControl function
  41974. * @returns the correct value for noPreventDefault
  41975. */
  41976. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  41977. /**
  41978. * Captures a screenshot of the current rendering
  41979. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41980. * @param engine defines the rendering engine
  41981. * @param camera defines the source camera
  41982. * @param size This parameter can be set to a single number or to an object with the
  41983. * following (optional) properties: precision, width, height. If a single number is passed,
  41984. * it will be used for both width and height. If an object is passed, the screenshot size
  41985. * will be derived from the parameters. The precision property is a multiplier allowing
  41986. * rendering at a higher or lower resolution
  41987. * @param successCallback defines the callback receives a single parameter which contains the
  41988. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41989. * src parameter of an <img> to display it
  41990. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41991. * Check your browser for supported MIME types
  41992. */
  41993. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41994. /**
  41995. * Captures a screenshot of the current rendering
  41996. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41997. * @param engine defines the rendering engine
  41998. * @param camera defines the source camera
  41999. * @param size This parameter can be set to a single number or to an object with the
  42000. * following (optional) properties: precision, width, height. If a single number is passed,
  42001. * it will be used for both width and height. If an object is passed, the screenshot size
  42002. * will be derived from the parameters. The precision property is a multiplier allowing
  42003. * rendering at a higher or lower resolution
  42004. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42005. * Check your browser for supported MIME types
  42006. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42007. * to the src parameter of an <img> to display it
  42008. */
  42009. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42010. /**
  42011. * Generates an image screenshot from the specified camera.
  42012. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42013. * @param engine The engine to use for rendering
  42014. * @param camera The camera to use for rendering
  42015. * @param size This parameter can be set to a single number or to an object with the
  42016. * following (optional) properties: precision, width, height. If a single number is passed,
  42017. * it will be used for both width and height. If an object is passed, the screenshot size
  42018. * will be derived from the parameters. The precision property is a multiplier allowing
  42019. * rendering at a higher or lower resolution
  42020. * @param successCallback The callback receives a single parameter which contains the
  42021. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42022. * src parameter of an <img> to display it
  42023. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42024. * Check your browser for supported MIME types
  42025. * @param samples Texture samples (default: 1)
  42026. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42027. * @param fileName A name for for the downloaded file.
  42028. */
  42029. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42030. /**
  42031. * Generates an image screenshot from the specified camera.
  42032. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42033. * @param engine The engine to use for rendering
  42034. * @param camera The camera to use for rendering
  42035. * @param size This parameter can be set to a single number or to an object with the
  42036. * following (optional) properties: precision, width, height. If a single number is passed,
  42037. * it will be used for both width and height. If an object is passed, the screenshot size
  42038. * will be derived from the parameters. The precision property is a multiplier allowing
  42039. * rendering at a higher or lower resolution
  42040. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42041. * Check your browser for supported MIME types
  42042. * @param samples Texture samples (default: 1)
  42043. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42044. * @param fileName A name for for the downloaded file.
  42045. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42046. * to the src parameter of an <img> to display it
  42047. */
  42048. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42049. /**
  42050. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42051. * Be aware Math.random() could cause collisions, but:
  42052. * "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"
  42053. * @returns a pseudo random id
  42054. */
  42055. static RandomId(): string;
  42056. /**
  42057. * Test if the given uri is a base64 string
  42058. * @param uri The uri to test
  42059. * @return True if the uri is a base64 string or false otherwise
  42060. */
  42061. static IsBase64(uri: string): boolean;
  42062. /**
  42063. * Decode the given base64 uri.
  42064. * @param uri The uri to decode
  42065. * @return The decoded base64 data.
  42066. */
  42067. static DecodeBase64(uri: string): ArrayBuffer;
  42068. /**
  42069. * Gets the absolute url.
  42070. * @param url the input url
  42071. * @return the absolute url
  42072. */
  42073. static GetAbsoluteUrl(url: string): string;
  42074. /**
  42075. * No log
  42076. */
  42077. static readonly NoneLogLevel: number;
  42078. /**
  42079. * Only message logs
  42080. */
  42081. static readonly MessageLogLevel: number;
  42082. /**
  42083. * Only warning logs
  42084. */
  42085. static readonly WarningLogLevel: number;
  42086. /**
  42087. * Only error logs
  42088. */
  42089. static readonly ErrorLogLevel: number;
  42090. /**
  42091. * All logs
  42092. */
  42093. static readonly AllLogLevel: number;
  42094. /**
  42095. * Gets a value indicating the number of loading errors
  42096. * @ignorenaming
  42097. */
  42098. static get errorsCount(): number;
  42099. /**
  42100. * Callback called when a new log is added
  42101. */
  42102. static OnNewCacheEntry: (entry: string) => void;
  42103. /**
  42104. * Log a message to the console
  42105. * @param message defines the message to log
  42106. */
  42107. static Log(message: string): void;
  42108. /**
  42109. * Write a warning message to the console
  42110. * @param message defines the message to log
  42111. */
  42112. static Warn(message: string): void;
  42113. /**
  42114. * Write an error message to the console
  42115. * @param message defines the message to log
  42116. */
  42117. static Error(message: string): void;
  42118. /**
  42119. * Gets current log cache (list of logs)
  42120. */
  42121. static get LogCache(): string;
  42122. /**
  42123. * Clears the log cache
  42124. */
  42125. static ClearLogCache(): void;
  42126. /**
  42127. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42128. */
  42129. static set LogLevels(level: number);
  42130. /**
  42131. * Checks if the window object exists
  42132. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42133. */
  42134. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42135. /**
  42136. * No performance log
  42137. */
  42138. static readonly PerformanceNoneLogLevel: number;
  42139. /**
  42140. * Use user marks to log performance
  42141. */
  42142. static readonly PerformanceUserMarkLogLevel: number;
  42143. /**
  42144. * Log performance to the console
  42145. */
  42146. static readonly PerformanceConsoleLogLevel: number;
  42147. private static _performance;
  42148. /**
  42149. * Sets the current performance log level
  42150. */
  42151. static set PerformanceLogLevel(level: number);
  42152. private static _StartPerformanceCounterDisabled;
  42153. private static _EndPerformanceCounterDisabled;
  42154. private static _StartUserMark;
  42155. private static _EndUserMark;
  42156. private static _StartPerformanceConsole;
  42157. private static _EndPerformanceConsole;
  42158. /**
  42159. * Starts a performance counter
  42160. */
  42161. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42162. /**
  42163. * Ends a specific performance coutner
  42164. */
  42165. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42166. /**
  42167. * Gets either window.performance.now() if supported or Date.now() else
  42168. */
  42169. static get Now(): number;
  42170. /**
  42171. * This method will return the name of the class used to create the instance of the given object.
  42172. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42173. * @param object the object to get the class name from
  42174. * @param isType defines if the object is actually a type
  42175. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42176. */
  42177. static GetClassName(object: any, isType?: boolean): string;
  42178. /**
  42179. * Gets the first element of an array satisfying a given predicate
  42180. * @param array defines the array to browse
  42181. * @param predicate defines the predicate to use
  42182. * @returns null if not found or the element
  42183. */
  42184. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42185. /**
  42186. * This method will return the name of the full name of the class, including its owning module (if any).
  42187. * 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).
  42188. * @param object the object to get the class name from
  42189. * @param isType defines if the object is actually a type
  42190. * @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.
  42191. * @ignorenaming
  42192. */
  42193. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42194. /**
  42195. * Returns a promise that resolves after the given amount of time.
  42196. * @param delay Number of milliseconds to delay
  42197. * @returns Promise that resolves after the given amount of time
  42198. */
  42199. static DelayAsync(delay: number): Promise<void>;
  42200. /**
  42201. * Utility function to detect if the current user agent is Safari
  42202. * @returns whether or not the current user agent is safari
  42203. */
  42204. static IsSafari(): boolean;
  42205. }
  42206. /**
  42207. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42208. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42209. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42210. * @param name The name of the class, case should be preserved
  42211. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42212. */
  42213. export function className(name: string, module?: string): (target: Object) => void;
  42214. /**
  42215. * An implementation of a loop for asynchronous functions.
  42216. */
  42217. export class AsyncLoop {
  42218. /**
  42219. * Defines the number of iterations for the loop
  42220. */
  42221. iterations: number;
  42222. /**
  42223. * Defines the current index of the loop.
  42224. */
  42225. index: number;
  42226. private _done;
  42227. private _fn;
  42228. private _successCallback;
  42229. /**
  42230. * Constructor.
  42231. * @param iterations the number of iterations.
  42232. * @param func the function to run each iteration
  42233. * @param successCallback the callback that will be called upon succesful execution
  42234. * @param offset starting offset.
  42235. */
  42236. constructor(
  42237. /**
  42238. * Defines the number of iterations for the loop
  42239. */
  42240. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42241. /**
  42242. * Execute the next iteration. Must be called after the last iteration was finished.
  42243. */
  42244. executeNext(): void;
  42245. /**
  42246. * Break the loop and run the success callback.
  42247. */
  42248. breakLoop(): void;
  42249. /**
  42250. * Create and run an async loop.
  42251. * @param iterations the number of iterations.
  42252. * @param fn the function to run each iteration
  42253. * @param successCallback the callback that will be called upon succesful execution
  42254. * @param offset starting offset.
  42255. * @returns the created async loop object
  42256. */
  42257. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42258. /**
  42259. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42260. * @param iterations total number of iterations
  42261. * @param syncedIterations number of synchronous iterations in each async iteration.
  42262. * @param fn the function to call each iteration.
  42263. * @param callback a success call back that will be called when iterating stops.
  42264. * @param breakFunction a break condition (optional)
  42265. * @param timeout timeout settings for the setTimeout function. default - 0.
  42266. * @returns the created async loop object
  42267. */
  42268. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42274. * The underlying implementation relies on an associative array to ensure the best performances.
  42275. * The value can be anything including 'null' but except 'undefined'
  42276. */
  42277. export class StringDictionary<T> {
  42278. /**
  42279. * This will clear this dictionary and copy the content from the 'source' one.
  42280. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42281. * @param source the dictionary to take the content from and copy to this dictionary
  42282. */
  42283. copyFrom(source: StringDictionary<T>): void;
  42284. /**
  42285. * Get a value based from its key
  42286. * @param key the given key to get the matching value from
  42287. * @return the value if found, otherwise undefined is returned
  42288. */
  42289. get(key: string): T | undefined;
  42290. /**
  42291. * Get a value from its key or add it if it doesn't exist.
  42292. * This method will ensure you that a given key/data will be present in the dictionary.
  42293. * @param key the given key to get the matching value from
  42294. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42295. * The factory will only be invoked if there's no data for the given key.
  42296. * @return the value corresponding to the key.
  42297. */
  42298. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42299. /**
  42300. * Get a value from its key if present in the dictionary otherwise add it
  42301. * @param key the key to get the value from
  42302. * @param val if there's no such key/value pair in the dictionary add it with this value
  42303. * @return the value corresponding to the key
  42304. */
  42305. getOrAdd(key: string, val: T): T;
  42306. /**
  42307. * Check if there's a given key in the dictionary
  42308. * @param key the key to check for
  42309. * @return true if the key is present, false otherwise
  42310. */
  42311. contains(key: string): boolean;
  42312. /**
  42313. * Add a new key and its corresponding value
  42314. * @param key the key to add
  42315. * @param value the value corresponding to the key
  42316. * @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
  42317. */
  42318. add(key: string, value: T): boolean;
  42319. /**
  42320. * Update a specific value associated to a key
  42321. * @param key defines the key to use
  42322. * @param value defines the value to store
  42323. * @returns true if the value was updated (or false if the key was not found)
  42324. */
  42325. set(key: string, value: T): boolean;
  42326. /**
  42327. * Get the element of the given key and remove it from the dictionary
  42328. * @param key defines the key to search
  42329. * @returns the value associated with the key or null if not found
  42330. */
  42331. getAndRemove(key: string): Nullable<T>;
  42332. /**
  42333. * Remove a key/value from the dictionary.
  42334. * @param key the key to remove
  42335. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42336. */
  42337. remove(key: string): boolean;
  42338. /**
  42339. * Clear the whole content of the dictionary
  42340. */
  42341. clear(): void;
  42342. /**
  42343. * Gets the current count
  42344. */
  42345. get count(): number;
  42346. /**
  42347. * Execute a callback on each key/val of the dictionary.
  42348. * Note that you can remove any element in this dictionary in the callback implementation
  42349. * @param callback the callback to execute on a given key/value pair
  42350. */
  42351. forEach(callback: (key: string, val: T) => void): void;
  42352. /**
  42353. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42354. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42355. * Note that you can remove any element in this dictionary in the callback implementation
  42356. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42357. * @returns the first item
  42358. */
  42359. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42360. private _count;
  42361. private _data;
  42362. }
  42363. }
  42364. declare module BABYLON {
  42365. /** @hidden */
  42366. export interface ICollisionCoordinator {
  42367. createCollider(): Collider;
  42368. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42369. init(scene: Scene): void;
  42370. }
  42371. /** @hidden */
  42372. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42373. private _scene;
  42374. private _scaledPosition;
  42375. private _scaledVelocity;
  42376. private _finalPosition;
  42377. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42378. createCollider(): Collider;
  42379. init(scene: Scene): void;
  42380. private _collideWithWorld;
  42381. }
  42382. }
  42383. declare module BABYLON {
  42384. /**
  42385. * Class used to manage all inputs for the scene.
  42386. */
  42387. export class InputManager {
  42388. /** The distance in pixel that you have to move to prevent some events */
  42389. static DragMovementThreshold: number;
  42390. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42391. static LongPressDelay: number;
  42392. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42393. static DoubleClickDelay: number;
  42394. /** If you need to check double click without raising a single click at first click, enable this flag */
  42395. static ExclusiveDoubleClickMode: boolean;
  42396. /** 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. */
  42397. private _alreadyAttached;
  42398. private _alreadyAttachedTo;
  42399. private _wheelEventName;
  42400. private _onPointerMove;
  42401. private _onPointerDown;
  42402. private _onPointerUp;
  42403. private _initClickEvent;
  42404. private _initActionManager;
  42405. private _delayedSimpleClick;
  42406. private _delayedSimpleClickTimeout;
  42407. private _previousDelayedSimpleClickTimeout;
  42408. private _meshPickProceed;
  42409. private _previousButtonPressed;
  42410. private _currentPickResult;
  42411. private _previousPickResult;
  42412. private _totalPointersPressed;
  42413. private _doubleClickOccured;
  42414. private _pointerOverMesh;
  42415. private _pickedDownMesh;
  42416. private _pickedUpMesh;
  42417. private _pointerX;
  42418. private _pointerY;
  42419. private _unTranslatedPointerX;
  42420. private _unTranslatedPointerY;
  42421. private _startingPointerPosition;
  42422. private _previousStartingPointerPosition;
  42423. private _startingPointerTime;
  42424. private _previousStartingPointerTime;
  42425. private _pointerCaptures;
  42426. private _meshUnderPointerId;
  42427. private _onKeyDown;
  42428. private _onKeyUp;
  42429. private _keyboardIsAttached;
  42430. private _onCanvasFocusObserver;
  42431. private _onCanvasBlurObserver;
  42432. private _scene;
  42433. /**
  42434. * Creates a new InputManager
  42435. * @param scene defines the hosting scene
  42436. */
  42437. constructor(scene: Scene);
  42438. /**
  42439. * Gets the mesh that is currently under the pointer
  42440. */
  42441. get meshUnderPointer(): Nullable<AbstractMesh>;
  42442. /**
  42443. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42444. * @param pointerId the pointer id to use
  42445. * @returns The mesh under this pointer id or null if not found
  42446. */
  42447. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42448. /**
  42449. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42450. */
  42451. get unTranslatedPointer(): Vector2;
  42452. /**
  42453. * Gets or sets the current on-screen X position of the pointer
  42454. */
  42455. get pointerX(): number;
  42456. set pointerX(value: number);
  42457. /**
  42458. * Gets or sets the current on-screen Y position of the pointer
  42459. */
  42460. get pointerY(): number;
  42461. set pointerY(value: number);
  42462. private _updatePointerPosition;
  42463. private _processPointerMove;
  42464. private _setRayOnPointerInfo;
  42465. private _checkPrePointerObservable;
  42466. /**
  42467. * Use this method to simulate a pointer move on a mesh
  42468. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42469. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42470. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42471. */
  42472. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42473. /**
  42474. * Use this method to simulate a pointer down on a mesh
  42475. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42476. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42477. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42478. */
  42479. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42480. private _processPointerDown;
  42481. /** @hidden */
  42482. _isPointerSwiping(): boolean;
  42483. /**
  42484. * Use this method to simulate a pointer up on a mesh
  42485. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42486. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42487. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42488. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42489. */
  42490. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42491. private _processPointerUp;
  42492. /**
  42493. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42494. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42495. * @returns true if the pointer was captured
  42496. */
  42497. isPointerCaptured(pointerId?: number): boolean;
  42498. /**
  42499. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42500. * @param attachUp defines if you want to attach events to pointerup
  42501. * @param attachDown defines if you want to attach events to pointerdown
  42502. * @param attachMove defines if you want to attach events to pointermove
  42503. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42504. */
  42505. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42506. /**
  42507. * Detaches all event handlers
  42508. */
  42509. detachControl(): void;
  42510. /**
  42511. * Force the value of meshUnderPointer
  42512. * @param mesh defines the mesh to use
  42513. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42514. */
  42515. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42516. /**
  42517. * Gets the mesh under the pointer
  42518. * @returns a Mesh or null if no mesh is under the pointer
  42519. */
  42520. getPointerOverMesh(): Nullable<AbstractMesh>;
  42521. }
  42522. }
  42523. declare module BABYLON {
  42524. /**
  42525. * This class defines the direct association between an animation and a target
  42526. */
  42527. export class TargetedAnimation {
  42528. /**
  42529. * Animation to perform
  42530. */
  42531. animation: Animation;
  42532. /**
  42533. * Target to animate
  42534. */
  42535. target: any;
  42536. /**
  42537. * Returns the string "TargetedAnimation"
  42538. * @returns "TargetedAnimation"
  42539. */
  42540. getClassName(): string;
  42541. /**
  42542. * Serialize the object
  42543. * @returns the JSON object representing the current entity
  42544. */
  42545. serialize(): any;
  42546. }
  42547. /**
  42548. * Use this class to create coordinated animations on multiple targets
  42549. */
  42550. export class AnimationGroup implements IDisposable {
  42551. /** The name of the animation group */
  42552. name: string;
  42553. private _scene;
  42554. private _targetedAnimations;
  42555. private _animatables;
  42556. private _from;
  42557. private _to;
  42558. private _isStarted;
  42559. private _isPaused;
  42560. private _speedRatio;
  42561. private _loopAnimation;
  42562. private _isAdditive;
  42563. /**
  42564. * Gets or sets the unique id of the node
  42565. */
  42566. uniqueId: number;
  42567. /**
  42568. * This observable will notify when one animation have ended
  42569. */
  42570. onAnimationEndObservable: Observable<TargetedAnimation>;
  42571. /**
  42572. * Observer raised when one animation loops
  42573. */
  42574. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42575. /**
  42576. * Observer raised when all animations have looped
  42577. */
  42578. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42579. /**
  42580. * This observable will notify when all animations have ended.
  42581. */
  42582. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42583. /**
  42584. * This observable will notify when all animations have paused.
  42585. */
  42586. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42587. /**
  42588. * This observable will notify when all animations are playing.
  42589. */
  42590. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42591. /**
  42592. * Gets the first frame
  42593. */
  42594. get from(): number;
  42595. /**
  42596. * Gets the last frame
  42597. */
  42598. get to(): number;
  42599. /**
  42600. * Define if the animations are started
  42601. */
  42602. get isStarted(): boolean;
  42603. /**
  42604. * Gets a value indicating that the current group is playing
  42605. */
  42606. get isPlaying(): boolean;
  42607. /**
  42608. * Gets or sets the speed ratio to use for all animations
  42609. */
  42610. get speedRatio(): number;
  42611. /**
  42612. * Gets or sets the speed ratio to use for all animations
  42613. */
  42614. set speedRatio(value: number);
  42615. /**
  42616. * Gets or sets if all animations should loop or not
  42617. */
  42618. get loopAnimation(): boolean;
  42619. set loopAnimation(value: boolean);
  42620. /**
  42621. * Gets or sets if all animations should be evaluated additively
  42622. */
  42623. get isAdditive(): boolean;
  42624. set isAdditive(value: boolean);
  42625. /**
  42626. * Gets the targeted animations for this animation group
  42627. */
  42628. get targetedAnimations(): Array<TargetedAnimation>;
  42629. /**
  42630. * returning the list of animatables controlled by this animation group.
  42631. */
  42632. get animatables(): Array<Animatable>;
  42633. /**
  42634. * Gets the list of target animations
  42635. */
  42636. get children(): TargetedAnimation[];
  42637. /**
  42638. * Instantiates a new Animation Group.
  42639. * This helps managing several animations at once.
  42640. * @see https://doc.babylonjs.com/how_to/group
  42641. * @param name Defines the name of the group
  42642. * @param scene Defines the scene the group belongs to
  42643. */
  42644. constructor(
  42645. /** The name of the animation group */
  42646. name: string, scene?: Nullable<Scene>);
  42647. /**
  42648. * Add an animation (with its target) in the group
  42649. * @param animation defines the animation we want to add
  42650. * @param target defines the target of the animation
  42651. * @returns the TargetedAnimation object
  42652. */
  42653. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42654. /**
  42655. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42656. * It can add constant keys at begin or end
  42657. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42658. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42659. * @returns the animation group
  42660. */
  42661. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42662. private _animationLoopCount;
  42663. private _animationLoopFlags;
  42664. private _processLoop;
  42665. /**
  42666. * Start all animations on given targets
  42667. * @param loop defines if animations must loop
  42668. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42669. * @param from defines the from key (optional)
  42670. * @param to defines the to key (optional)
  42671. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42672. * @returns the current animation group
  42673. */
  42674. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42675. /**
  42676. * Pause all animations
  42677. * @returns the animation group
  42678. */
  42679. pause(): AnimationGroup;
  42680. /**
  42681. * Play all animations to initial state
  42682. * This function will start() the animations if they were not started or will restart() them if they were paused
  42683. * @param loop defines if animations must loop
  42684. * @returns the animation group
  42685. */
  42686. play(loop?: boolean): AnimationGroup;
  42687. /**
  42688. * Reset all animations to initial state
  42689. * @returns the animation group
  42690. */
  42691. reset(): AnimationGroup;
  42692. /**
  42693. * Restart animations from key 0
  42694. * @returns the animation group
  42695. */
  42696. restart(): AnimationGroup;
  42697. /**
  42698. * Stop all animations
  42699. * @returns the animation group
  42700. */
  42701. stop(): AnimationGroup;
  42702. /**
  42703. * Set animation weight for all animatables
  42704. * @param weight defines the weight to use
  42705. * @return the animationGroup
  42706. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42707. */
  42708. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42709. /**
  42710. * Synchronize and normalize all animatables with a source animatable
  42711. * @param root defines the root animatable to synchronize with
  42712. * @return the animationGroup
  42713. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42714. */
  42715. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42716. /**
  42717. * Goes to a specific frame in this animation group
  42718. * @param frame the frame number to go to
  42719. * @return the animationGroup
  42720. */
  42721. goToFrame(frame: number): AnimationGroup;
  42722. /**
  42723. * Dispose all associated resources
  42724. */
  42725. dispose(): void;
  42726. private _checkAnimationGroupEnded;
  42727. /**
  42728. * Clone the current animation group and returns a copy
  42729. * @param newName defines the name of the new group
  42730. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42731. * @returns the new aniamtion group
  42732. */
  42733. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42734. /**
  42735. * Serializes the animationGroup to an object
  42736. * @returns Serialized object
  42737. */
  42738. serialize(): any;
  42739. /**
  42740. * Returns a new AnimationGroup object parsed from the source provided.
  42741. * @param parsedAnimationGroup defines the source
  42742. * @param scene defines the scene that will receive the animationGroup
  42743. * @returns a new AnimationGroup
  42744. */
  42745. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42746. /**
  42747. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42748. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42749. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42750. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42751. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42752. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42753. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42754. */
  42755. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42756. /**
  42757. * Returns the string "AnimationGroup"
  42758. * @returns "AnimationGroup"
  42759. */
  42760. getClassName(): string;
  42761. /**
  42762. * Creates a detailled string about the object
  42763. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42764. * @returns a string representing the object
  42765. */
  42766. toString(fullDetails?: boolean): string;
  42767. }
  42768. }
  42769. declare module BABYLON {
  42770. /**
  42771. * Define an interface for all classes that will hold resources
  42772. */
  42773. export interface IDisposable {
  42774. /**
  42775. * Releases all held resources
  42776. */
  42777. dispose(): void;
  42778. }
  42779. /** Interface defining initialization parameters for Scene class */
  42780. export interface SceneOptions {
  42781. /**
  42782. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42783. * It will improve performance when the number of geometries becomes important.
  42784. */
  42785. useGeometryUniqueIdsMap?: boolean;
  42786. /**
  42787. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42788. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42789. */
  42790. useMaterialMeshMap?: boolean;
  42791. /**
  42792. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42793. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42794. */
  42795. useClonedMeshMap?: boolean;
  42796. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42797. virtual?: boolean;
  42798. }
  42799. /**
  42800. * Represents a scene to be rendered by the engine.
  42801. * @see https://doc.babylonjs.com/features/scene
  42802. */
  42803. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42804. /** The fog is deactivated */
  42805. static readonly FOGMODE_NONE: number;
  42806. /** The fog density is following an exponential function */
  42807. static readonly FOGMODE_EXP: number;
  42808. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42809. static readonly FOGMODE_EXP2: number;
  42810. /** The fog density is following a linear function. */
  42811. static readonly FOGMODE_LINEAR: number;
  42812. /**
  42813. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42814. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42815. */
  42816. static MinDeltaTime: number;
  42817. /**
  42818. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42819. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42820. */
  42821. static MaxDeltaTime: number;
  42822. /**
  42823. * Factory used to create the default material.
  42824. * @param name The name of the material to create
  42825. * @param scene The scene to create the material for
  42826. * @returns The default material
  42827. */
  42828. static DefaultMaterialFactory(scene: Scene): Material;
  42829. /**
  42830. * Factory used to create the a collision coordinator.
  42831. * @returns The collision coordinator
  42832. */
  42833. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42834. /** @hidden */
  42835. _inputManager: InputManager;
  42836. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42837. cameraToUseForPointers: Nullable<Camera>;
  42838. /** @hidden */
  42839. readonly _isScene: boolean;
  42840. /** @hidden */
  42841. _blockEntityCollection: boolean;
  42842. /**
  42843. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42844. */
  42845. autoClear: boolean;
  42846. /**
  42847. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42848. */
  42849. autoClearDepthAndStencil: boolean;
  42850. /**
  42851. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42852. */
  42853. clearColor: Color4;
  42854. /**
  42855. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42856. */
  42857. ambientColor: Color3;
  42858. /**
  42859. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42860. * It should only be one of the following (if not the default embedded one):
  42861. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42862. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42863. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42864. * The material properties need to be setup according to the type of texture in use.
  42865. */
  42866. environmentBRDFTexture: BaseTexture;
  42867. /**
  42868. * Texture used in all pbr material as the reflection texture.
  42869. * As in the majority of the scene they are the same (exception for multi room and so on),
  42870. * this is easier to reference from here than from all the materials.
  42871. */
  42872. get environmentTexture(): Nullable<BaseTexture>;
  42873. /**
  42874. * Texture used in all pbr material as the reflection texture.
  42875. * As in the majority of the scene they are the same (exception for multi room and so on),
  42876. * this is easier to set here than in all the materials.
  42877. */
  42878. set environmentTexture(value: Nullable<BaseTexture>);
  42879. /** @hidden */
  42880. protected _environmentIntensity: number;
  42881. /**
  42882. * Intensity of the environment in all pbr material.
  42883. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42884. * As in the majority of the scene they are the same (exception for multi room and so on),
  42885. * this is easier to reference from here than from all the materials.
  42886. */
  42887. get environmentIntensity(): number;
  42888. /**
  42889. * Intensity of the environment in all pbr material.
  42890. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42891. * As in the majority of the scene they are the same (exception for multi room and so on),
  42892. * this is easier to set here than in all the materials.
  42893. */
  42894. set environmentIntensity(value: number);
  42895. /** @hidden */
  42896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42897. /**
  42898. * Default image processing configuration used either in the rendering
  42899. * Forward main pass or through the imageProcessingPostProcess if present.
  42900. * As in the majority of the scene they are the same (exception for multi camera),
  42901. * this is easier to reference from here than from all the materials and post process.
  42902. *
  42903. * No setter as we it is a shared configuration, you can set the values instead.
  42904. */
  42905. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42906. private _forceWireframe;
  42907. /**
  42908. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42909. */
  42910. set forceWireframe(value: boolean);
  42911. get forceWireframe(): boolean;
  42912. private _skipFrustumClipping;
  42913. /**
  42914. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42915. */
  42916. set skipFrustumClipping(value: boolean);
  42917. get skipFrustumClipping(): boolean;
  42918. private _forcePointsCloud;
  42919. /**
  42920. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42921. */
  42922. set forcePointsCloud(value: boolean);
  42923. get forcePointsCloud(): boolean;
  42924. /**
  42925. * Gets or sets the active clipplane 1
  42926. */
  42927. clipPlane: Nullable<Plane>;
  42928. /**
  42929. * Gets or sets the active clipplane 2
  42930. */
  42931. clipPlane2: Nullable<Plane>;
  42932. /**
  42933. * Gets or sets the active clipplane 3
  42934. */
  42935. clipPlane3: Nullable<Plane>;
  42936. /**
  42937. * Gets or sets the active clipplane 4
  42938. */
  42939. clipPlane4: Nullable<Plane>;
  42940. /**
  42941. * Gets or sets the active clipplane 5
  42942. */
  42943. clipPlane5: Nullable<Plane>;
  42944. /**
  42945. * Gets or sets the active clipplane 6
  42946. */
  42947. clipPlane6: Nullable<Plane>;
  42948. /**
  42949. * Gets or sets a boolean indicating if animations are enabled
  42950. */
  42951. animationsEnabled: boolean;
  42952. private _animationPropertiesOverride;
  42953. /**
  42954. * Gets or sets the animation properties override
  42955. */
  42956. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42957. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42958. /**
  42959. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42960. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42961. */
  42962. useConstantAnimationDeltaTime: boolean;
  42963. /**
  42964. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42965. * Please note that it requires to run a ray cast through the scene on every frame
  42966. */
  42967. constantlyUpdateMeshUnderPointer: boolean;
  42968. /**
  42969. * Defines the HTML cursor to use when hovering over interactive elements
  42970. */
  42971. hoverCursor: string;
  42972. /**
  42973. * Defines the HTML default cursor to use (empty by default)
  42974. */
  42975. defaultCursor: string;
  42976. /**
  42977. * Defines whether cursors are handled by the scene.
  42978. */
  42979. doNotHandleCursors: boolean;
  42980. /**
  42981. * This is used to call preventDefault() on pointer down
  42982. * in order to block unwanted artifacts like system double clicks
  42983. */
  42984. preventDefaultOnPointerDown: boolean;
  42985. /**
  42986. * This is used to call preventDefault() on pointer up
  42987. * in order to block unwanted artifacts like system double clicks
  42988. */
  42989. preventDefaultOnPointerUp: boolean;
  42990. /**
  42991. * Gets or sets user defined metadata
  42992. */
  42993. metadata: any;
  42994. /**
  42995. * For internal use only. Please do not use.
  42996. */
  42997. reservedDataStore: any;
  42998. /**
  42999. * Gets the name of the plugin used to load this scene (null by default)
  43000. */
  43001. loadingPluginName: string;
  43002. /**
  43003. * Use this array to add regular expressions used to disable offline support for specific urls
  43004. */
  43005. disableOfflineSupportExceptionRules: RegExp[];
  43006. /**
  43007. * An event triggered when the scene is disposed.
  43008. */
  43009. onDisposeObservable: Observable<Scene>;
  43010. private _onDisposeObserver;
  43011. /** Sets a function to be executed when this scene is disposed. */
  43012. set onDispose(callback: () => void);
  43013. /**
  43014. * An event triggered before rendering the scene (right after animations and physics)
  43015. */
  43016. onBeforeRenderObservable: Observable<Scene>;
  43017. private _onBeforeRenderObserver;
  43018. /** Sets a function to be executed before rendering this scene */
  43019. set beforeRender(callback: Nullable<() => void>);
  43020. /**
  43021. * An event triggered after rendering the scene
  43022. */
  43023. onAfterRenderObservable: Observable<Scene>;
  43024. /**
  43025. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43026. */
  43027. onAfterRenderCameraObservable: Observable<Camera>;
  43028. private _onAfterRenderObserver;
  43029. /** Sets a function to be executed after rendering this scene */
  43030. set afterRender(callback: Nullable<() => void>);
  43031. /**
  43032. * An event triggered before animating the scene
  43033. */
  43034. onBeforeAnimationsObservable: Observable<Scene>;
  43035. /**
  43036. * An event triggered after animations processing
  43037. */
  43038. onAfterAnimationsObservable: Observable<Scene>;
  43039. /**
  43040. * An event triggered before draw calls are ready to be sent
  43041. */
  43042. onBeforeDrawPhaseObservable: Observable<Scene>;
  43043. /**
  43044. * An event triggered after draw calls have been sent
  43045. */
  43046. onAfterDrawPhaseObservable: Observable<Scene>;
  43047. /**
  43048. * An event triggered when the scene is ready
  43049. */
  43050. onReadyObservable: Observable<Scene>;
  43051. /**
  43052. * An event triggered before rendering a camera
  43053. */
  43054. onBeforeCameraRenderObservable: Observable<Camera>;
  43055. private _onBeforeCameraRenderObserver;
  43056. /** Sets a function to be executed before rendering a camera*/
  43057. set beforeCameraRender(callback: () => void);
  43058. /**
  43059. * An event triggered after rendering a camera
  43060. */
  43061. onAfterCameraRenderObservable: Observable<Camera>;
  43062. private _onAfterCameraRenderObserver;
  43063. /** Sets a function to be executed after rendering a camera*/
  43064. set afterCameraRender(callback: () => void);
  43065. /**
  43066. * An event triggered when active meshes evaluation is about to start
  43067. */
  43068. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43069. /**
  43070. * An event triggered when active meshes evaluation is done
  43071. */
  43072. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43073. /**
  43074. * An event triggered when particles rendering is about to start
  43075. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43076. */
  43077. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43078. /**
  43079. * An event triggered when particles rendering is done
  43080. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43081. */
  43082. onAfterParticlesRenderingObservable: Observable<Scene>;
  43083. /**
  43084. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43085. */
  43086. onDataLoadedObservable: Observable<Scene>;
  43087. /**
  43088. * An event triggered when a camera is created
  43089. */
  43090. onNewCameraAddedObservable: Observable<Camera>;
  43091. /**
  43092. * An event triggered when a camera is removed
  43093. */
  43094. onCameraRemovedObservable: Observable<Camera>;
  43095. /**
  43096. * An event triggered when a light is created
  43097. */
  43098. onNewLightAddedObservable: Observable<Light>;
  43099. /**
  43100. * An event triggered when a light is removed
  43101. */
  43102. onLightRemovedObservable: Observable<Light>;
  43103. /**
  43104. * An event triggered when a geometry is created
  43105. */
  43106. onNewGeometryAddedObservable: Observable<Geometry>;
  43107. /**
  43108. * An event triggered when a geometry is removed
  43109. */
  43110. onGeometryRemovedObservable: Observable<Geometry>;
  43111. /**
  43112. * An event triggered when a transform node is created
  43113. */
  43114. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43115. /**
  43116. * An event triggered when a transform node is removed
  43117. */
  43118. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43119. /**
  43120. * An event triggered when a mesh is created
  43121. */
  43122. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43123. /**
  43124. * An event triggered when a mesh is removed
  43125. */
  43126. onMeshRemovedObservable: Observable<AbstractMesh>;
  43127. /**
  43128. * An event triggered when a skeleton is created
  43129. */
  43130. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43131. /**
  43132. * An event triggered when a skeleton is removed
  43133. */
  43134. onSkeletonRemovedObservable: Observable<Skeleton>;
  43135. /**
  43136. * An event triggered when a material is created
  43137. */
  43138. onNewMaterialAddedObservable: Observable<Material>;
  43139. /**
  43140. * An event triggered when a material is removed
  43141. */
  43142. onMaterialRemovedObservable: Observable<Material>;
  43143. /**
  43144. * An event triggered when a texture is created
  43145. */
  43146. onNewTextureAddedObservable: Observable<BaseTexture>;
  43147. /**
  43148. * An event triggered when a texture is removed
  43149. */
  43150. onTextureRemovedObservable: Observable<BaseTexture>;
  43151. /**
  43152. * An event triggered when render targets are about to be rendered
  43153. * Can happen multiple times per frame.
  43154. */
  43155. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43156. /**
  43157. * An event triggered when render targets were rendered.
  43158. * Can happen multiple times per frame.
  43159. */
  43160. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43161. /**
  43162. * An event triggered before calculating deterministic simulation step
  43163. */
  43164. onBeforeStepObservable: Observable<Scene>;
  43165. /**
  43166. * An event triggered after calculating deterministic simulation step
  43167. */
  43168. onAfterStepObservable: Observable<Scene>;
  43169. /**
  43170. * An event triggered when the activeCamera property is updated
  43171. */
  43172. onActiveCameraChanged: Observable<Scene>;
  43173. /**
  43174. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43175. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43176. * 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)
  43177. */
  43178. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43179. /**
  43180. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43181. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43182. * 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)
  43183. */
  43184. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43185. /**
  43186. * This Observable will when a mesh has been imported into the scene.
  43187. */
  43188. onMeshImportedObservable: Observable<AbstractMesh>;
  43189. /**
  43190. * This Observable will when an animation file has been imported into the scene.
  43191. */
  43192. onAnimationFileImportedObservable: Observable<Scene>;
  43193. /**
  43194. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43195. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43196. */
  43197. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43198. /** @hidden */
  43199. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43200. /**
  43201. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43202. */
  43203. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43204. /**
  43205. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43206. */
  43207. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43208. /**
  43209. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43210. */
  43211. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43212. /** Callback called when a pointer move is detected */
  43213. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43214. /** Callback called when a pointer down is detected */
  43215. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43216. /** Callback called when a pointer up is detected */
  43217. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43218. /** Callback called when a pointer pick is detected */
  43219. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43220. /**
  43221. * 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).
  43222. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43223. */
  43224. onPrePointerObservable: Observable<PointerInfoPre>;
  43225. /**
  43226. * Observable event triggered each time an input event is received from the rendering canvas
  43227. */
  43228. onPointerObservable: Observable<PointerInfo>;
  43229. /**
  43230. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43231. */
  43232. get unTranslatedPointer(): Vector2;
  43233. /**
  43234. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43235. */
  43236. static get DragMovementThreshold(): number;
  43237. static set DragMovementThreshold(value: number);
  43238. /**
  43239. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43240. */
  43241. static get LongPressDelay(): number;
  43242. static set LongPressDelay(value: number);
  43243. /**
  43244. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43245. */
  43246. static get DoubleClickDelay(): number;
  43247. static set DoubleClickDelay(value: number);
  43248. /** If you need to check double click without raising a single click at first click, enable this flag */
  43249. static get ExclusiveDoubleClickMode(): boolean;
  43250. static set ExclusiveDoubleClickMode(value: boolean);
  43251. /** @hidden */
  43252. _mirroredCameraPosition: Nullable<Vector3>;
  43253. /**
  43254. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43255. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43256. */
  43257. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43258. /**
  43259. * Observable event triggered each time an keyboard event is received from the hosting window
  43260. */
  43261. onKeyboardObservable: Observable<KeyboardInfo>;
  43262. private _useRightHandedSystem;
  43263. /**
  43264. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43265. */
  43266. set useRightHandedSystem(value: boolean);
  43267. get useRightHandedSystem(): boolean;
  43268. private _timeAccumulator;
  43269. private _currentStepId;
  43270. private _currentInternalStep;
  43271. /**
  43272. * Sets the step Id used by deterministic lock step
  43273. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43274. * @param newStepId defines the step Id
  43275. */
  43276. setStepId(newStepId: number): void;
  43277. /**
  43278. * Gets the step Id used by deterministic lock step
  43279. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43280. * @returns the step Id
  43281. */
  43282. getStepId(): number;
  43283. /**
  43284. * Gets the internal step used by deterministic lock step
  43285. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43286. * @returns the internal step
  43287. */
  43288. getInternalStep(): number;
  43289. private _fogEnabled;
  43290. /**
  43291. * Gets or sets a boolean indicating if fog is enabled on this scene
  43292. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43293. * (Default is true)
  43294. */
  43295. set fogEnabled(value: boolean);
  43296. get fogEnabled(): boolean;
  43297. private _fogMode;
  43298. /**
  43299. * Gets or sets the fog mode to use
  43300. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43301. * | mode | value |
  43302. * | --- | --- |
  43303. * | FOGMODE_NONE | 0 |
  43304. * | FOGMODE_EXP | 1 |
  43305. * | FOGMODE_EXP2 | 2 |
  43306. * | FOGMODE_LINEAR | 3 |
  43307. */
  43308. set fogMode(value: number);
  43309. get fogMode(): number;
  43310. /**
  43311. * Gets or sets the fog color to use
  43312. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43313. * (Default is Color3(0.2, 0.2, 0.3))
  43314. */
  43315. fogColor: Color3;
  43316. /**
  43317. * Gets or sets the fog density to use
  43318. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43319. * (Default is 0.1)
  43320. */
  43321. fogDensity: number;
  43322. /**
  43323. * Gets or sets the fog start distance to use
  43324. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43325. * (Default is 0)
  43326. */
  43327. fogStart: number;
  43328. /**
  43329. * Gets or sets the fog end distance to use
  43330. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43331. * (Default is 1000)
  43332. */
  43333. fogEnd: number;
  43334. /**
  43335. * Flag indicating that the frame buffer binding is handled by another component
  43336. */
  43337. prePass: boolean;
  43338. private _shadowsEnabled;
  43339. /**
  43340. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43341. */
  43342. set shadowsEnabled(value: boolean);
  43343. get shadowsEnabled(): boolean;
  43344. private _lightsEnabled;
  43345. /**
  43346. * Gets or sets a boolean indicating if lights are enabled on this scene
  43347. */
  43348. set lightsEnabled(value: boolean);
  43349. get lightsEnabled(): boolean;
  43350. /** All of the active cameras added to this scene. */
  43351. activeCameras: Camera[];
  43352. /** @hidden */
  43353. _activeCamera: Nullable<Camera>;
  43354. /** Gets or sets the current active camera */
  43355. get activeCamera(): Nullable<Camera>;
  43356. set activeCamera(value: Nullable<Camera>);
  43357. private _defaultMaterial;
  43358. /** The default material used on meshes when no material is affected */
  43359. get defaultMaterial(): Material;
  43360. /** The default material used on meshes when no material is affected */
  43361. set defaultMaterial(value: Material);
  43362. private _texturesEnabled;
  43363. /**
  43364. * Gets or sets a boolean indicating if textures are enabled on this scene
  43365. */
  43366. set texturesEnabled(value: boolean);
  43367. get texturesEnabled(): boolean;
  43368. /**
  43369. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43370. */
  43371. physicsEnabled: boolean;
  43372. /**
  43373. * Gets or sets a boolean indicating if particles are enabled on this scene
  43374. */
  43375. particlesEnabled: boolean;
  43376. /**
  43377. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43378. */
  43379. spritesEnabled: boolean;
  43380. private _skeletonsEnabled;
  43381. /**
  43382. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43383. */
  43384. set skeletonsEnabled(value: boolean);
  43385. get skeletonsEnabled(): boolean;
  43386. /**
  43387. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43388. */
  43389. lensFlaresEnabled: boolean;
  43390. /**
  43391. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43392. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43393. */
  43394. collisionsEnabled: boolean;
  43395. private _collisionCoordinator;
  43396. /** @hidden */
  43397. get collisionCoordinator(): ICollisionCoordinator;
  43398. /**
  43399. * Defines the gravity applied to this scene (used only for collisions)
  43400. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43401. */
  43402. gravity: Vector3;
  43403. /**
  43404. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43405. */
  43406. postProcessesEnabled: boolean;
  43407. /**
  43408. * Gets the current postprocess manager
  43409. */
  43410. postProcessManager: PostProcessManager;
  43411. /**
  43412. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43413. */
  43414. renderTargetsEnabled: boolean;
  43415. /**
  43416. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43417. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43418. */
  43419. dumpNextRenderTargets: boolean;
  43420. /**
  43421. * The list of user defined render targets added to the scene
  43422. */
  43423. customRenderTargets: RenderTargetTexture[];
  43424. /**
  43425. * Defines if texture loading must be delayed
  43426. * If true, textures will only be loaded when they need to be rendered
  43427. */
  43428. useDelayedTextureLoading: boolean;
  43429. /**
  43430. * Gets the list of meshes imported to the scene through SceneLoader
  43431. */
  43432. importedMeshesFiles: String[];
  43433. /**
  43434. * Gets or sets a boolean indicating if probes are enabled on this scene
  43435. */
  43436. probesEnabled: boolean;
  43437. /**
  43438. * Gets or sets the current offline provider to use to store scene data
  43439. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43440. */
  43441. offlineProvider: IOfflineProvider;
  43442. /**
  43443. * Gets or sets the action manager associated with the scene
  43444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43445. */
  43446. actionManager: AbstractActionManager;
  43447. private _meshesForIntersections;
  43448. /**
  43449. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43450. */
  43451. proceduralTexturesEnabled: boolean;
  43452. private _engine;
  43453. private _totalVertices;
  43454. /** @hidden */
  43455. _activeIndices: PerfCounter;
  43456. /** @hidden */
  43457. _activeParticles: PerfCounter;
  43458. /** @hidden */
  43459. _activeBones: PerfCounter;
  43460. private _animationRatio;
  43461. /** @hidden */
  43462. _animationTimeLast: number;
  43463. /** @hidden */
  43464. _animationTime: number;
  43465. /**
  43466. * Gets or sets a general scale for animation speed
  43467. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43468. */
  43469. animationTimeScale: number;
  43470. /** @hidden */
  43471. _cachedMaterial: Nullable<Material>;
  43472. /** @hidden */
  43473. _cachedEffect: Nullable<Effect>;
  43474. /** @hidden */
  43475. _cachedVisibility: Nullable<number>;
  43476. private _renderId;
  43477. private _frameId;
  43478. private _executeWhenReadyTimeoutId;
  43479. private _intermediateRendering;
  43480. private _viewUpdateFlag;
  43481. private _projectionUpdateFlag;
  43482. /** @hidden */
  43483. _toBeDisposed: Nullable<IDisposable>[];
  43484. private _activeRequests;
  43485. /** @hidden */
  43486. _pendingData: any[];
  43487. private _isDisposed;
  43488. /**
  43489. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43490. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43491. */
  43492. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43493. private _activeMeshes;
  43494. private _processedMaterials;
  43495. private _renderTargets;
  43496. /** @hidden */
  43497. _activeParticleSystems: SmartArray<IParticleSystem>;
  43498. private _activeSkeletons;
  43499. private _softwareSkinnedMeshes;
  43500. private _renderingManager;
  43501. /** @hidden */
  43502. _activeAnimatables: Animatable[];
  43503. private _transformMatrix;
  43504. private _sceneUbo;
  43505. /** @hidden */
  43506. _viewMatrix: Matrix;
  43507. private _projectionMatrix;
  43508. /** @hidden */
  43509. _forcedViewPosition: Nullable<Vector3>;
  43510. /** @hidden */
  43511. _frustumPlanes: Plane[];
  43512. /**
  43513. * Gets the list of frustum planes (built from the active camera)
  43514. */
  43515. get frustumPlanes(): Plane[];
  43516. /**
  43517. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43518. * This is useful if there are more lights that the maximum simulteanous authorized
  43519. */
  43520. requireLightSorting: boolean;
  43521. /** @hidden */
  43522. readonly useMaterialMeshMap: boolean;
  43523. /** @hidden */
  43524. readonly useClonedMeshMap: boolean;
  43525. private _externalData;
  43526. private _uid;
  43527. /**
  43528. * @hidden
  43529. * Backing store of defined scene components.
  43530. */
  43531. _components: ISceneComponent[];
  43532. /**
  43533. * @hidden
  43534. * Backing store of defined scene components.
  43535. */
  43536. _serializableComponents: ISceneSerializableComponent[];
  43537. /**
  43538. * List of components to register on the next registration step.
  43539. */
  43540. private _transientComponents;
  43541. /**
  43542. * Registers the transient components if needed.
  43543. */
  43544. private _registerTransientComponents;
  43545. /**
  43546. * @hidden
  43547. * Add a component to the scene.
  43548. * Note that the ccomponent could be registered on th next frame if this is called after
  43549. * the register component stage.
  43550. * @param component Defines the component to add to the scene
  43551. */
  43552. _addComponent(component: ISceneComponent): void;
  43553. /**
  43554. * @hidden
  43555. * Gets a component from the scene.
  43556. * @param name defines the name of the component to retrieve
  43557. * @returns the component or null if not present
  43558. */
  43559. _getComponent(name: string): Nullable<ISceneComponent>;
  43560. /**
  43561. * @hidden
  43562. * Defines the actions happening before camera updates.
  43563. */
  43564. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43565. /**
  43566. * @hidden
  43567. * Defines the actions happening before clear the canvas.
  43568. */
  43569. _beforeClearStage: Stage<SimpleStageAction>;
  43570. /**
  43571. * @hidden
  43572. * Defines the actions when collecting render targets for the frame.
  43573. */
  43574. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43575. /**
  43576. * @hidden
  43577. * Defines the actions happening for one camera in the frame.
  43578. */
  43579. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43580. /**
  43581. * @hidden
  43582. * Defines the actions happening during the per mesh ready checks.
  43583. */
  43584. _isReadyForMeshStage: Stage<MeshStageAction>;
  43585. /**
  43586. * @hidden
  43587. * Defines the actions happening before evaluate active mesh checks.
  43588. */
  43589. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43590. /**
  43591. * @hidden
  43592. * Defines the actions happening during the evaluate sub mesh checks.
  43593. */
  43594. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43595. /**
  43596. * @hidden
  43597. * Defines the actions happening during the active mesh stage.
  43598. */
  43599. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43600. /**
  43601. * @hidden
  43602. * Defines the actions happening during the per camera render target step.
  43603. */
  43604. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43605. /**
  43606. * @hidden
  43607. * Defines the actions happening just before the active camera is drawing.
  43608. */
  43609. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43610. /**
  43611. * @hidden
  43612. * Defines the actions happening just before a render target is drawing.
  43613. */
  43614. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43615. /**
  43616. * @hidden
  43617. * Defines the actions happening just before a rendering group is drawing.
  43618. */
  43619. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43620. /**
  43621. * @hidden
  43622. * Defines the actions happening just before a mesh is drawing.
  43623. */
  43624. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43625. /**
  43626. * @hidden
  43627. * Defines the actions happening just after a mesh has been drawn.
  43628. */
  43629. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43630. /**
  43631. * @hidden
  43632. * Defines the actions happening just after a rendering group has been drawn.
  43633. */
  43634. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43635. /**
  43636. * @hidden
  43637. * Defines the actions happening just after the active camera has been drawn.
  43638. */
  43639. _afterCameraDrawStage: Stage<CameraStageAction>;
  43640. /**
  43641. * @hidden
  43642. * Defines the actions happening just after a render target has been drawn.
  43643. */
  43644. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43645. /**
  43646. * @hidden
  43647. * Defines the actions happening just after rendering all cameras and computing intersections.
  43648. */
  43649. _afterRenderStage: Stage<SimpleStageAction>;
  43650. /**
  43651. * @hidden
  43652. * Defines the actions happening when a pointer move event happens.
  43653. */
  43654. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43655. /**
  43656. * @hidden
  43657. * Defines the actions happening when a pointer down event happens.
  43658. */
  43659. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43660. /**
  43661. * @hidden
  43662. * Defines the actions happening when a pointer up event happens.
  43663. */
  43664. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43665. /**
  43666. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43667. */
  43668. private geometriesByUniqueId;
  43669. /**
  43670. * Creates a new Scene
  43671. * @param engine defines the engine to use to render this scene
  43672. * @param options defines the scene options
  43673. */
  43674. constructor(engine: Engine, options?: SceneOptions);
  43675. /**
  43676. * Gets a string identifying the name of the class
  43677. * @returns "Scene" string
  43678. */
  43679. getClassName(): string;
  43680. private _defaultMeshCandidates;
  43681. /**
  43682. * @hidden
  43683. */
  43684. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43685. private _defaultSubMeshCandidates;
  43686. /**
  43687. * @hidden
  43688. */
  43689. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43690. /**
  43691. * Sets the default candidate providers for the scene.
  43692. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43693. * and getCollidingSubMeshCandidates to their default function
  43694. */
  43695. setDefaultCandidateProviders(): void;
  43696. /**
  43697. * Gets the mesh that is currently under the pointer
  43698. */
  43699. get meshUnderPointer(): Nullable<AbstractMesh>;
  43700. /**
  43701. * Gets or sets the current on-screen X position of the pointer
  43702. */
  43703. get pointerX(): number;
  43704. set pointerX(value: number);
  43705. /**
  43706. * Gets or sets the current on-screen Y position of the pointer
  43707. */
  43708. get pointerY(): number;
  43709. set pointerY(value: number);
  43710. /**
  43711. * Gets the cached material (ie. the latest rendered one)
  43712. * @returns the cached material
  43713. */
  43714. getCachedMaterial(): Nullable<Material>;
  43715. /**
  43716. * Gets the cached effect (ie. the latest rendered one)
  43717. * @returns the cached effect
  43718. */
  43719. getCachedEffect(): Nullable<Effect>;
  43720. /**
  43721. * Gets the cached visibility state (ie. the latest rendered one)
  43722. * @returns the cached visibility state
  43723. */
  43724. getCachedVisibility(): Nullable<number>;
  43725. /**
  43726. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43727. * @param material defines the current material
  43728. * @param effect defines the current effect
  43729. * @param visibility defines the current visibility state
  43730. * @returns true if one parameter is not cached
  43731. */
  43732. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43733. /**
  43734. * Gets the engine associated with the scene
  43735. * @returns an Engine
  43736. */
  43737. getEngine(): Engine;
  43738. /**
  43739. * Gets the total number of vertices rendered per frame
  43740. * @returns the total number of vertices rendered per frame
  43741. */
  43742. getTotalVertices(): number;
  43743. /**
  43744. * Gets the performance counter for total vertices
  43745. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43746. */
  43747. get totalVerticesPerfCounter(): PerfCounter;
  43748. /**
  43749. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43750. * @returns the total number of active indices rendered per frame
  43751. */
  43752. getActiveIndices(): number;
  43753. /**
  43754. * Gets the performance counter for active indices
  43755. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43756. */
  43757. get totalActiveIndicesPerfCounter(): PerfCounter;
  43758. /**
  43759. * Gets the total number of active particles rendered per frame
  43760. * @returns the total number of active particles rendered per frame
  43761. */
  43762. getActiveParticles(): number;
  43763. /**
  43764. * Gets the performance counter for active particles
  43765. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43766. */
  43767. get activeParticlesPerfCounter(): PerfCounter;
  43768. /**
  43769. * Gets the total number of active bones rendered per frame
  43770. * @returns the total number of active bones rendered per frame
  43771. */
  43772. getActiveBones(): number;
  43773. /**
  43774. * Gets the performance counter for active bones
  43775. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43776. */
  43777. get activeBonesPerfCounter(): PerfCounter;
  43778. /**
  43779. * Gets the array of active meshes
  43780. * @returns an array of AbstractMesh
  43781. */
  43782. getActiveMeshes(): SmartArray<AbstractMesh>;
  43783. /**
  43784. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43785. * @returns a number
  43786. */
  43787. getAnimationRatio(): number;
  43788. /**
  43789. * Gets an unique Id for the current render phase
  43790. * @returns a number
  43791. */
  43792. getRenderId(): number;
  43793. /**
  43794. * Gets an unique Id for the current frame
  43795. * @returns a number
  43796. */
  43797. getFrameId(): number;
  43798. /** Call this function if you want to manually increment the render Id*/
  43799. incrementRenderId(): void;
  43800. private _createUbo;
  43801. /**
  43802. * Use this method to simulate a pointer move on a mesh
  43803. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43804. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43805. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43806. * @returns the current scene
  43807. */
  43808. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43809. /**
  43810. * Use this method to simulate a pointer down on a mesh
  43811. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43812. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43813. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43814. * @returns the current scene
  43815. */
  43816. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43817. /**
  43818. * Use this method to simulate a pointer up on a mesh
  43819. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43820. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43821. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43822. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43823. * @returns the current scene
  43824. */
  43825. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43826. /**
  43827. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43828. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43829. * @returns true if the pointer was captured
  43830. */
  43831. isPointerCaptured(pointerId?: number): boolean;
  43832. /**
  43833. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43834. * @param attachUp defines if you want to attach events to pointerup
  43835. * @param attachDown defines if you want to attach events to pointerdown
  43836. * @param attachMove defines if you want to attach events to pointermove
  43837. */
  43838. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43839. /** Detaches all event handlers*/
  43840. detachControl(): void;
  43841. /**
  43842. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43843. * Delay loaded resources are not taking in account
  43844. * @return true if all required resources are ready
  43845. */
  43846. isReady(): boolean;
  43847. /** Resets all cached information relative to material (including effect and visibility) */
  43848. resetCachedMaterial(): void;
  43849. /**
  43850. * Registers a function to be called before every frame render
  43851. * @param func defines the function to register
  43852. */
  43853. registerBeforeRender(func: () => void): void;
  43854. /**
  43855. * Unregisters a function called before every frame render
  43856. * @param func defines the function to unregister
  43857. */
  43858. unregisterBeforeRender(func: () => void): void;
  43859. /**
  43860. * Registers a function to be called after every frame render
  43861. * @param func defines the function to register
  43862. */
  43863. registerAfterRender(func: () => void): void;
  43864. /**
  43865. * Unregisters a function called after every frame render
  43866. * @param func defines the function to unregister
  43867. */
  43868. unregisterAfterRender(func: () => void): void;
  43869. private _executeOnceBeforeRender;
  43870. /**
  43871. * The provided function will run before render once and will be disposed afterwards.
  43872. * A timeout delay can be provided so that the function will be executed in N ms.
  43873. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43874. * @param func The function to be executed.
  43875. * @param timeout optional delay in ms
  43876. */
  43877. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43878. /** @hidden */
  43879. _addPendingData(data: any): void;
  43880. /** @hidden */
  43881. _removePendingData(data: any): void;
  43882. /**
  43883. * Returns the number of items waiting to be loaded
  43884. * @returns the number of items waiting to be loaded
  43885. */
  43886. getWaitingItemsCount(): number;
  43887. /**
  43888. * Returns a boolean indicating if the scene is still loading data
  43889. */
  43890. get isLoading(): boolean;
  43891. /**
  43892. * Registers a function to be executed when the scene is ready
  43893. * @param {Function} func - the function to be executed
  43894. */
  43895. executeWhenReady(func: () => void): void;
  43896. /**
  43897. * Returns a promise that resolves when the scene is ready
  43898. * @returns A promise that resolves when the scene is ready
  43899. */
  43900. whenReadyAsync(): Promise<void>;
  43901. /** @hidden */
  43902. _checkIsReady(): void;
  43903. /**
  43904. * Gets all animatable attached to the scene
  43905. */
  43906. get animatables(): Animatable[];
  43907. /**
  43908. * Resets the last animation time frame.
  43909. * Useful to override when animations start running when loading a scene for the first time.
  43910. */
  43911. resetLastAnimationTimeFrame(): void;
  43912. /**
  43913. * Gets the current view matrix
  43914. * @returns a Matrix
  43915. */
  43916. getViewMatrix(): Matrix;
  43917. /**
  43918. * Gets the current projection matrix
  43919. * @returns a Matrix
  43920. */
  43921. getProjectionMatrix(): Matrix;
  43922. /**
  43923. * Gets the current transform matrix
  43924. * @returns a Matrix made of View * Projection
  43925. */
  43926. getTransformMatrix(): Matrix;
  43927. /**
  43928. * Sets the current transform matrix
  43929. * @param viewL defines the View matrix to use
  43930. * @param projectionL defines the Projection matrix to use
  43931. * @param viewR defines the right View matrix to use (if provided)
  43932. * @param projectionR defines the right Projection matrix to use (if provided)
  43933. */
  43934. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43935. /**
  43936. * Gets the uniform buffer used to store scene data
  43937. * @returns a UniformBuffer
  43938. */
  43939. getSceneUniformBuffer(): UniformBuffer;
  43940. /**
  43941. * Gets an unique (relatively to the current scene) Id
  43942. * @returns an unique number for the scene
  43943. */
  43944. getUniqueId(): number;
  43945. /**
  43946. * Add a mesh to the list of scene's meshes
  43947. * @param newMesh defines the mesh to add
  43948. * @param recursive if all child meshes should also be added to the scene
  43949. */
  43950. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43951. /**
  43952. * Remove a mesh for the list of scene's meshes
  43953. * @param toRemove defines the mesh to remove
  43954. * @param recursive if all child meshes should also be removed from the scene
  43955. * @returns the index where the mesh was in the mesh list
  43956. */
  43957. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43958. /**
  43959. * Add a transform node to the list of scene's transform nodes
  43960. * @param newTransformNode defines the transform node to add
  43961. */
  43962. addTransformNode(newTransformNode: TransformNode): void;
  43963. /**
  43964. * Remove a transform node for the list of scene's transform nodes
  43965. * @param toRemove defines the transform node to remove
  43966. * @returns the index where the transform node was in the transform node list
  43967. */
  43968. removeTransformNode(toRemove: TransformNode): number;
  43969. /**
  43970. * Remove a skeleton for the list of scene's skeletons
  43971. * @param toRemove defines the skeleton to remove
  43972. * @returns the index where the skeleton was in the skeleton list
  43973. */
  43974. removeSkeleton(toRemove: Skeleton): number;
  43975. /**
  43976. * Remove a morph target for the list of scene's morph targets
  43977. * @param toRemove defines the morph target to remove
  43978. * @returns the index where the morph target was in the morph target list
  43979. */
  43980. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43981. /**
  43982. * Remove a light for the list of scene's lights
  43983. * @param toRemove defines the light to remove
  43984. * @returns the index where the light was in the light list
  43985. */
  43986. removeLight(toRemove: Light): number;
  43987. /**
  43988. * Remove a camera for the list of scene's cameras
  43989. * @param toRemove defines the camera to remove
  43990. * @returns the index where the camera was in the camera list
  43991. */
  43992. removeCamera(toRemove: Camera): number;
  43993. /**
  43994. * Remove a particle system for the list of scene's particle systems
  43995. * @param toRemove defines the particle system to remove
  43996. * @returns the index where the particle system was in the particle system list
  43997. */
  43998. removeParticleSystem(toRemove: IParticleSystem): number;
  43999. /**
  44000. * Remove a animation for the list of scene's animations
  44001. * @param toRemove defines the animation to remove
  44002. * @returns the index where the animation was in the animation list
  44003. */
  44004. removeAnimation(toRemove: Animation): number;
  44005. /**
  44006. * Will stop the animation of the given target
  44007. * @param target - the target
  44008. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44009. * @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)
  44010. */
  44011. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44012. /**
  44013. * Removes the given animation group from this scene.
  44014. * @param toRemove The animation group to remove
  44015. * @returns The index of the removed animation group
  44016. */
  44017. removeAnimationGroup(toRemove: AnimationGroup): number;
  44018. /**
  44019. * Removes the given multi-material from this scene.
  44020. * @param toRemove The multi-material to remove
  44021. * @returns The index of the removed multi-material
  44022. */
  44023. removeMultiMaterial(toRemove: MultiMaterial): number;
  44024. /**
  44025. * Removes the given material from this scene.
  44026. * @param toRemove The material to remove
  44027. * @returns The index of the removed material
  44028. */
  44029. removeMaterial(toRemove: Material): number;
  44030. /**
  44031. * Removes the given action manager from this scene.
  44032. * @param toRemove The action manager to remove
  44033. * @returns The index of the removed action manager
  44034. */
  44035. removeActionManager(toRemove: AbstractActionManager): number;
  44036. /**
  44037. * Removes the given texture from this scene.
  44038. * @param toRemove The texture to remove
  44039. * @returns The index of the removed texture
  44040. */
  44041. removeTexture(toRemove: BaseTexture): number;
  44042. /**
  44043. * Adds the given light to this scene
  44044. * @param newLight The light to add
  44045. */
  44046. addLight(newLight: Light): void;
  44047. /**
  44048. * Sorts the list list based on light priorities
  44049. */
  44050. sortLightsByPriority(): void;
  44051. /**
  44052. * Adds the given camera to this scene
  44053. * @param newCamera The camera to add
  44054. */
  44055. addCamera(newCamera: Camera): void;
  44056. /**
  44057. * Adds the given skeleton to this scene
  44058. * @param newSkeleton The skeleton to add
  44059. */
  44060. addSkeleton(newSkeleton: Skeleton): void;
  44061. /**
  44062. * Adds the given particle system to this scene
  44063. * @param newParticleSystem The particle system to add
  44064. */
  44065. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44066. /**
  44067. * Adds the given animation to this scene
  44068. * @param newAnimation The animation to add
  44069. */
  44070. addAnimation(newAnimation: Animation): void;
  44071. /**
  44072. * Adds the given animation group to this scene.
  44073. * @param newAnimationGroup The animation group to add
  44074. */
  44075. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44076. /**
  44077. * Adds the given multi-material to this scene
  44078. * @param newMultiMaterial The multi-material to add
  44079. */
  44080. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44081. /**
  44082. * Adds the given material to this scene
  44083. * @param newMaterial The material to add
  44084. */
  44085. addMaterial(newMaterial: Material): void;
  44086. /**
  44087. * Adds the given morph target to this scene
  44088. * @param newMorphTargetManager The morph target to add
  44089. */
  44090. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44091. /**
  44092. * Adds the given geometry to this scene
  44093. * @param newGeometry The geometry to add
  44094. */
  44095. addGeometry(newGeometry: Geometry): void;
  44096. /**
  44097. * Adds the given action manager to this scene
  44098. * @param newActionManager The action manager to add
  44099. */
  44100. addActionManager(newActionManager: AbstractActionManager): void;
  44101. /**
  44102. * Adds the given texture to this scene.
  44103. * @param newTexture The texture to add
  44104. */
  44105. addTexture(newTexture: BaseTexture): void;
  44106. /**
  44107. * Switch active camera
  44108. * @param newCamera defines the new active camera
  44109. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44110. */
  44111. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44112. /**
  44113. * sets the active camera of the scene using its ID
  44114. * @param id defines the camera's ID
  44115. * @return the new active camera or null if none found.
  44116. */
  44117. setActiveCameraByID(id: string): Nullable<Camera>;
  44118. /**
  44119. * sets the active camera of the scene using its name
  44120. * @param name defines the camera's name
  44121. * @returns the new active camera or null if none found.
  44122. */
  44123. setActiveCameraByName(name: string): Nullable<Camera>;
  44124. /**
  44125. * get an animation group using its name
  44126. * @param name defines the material's name
  44127. * @return the animation group or null if none found.
  44128. */
  44129. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44130. /**
  44131. * Get a material using its unique id
  44132. * @param uniqueId defines the material's unique id
  44133. * @return the material or null if none found.
  44134. */
  44135. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44136. /**
  44137. * get a material using its id
  44138. * @param id defines the material's ID
  44139. * @return the material or null if none found.
  44140. */
  44141. getMaterialByID(id: string): Nullable<Material>;
  44142. /**
  44143. * Gets a the last added material using a given id
  44144. * @param id defines the material's ID
  44145. * @return the last material with the given id or null if none found.
  44146. */
  44147. getLastMaterialByID(id: string): Nullable<Material>;
  44148. /**
  44149. * Gets a material using its name
  44150. * @param name defines the material's name
  44151. * @return the material or null if none found.
  44152. */
  44153. getMaterialByName(name: string): Nullable<Material>;
  44154. /**
  44155. * Get a texture using its unique id
  44156. * @param uniqueId defines the texture's unique id
  44157. * @return the texture or null if none found.
  44158. */
  44159. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44160. /**
  44161. * Gets a camera using its id
  44162. * @param id defines the id to look for
  44163. * @returns the camera or null if not found
  44164. */
  44165. getCameraByID(id: string): Nullable<Camera>;
  44166. /**
  44167. * Gets a camera using its unique id
  44168. * @param uniqueId defines the unique id to look for
  44169. * @returns the camera or null if not found
  44170. */
  44171. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44172. /**
  44173. * Gets a camera using its name
  44174. * @param name defines the camera's name
  44175. * @return the camera or null if none found.
  44176. */
  44177. getCameraByName(name: string): Nullable<Camera>;
  44178. /**
  44179. * Gets a bone using its id
  44180. * @param id defines the bone's id
  44181. * @return the bone or null if not found
  44182. */
  44183. getBoneByID(id: string): Nullable<Bone>;
  44184. /**
  44185. * Gets a bone using its id
  44186. * @param name defines the bone's name
  44187. * @return the bone or null if not found
  44188. */
  44189. getBoneByName(name: string): Nullable<Bone>;
  44190. /**
  44191. * Gets a light node using its name
  44192. * @param name defines the the light's name
  44193. * @return the light or null if none found.
  44194. */
  44195. getLightByName(name: string): Nullable<Light>;
  44196. /**
  44197. * Gets a light node using its id
  44198. * @param id defines the light's id
  44199. * @return the light or null if none found.
  44200. */
  44201. getLightByID(id: string): Nullable<Light>;
  44202. /**
  44203. * Gets a light node using its scene-generated unique ID
  44204. * @param uniqueId defines the light's unique id
  44205. * @return the light or null if none found.
  44206. */
  44207. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44208. /**
  44209. * Gets a particle system by id
  44210. * @param id defines the particle system id
  44211. * @return the corresponding system or null if none found
  44212. */
  44213. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44214. /**
  44215. * Gets a geometry using its ID
  44216. * @param id defines the geometry's id
  44217. * @return the geometry or null if none found.
  44218. */
  44219. getGeometryByID(id: string): Nullable<Geometry>;
  44220. private _getGeometryByUniqueID;
  44221. /**
  44222. * Add a new geometry to this scene
  44223. * @param geometry defines the geometry to be added to the scene.
  44224. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44225. * @return a boolean defining if the geometry was added or not
  44226. */
  44227. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44228. /**
  44229. * Removes an existing geometry
  44230. * @param geometry defines the geometry to be removed from the scene
  44231. * @return a boolean defining if the geometry was removed or not
  44232. */
  44233. removeGeometry(geometry: Geometry): boolean;
  44234. /**
  44235. * Gets the list of geometries attached to the scene
  44236. * @returns an array of Geometry
  44237. */
  44238. getGeometries(): Geometry[];
  44239. /**
  44240. * Gets the first added mesh found of a given ID
  44241. * @param id defines the id to search for
  44242. * @return the mesh found or null if not found at all
  44243. */
  44244. getMeshByID(id: string): Nullable<AbstractMesh>;
  44245. /**
  44246. * Gets a list of meshes using their id
  44247. * @param id defines the id to search for
  44248. * @returns a list of meshes
  44249. */
  44250. getMeshesByID(id: string): Array<AbstractMesh>;
  44251. /**
  44252. * Gets the first added transform node found of a given ID
  44253. * @param id defines the id to search for
  44254. * @return the found transform node or null if not found at all.
  44255. */
  44256. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44257. /**
  44258. * Gets a transform node with its auto-generated unique id
  44259. * @param uniqueId efines the unique id to search for
  44260. * @return the found transform node or null if not found at all.
  44261. */
  44262. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44263. /**
  44264. * Gets a list of transform nodes using their id
  44265. * @param id defines the id to search for
  44266. * @returns a list of transform nodes
  44267. */
  44268. getTransformNodesByID(id: string): Array<TransformNode>;
  44269. /**
  44270. * Gets a mesh with its auto-generated unique id
  44271. * @param uniqueId defines the unique id to search for
  44272. * @return the found mesh or null if not found at all.
  44273. */
  44274. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44275. /**
  44276. * Gets a the last added mesh using a given id
  44277. * @param id defines the id to search for
  44278. * @return the found mesh or null if not found at all.
  44279. */
  44280. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44281. /**
  44282. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44283. * @param id defines the id to search for
  44284. * @return the found node or null if not found at all
  44285. */
  44286. getLastEntryByID(id: string): Nullable<Node>;
  44287. /**
  44288. * Gets a node (Mesh, Camera, Light) using a given id
  44289. * @param id defines the id to search for
  44290. * @return the found node or null if not found at all
  44291. */
  44292. getNodeByID(id: string): Nullable<Node>;
  44293. /**
  44294. * Gets a node (Mesh, Camera, Light) using a given name
  44295. * @param name defines the name to search for
  44296. * @return the found node or null if not found at all.
  44297. */
  44298. getNodeByName(name: string): Nullable<Node>;
  44299. /**
  44300. * Gets a mesh using a given name
  44301. * @param name defines the name to search for
  44302. * @return the found mesh or null if not found at all.
  44303. */
  44304. getMeshByName(name: string): Nullable<AbstractMesh>;
  44305. /**
  44306. * Gets a transform node using a given name
  44307. * @param name defines the name to search for
  44308. * @return the found transform node or null if not found at all.
  44309. */
  44310. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44311. /**
  44312. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44313. * @param id defines the id to search for
  44314. * @return the found skeleton or null if not found at all.
  44315. */
  44316. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44317. /**
  44318. * Gets a skeleton using a given auto generated unique id
  44319. * @param uniqueId defines the unique id to search for
  44320. * @return the found skeleton or null if not found at all.
  44321. */
  44322. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44323. /**
  44324. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44325. * @param id defines the id to search for
  44326. * @return the found skeleton or null if not found at all.
  44327. */
  44328. getSkeletonById(id: string): Nullable<Skeleton>;
  44329. /**
  44330. * Gets a skeleton using a given name
  44331. * @param name defines the name to search for
  44332. * @return the found skeleton or null if not found at all.
  44333. */
  44334. getSkeletonByName(name: string): Nullable<Skeleton>;
  44335. /**
  44336. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44337. * @param id defines the id to search for
  44338. * @return the found morph target manager or null if not found at all.
  44339. */
  44340. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44341. /**
  44342. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44343. * @param id defines the id to search for
  44344. * @return the found morph target or null if not found at all.
  44345. */
  44346. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44347. /**
  44348. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44349. * @param name defines the name to search for
  44350. * @return the found morph target or null if not found at all.
  44351. */
  44352. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44353. /**
  44354. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44355. * @param name defines the name to search for
  44356. * @return the found post process or null if not found at all.
  44357. */
  44358. getPostProcessByName(name: string): Nullable<PostProcess>;
  44359. /**
  44360. * Gets a boolean indicating if the given mesh is active
  44361. * @param mesh defines the mesh to look for
  44362. * @returns true if the mesh is in the active list
  44363. */
  44364. isActiveMesh(mesh: AbstractMesh): boolean;
  44365. /**
  44366. * Return a unique id as a string which can serve as an identifier for the scene
  44367. */
  44368. get uid(): string;
  44369. /**
  44370. * Add an externaly attached data from its key.
  44371. * This method call will fail and return false, if such key already exists.
  44372. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44373. * @param key the unique key that identifies the data
  44374. * @param data the data object to associate to the key for this Engine instance
  44375. * @return true if no such key were already present and the data was added successfully, false otherwise
  44376. */
  44377. addExternalData<T>(key: string, data: T): boolean;
  44378. /**
  44379. * Get an externaly attached data from its key
  44380. * @param key the unique key that identifies the data
  44381. * @return the associated data, if present (can be null), or undefined if not present
  44382. */
  44383. getExternalData<T>(key: string): Nullable<T>;
  44384. /**
  44385. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44386. * @param key the unique key that identifies the data
  44387. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44388. * @return the associated data, can be null if the factory returned null.
  44389. */
  44390. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44391. /**
  44392. * Remove an externaly attached data from the Engine instance
  44393. * @param key the unique key that identifies the data
  44394. * @return true if the data was successfully removed, false if it doesn't exist
  44395. */
  44396. removeExternalData(key: string): boolean;
  44397. private _evaluateSubMesh;
  44398. /**
  44399. * Clear the processed materials smart array preventing retention point in material dispose.
  44400. */
  44401. freeProcessedMaterials(): void;
  44402. private _preventFreeActiveMeshesAndRenderingGroups;
  44403. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44404. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44405. * when disposing several meshes in a row or a hierarchy of meshes.
  44406. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44407. */
  44408. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44409. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44410. /**
  44411. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44412. */
  44413. freeActiveMeshes(): void;
  44414. /**
  44415. * Clear the info related to rendering groups preventing retention points during dispose.
  44416. */
  44417. freeRenderingGroups(): void;
  44418. /** @hidden */
  44419. _isInIntermediateRendering(): boolean;
  44420. /**
  44421. * Lambda returning the list of potentially active meshes.
  44422. */
  44423. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44424. /**
  44425. * Lambda returning the list of potentially active sub meshes.
  44426. */
  44427. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44428. /**
  44429. * Lambda returning the list of potentially intersecting sub meshes.
  44430. */
  44431. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44432. /**
  44433. * Lambda returning the list of potentially colliding sub meshes.
  44434. */
  44435. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44436. private _activeMeshesFrozen;
  44437. private _skipEvaluateActiveMeshesCompletely;
  44438. /**
  44439. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44440. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44441. * @param onSuccess optional success callback
  44442. * @param onError optional error callback
  44443. * @returns the current scene
  44444. */
  44445. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44446. /**
  44447. * Use this function to restart evaluating active meshes on every frame
  44448. * @returns the current scene
  44449. */
  44450. unfreezeActiveMeshes(): Scene;
  44451. private _evaluateActiveMeshes;
  44452. private _activeMesh;
  44453. /**
  44454. * Update the transform matrix to update from the current active camera
  44455. * @param force defines a boolean used to force the update even if cache is up to date
  44456. */
  44457. updateTransformMatrix(force?: boolean): void;
  44458. private _bindFrameBuffer;
  44459. /** @hidden */
  44460. _allowPostProcessClearColor: boolean;
  44461. /** @hidden */
  44462. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44463. private _processSubCameras;
  44464. private _checkIntersections;
  44465. /** @hidden */
  44466. _advancePhysicsEngineStep(step: number): void;
  44467. /**
  44468. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44469. */
  44470. getDeterministicFrameTime: () => number;
  44471. /** @hidden */
  44472. _animate(): void;
  44473. /** Execute all animations (for a frame) */
  44474. animate(): void;
  44475. /**
  44476. * Render the scene
  44477. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44478. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44479. */
  44480. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44481. /**
  44482. * Freeze all materials
  44483. * A frozen material will not be updatable but should be faster to render
  44484. */
  44485. freezeMaterials(): void;
  44486. /**
  44487. * Unfreeze all materials
  44488. * A frozen material will not be updatable but should be faster to render
  44489. */
  44490. unfreezeMaterials(): void;
  44491. /**
  44492. * Releases all held ressources
  44493. */
  44494. dispose(): void;
  44495. /**
  44496. * Gets if the scene is already disposed
  44497. */
  44498. get isDisposed(): boolean;
  44499. /**
  44500. * Call this function to reduce memory footprint of the scene.
  44501. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44502. */
  44503. clearCachedVertexData(): void;
  44504. /**
  44505. * This function will remove the local cached buffer data from texture.
  44506. * It will save memory but will prevent the texture from being rebuilt
  44507. */
  44508. cleanCachedTextureBuffer(): void;
  44509. /**
  44510. * Get the world extend vectors with an optional filter
  44511. *
  44512. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44513. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44514. */
  44515. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44516. min: Vector3;
  44517. max: Vector3;
  44518. };
  44519. /**
  44520. * Creates a ray that can be used to pick in the scene
  44521. * @param x defines the x coordinate of the origin (on-screen)
  44522. * @param y defines the y coordinate of the origin (on-screen)
  44523. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44524. * @param camera defines the camera to use for the picking
  44525. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44526. * @returns a Ray
  44527. */
  44528. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44529. /**
  44530. * Creates a ray that can be used to pick in the scene
  44531. * @param x defines the x coordinate of the origin (on-screen)
  44532. * @param y defines the y coordinate of the origin (on-screen)
  44533. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44534. * @param result defines the ray where to store the picking ray
  44535. * @param camera defines the camera to use for the picking
  44536. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44537. * @returns the current scene
  44538. */
  44539. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44540. /**
  44541. * Creates a ray that can be used to pick in the scene
  44542. * @param x defines the x coordinate of the origin (on-screen)
  44543. * @param y defines the y coordinate of the origin (on-screen)
  44544. * @param camera defines the camera to use for the picking
  44545. * @returns a Ray
  44546. */
  44547. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44548. /**
  44549. * Creates a ray that can be used to pick in the scene
  44550. * @param x defines the x coordinate of the origin (on-screen)
  44551. * @param y defines the y coordinate of the origin (on-screen)
  44552. * @param result defines the ray where to store the picking ray
  44553. * @param camera defines the camera to use for the picking
  44554. * @returns the current scene
  44555. */
  44556. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44557. /** Launch a ray to try to pick a mesh in the scene
  44558. * @param x position on screen
  44559. * @param y position on screen
  44560. * @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
  44561. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44562. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44563. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44564. * @returns a PickingInfo
  44565. */
  44566. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44567. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44568. * @param x position on screen
  44569. * @param y position on screen
  44570. * @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
  44571. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44572. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44573. * @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)
  44574. */
  44575. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44576. /** Use the given ray to pick a mesh in the scene
  44577. * @param ray The ray to use to pick meshes
  44578. * @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
  44579. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44581. * @returns a PickingInfo
  44582. */
  44583. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44584. /**
  44585. * Launch a ray to try to pick a mesh in the scene
  44586. * @param x X position on screen
  44587. * @param y Y position on screen
  44588. * @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
  44589. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44591. * @returns an array of PickingInfo
  44592. */
  44593. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44594. /**
  44595. * Launch a ray to try to pick a mesh in the scene
  44596. * @param ray Ray to use
  44597. * @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
  44598. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44599. * @returns an array of PickingInfo
  44600. */
  44601. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44602. /**
  44603. * Force the value of meshUnderPointer
  44604. * @param mesh defines the mesh to use
  44605. * @param pointerId optional pointer id when using more than one pointer
  44606. */
  44607. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44608. /**
  44609. * Gets the mesh under the pointer
  44610. * @returns a Mesh or null if no mesh is under the pointer
  44611. */
  44612. getPointerOverMesh(): Nullable<AbstractMesh>;
  44613. /** @hidden */
  44614. _rebuildGeometries(): void;
  44615. /** @hidden */
  44616. _rebuildTextures(): void;
  44617. private _getByTags;
  44618. /**
  44619. * Get a list of meshes by tags
  44620. * @param tagsQuery defines the tags query to use
  44621. * @param forEach defines a predicate used to filter results
  44622. * @returns an array of Mesh
  44623. */
  44624. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44625. /**
  44626. * Get a list of cameras by tags
  44627. * @param tagsQuery defines the tags query to use
  44628. * @param forEach defines a predicate used to filter results
  44629. * @returns an array of Camera
  44630. */
  44631. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44632. /**
  44633. * Get a list of lights by tags
  44634. * @param tagsQuery defines the tags query to use
  44635. * @param forEach defines a predicate used to filter results
  44636. * @returns an array of Light
  44637. */
  44638. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44639. /**
  44640. * Get a list of materials by tags
  44641. * @param tagsQuery defines the tags query to use
  44642. * @param forEach defines a predicate used to filter results
  44643. * @returns an array of Material
  44644. */
  44645. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44646. /**
  44647. * Get a list of transform nodes by tags
  44648. * @param tagsQuery defines the tags query to use
  44649. * @param forEach defines a predicate used to filter results
  44650. * @returns an array of TransformNode
  44651. */
  44652. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44653. /**
  44654. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44655. * This allowed control for front to back rendering or reversly depending of the special needs.
  44656. *
  44657. * @param renderingGroupId The rendering group id corresponding to its index
  44658. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44659. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44660. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44661. */
  44662. 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;
  44663. /**
  44664. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44665. *
  44666. * @param renderingGroupId The rendering group id corresponding to its index
  44667. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44668. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44669. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44670. */
  44671. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44672. /**
  44673. * Gets the current auto clear configuration for one rendering group of the rendering
  44674. * manager.
  44675. * @param index the rendering group index to get the information for
  44676. * @returns The auto clear setup for the requested rendering group
  44677. */
  44678. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44679. private _blockMaterialDirtyMechanism;
  44680. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44681. get blockMaterialDirtyMechanism(): boolean;
  44682. set blockMaterialDirtyMechanism(value: boolean);
  44683. /**
  44684. * Will flag all materials as dirty to trigger new shader compilation
  44685. * @param flag defines the flag used to specify which material part must be marked as dirty
  44686. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44687. */
  44688. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44689. /** @hidden */
  44690. _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;
  44691. /** @hidden */
  44692. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44693. /** @hidden */
  44694. _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;
  44695. /** @hidden */
  44696. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44697. /** @hidden */
  44698. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44699. /** @hidden */
  44700. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44701. }
  44702. }
  44703. declare module BABYLON {
  44704. /**
  44705. * Set of assets to keep when moving a scene into an asset container.
  44706. */
  44707. export class KeepAssets extends AbstractScene {
  44708. }
  44709. /**
  44710. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44711. */
  44712. export class InstantiatedEntries {
  44713. /**
  44714. * List of new root nodes (eg. nodes with no parent)
  44715. */
  44716. rootNodes: TransformNode[];
  44717. /**
  44718. * List of new skeletons
  44719. */
  44720. skeletons: Skeleton[];
  44721. /**
  44722. * List of new animation groups
  44723. */
  44724. animationGroups: AnimationGroup[];
  44725. }
  44726. /**
  44727. * Container with a set of assets that can be added or removed from a scene.
  44728. */
  44729. export class AssetContainer extends AbstractScene {
  44730. private _wasAddedToScene;
  44731. /**
  44732. * The scene the AssetContainer belongs to.
  44733. */
  44734. scene: Scene;
  44735. /**
  44736. * Instantiates an AssetContainer.
  44737. * @param scene The scene the AssetContainer belongs to.
  44738. */
  44739. constructor(scene: Scene);
  44740. /**
  44741. * Instantiate or clone all meshes and add the new ones to the scene.
  44742. * Skeletons and animation groups will all be cloned
  44743. * @param nameFunction defines an optional function used to get new names for clones
  44744. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44745. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44746. */
  44747. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44748. /**
  44749. * Adds all the assets from the container to the scene.
  44750. */
  44751. addAllToScene(): void;
  44752. /**
  44753. * Removes all the assets in the container from the scene
  44754. */
  44755. removeAllFromScene(): void;
  44756. /**
  44757. * Disposes all the assets in the container
  44758. */
  44759. dispose(): void;
  44760. private _moveAssets;
  44761. /**
  44762. * Removes all the assets contained in the scene and adds them to the container.
  44763. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44764. */
  44765. moveAllFromScene(keepAssets?: KeepAssets): void;
  44766. /**
  44767. * 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.
  44768. * @returns the root mesh
  44769. */
  44770. createRootMesh(): Mesh;
  44771. /**
  44772. * Merge animations (direct and animation groups) from this asset container into a scene
  44773. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44774. * @param animatables set of animatables to retarget to a node from the scene
  44775. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44776. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44777. */
  44778. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * Defines how the parser contract is defined.
  44784. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44785. */
  44786. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44787. /**
  44788. * Defines how the individual parser contract is defined.
  44789. * These parser can parse an individual asset
  44790. */
  44791. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44792. /**
  44793. * Base class of the scene acting as a container for the different elements composing a scene.
  44794. * This class is dynamically extended by the different components of the scene increasing
  44795. * flexibility and reducing coupling
  44796. */
  44797. export abstract class AbstractScene {
  44798. /**
  44799. * Stores the list of available parsers in the application.
  44800. */
  44801. private static _BabylonFileParsers;
  44802. /**
  44803. * Stores the list of available individual parsers in the application.
  44804. */
  44805. private static _IndividualBabylonFileParsers;
  44806. /**
  44807. * Adds a parser in the list of available ones
  44808. * @param name Defines the name of the parser
  44809. * @param parser Defines the parser to add
  44810. */
  44811. static AddParser(name: string, parser: BabylonFileParser): void;
  44812. /**
  44813. * Gets a general parser from the list of avaialble ones
  44814. * @param name Defines the name of the parser
  44815. * @returns the requested parser or null
  44816. */
  44817. static GetParser(name: string): Nullable<BabylonFileParser>;
  44818. /**
  44819. * Adds n individual parser in the list of available ones
  44820. * @param name Defines the name of the parser
  44821. * @param parser Defines the parser to add
  44822. */
  44823. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44824. /**
  44825. * Gets an individual parser from the list of avaialble ones
  44826. * @param name Defines the name of the parser
  44827. * @returns the requested parser or null
  44828. */
  44829. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44830. /**
  44831. * Parser json data and populate both a scene and its associated container object
  44832. * @param jsonData Defines the data to parse
  44833. * @param scene Defines the scene to parse the data for
  44834. * @param container Defines the container attached to the parsing sequence
  44835. * @param rootUrl Defines the root url of the data
  44836. */
  44837. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44838. /**
  44839. * Gets the list of root nodes (ie. nodes with no parent)
  44840. */
  44841. rootNodes: Node[];
  44842. /** All of the cameras added to this scene
  44843. * @see https://doc.babylonjs.com/babylon101/cameras
  44844. */
  44845. cameras: Camera[];
  44846. /**
  44847. * All of the lights added to this scene
  44848. * @see https://doc.babylonjs.com/babylon101/lights
  44849. */
  44850. lights: Light[];
  44851. /**
  44852. * All of the (abstract) meshes added to this scene
  44853. */
  44854. meshes: AbstractMesh[];
  44855. /**
  44856. * The list of skeletons added to the scene
  44857. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44858. */
  44859. skeletons: Skeleton[];
  44860. /**
  44861. * All of the particle systems added to this scene
  44862. * @see https://doc.babylonjs.com/babylon101/particles
  44863. */
  44864. particleSystems: IParticleSystem[];
  44865. /**
  44866. * Gets a list of Animations associated with the scene
  44867. */
  44868. animations: Animation[];
  44869. /**
  44870. * All of the animation groups added to this scene
  44871. * @see https://doc.babylonjs.com/how_to/group
  44872. */
  44873. animationGroups: AnimationGroup[];
  44874. /**
  44875. * All of the multi-materials added to this scene
  44876. * @see https://doc.babylonjs.com/how_to/multi_materials
  44877. */
  44878. multiMaterials: MultiMaterial[];
  44879. /**
  44880. * All of the materials added to this scene
  44881. * In the context of a Scene, it is not supposed to be modified manually.
  44882. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44883. * Note also that the order of the Material within the array is not significant and might change.
  44884. * @see https://doc.babylonjs.com/babylon101/materials
  44885. */
  44886. materials: Material[];
  44887. /**
  44888. * The list of morph target managers added to the scene
  44889. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44890. */
  44891. morphTargetManagers: MorphTargetManager[];
  44892. /**
  44893. * The list of geometries used in the scene.
  44894. */
  44895. geometries: Geometry[];
  44896. /**
  44897. * All of the tranform nodes added to this scene
  44898. * In the context of a Scene, it is not supposed to be modified manually.
  44899. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44900. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44901. * @see https://doc.babylonjs.com/how_to/transformnode
  44902. */
  44903. transformNodes: TransformNode[];
  44904. /**
  44905. * ActionManagers available on the scene.
  44906. */
  44907. actionManagers: AbstractActionManager[];
  44908. /**
  44909. * Textures to keep.
  44910. */
  44911. textures: BaseTexture[];
  44912. /** @hidden */
  44913. protected _environmentTexture: Nullable<BaseTexture>;
  44914. /**
  44915. * Texture used in all pbr material as the reflection texture.
  44916. * As in the majority of the scene they are the same (exception for multi room and so on),
  44917. * this is easier to reference from here than from all the materials.
  44918. */
  44919. get environmentTexture(): Nullable<BaseTexture>;
  44920. set environmentTexture(value: Nullable<BaseTexture>);
  44921. /**
  44922. * The list of postprocesses added to the scene
  44923. */
  44924. postProcesses: PostProcess[];
  44925. /**
  44926. * @returns all meshes, lights, cameras, transformNodes and bones
  44927. */
  44928. getNodes(): Array<Node>;
  44929. }
  44930. }
  44931. declare module BABYLON {
  44932. /**
  44933. * Interface used to define options for Sound class
  44934. */
  44935. export interface ISoundOptions {
  44936. /**
  44937. * Does the sound autoplay once loaded.
  44938. */
  44939. autoplay?: boolean;
  44940. /**
  44941. * Does the sound loop after it finishes playing once.
  44942. */
  44943. loop?: boolean;
  44944. /**
  44945. * Sound's volume
  44946. */
  44947. volume?: number;
  44948. /**
  44949. * Is it a spatial sound?
  44950. */
  44951. spatialSound?: boolean;
  44952. /**
  44953. * Maximum distance to hear that sound
  44954. */
  44955. maxDistance?: number;
  44956. /**
  44957. * Uses user defined attenuation function
  44958. */
  44959. useCustomAttenuation?: boolean;
  44960. /**
  44961. * Define the roll off factor of spatial sounds.
  44962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44963. */
  44964. rolloffFactor?: number;
  44965. /**
  44966. * Define the reference distance the sound should be heard perfectly.
  44967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44968. */
  44969. refDistance?: number;
  44970. /**
  44971. * Define the distance attenuation model the sound will follow.
  44972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44973. */
  44974. distanceModel?: string;
  44975. /**
  44976. * Defines the playback speed (1 by default)
  44977. */
  44978. playbackRate?: number;
  44979. /**
  44980. * Defines if the sound is from a streaming source
  44981. */
  44982. streaming?: boolean;
  44983. /**
  44984. * Defines an optional length (in seconds) inside the sound file
  44985. */
  44986. length?: number;
  44987. /**
  44988. * Defines an optional offset (in seconds) inside the sound file
  44989. */
  44990. offset?: number;
  44991. /**
  44992. * If true, URLs will not be required to state the audio file codec to use.
  44993. */
  44994. skipCodecCheck?: boolean;
  44995. }
  44996. }
  44997. declare module BABYLON {
  44998. /**
  44999. * Defines a sound that can be played in the application.
  45000. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45002. */
  45003. export class Sound {
  45004. /**
  45005. * The name of the sound in the scene.
  45006. */
  45007. name: string;
  45008. /**
  45009. * Does the sound autoplay once loaded.
  45010. */
  45011. autoplay: boolean;
  45012. /**
  45013. * Does the sound loop after it finishes playing once.
  45014. */
  45015. loop: boolean;
  45016. /**
  45017. * Does the sound use a custom attenuation curve to simulate the falloff
  45018. * happening when the source gets further away from the camera.
  45019. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45020. */
  45021. useCustomAttenuation: boolean;
  45022. /**
  45023. * The sound track id this sound belongs to.
  45024. */
  45025. soundTrackId: number;
  45026. /**
  45027. * Is this sound currently played.
  45028. */
  45029. isPlaying: boolean;
  45030. /**
  45031. * Is this sound currently paused.
  45032. */
  45033. isPaused: boolean;
  45034. /**
  45035. * Does this sound enables spatial sound.
  45036. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45037. */
  45038. spatialSound: boolean;
  45039. /**
  45040. * Define the reference distance the sound should be heard perfectly.
  45041. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45042. */
  45043. refDistance: number;
  45044. /**
  45045. * Define the roll off factor of spatial sounds.
  45046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45047. */
  45048. rolloffFactor: number;
  45049. /**
  45050. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45051. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45052. */
  45053. maxDistance: number;
  45054. /**
  45055. * Define the distance attenuation model the sound will follow.
  45056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45057. */
  45058. distanceModel: string;
  45059. /**
  45060. * @hidden
  45061. * Back Compat
  45062. **/
  45063. onended: () => any;
  45064. /**
  45065. * Gets or sets an object used to store user defined information for the sound.
  45066. */
  45067. metadata: any;
  45068. /**
  45069. * Observable event when the current playing sound finishes.
  45070. */
  45071. onEndedObservable: Observable<Sound>;
  45072. /**
  45073. * Gets the current time for the sound.
  45074. */
  45075. get currentTime(): number;
  45076. private _panningModel;
  45077. private _playbackRate;
  45078. private _streaming;
  45079. private _startTime;
  45080. private _startOffset;
  45081. private _position;
  45082. /** @hidden */
  45083. _positionInEmitterSpace: boolean;
  45084. private _localDirection;
  45085. private _volume;
  45086. private _isReadyToPlay;
  45087. private _isDirectional;
  45088. private _readyToPlayCallback;
  45089. private _audioBuffer;
  45090. private _soundSource;
  45091. private _streamingSource;
  45092. private _soundPanner;
  45093. private _soundGain;
  45094. private _inputAudioNode;
  45095. private _outputAudioNode;
  45096. private _coneInnerAngle;
  45097. private _coneOuterAngle;
  45098. private _coneOuterGain;
  45099. private _scene;
  45100. private _connectedTransformNode;
  45101. private _customAttenuationFunction;
  45102. private _registerFunc;
  45103. private _isOutputConnected;
  45104. private _htmlAudioElement;
  45105. private _urlType;
  45106. private _length?;
  45107. private _offset?;
  45108. /** @hidden */
  45109. static _SceneComponentInitialization: (scene: Scene) => void;
  45110. /**
  45111. * Create a sound and attach it to a scene
  45112. * @param name Name of your sound
  45113. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45114. * @param scene defines the scene the sound belongs to
  45115. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45116. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45117. */
  45118. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45119. /**
  45120. * Release the sound and its associated resources
  45121. */
  45122. dispose(): void;
  45123. /**
  45124. * Gets if the sounds is ready to be played or not.
  45125. * @returns true if ready, otherwise false
  45126. */
  45127. isReady(): boolean;
  45128. private _soundLoaded;
  45129. /**
  45130. * Sets the data of the sound from an audiobuffer
  45131. * @param audioBuffer The audioBuffer containing the data
  45132. */
  45133. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45134. /**
  45135. * Updates the current sounds options such as maxdistance, loop...
  45136. * @param options A JSON object containing values named as the object properties
  45137. */
  45138. updateOptions(options: ISoundOptions): void;
  45139. private _createSpatialParameters;
  45140. private _updateSpatialParameters;
  45141. /**
  45142. * Switch the panning model to HRTF:
  45143. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45145. */
  45146. switchPanningModelToHRTF(): void;
  45147. /**
  45148. * Switch the panning model to Equal Power:
  45149. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45150. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45151. */
  45152. switchPanningModelToEqualPower(): void;
  45153. private _switchPanningModel;
  45154. /**
  45155. * Connect this sound to a sound track audio node like gain...
  45156. * @param soundTrackAudioNode the sound track audio node to connect to
  45157. */
  45158. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45159. /**
  45160. * Transform this sound into a directional source
  45161. * @param coneInnerAngle Size of the inner cone in degree
  45162. * @param coneOuterAngle Size of the outer cone in degree
  45163. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45164. */
  45165. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45166. /**
  45167. * Gets or sets the inner angle for the directional cone.
  45168. */
  45169. get directionalConeInnerAngle(): number;
  45170. /**
  45171. * Gets or sets the inner angle for the directional cone.
  45172. */
  45173. set directionalConeInnerAngle(value: number);
  45174. /**
  45175. * Gets or sets the outer angle for the directional cone.
  45176. */
  45177. get directionalConeOuterAngle(): number;
  45178. /**
  45179. * Gets or sets the outer angle for the directional cone.
  45180. */
  45181. set directionalConeOuterAngle(value: number);
  45182. /**
  45183. * Sets the position of the emitter if spatial sound is enabled
  45184. * @param newPosition Defines the new posisiton
  45185. */
  45186. setPosition(newPosition: Vector3): void;
  45187. /**
  45188. * Sets the local direction of the emitter if spatial sound is enabled
  45189. * @param newLocalDirection Defines the new local direction
  45190. */
  45191. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45192. private _updateDirection;
  45193. /** @hidden */
  45194. updateDistanceFromListener(): void;
  45195. /**
  45196. * Sets a new custom attenuation function for the sound.
  45197. * @param callback Defines the function used for the attenuation
  45198. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45199. */
  45200. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45201. /**
  45202. * Play the sound
  45203. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45204. * @param offset (optional) Start the sound at a specific time in seconds
  45205. * @param length (optional) Sound duration (in seconds)
  45206. */
  45207. play(time?: number, offset?: number, length?: number): void;
  45208. private _onended;
  45209. /**
  45210. * Stop the sound
  45211. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45212. */
  45213. stop(time?: number): void;
  45214. /**
  45215. * Put the sound in pause
  45216. */
  45217. pause(): void;
  45218. /**
  45219. * Sets a dedicated volume for this sounds
  45220. * @param newVolume Define the new volume of the sound
  45221. * @param time Define time for gradual change to new volume
  45222. */
  45223. setVolume(newVolume: number, time?: number): void;
  45224. /**
  45225. * Set the sound play back rate
  45226. * @param newPlaybackRate Define the playback rate the sound should be played at
  45227. */
  45228. setPlaybackRate(newPlaybackRate: number): void;
  45229. /**
  45230. * Gets the volume of the sound.
  45231. * @returns the volume of the sound
  45232. */
  45233. getVolume(): number;
  45234. /**
  45235. * Attach the sound to a dedicated mesh
  45236. * @param transformNode The transform node to connect the sound with
  45237. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45238. */
  45239. attachToMesh(transformNode: TransformNode): void;
  45240. /**
  45241. * Detach the sound from the previously attached mesh
  45242. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45243. */
  45244. detachFromMesh(): void;
  45245. private _onRegisterAfterWorldMatrixUpdate;
  45246. /**
  45247. * Clone the current sound in the scene.
  45248. * @returns the new sound clone
  45249. */
  45250. clone(): Nullable<Sound>;
  45251. /**
  45252. * Gets the current underlying audio buffer containing the data
  45253. * @returns the audio buffer
  45254. */
  45255. getAudioBuffer(): Nullable<AudioBuffer>;
  45256. /**
  45257. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45258. * @returns the source node
  45259. */
  45260. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45261. /**
  45262. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45263. * @returns the gain node
  45264. */
  45265. getSoundGain(): Nullable<GainNode>;
  45266. /**
  45267. * Serializes the Sound in a JSON representation
  45268. * @returns the JSON representation of the sound
  45269. */
  45270. serialize(): any;
  45271. /**
  45272. * Parse a JSON representation of a sound to innstantiate in a given scene
  45273. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45274. * @param scene Define the scene the new parsed sound should be created in
  45275. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45276. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45277. * @returns the newly parsed sound
  45278. */
  45279. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45280. }
  45281. }
  45282. declare module BABYLON {
  45283. /**
  45284. * This defines an action helpful to play a defined sound on a triggered action.
  45285. */
  45286. export class PlaySoundAction extends Action {
  45287. private _sound;
  45288. /**
  45289. * Instantiate the action
  45290. * @param triggerOptions defines the trigger options
  45291. * @param sound defines the sound to play
  45292. * @param condition defines the trigger related conditions
  45293. */
  45294. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45295. /** @hidden */
  45296. _prepare(): void;
  45297. /**
  45298. * Execute the action and play the sound.
  45299. */
  45300. execute(): void;
  45301. /**
  45302. * Serializes the actions and its related information.
  45303. * @param parent defines the object to serialize in
  45304. * @returns the serialized object
  45305. */
  45306. serialize(parent: any): any;
  45307. }
  45308. /**
  45309. * This defines an action helpful to stop a defined sound on a triggered action.
  45310. */
  45311. export class StopSoundAction extends Action {
  45312. private _sound;
  45313. /**
  45314. * Instantiate the action
  45315. * @param triggerOptions defines the trigger options
  45316. * @param sound defines the sound to stop
  45317. * @param condition defines the trigger related conditions
  45318. */
  45319. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45320. /** @hidden */
  45321. _prepare(): void;
  45322. /**
  45323. * Execute the action and stop the sound.
  45324. */
  45325. execute(): void;
  45326. /**
  45327. * Serializes the actions and its related information.
  45328. * @param parent defines the object to serialize in
  45329. * @returns the serialized object
  45330. */
  45331. serialize(parent: any): any;
  45332. }
  45333. }
  45334. declare module BABYLON {
  45335. /**
  45336. * This defines an action responsible to change the value of a property
  45337. * by interpolating between its current value and the newly set one once triggered.
  45338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45339. */
  45340. export class InterpolateValueAction extends Action {
  45341. /**
  45342. * Defines the path of the property where the value should be interpolated
  45343. */
  45344. propertyPath: string;
  45345. /**
  45346. * Defines the target value at the end of the interpolation.
  45347. */
  45348. value: any;
  45349. /**
  45350. * Defines the time it will take for the property to interpolate to the value.
  45351. */
  45352. duration: number;
  45353. /**
  45354. * Defines if the other scene animations should be stopped when the action has been triggered
  45355. */
  45356. stopOtherAnimations?: boolean;
  45357. /**
  45358. * Defines a callback raised once the interpolation animation has been done.
  45359. */
  45360. onInterpolationDone?: () => void;
  45361. /**
  45362. * Observable triggered once the interpolation animation has been done.
  45363. */
  45364. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45365. private _target;
  45366. private _effectiveTarget;
  45367. private _property;
  45368. /**
  45369. * Instantiate the action
  45370. * @param triggerOptions defines the trigger options
  45371. * @param target defines the object containing the value to interpolate
  45372. * @param propertyPath defines the path to the property in the target object
  45373. * @param value defines the target value at the end of the interpolation
  45374. * @param duration deines the time it will take for the property to interpolate to the value.
  45375. * @param condition defines the trigger related conditions
  45376. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45377. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45378. */
  45379. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45380. /** @hidden */
  45381. _prepare(): void;
  45382. /**
  45383. * Execute the action starts the value interpolation.
  45384. */
  45385. execute(): void;
  45386. /**
  45387. * Serializes the actions and its related information.
  45388. * @param parent defines the object to serialize in
  45389. * @returns the serialized object
  45390. */
  45391. serialize(parent: any): any;
  45392. }
  45393. }
  45394. declare module BABYLON {
  45395. /**
  45396. * This represents the default audio engine used in babylon.
  45397. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45398. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45399. */
  45400. export class AudioEngine implements IAudioEngine {
  45401. private _audioContext;
  45402. private _audioContextInitialized;
  45403. private _muteButton;
  45404. private _hostElement;
  45405. /**
  45406. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45407. */
  45408. canUseWebAudio: boolean;
  45409. /**
  45410. * The master gain node defines the global audio volume of your audio engine.
  45411. */
  45412. masterGain: GainNode;
  45413. /**
  45414. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45415. * @ignoreNaming
  45416. */
  45417. WarnedWebAudioUnsupported: boolean;
  45418. /**
  45419. * Gets whether or not mp3 are supported by your browser.
  45420. */
  45421. isMP3supported: boolean;
  45422. /**
  45423. * Gets whether or not ogg are supported by your browser.
  45424. */
  45425. isOGGsupported: boolean;
  45426. /**
  45427. * Gets whether audio has been unlocked on the device.
  45428. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45429. * a user interaction has happened.
  45430. */
  45431. unlocked: boolean;
  45432. /**
  45433. * Defines if the audio engine relies on a custom unlocked button.
  45434. * In this case, the embedded button will not be displayed.
  45435. */
  45436. useCustomUnlockedButton: boolean;
  45437. /**
  45438. * Event raised when audio has been unlocked on the browser.
  45439. */
  45440. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45441. /**
  45442. * Event raised when audio has been locked on the browser.
  45443. */
  45444. onAudioLockedObservable: Observable<IAudioEngine>;
  45445. /**
  45446. * Gets the current AudioContext if available.
  45447. */
  45448. get audioContext(): Nullable<AudioContext>;
  45449. private _connectedAnalyser;
  45450. /**
  45451. * Instantiates a new audio engine.
  45452. *
  45453. * There should be only one per page as some browsers restrict the number
  45454. * of audio contexts you can create.
  45455. * @param hostElement defines the host element where to display the mute icon if necessary
  45456. */
  45457. constructor(hostElement?: Nullable<HTMLElement>);
  45458. /**
  45459. * Flags the audio engine in Locked state.
  45460. * This happens due to new browser policies preventing audio to autoplay.
  45461. */
  45462. lock(): void;
  45463. /**
  45464. * Unlocks the audio engine once a user action has been done on the dom.
  45465. * This is helpful to resume play once browser policies have been satisfied.
  45466. */
  45467. unlock(): void;
  45468. private _resumeAudioContext;
  45469. private _initializeAudioContext;
  45470. private _tryToRun;
  45471. private _triggerRunningState;
  45472. private _triggerSuspendedState;
  45473. private _displayMuteButton;
  45474. private _moveButtonToTopLeft;
  45475. private _onResize;
  45476. private _hideMuteButton;
  45477. /**
  45478. * Destroy and release the resources associated with the audio ccontext.
  45479. */
  45480. dispose(): void;
  45481. /**
  45482. * Gets the global volume sets on the master gain.
  45483. * @returns the global volume if set or -1 otherwise
  45484. */
  45485. getGlobalVolume(): number;
  45486. /**
  45487. * Sets the global volume of your experience (sets on the master gain).
  45488. * @param newVolume Defines the new global volume of the application
  45489. */
  45490. setGlobalVolume(newVolume: number): void;
  45491. /**
  45492. * Connect the audio engine to an audio analyser allowing some amazing
  45493. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45495. * @param analyser The analyser to connect to the engine
  45496. */
  45497. connectToAnalyser(analyser: Analyser): void;
  45498. }
  45499. }
  45500. declare module BABYLON {
  45501. /**
  45502. * Options allowed during the creation of a sound track.
  45503. */
  45504. export interface ISoundTrackOptions {
  45505. /**
  45506. * The volume the sound track should take during creation
  45507. */
  45508. volume?: number;
  45509. /**
  45510. * Define if the sound track is the main sound track of the scene
  45511. */
  45512. mainTrack?: boolean;
  45513. }
  45514. /**
  45515. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45516. * It will be also used in a future release to apply effects on a specific track.
  45517. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45518. */
  45519. export class SoundTrack {
  45520. /**
  45521. * The unique identifier of the sound track in the scene.
  45522. */
  45523. id: number;
  45524. /**
  45525. * The list of sounds included in the sound track.
  45526. */
  45527. soundCollection: Array<Sound>;
  45528. private _outputAudioNode;
  45529. private _scene;
  45530. private _connectedAnalyser;
  45531. private _options;
  45532. private _isInitialized;
  45533. /**
  45534. * Creates a new sound track.
  45535. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45536. * @param scene Define the scene the sound track belongs to
  45537. * @param options
  45538. */
  45539. constructor(scene: Scene, options?: ISoundTrackOptions);
  45540. private _initializeSoundTrackAudioGraph;
  45541. /**
  45542. * Release the sound track and its associated resources
  45543. */
  45544. dispose(): void;
  45545. /**
  45546. * Adds a sound to this sound track
  45547. * @param sound define the cound to add
  45548. * @ignoreNaming
  45549. */
  45550. addSound(sound: Sound): void;
  45551. /**
  45552. * Removes a sound to this sound track
  45553. * @param sound define the cound to remove
  45554. * @ignoreNaming
  45555. */
  45556. removeSound(sound: Sound): void;
  45557. /**
  45558. * Set a global volume for the full sound track.
  45559. * @param newVolume Define the new volume of the sound track
  45560. */
  45561. setVolume(newVolume: number): void;
  45562. /**
  45563. * Switch the panning model to HRTF:
  45564. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45565. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45566. */
  45567. switchPanningModelToHRTF(): void;
  45568. /**
  45569. * Switch the panning model to Equal Power:
  45570. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45571. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45572. */
  45573. switchPanningModelToEqualPower(): void;
  45574. /**
  45575. * Connect the sound track to an audio analyser allowing some amazing
  45576. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45577. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45578. * @param analyser The analyser to connect to the engine
  45579. */
  45580. connectToAnalyser(analyser: Analyser): void;
  45581. }
  45582. }
  45583. declare module BABYLON {
  45584. interface AbstractScene {
  45585. /**
  45586. * The list of sounds used in the scene.
  45587. */
  45588. sounds: Nullable<Array<Sound>>;
  45589. }
  45590. interface Scene {
  45591. /**
  45592. * @hidden
  45593. * Backing field
  45594. */
  45595. _mainSoundTrack: SoundTrack;
  45596. /**
  45597. * The main sound track played by the scene.
  45598. * It cotains your primary collection of sounds.
  45599. */
  45600. mainSoundTrack: SoundTrack;
  45601. /**
  45602. * The list of sound tracks added to the scene
  45603. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45604. */
  45605. soundTracks: Nullable<Array<SoundTrack>>;
  45606. /**
  45607. * Gets a sound using a given name
  45608. * @param name defines the name to search for
  45609. * @return the found sound or null if not found at all.
  45610. */
  45611. getSoundByName(name: string): Nullable<Sound>;
  45612. /**
  45613. * Gets or sets if audio support is enabled
  45614. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45615. */
  45616. audioEnabled: boolean;
  45617. /**
  45618. * Gets or sets if audio will be output to headphones
  45619. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45620. */
  45621. headphone: boolean;
  45622. /**
  45623. * Gets or sets custom audio listener position provider
  45624. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45625. */
  45626. audioListenerPositionProvider: Nullable<() => Vector3>;
  45627. /**
  45628. * Gets or sets a refresh rate when using 3D audio positioning
  45629. */
  45630. audioPositioningRefreshRate: number;
  45631. }
  45632. /**
  45633. * Defines the sound scene component responsible to manage any sounds
  45634. * in a given scene.
  45635. */
  45636. export class AudioSceneComponent implements ISceneSerializableComponent {
  45637. private static _CameraDirectionLH;
  45638. private static _CameraDirectionRH;
  45639. /**
  45640. * The component name helpfull to identify the component in the list of scene components.
  45641. */
  45642. readonly name: string;
  45643. /**
  45644. * The scene the component belongs to.
  45645. */
  45646. scene: Scene;
  45647. private _audioEnabled;
  45648. /**
  45649. * Gets whether audio is enabled or not.
  45650. * Please use related enable/disable method to switch state.
  45651. */
  45652. get audioEnabled(): boolean;
  45653. private _headphone;
  45654. /**
  45655. * Gets whether audio is outputing to headphone or not.
  45656. * Please use the according Switch methods to change output.
  45657. */
  45658. get headphone(): boolean;
  45659. /**
  45660. * Gets or sets a refresh rate when using 3D audio positioning
  45661. */
  45662. audioPositioningRefreshRate: number;
  45663. private _audioListenerPositionProvider;
  45664. /**
  45665. * Gets the current audio listener position provider
  45666. */
  45667. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45668. /**
  45669. * Sets a custom listener position for all sounds in the scene
  45670. * By default, this is the position of the first active camera
  45671. */
  45672. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45673. /**
  45674. * Creates a new instance of the component for the given scene
  45675. * @param scene Defines the scene to register the component in
  45676. */
  45677. constructor(scene: Scene);
  45678. /**
  45679. * Registers the component in a given scene
  45680. */
  45681. register(): void;
  45682. /**
  45683. * Rebuilds the elements related to this component in case of
  45684. * context lost for instance.
  45685. */
  45686. rebuild(): void;
  45687. /**
  45688. * Serializes the component data to the specified json object
  45689. * @param serializationObject The object to serialize to
  45690. */
  45691. serialize(serializationObject: any): void;
  45692. /**
  45693. * Adds all the elements from the container to the scene
  45694. * @param container the container holding the elements
  45695. */
  45696. addFromContainer(container: AbstractScene): void;
  45697. /**
  45698. * Removes all the elements in the container from the scene
  45699. * @param container contains the elements to remove
  45700. * @param dispose if the removed element should be disposed (default: false)
  45701. */
  45702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45703. /**
  45704. * Disposes the component and the associated ressources.
  45705. */
  45706. dispose(): void;
  45707. /**
  45708. * Disables audio in the associated scene.
  45709. */
  45710. disableAudio(): void;
  45711. /**
  45712. * Enables audio in the associated scene.
  45713. */
  45714. enableAudio(): void;
  45715. /**
  45716. * Switch audio to headphone output.
  45717. */
  45718. switchAudioModeForHeadphones(): void;
  45719. /**
  45720. * Switch audio to normal speakers.
  45721. */
  45722. switchAudioModeForNormalSpeakers(): void;
  45723. private _cachedCameraDirection;
  45724. private _cachedCameraPosition;
  45725. private _lastCheck;
  45726. private _afterRender;
  45727. }
  45728. }
  45729. declare module BABYLON {
  45730. /**
  45731. * Wraps one or more Sound objects and selects one with random weight for playback.
  45732. */
  45733. export class WeightedSound {
  45734. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45735. loop: boolean;
  45736. private _coneInnerAngle;
  45737. private _coneOuterAngle;
  45738. private _volume;
  45739. /** A Sound is currently playing. */
  45740. isPlaying: boolean;
  45741. /** A Sound is currently paused. */
  45742. isPaused: boolean;
  45743. private _sounds;
  45744. private _weights;
  45745. private _currentIndex?;
  45746. /**
  45747. * Creates a new WeightedSound from the list of sounds given.
  45748. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45749. * @param sounds Array of Sounds that will be selected from.
  45750. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45751. */
  45752. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45753. /**
  45754. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45755. */
  45756. get directionalConeInnerAngle(): number;
  45757. /**
  45758. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45759. */
  45760. set directionalConeInnerAngle(value: number);
  45761. /**
  45762. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45763. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45764. */
  45765. get directionalConeOuterAngle(): number;
  45766. /**
  45767. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45768. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45769. */
  45770. set directionalConeOuterAngle(value: number);
  45771. /**
  45772. * Playback volume.
  45773. */
  45774. get volume(): number;
  45775. /**
  45776. * Playback volume.
  45777. */
  45778. set volume(value: number);
  45779. private _onended;
  45780. /**
  45781. * Suspend playback
  45782. */
  45783. pause(): void;
  45784. /**
  45785. * Stop playback
  45786. */
  45787. stop(): void;
  45788. /**
  45789. * Start playback.
  45790. * @param startOffset Position the clip head at a specific time in seconds.
  45791. */
  45792. play(startOffset?: number): void;
  45793. }
  45794. }
  45795. declare module BABYLON {
  45796. /**
  45797. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45798. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45799. */
  45800. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45801. /**
  45802. * Gets the name of the behavior.
  45803. */
  45804. get name(): string;
  45805. /**
  45806. * The easing function used by animations
  45807. */
  45808. static EasingFunction: BackEase;
  45809. /**
  45810. * The easing mode used by animations
  45811. */
  45812. static EasingMode: number;
  45813. /**
  45814. * The duration of the animation, in milliseconds
  45815. */
  45816. transitionDuration: number;
  45817. /**
  45818. * Length of the distance animated by the transition when lower radius is reached
  45819. */
  45820. lowerRadiusTransitionRange: number;
  45821. /**
  45822. * Length of the distance animated by the transition when upper radius is reached
  45823. */
  45824. upperRadiusTransitionRange: number;
  45825. private _autoTransitionRange;
  45826. /**
  45827. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45828. */
  45829. get autoTransitionRange(): boolean;
  45830. /**
  45831. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45832. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45833. */
  45834. set autoTransitionRange(value: boolean);
  45835. private _attachedCamera;
  45836. private _onAfterCheckInputsObserver;
  45837. private _onMeshTargetChangedObserver;
  45838. /**
  45839. * Initializes the behavior.
  45840. */
  45841. init(): void;
  45842. /**
  45843. * Attaches the behavior to its arc rotate camera.
  45844. * @param camera Defines the camera to attach the behavior to
  45845. */
  45846. attach(camera: ArcRotateCamera): void;
  45847. /**
  45848. * Detaches the behavior from its current arc rotate camera.
  45849. */
  45850. detach(): void;
  45851. private _radiusIsAnimating;
  45852. private _radiusBounceTransition;
  45853. private _animatables;
  45854. private _cachedWheelPrecision;
  45855. /**
  45856. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45857. * @param radiusLimit The limit to check against.
  45858. * @return Bool to indicate if at limit.
  45859. */
  45860. private _isRadiusAtLimit;
  45861. /**
  45862. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45863. * @param radiusDelta The delta by which to animate to. Can be negative.
  45864. */
  45865. private _applyBoundRadiusAnimation;
  45866. /**
  45867. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45868. */
  45869. protected _clearAnimationLocks(): void;
  45870. /**
  45871. * Stops and removes all animations that have been applied to the camera
  45872. */
  45873. stopAllAnimations(): void;
  45874. }
  45875. }
  45876. declare module BABYLON {
  45877. /**
  45878. * 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.
  45879. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45880. */
  45881. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45882. /**
  45883. * Gets the name of the behavior.
  45884. */
  45885. get name(): string;
  45886. private _mode;
  45887. private _radiusScale;
  45888. private _positionScale;
  45889. private _defaultElevation;
  45890. private _elevationReturnTime;
  45891. private _elevationReturnWaitTime;
  45892. private _zoomStopsAnimation;
  45893. private _framingTime;
  45894. /**
  45895. * The easing function used by animations
  45896. */
  45897. static EasingFunction: ExponentialEase;
  45898. /**
  45899. * The easing mode used by animations
  45900. */
  45901. static EasingMode: number;
  45902. /**
  45903. * Sets the current mode used by the behavior
  45904. */
  45905. set mode(mode: number);
  45906. /**
  45907. * Gets current mode used by the behavior.
  45908. */
  45909. get mode(): number;
  45910. /**
  45911. * Sets the scale applied to the radius (1 by default)
  45912. */
  45913. set radiusScale(radius: number);
  45914. /**
  45915. * Gets the scale applied to the radius
  45916. */
  45917. get radiusScale(): number;
  45918. /**
  45919. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45920. */
  45921. set positionScale(scale: number);
  45922. /**
  45923. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45924. */
  45925. get positionScale(): number;
  45926. /**
  45927. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45928. * behaviour is triggered, in radians.
  45929. */
  45930. set defaultElevation(elevation: number);
  45931. /**
  45932. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45933. * behaviour is triggered, in radians.
  45934. */
  45935. get defaultElevation(): number;
  45936. /**
  45937. * Sets the time (in milliseconds) taken to return to the default beta position.
  45938. * Negative value indicates camera should not return to default.
  45939. */
  45940. set elevationReturnTime(speed: number);
  45941. /**
  45942. * Gets the time (in milliseconds) taken to return to the default beta position.
  45943. * Negative value indicates camera should not return to default.
  45944. */
  45945. get elevationReturnTime(): number;
  45946. /**
  45947. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45948. */
  45949. set elevationReturnWaitTime(time: number);
  45950. /**
  45951. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45952. */
  45953. get elevationReturnWaitTime(): number;
  45954. /**
  45955. * Sets the flag that indicates if user zooming should stop animation.
  45956. */
  45957. set zoomStopsAnimation(flag: boolean);
  45958. /**
  45959. * Gets the flag that indicates if user zooming should stop animation.
  45960. */
  45961. get zoomStopsAnimation(): boolean;
  45962. /**
  45963. * Sets the transition time when framing the mesh, in milliseconds
  45964. */
  45965. set framingTime(time: number);
  45966. /**
  45967. * Gets the transition time when framing the mesh, in milliseconds
  45968. */
  45969. get framingTime(): number;
  45970. /**
  45971. * Define if the behavior should automatically change the configured
  45972. * camera limits and sensibilities.
  45973. */
  45974. autoCorrectCameraLimitsAndSensibility: boolean;
  45975. private _onPrePointerObservableObserver;
  45976. private _onAfterCheckInputsObserver;
  45977. private _onMeshTargetChangedObserver;
  45978. private _attachedCamera;
  45979. private _isPointerDown;
  45980. private _lastInteractionTime;
  45981. /**
  45982. * Initializes the behavior.
  45983. */
  45984. init(): void;
  45985. /**
  45986. * Attaches the behavior to its arc rotate camera.
  45987. * @param camera Defines the camera to attach the behavior to
  45988. */
  45989. attach(camera: ArcRotateCamera): void;
  45990. /**
  45991. * Detaches the behavior from its current arc rotate camera.
  45992. */
  45993. detach(): void;
  45994. private _animatables;
  45995. private _betaIsAnimating;
  45996. private _betaTransition;
  45997. private _radiusTransition;
  45998. private _vectorTransition;
  45999. /**
  46000. * Targets the given mesh and updates zoom level accordingly.
  46001. * @param mesh The mesh to target.
  46002. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46003. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46004. */
  46005. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46006. /**
  46007. * Targets the given mesh with its children and updates zoom level accordingly.
  46008. * @param mesh The mesh to target.
  46009. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46010. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46011. */
  46012. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46013. /**
  46014. * Targets the given meshes with their children and updates zoom level accordingly.
  46015. * @param meshes The mesh to target.
  46016. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46017. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46018. */
  46019. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46020. /**
  46021. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46022. * @param minimumWorld Determines the smaller position of the bounding box extend
  46023. * @param maximumWorld Determines the bigger position of the bounding box extend
  46024. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46025. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46026. */
  46027. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46028. /**
  46029. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46030. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46031. * frustum width.
  46032. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46033. * to fully enclose the mesh in the viewing frustum.
  46034. */
  46035. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46036. /**
  46037. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46038. * is automatically returned to its default position (expected to be above ground plane).
  46039. */
  46040. private _maintainCameraAboveGround;
  46041. /**
  46042. * Returns the frustum slope based on the canvas ratio and camera FOV
  46043. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46044. */
  46045. private _getFrustumSlope;
  46046. /**
  46047. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46048. */
  46049. private _clearAnimationLocks;
  46050. /**
  46051. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46052. */
  46053. private _applyUserInteraction;
  46054. /**
  46055. * Stops and removes all animations that have been applied to the camera
  46056. */
  46057. stopAllAnimations(): void;
  46058. /**
  46059. * Gets a value indicating if the user is moving the camera
  46060. */
  46061. get isUserIsMoving(): boolean;
  46062. /**
  46063. * The camera can move all the way towards the mesh.
  46064. */
  46065. static IgnoreBoundsSizeMode: number;
  46066. /**
  46067. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46068. */
  46069. static FitFrustumSidesMode: number;
  46070. }
  46071. }
  46072. declare module BABYLON {
  46073. /**
  46074. * Base class for Camera Pointer Inputs.
  46075. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46076. * for example usage.
  46077. */
  46078. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46079. /**
  46080. * Defines the camera the input is attached to.
  46081. */
  46082. abstract camera: Camera;
  46083. /**
  46084. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46085. */
  46086. protected _altKey: boolean;
  46087. protected _ctrlKey: boolean;
  46088. protected _metaKey: boolean;
  46089. protected _shiftKey: boolean;
  46090. /**
  46091. * Which mouse buttons were pressed at time of last mouse event.
  46092. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46093. */
  46094. protected _buttonsPressed: number;
  46095. /**
  46096. * Defines the buttons associated with the input to handle camera move.
  46097. */
  46098. buttons: number[];
  46099. /**
  46100. * Attach the input controls to a specific dom element to get the input from.
  46101. * @param element Defines the element the controls should be listened from
  46102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46103. */
  46104. attachControl(noPreventDefault?: boolean): void;
  46105. /**
  46106. * Detach the current controls from the specified dom element.
  46107. */
  46108. detachControl(): void;
  46109. /**
  46110. * Gets the class name of the current input.
  46111. * @returns the class name
  46112. */
  46113. getClassName(): string;
  46114. /**
  46115. * Get the friendly name associated with the input class.
  46116. * @returns the input friendly name
  46117. */
  46118. getSimpleName(): string;
  46119. /**
  46120. * Called on pointer POINTERDOUBLETAP event.
  46121. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46122. */
  46123. protected onDoubleTap(type: string): void;
  46124. /**
  46125. * Called on pointer POINTERMOVE event if only a single touch is active.
  46126. * Override this method to provide functionality.
  46127. */
  46128. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46129. /**
  46130. * Called on pointer POINTERMOVE event if multiple touches are active.
  46131. * Override this method to provide functionality.
  46132. */
  46133. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46134. /**
  46135. * Called on JS contextmenu event.
  46136. * Override this method to provide functionality.
  46137. */
  46138. protected onContextMenu(evt: PointerEvent): void;
  46139. /**
  46140. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46141. * press.
  46142. * Override this method to provide functionality.
  46143. */
  46144. protected onButtonDown(evt: PointerEvent): void;
  46145. /**
  46146. * Called each time a new POINTERUP event occurs. Ie, for each button
  46147. * release.
  46148. * Override this method to provide functionality.
  46149. */
  46150. protected onButtonUp(evt: PointerEvent): void;
  46151. /**
  46152. * Called when window becomes inactive.
  46153. * Override this method to provide functionality.
  46154. */
  46155. protected onLostFocus(): void;
  46156. private _pointerInput;
  46157. private _observer;
  46158. private _onLostFocus;
  46159. private pointA;
  46160. private pointB;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * Manage the pointers inputs to control an arc rotate camera.
  46166. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46167. */
  46168. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46169. /**
  46170. * Defines the camera the input is attached to.
  46171. */
  46172. camera: ArcRotateCamera;
  46173. /**
  46174. * Gets the class name of the current input.
  46175. * @returns the class name
  46176. */
  46177. getClassName(): string;
  46178. /**
  46179. * Defines the buttons associated with the input to handle camera move.
  46180. */
  46181. buttons: number[];
  46182. /**
  46183. * Defines the pointer angular sensibility along the X axis or how fast is
  46184. * the camera rotating.
  46185. */
  46186. angularSensibilityX: number;
  46187. /**
  46188. * Defines the pointer angular sensibility along the Y axis or how fast is
  46189. * the camera rotating.
  46190. */
  46191. angularSensibilityY: number;
  46192. /**
  46193. * Defines the pointer pinch precision or how fast is the camera zooming.
  46194. */
  46195. pinchPrecision: number;
  46196. /**
  46197. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46198. * from 0.
  46199. * It defines the percentage of current camera.radius to use as delta when
  46200. * pinch zoom is used.
  46201. */
  46202. pinchDeltaPercentage: number;
  46203. /**
  46204. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46205. * that any object in the plane at the camera's target point will scale
  46206. * perfectly with finger motion.
  46207. * Overrides pinchDeltaPercentage and pinchPrecision.
  46208. */
  46209. useNaturalPinchZoom: boolean;
  46210. /**
  46211. * Defines the pointer panning sensibility or how fast is the camera moving.
  46212. */
  46213. panningSensibility: number;
  46214. /**
  46215. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46216. */
  46217. multiTouchPanning: boolean;
  46218. /**
  46219. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46220. * zoom (pinch) through multitouch.
  46221. */
  46222. multiTouchPanAndZoom: boolean;
  46223. /**
  46224. * Revers pinch action direction.
  46225. */
  46226. pinchInwards: boolean;
  46227. private _isPanClick;
  46228. private _twoFingerActivityCount;
  46229. private _isPinching;
  46230. /**
  46231. * Called on pointer POINTERMOVE event if only a single touch is active.
  46232. */
  46233. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46234. /**
  46235. * Called on pointer POINTERDOUBLETAP event.
  46236. */
  46237. protected onDoubleTap(type: string): void;
  46238. /**
  46239. * Called on pointer POINTERMOVE event if multiple touches are active.
  46240. */
  46241. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46242. /**
  46243. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46244. * press.
  46245. */
  46246. protected onButtonDown(evt: PointerEvent): void;
  46247. /**
  46248. * Called each time a new POINTERUP event occurs. Ie, for each button
  46249. * release.
  46250. */
  46251. protected onButtonUp(evt: PointerEvent): void;
  46252. /**
  46253. * Called when window becomes inactive.
  46254. */
  46255. protected onLostFocus(): void;
  46256. }
  46257. }
  46258. declare module BABYLON {
  46259. /**
  46260. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46261. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46262. */
  46263. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46264. /**
  46265. * Defines the camera the input is attached to.
  46266. */
  46267. camera: ArcRotateCamera;
  46268. /**
  46269. * Defines the list of key codes associated with the up action (increase alpha)
  46270. */
  46271. keysUp: number[];
  46272. /**
  46273. * Defines the list of key codes associated with the down action (decrease alpha)
  46274. */
  46275. keysDown: number[];
  46276. /**
  46277. * Defines the list of key codes associated with the left action (increase beta)
  46278. */
  46279. keysLeft: number[];
  46280. /**
  46281. * Defines the list of key codes associated with the right action (decrease beta)
  46282. */
  46283. keysRight: number[];
  46284. /**
  46285. * Defines the list of key codes associated with the reset action.
  46286. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46287. */
  46288. keysReset: number[];
  46289. /**
  46290. * Defines the panning sensibility of the inputs.
  46291. * (How fast is the camera panning)
  46292. */
  46293. panningSensibility: number;
  46294. /**
  46295. * Defines the zooming sensibility of the inputs.
  46296. * (How fast is the camera zooming)
  46297. */
  46298. zoomingSensibility: number;
  46299. /**
  46300. * Defines whether maintaining the alt key down switch the movement mode from
  46301. * orientation to zoom.
  46302. */
  46303. useAltToZoom: boolean;
  46304. /**
  46305. * Rotation speed of the camera
  46306. */
  46307. angularSpeed: number;
  46308. private _keys;
  46309. private _ctrlPressed;
  46310. private _altPressed;
  46311. private _onCanvasBlurObserver;
  46312. private _onKeyboardObserver;
  46313. private _engine;
  46314. private _scene;
  46315. /**
  46316. * Attach the input controls to a specific dom element to get the input from.
  46317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46318. */
  46319. attachControl(noPreventDefault?: boolean): void;
  46320. /**
  46321. * Detach the current controls from the specified dom element.
  46322. */
  46323. detachControl(): void;
  46324. /**
  46325. * Update the current camera state depending on the inputs that have been used this frame.
  46326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46327. */
  46328. checkInputs(): void;
  46329. /**
  46330. * Gets the class name of the current intput.
  46331. * @returns the class name
  46332. */
  46333. getClassName(): string;
  46334. /**
  46335. * Get the friendly name associated with the input class.
  46336. * @returns the input friendly name
  46337. */
  46338. getSimpleName(): string;
  46339. }
  46340. }
  46341. declare module BABYLON {
  46342. /**
  46343. * Manage the mouse wheel inputs to control an arc rotate camera.
  46344. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46345. */
  46346. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46347. /**
  46348. * Defines the camera the input is attached to.
  46349. */
  46350. camera: ArcRotateCamera;
  46351. /**
  46352. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46353. */
  46354. wheelPrecision: number;
  46355. /**
  46356. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46357. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46358. */
  46359. wheelDeltaPercentage: number;
  46360. private _wheel;
  46361. private _observer;
  46362. private computeDeltaFromMouseWheelLegacyEvent;
  46363. /**
  46364. * Attach the input controls to a specific dom element to get the input from.
  46365. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46366. */
  46367. attachControl(noPreventDefault?: boolean): void;
  46368. /**
  46369. * Detach the current controls from the specified dom element.
  46370. */
  46371. detachControl(): void;
  46372. /**
  46373. * Gets the class name of the current intput.
  46374. * @returns the class name
  46375. */
  46376. getClassName(): string;
  46377. /**
  46378. * Get the friendly name associated with the input class.
  46379. * @returns the input friendly name
  46380. */
  46381. getSimpleName(): string;
  46382. }
  46383. }
  46384. declare module BABYLON {
  46385. /**
  46386. * Default Inputs manager for the ArcRotateCamera.
  46387. * It groups all the default supported inputs for ease of use.
  46388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46389. */
  46390. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46391. /**
  46392. * Instantiates a new ArcRotateCameraInputsManager.
  46393. * @param camera Defines the camera the inputs belong to
  46394. */
  46395. constructor(camera: ArcRotateCamera);
  46396. /**
  46397. * Add mouse wheel input support to the input manager.
  46398. * @returns the current input manager
  46399. */
  46400. addMouseWheel(): ArcRotateCameraInputsManager;
  46401. /**
  46402. * Add pointers input support to the input manager.
  46403. * @returns the current input manager
  46404. */
  46405. addPointers(): ArcRotateCameraInputsManager;
  46406. /**
  46407. * Add keyboard input support to the input manager.
  46408. * @returns the current input manager
  46409. */
  46410. addKeyboard(): ArcRotateCameraInputsManager;
  46411. }
  46412. }
  46413. declare module BABYLON {
  46414. /**
  46415. * This represents an orbital type of camera.
  46416. *
  46417. * 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.
  46418. * 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.
  46419. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46420. */
  46421. export class ArcRotateCamera extends TargetCamera {
  46422. /**
  46423. * Defines the rotation angle of the camera along the longitudinal axis.
  46424. */
  46425. alpha: number;
  46426. /**
  46427. * Defines the rotation angle of the camera along the latitudinal axis.
  46428. */
  46429. beta: number;
  46430. /**
  46431. * Defines the radius of the camera from it s target point.
  46432. */
  46433. radius: number;
  46434. protected _target: Vector3;
  46435. protected _targetHost: Nullable<AbstractMesh>;
  46436. /**
  46437. * Defines the target point of the camera.
  46438. * The camera looks towards it form the radius distance.
  46439. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46440. */
  46441. get target(): Vector3;
  46442. set target(value: Vector3);
  46443. /**
  46444. * Define the current local position of the camera in the scene
  46445. */
  46446. get position(): Vector3;
  46447. set position(newPosition: Vector3);
  46448. protected _upToYMatrix: Matrix;
  46449. protected _YToUpMatrix: Matrix;
  46450. /**
  46451. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46452. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46453. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46454. */
  46455. set upVector(vec: Vector3);
  46456. get upVector(): Vector3;
  46457. /**
  46458. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46459. */
  46460. setMatUp(): void;
  46461. /**
  46462. * Current inertia value on the longitudinal axis.
  46463. * The bigger this number the longer it will take for the camera to stop.
  46464. */
  46465. inertialAlphaOffset: number;
  46466. /**
  46467. * Current inertia value on the latitudinal axis.
  46468. * The bigger this number the longer it will take for the camera to stop.
  46469. */
  46470. inertialBetaOffset: number;
  46471. /**
  46472. * Current inertia value on the radius axis.
  46473. * The bigger this number the longer it will take for the camera to stop.
  46474. */
  46475. inertialRadiusOffset: number;
  46476. /**
  46477. * Minimum allowed angle on the longitudinal axis.
  46478. * This can help limiting how the Camera is able to move in the scene.
  46479. */
  46480. lowerAlphaLimit: Nullable<number>;
  46481. /**
  46482. * Maximum allowed angle on the longitudinal axis.
  46483. * This can help limiting how the Camera is able to move in the scene.
  46484. */
  46485. upperAlphaLimit: Nullable<number>;
  46486. /**
  46487. * Minimum allowed angle on the latitudinal axis.
  46488. * This can help limiting how the Camera is able to move in the scene.
  46489. */
  46490. lowerBetaLimit: number;
  46491. /**
  46492. * Maximum allowed angle on the latitudinal axis.
  46493. * This can help limiting how the Camera is able to move in the scene.
  46494. */
  46495. upperBetaLimit: number;
  46496. /**
  46497. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46498. * This can help limiting how the Camera is able to move in the scene.
  46499. */
  46500. lowerRadiusLimit: Nullable<number>;
  46501. /**
  46502. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46503. * This can help limiting how the Camera is able to move in the scene.
  46504. */
  46505. upperRadiusLimit: Nullable<number>;
  46506. /**
  46507. * Defines the current inertia value used during panning of the camera along the X axis.
  46508. */
  46509. inertialPanningX: number;
  46510. /**
  46511. * Defines the current inertia value used during panning of the camera along the Y axis.
  46512. */
  46513. inertialPanningY: number;
  46514. /**
  46515. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46516. * Basically if your fingers moves away from more than this distance you will be considered
  46517. * in pinch mode.
  46518. */
  46519. pinchToPanMaxDistance: number;
  46520. /**
  46521. * Defines the maximum distance the camera can pan.
  46522. * This could help keeping the cammera always in your scene.
  46523. */
  46524. panningDistanceLimit: Nullable<number>;
  46525. /**
  46526. * Defines the target of the camera before paning.
  46527. */
  46528. panningOriginTarget: Vector3;
  46529. /**
  46530. * Defines the value of the inertia used during panning.
  46531. * 0 would mean stop inertia and one would mean no decelleration at all.
  46532. */
  46533. panningInertia: number;
  46534. /**
  46535. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46536. */
  46537. get angularSensibilityX(): number;
  46538. set angularSensibilityX(value: number);
  46539. /**
  46540. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46541. */
  46542. get angularSensibilityY(): number;
  46543. set angularSensibilityY(value: number);
  46544. /**
  46545. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46546. */
  46547. get pinchPrecision(): number;
  46548. set pinchPrecision(value: number);
  46549. /**
  46550. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46551. * It will be used instead of pinchDeltaPrecision if different from 0.
  46552. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46553. */
  46554. get pinchDeltaPercentage(): number;
  46555. set pinchDeltaPercentage(value: number);
  46556. /**
  46557. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46558. * and pinch delta percentage.
  46559. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46560. * that any object in the plane at the camera's target point will scale
  46561. * perfectly with finger motion.
  46562. */
  46563. get useNaturalPinchZoom(): boolean;
  46564. set useNaturalPinchZoom(value: boolean);
  46565. /**
  46566. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46567. */
  46568. get panningSensibility(): number;
  46569. set panningSensibility(value: number);
  46570. /**
  46571. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46572. */
  46573. get keysUp(): number[];
  46574. set keysUp(value: number[]);
  46575. /**
  46576. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46577. */
  46578. get keysDown(): number[];
  46579. set keysDown(value: number[]);
  46580. /**
  46581. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46582. */
  46583. get keysLeft(): number[];
  46584. set keysLeft(value: number[]);
  46585. /**
  46586. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46587. */
  46588. get keysRight(): number[];
  46589. set keysRight(value: number[]);
  46590. /**
  46591. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46592. */
  46593. get wheelPrecision(): number;
  46594. set wheelPrecision(value: number);
  46595. /**
  46596. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46597. * It will be used instead of pinchDeltaPrecision if different from 0.
  46598. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46599. */
  46600. get wheelDeltaPercentage(): number;
  46601. set wheelDeltaPercentage(value: number);
  46602. /**
  46603. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46604. */
  46605. zoomOnFactor: number;
  46606. /**
  46607. * Defines a screen offset for the camera position.
  46608. */
  46609. targetScreenOffset: Vector2;
  46610. /**
  46611. * Allows the camera to be completely reversed.
  46612. * If false the camera can not arrive upside down.
  46613. */
  46614. allowUpsideDown: boolean;
  46615. /**
  46616. * Define if double tap/click is used to restore the previously saved state of the camera.
  46617. */
  46618. useInputToRestoreState: boolean;
  46619. /** @hidden */
  46620. _viewMatrix: Matrix;
  46621. /** @hidden */
  46622. _useCtrlForPanning: boolean;
  46623. /** @hidden */
  46624. _panningMouseButton: number;
  46625. /**
  46626. * Defines the input associated to the camera.
  46627. */
  46628. inputs: ArcRotateCameraInputsManager;
  46629. /** @hidden */
  46630. _reset: () => void;
  46631. /**
  46632. * Defines the allowed panning axis.
  46633. */
  46634. panningAxis: Vector3;
  46635. protected _localDirection: Vector3;
  46636. protected _transformedDirection: Vector3;
  46637. private _bouncingBehavior;
  46638. /**
  46639. * Gets the bouncing behavior of the camera if it has been enabled.
  46640. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46641. */
  46642. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46643. /**
  46644. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46645. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46646. */
  46647. get useBouncingBehavior(): boolean;
  46648. set useBouncingBehavior(value: boolean);
  46649. private _framingBehavior;
  46650. /**
  46651. * Gets the framing behavior of the camera if it has been enabled.
  46652. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46653. */
  46654. get framingBehavior(): Nullable<FramingBehavior>;
  46655. /**
  46656. * Defines if the framing behavior of the camera is enabled on the camera.
  46657. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46658. */
  46659. get useFramingBehavior(): boolean;
  46660. set useFramingBehavior(value: boolean);
  46661. private _autoRotationBehavior;
  46662. /**
  46663. * Gets the auto rotation behavior of the camera if it has been enabled.
  46664. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46665. */
  46666. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46667. /**
  46668. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46669. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46670. */
  46671. get useAutoRotationBehavior(): boolean;
  46672. set useAutoRotationBehavior(value: boolean);
  46673. /**
  46674. * Observable triggered when the mesh target has been changed on the camera.
  46675. */
  46676. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46677. /**
  46678. * Event raised when the camera is colliding with a mesh.
  46679. */
  46680. onCollide: (collidedMesh: AbstractMesh) => void;
  46681. /**
  46682. * Defines whether the camera should check collision with the objects oh the scene.
  46683. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46684. */
  46685. checkCollisions: boolean;
  46686. /**
  46687. * Defines the collision radius of the camera.
  46688. * This simulates a sphere around the camera.
  46689. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46690. */
  46691. collisionRadius: Vector3;
  46692. protected _collider: Collider;
  46693. protected _previousPosition: Vector3;
  46694. protected _collisionVelocity: Vector3;
  46695. protected _newPosition: Vector3;
  46696. protected _previousAlpha: number;
  46697. protected _previousBeta: number;
  46698. protected _previousRadius: number;
  46699. protected _collisionTriggered: boolean;
  46700. protected _targetBoundingCenter: Nullable<Vector3>;
  46701. private _computationVector;
  46702. /**
  46703. * Instantiates a new ArcRotateCamera in a given scene
  46704. * @param name Defines the name of the camera
  46705. * @param alpha Defines the camera rotation along the logitudinal axis
  46706. * @param beta Defines the camera rotation along the latitudinal axis
  46707. * @param radius Defines the camera distance from its target
  46708. * @param target Defines the camera target
  46709. * @param scene Defines the scene the camera belongs to
  46710. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46711. */
  46712. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46713. /** @hidden */
  46714. _initCache(): void;
  46715. /** @hidden */
  46716. _updateCache(ignoreParentClass?: boolean): void;
  46717. protected _getTargetPosition(): Vector3;
  46718. private _storedAlpha;
  46719. private _storedBeta;
  46720. private _storedRadius;
  46721. private _storedTarget;
  46722. private _storedTargetScreenOffset;
  46723. /**
  46724. * Stores the current state of the camera (alpha, beta, radius and target)
  46725. * @returns the camera itself
  46726. */
  46727. storeState(): Camera;
  46728. /**
  46729. * @hidden
  46730. * Restored camera state. You must call storeState() first
  46731. */
  46732. _restoreStateValues(): boolean;
  46733. /** @hidden */
  46734. _isSynchronizedViewMatrix(): boolean;
  46735. /**
  46736. * Attach the input controls to a specific dom element to get the input from.
  46737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46738. */
  46739. attachControl(noPreventDefault?: boolean): void;
  46740. /**
  46741. * Attach the input controls to a specific dom element to get the input from.
  46742. * @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
  46743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46744. */
  46745. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46746. /**
  46747. * Attached controls to the current camera.
  46748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46749. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46750. */
  46751. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46752. /**
  46753. * Attached controls to the current camera.
  46754. * @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
  46755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46756. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46757. */
  46758. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46759. /**
  46760. * Attached controls to the current camera.
  46761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46762. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46763. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46764. */
  46765. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46766. /**
  46767. * Detach the current controls from the specified dom element.
  46768. */
  46769. detachControl(): void;
  46770. /** @hidden */
  46771. _checkInputs(): void;
  46772. protected _checkLimits(): void;
  46773. /**
  46774. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46775. */
  46776. rebuildAnglesAndRadius(): void;
  46777. /**
  46778. * Use a position to define the current camera related information like alpha, beta and radius
  46779. * @param position Defines the position to set the camera at
  46780. */
  46781. setPosition(position: Vector3): void;
  46782. /**
  46783. * Defines the target the camera should look at.
  46784. * This will automatically adapt alpha beta and radius to fit within the new target.
  46785. * @param target Defines the new target as a Vector or a mesh
  46786. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46787. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46788. */
  46789. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46790. /** @hidden */
  46791. _getViewMatrix(): Matrix;
  46792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46793. /**
  46794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46795. * @param meshes Defines the mesh to zoom on
  46796. * @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)
  46797. */
  46798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46799. /**
  46800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46801. * The target will be changed but the radius
  46802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46803. * @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)
  46804. */
  46805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46806. min: Vector3;
  46807. max: Vector3;
  46808. distance: number;
  46809. }, doNotUpdateMaxZ?: boolean): void;
  46810. /**
  46811. * @override
  46812. * Override Camera.createRigCamera
  46813. */
  46814. createRigCamera(name: string, cameraIndex: number): Camera;
  46815. /**
  46816. * @hidden
  46817. * @override
  46818. * Override Camera._updateRigCameras
  46819. */
  46820. _updateRigCameras(): void;
  46821. /**
  46822. * Destroy the camera and release the current resources hold by it.
  46823. */
  46824. dispose(): void;
  46825. /**
  46826. * Gets the current object class name.
  46827. * @return the class name
  46828. */
  46829. getClassName(): string;
  46830. }
  46831. }
  46832. declare module BABYLON {
  46833. /**
  46834. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46835. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46836. */
  46837. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46838. /**
  46839. * Gets the name of the behavior.
  46840. */
  46841. get name(): string;
  46842. private _zoomStopsAnimation;
  46843. private _idleRotationSpeed;
  46844. private _idleRotationWaitTime;
  46845. private _idleRotationSpinupTime;
  46846. /**
  46847. * Sets the flag that indicates if user zooming should stop animation.
  46848. */
  46849. set zoomStopsAnimation(flag: boolean);
  46850. /**
  46851. * Gets the flag that indicates if user zooming should stop animation.
  46852. */
  46853. get zoomStopsAnimation(): boolean;
  46854. /**
  46855. * Sets the default speed at which the camera rotates around the model.
  46856. */
  46857. set idleRotationSpeed(speed: number);
  46858. /**
  46859. * Gets the default speed at which the camera rotates around the model.
  46860. */
  46861. get idleRotationSpeed(): number;
  46862. /**
  46863. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46864. */
  46865. set idleRotationWaitTime(time: number);
  46866. /**
  46867. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46868. */
  46869. get idleRotationWaitTime(): number;
  46870. /**
  46871. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46872. */
  46873. set idleRotationSpinupTime(time: number);
  46874. /**
  46875. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46876. */
  46877. get idleRotationSpinupTime(): number;
  46878. /**
  46879. * Gets a value indicating if the camera is currently rotating because of this behavior
  46880. */
  46881. get rotationInProgress(): boolean;
  46882. private _onPrePointerObservableObserver;
  46883. private _onAfterCheckInputsObserver;
  46884. private _attachedCamera;
  46885. private _isPointerDown;
  46886. private _lastFrameTime;
  46887. private _lastInteractionTime;
  46888. private _cameraRotationSpeed;
  46889. /**
  46890. * Initializes the behavior.
  46891. */
  46892. init(): void;
  46893. /**
  46894. * Attaches the behavior to its arc rotate camera.
  46895. * @param camera Defines the camera to attach the behavior to
  46896. */
  46897. attach(camera: ArcRotateCamera): void;
  46898. /**
  46899. * Detaches the behavior from its current arc rotate camera.
  46900. */
  46901. detach(): void;
  46902. /**
  46903. * Returns true if user is scrolling.
  46904. * @return true if user is scrolling.
  46905. */
  46906. private _userIsZooming;
  46907. private _lastFrameRadius;
  46908. private _shouldAnimationStopForInteraction;
  46909. /**
  46910. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46911. */
  46912. private _applyUserInteraction;
  46913. private _userIsMoving;
  46914. }
  46915. }
  46916. declare module BABYLON {
  46917. /**
  46918. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46919. */
  46920. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46921. private ui;
  46922. /**
  46923. * The name of the behavior
  46924. */
  46925. name: string;
  46926. /**
  46927. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46928. */
  46929. distanceAwayFromFace: number;
  46930. /**
  46931. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46932. */
  46933. distanceAwayFromBottomOfFace: number;
  46934. private _faceVectors;
  46935. private _target;
  46936. private _scene;
  46937. private _onRenderObserver;
  46938. private _tmpMatrix;
  46939. private _tmpVector;
  46940. /**
  46941. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46942. * @param ui The transform node that should be attched to the mesh
  46943. */
  46944. constructor(ui: TransformNode);
  46945. /**
  46946. * Initializes the behavior
  46947. */
  46948. init(): void;
  46949. private _closestFace;
  46950. private _zeroVector;
  46951. private _lookAtTmpMatrix;
  46952. private _lookAtToRef;
  46953. /**
  46954. * Attaches the AttachToBoxBehavior to the passed in mesh
  46955. * @param target The mesh that the specified node will be attached to
  46956. */
  46957. attach(target: Mesh): void;
  46958. /**
  46959. * Detaches the behavior from the mesh
  46960. */
  46961. detach(): void;
  46962. }
  46963. }
  46964. declare module BABYLON {
  46965. /**
  46966. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46967. */
  46968. export class FadeInOutBehavior implements Behavior<Mesh> {
  46969. /**
  46970. * Time in milliseconds to delay before fading in (Default: 0)
  46971. */
  46972. delay: number;
  46973. /**
  46974. * Time in milliseconds for the mesh to fade in (Default: 300)
  46975. */
  46976. fadeInTime: number;
  46977. private _millisecondsPerFrame;
  46978. private _hovered;
  46979. private _hoverValue;
  46980. private _ownerNode;
  46981. /**
  46982. * Instatiates the FadeInOutBehavior
  46983. */
  46984. constructor();
  46985. /**
  46986. * The name of the behavior
  46987. */
  46988. get name(): string;
  46989. /**
  46990. * Initializes the behavior
  46991. */
  46992. init(): void;
  46993. /**
  46994. * Attaches the fade behavior on the passed in mesh
  46995. * @param ownerNode The mesh that will be faded in/out once attached
  46996. */
  46997. attach(ownerNode: Mesh): void;
  46998. /**
  46999. * Detaches the behavior from the mesh
  47000. */
  47001. detach(): void;
  47002. /**
  47003. * Triggers the mesh to begin fading in or out
  47004. * @param value if the object should fade in or out (true to fade in)
  47005. */
  47006. fadeIn(value: boolean): void;
  47007. private _update;
  47008. private _setAllVisibility;
  47009. }
  47010. }
  47011. declare module BABYLON {
  47012. /**
  47013. * Class containing a set of static utilities functions for managing Pivots
  47014. * @hidden
  47015. */
  47016. export class PivotTools {
  47017. private static _PivotCached;
  47018. private static _OldPivotPoint;
  47019. private static _PivotTranslation;
  47020. private static _PivotTmpVector;
  47021. private static _PivotPostMultiplyPivotMatrix;
  47022. /** @hidden */
  47023. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47024. /** @hidden */
  47025. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47026. }
  47027. }
  47028. declare module BABYLON {
  47029. /**
  47030. * Class containing static functions to help procedurally build meshes
  47031. */
  47032. export class PlaneBuilder {
  47033. /**
  47034. * Creates a plane mesh
  47035. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47036. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47037. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47039. * * 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
  47040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47041. * @param name defines the name of the mesh
  47042. * @param options defines the options used to create the mesh
  47043. * @param scene defines the hosting scene
  47044. * @returns the plane mesh
  47045. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47046. */
  47047. static CreatePlane(name: string, options: {
  47048. size?: number;
  47049. width?: number;
  47050. height?: number;
  47051. sideOrientation?: number;
  47052. frontUVs?: Vector4;
  47053. backUVs?: Vector4;
  47054. updatable?: boolean;
  47055. sourcePlane?: Plane;
  47056. }, scene?: Nullable<Scene>): Mesh;
  47057. }
  47058. }
  47059. declare module BABYLON {
  47060. /**
  47061. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47062. */
  47063. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47064. private static _AnyMouseID;
  47065. /**
  47066. * Abstract mesh the behavior is set on
  47067. */
  47068. attachedNode: AbstractMesh;
  47069. private _dragPlane;
  47070. private _scene;
  47071. private _pointerObserver;
  47072. private _beforeRenderObserver;
  47073. private static _planeScene;
  47074. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47075. /**
  47076. * 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)
  47077. */
  47078. maxDragAngle: number;
  47079. /**
  47080. * @hidden
  47081. */
  47082. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47083. /**
  47084. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47085. */
  47086. currentDraggingPointerID: number;
  47087. /**
  47088. * The last position where the pointer hit the drag plane in world space
  47089. */
  47090. lastDragPosition: Vector3;
  47091. /**
  47092. * If the behavior is currently in a dragging state
  47093. */
  47094. dragging: boolean;
  47095. /**
  47096. * 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)
  47097. */
  47098. dragDeltaRatio: number;
  47099. /**
  47100. * If the drag plane orientation should be updated during the dragging (Default: true)
  47101. */
  47102. updateDragPlane: boolean;
  47103. private _debugMode;
  47104. private _moving;
  47105. /**
  47106. * Fires each time the attached mesh is dragged with the pointer
  47107. * * delta between last drag position and current drag position in world space
  47108. * * dragDistance along the drag axis
  47109. * * dragPlaneNormal normal of the current drag plane used during the drag
  47110. * * dragPlanePoint in world space where the drag intersects the drag plane
  47111. */
  47112. onDragObservable: Observable<{
  47113. delta: Vector3;
  47114. dragPlanePoint: Vector3;
  47115. dragPlaneNormal: Vector3;
  47116. dragDistance: number;
  47117. pointerId: number;
  47118. }>;
  47119. /**
  47120. * Fires each time a drag begins (eg. mouse down on mesh)
  47121. */
  47122. onDragStartObservable: Observable<{
  47123. dragPlanePoint: Vector3;
  47124. pointerId: number;
  47125. }>;
  47126. /**
  47127. * Fires each time a drag ends (eg. mouse release after drag)
  47128. */
  47129. onDragEndObservable: Observable<{
  47130. dragPlanePoint: Vector3;
  47131. pointerId: number;
  47132. }>;
  47133. /**
  47134. * If the attached mesh should be moved when dragged
  47135. */
  47136. moveAttached: boolean;
  47137. /**
  47138. * If the drag behavior will react to drag events (Default: true)
  47139. */
  47140. enabled: boolean;
  47141. /**
  47142. * If pointer events should start and release the drag (Default: true)
  47143. */
  47144. startAndReleaseDragOnPointerEvents: boolean;
  47145. /**
  47146. * If camera controls should be detached during the drag
  47147. */
  47148. detachCameraControls: boolean;
  47149. /**
  47150. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47151. */
  47152. useObjectOrientationForDragging: boolean;
  47153. private _options;
  47154. /**
  47155. * Gets the options used by the behavior
  47156. */
  47157. get options(): {
  47158. dragAxis?: Vector3;
  47159. dragPlaneNormal?: Vector3;
  47160. };
  47161. /**
  47162. * Sets the options used by the behavior
  47163. */
  47164. set options(options: {
  47165. dragAxis?: Vector3;
  47166. dragPlaneNormal?: Vector3;
  47167. });
  47168. /**
  47169. * Creates a pointer drag behavior that can be attached to a mesh
  47170. * @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)
  47171. */
  47172. constructor(options?: {
  47173. dragAxis?: Vector3;
  47174. dragPlaneNormal?: Vector3;
  47175. });
  47176. /**
  47177. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47178. */
  47179. validateDrag: (targetPosition: Vector3) => boolean;
  47180. /**
  47181. * The name of the behavior
  47182. */
  47183. get name(): string;
  47184. /**
  47185. * Initializes the behavior
  47186. */
  47187. init(): void;
  47188. private _tmpVector;
  47189. private _alternatePickedPoint;
  47190. private _worldDragAxis;
  47191. private _targetPosition;
  47192. private _attachedToElement;
  47193. /**
  47194. * Attaches the drag behavior the passed in mesh
  47195. * @param ownerNode The mesh that will be dragged around once attached
  47196. * @param predicate Predicate to use for pick filtering
  47197. */
  47198. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47199. /**
  47200. * Force relase the drag action by code.
  47201. */
  47202. releaseDrag(): void;
  47203. private _startDragRay;
  47204. private _lastPointerRay;
  47205. /**
  47206. * Simulates the start of a pointer drag event on the behavior
  47207. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47208. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47209. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47210. */
  47211. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47212. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47213. private _dragDelta;
  47214. protected _moveDrag(ray: Ray): void;
  47215. private _pickWithRayOnDragPlane;
  47216. private _pointA;
  47217. private _pointC;
  47218. private _localAxis;
  47219. private _lookAt;
  47220. private _updateDragPlanePosition;
  47221. /**
  47222. * Detaches the behavior from the mesh
  47223. */
  47224. detach(): void;
  47225. }
  47226. }
  47227. declare module BABYLON {
  47228. /**
  47229. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47230. */
  47231. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47232. private _dragBehaviorA;
  47233. private _dragBehaviorB;
  47234. private _startDistance;
  47235. private _initialScale;
  47236. private _targetScale;
  47237. private _ownerNode;
  47238. private _sceneRenderObserver;
  47239. /**
  47240. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47241. */
  47242. constructor();
  47243. /**
  47244. * The name of the behavior
  47245. */
  47246. get name(): string;
  47247. /**
  47248. * Initializes the behavior
  47249. */
  47250. init(): void;
  47251. private _getCurrentDistance;
  47252. /**
  47253. * Attaches the scale behavior the passed in mesh
  47254. * @param ownerNode The mesh that will be scaled around once attached
  47255. */
  47256. attach(ownerNode: Mesh): void;
  47257. /**
  47258. * Detaches the behavior from the mesh
  47259. */
  47260. detach(): void;
  47261. }
  47262. }
  47263. declare module BABYLON {
  47264. /**
  47265. * 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
  47266. */
  47267. export class SixDofDragBehavior implements Behavior<Mesh> {
  47268. private static _virtualScene;
  47269. private _ownerNode;
  47270. private _sceneRenderObserver;
  47271. private _scene;
  47272. private _targetPosition;
  47273. private _virtualOriginMesh;
  47274. private _virtualDragMesh;
  47275. private _pointerObserver;
  47276. private _moving;
  47277. private _startingOrientation;
  47278. private _attachedToElement;
  47279. /**
  47280. * 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)
  47281. */
  47282. private zDragFactor;
  47283. /**
  47284. * If the object should rotate to face the drag origin
  47285. */
  47286. rotateDraggedObject: boolean;
  47287. /**
  47288. * If the behavior is currently in a dragging state
  47289. */
  47290. dragging: boolean;
  47291. /**
  47292. * 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)
  47293. */
  47294. dragDeltaRatio: number;
  47295. /**
  47296. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47297. */
  47298. currentDraggingPointerID: number;
  47299. /**
  47300. * If camera controls should be detached during the drag
  47301. */
  47302. detachCameraControls: boolean;
  47303. /**
  47304. * Fires each time a drag starts
  47305. */
  47306. onDragStartObservable: Observable<{}>;
  47307. /**
  47308. * Fires each time a drag ends (eg. mouse release after drag)
  47309. */
  47310. onDragEndObservable: Observable<{}>;
  47311. /**
  47312. * 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
  47313. */
  47314. constructor();
  47315. /**
  47316. * The name of the behavior
  47317. */
  47318. get name(): string;
  47319. /**
  47320. * Initializes the behavior
  47321. */
  47322. init(): void;
  47323. /**
  47324. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47325. */
  47326. private get _pointerCamera();
  47327. /**
  47328. * Attaches the scale behavior the passed in mesh
  47329. * @param ownerNode The mesh that will be scaled around once attached
  47330. */
  47331. attach(ownerNode: Mesh): void;
  47332. /**
  47333. * Detaches the behavior from the mesh
  47334. */
  47335. detach(): void;
  47336. }
  47337. }
  47338. declare module BABYLON {
  47339. /**
  47340. * Class used to apply inverse kinematics to bones
  47341. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47342. */
  47343. export class BoneIKController {
  47344. private static _tmpVecs;
  47345. private static _tmpQuat;
  47346. private static _tmpMats;
  47347. /**
  47348. * Gets or sets the target mesh
  47349. */
  47350. targetMesh: AbstractMesh;
  47351. /** Gets or sets the mesh used as pole */
  47352. poleTargetMesh: AbstractMesh;
  47353. /**
  47354. * Gets or sets the bone used as pole
  47355. */
  47356. poleTargetBone: Nullable<Bone>;
  47357. /**
  47358. * Gets or sets the target position
  47359. */
  47360. targetPosition: Vector3;
  47361. /**
  47362. * Gets or sets the pole target position
  47363. */
  47364. poleTargetPosition: Vector3;
  47365. /**
  47366. * Gets or sets the pole target local offset
  47367. */
  47368. poleTargetLocalOffset: Vector3;
  47369. /**
  47370. * Gets or sets the pole angle
  47371. */
  47372. poleAngle: number;
  47373. /**
  47374. * Gets or sets the mesh associated with the controller
  47375. */
  47376. mesh: AbstractMesh;
  47377. /**
  47378. * 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)
  47379. */
  47380. slerpAmount: number;
  47381. private _bone1Quat;
  47382. private _bone1Mat;
  47383. private _bone2Ang;
  47384. private _bone1;
  47385. private _bone2;
  47386. private _bone1Length;
  47387. private _bone2Length;
  47388. private _maxAngle;
  47389. private _maxReach;
  47390. private _rightHandedSystem;
  47391. private _bendAxis;
  47392. private _slerping;
  47393. private _adjustRoll;
  47394. /**
  47395. * Gets or sets maximum allowed angle
  47396. */
  47397. get maxAngle(): number;
  47398. set maxAngle(value: number);
  47399. /**
  47400. * Creates a new BoneIKController
  47401. * @param mesh defines the mesh to control
  47402. * @param bone defines the bone to control
  47403. * @param options defines options to set up the controller
  47404. */
  47405. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47406. targetMesh?: AbstractMesh;
  47407. poleTargetMesh?: AbstractMesh;
  47408. poleTargetBone?: Bone;
  47409. poleTargetLocalOffset?: Vector3;
  47410. poleAngle?: number;
  47411. bendAxis?: Vector3;
  47412. maxAngle?: number;
  47413. slerpAmount?: number;
  47414. });
  47415. private _setMaxAngle;
  47416. /**
  47417. * Force the controller to update the bones
  47418. */
  47419. update(): void;
  47420. }
  47421. }
  47422. declare module BABYLON {
  47423. /**
  47424. * Class used to make a bone look toward a point in space
  47425. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47426. */
  47427. export class BoneLookController {
  47428. private static _tmpVecs;
  47429. private static _tmpQuat;
  47430. private static _tmpMats;
  47431. /**
  47432. * The target Vector3 that the bone will look at
  47433. */
  47434. target: Vector3;
  47435. /**
  47436. * The mesh that the bone is attached to
  47437. */
  47438. mesh: AbstractMesh;
  47439. /**
  47440. * The bone that will be looking to the target
  47441. */
  47442. bone: Bone;
  47443. /**
  47444. * The up axis of the coordinate system that is used when the bone is rotated
  47445. */
  47446. upAxis: Vector3;
  47447. /**
  47448. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47449. */
  47450. upAxisSpace: Space;
  47451. /**
  47452. * Used to make an adjustment to the yaw of the bone
  47453. */
  47454. adjustYaw: number;
  47455. /**
  47456. * Used to make an adjustment to the pitch of the bone
  47457. */
  47458. adjustPitch: number;
  47459. /**
  47460. * Used to make an adjustment to the roll of the bone
  47461. */
  47462. adjustRoll: number;
  47463. /**
  47464. * 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)
  47465. */
  47466. slerpAmount: number;
  47467. private _minYaw;
  47468. private _maxYaw;
  47469. private _minPitch;
  47470. private _maxPitch;
  47471. private _minYawSin;
  47472. private _minYawCos;
  47473. private _maxYawSin;
  47474. private _maxYawCos;
  47475. private _midYawConstraint;
  47476. private _minPitchTan;
  47477. private _maxPitchTan;
  47478. private _boneQuat;
  47479. private _slerping;
  47480. private _transformYawPitch;
  47481. private _transformYawPitchInv;
  47482. private _firstFrameSkipped;
  47483. private _yawRange;
  47484. private _fowardAxis;
  47485. /**
  47486. * Gets or sets the minimum yaw angle that the bone can look to
  47487. */
  47488. get minYaw(): number;
  47489. set minYaw(value: number);
  47490. /**
  47491. * Gets or sets the maximum yaw angle that the bone can look to
  47492. */
  47493. get maxYaw(): number;
  47494. set maxYaw(value: number);
  47495. /**
  47496. * Gets or sets the minimum pitch angle that the bone can look to
  47497. */
  47498. get minPitch(): number;
  47499. set minPitch(value: number);
  47500. /**
  47501. * Gets or sets the maximum pitch angle that the bone can look to
  47502. */
  47503. get maxPitch(): number;
  47504. set maxPitch(value: number);
  47505. /**
  47506. * Create a BoneLookController
  47507. * @param mesh the mesh that the bone belongs to
  47508. * @param bone the bone that will be looking to the target
  47509. * @param target the target Vector3 to look at
  47510. * @param options optional settings:
  47511. * * maxYaw: the maximum angle the bone will yaw to
  47512. * * minYaw: the minimum angle the bone will yaw to
  47513. * * maxPitch: the maximum angle the bone will pitch to
  47514. * * minPitch: the minimum angle the bone will yaw to
  47515. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47516. * * upAxis: the up axis of the coordinate system
  47517. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47518. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47519. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47520. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47521. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47522. * * adjustRoll: used to make an adjustment to the roll of the bone
  47523. **/
  47524. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47525. maxYaw?: number;
  47526. minYaw?: number;
  47527. maxPitch?: number;
  47528. minPitch?: number;
  47529. slerpAmount?: number;
  47530. upAxis?: Vector3;
  47531. upAxisSpace?: Space;
  47532. yawAxis?: Vector3;
  47533. pitchAxis?: Vector3;
  47534. adjustYaw?: number;
  47535. adjustPitch?: number;
  47536. adjustRoll?: number;
  47537. });
  47538. /**
  47539. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47540. */
  47541. update(): void;
  47542. private _getAngleDiff;
  47543. private _getAngleBetween;
  47544. private _isAngleBetween;
  47545. }
  47546. }
  47547. declare module BABYLON {
  47548. /**
  47549. * Manage the gamepad inputs to control an arc rotate camera.
  47550. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47551. */
  47552. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47553. /**
  47554. * Defines the camera the input is attached to.
  47555. */
  47556. camera: ArcRotateCamera;
  47557. /**
  47558. * Defines the gamepad the input is gathering event from.
  47559. */
  47560. gamepad: Nullable<Gamepad>;
  47561. /**
  47562. * Defines the gamepad rotation sensiblity.
  47563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47564. */
  47565. gamepadRotationSensibility: number;
  47566. /**
  47567. * Defines the gamepad move sensiblity.
  47568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47569. */
  47570. gamepadMoveSensibility: number;
  47571. private _yAxisScale;
  47572. /**
  47573. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47574. */
  47575. get invertYAxis(): boolean;
  47576. set invertYAxis(value: boolean);
  47577. private _onGamepadConnectedObserver;
  47578. private _onGamepadDisconnectedObserver;
  47579. /**
  47580. * Attach the input controls to a specific dom element to get the input from.
  47581. */
  47582. attachControl(): void;
  47583. /**
  47584. * Detach the current controls from the specified dom element.
  47585. */
  47586. detachControl(): void;
  47587. /**
  47588. * Update the current camera state depending on the inputs that have been used this frame.
  47589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47590. */
  47591. checkInputs(): void;
  47592. /**
  47593. * Gets the class name of the current intput.
  47594. * @returns the class name
  47595. */
  47596. getClassName(): string;
  47597. /**
  47598. * Get the friendly name associated with the input class.
  47599. * @returns the input friendly name
  47600. */
  47601. getSimpleName(): string;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. interface ArcRotateCameraInputsManager {
  47606. /**
  47607. * Add orientation input support to the input manager.
  47608. * @returns the current input manager
  47609. */
  47610. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47611. }
  47612. /**
  47613. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47615. */
  47616. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47617. /**
  47618. * Defines the camera the input is attached to.
  47619. */
  47620. camera: ArcRotateCamera;
  47621. /**
  47622. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47623. */
  47624. alphaCorrection: number;
  47625. /**
  47626. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47627. */
  47628. gammaCorrection: number;
  47629. private _alpha;
  47630. private _gamma;
  47631. private _dirty;
  47632. private _deviceOrientationHandler;
  47633. /**
  47634. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47635. */
  47636. constructor();
  47637. /**
  47638. * Attach the input controls to a specific dom element to get the input from.
  47639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47640. */
  47641. attachControl(noPreventDefault?: boolean): void;
  47642. /** @hidden */
  47643. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47644. /**
  47645. * Update the current camera state depending on the inputs that have been used this frame.
  47646. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47647. */
  47648. checkInputs(): void;
  47649. /**
  47650. * Detach the current controls from the specified dom element.
  47651. */
  47652. detachControl(): void;
  47653. /**
  47654. * Gets the class name of the current intput.
  47655. * @returns the class name
  47656. */
  47657. getClassName(): string;
  47658. /**
  47659. * Get the friendly name associated with the input class.
  47660. * @returns the input friendly name
  47661. */
  47662. getSimpleName(): string;
  47663. }
  47664. }
  47665. declare module BABYLON {
  47666. /**
  47667. * Listen to mouse events to control the camera.
  47668. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47669. */
  47670. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47671. /**
  47672. * Defines the camera the input is attached to.
  47673. */
  47674. camera: FlyCamera;
  47675. /**
  47676. * Defines if touch is enabled. (Default is true.)
  47677. */
  47678. touchEnabled: boolean;
  47679. /**
  47680. * Defines the buttons associated with the input to handle camera rotation.
  47681. */
  47682. buttons: number[];
  47683. /**
  47684. * Assign buttons for Yaw control.
  47685. */
  47686. buttonsYaw: number[];
  47687. /**
  47688. * Assign buttons for Pitch control.
  47689. */
  47690. buttonsPitch: number[];
  47691. /**
  47692. * Assign buttons for Roll control.
  47693. */
  47694. buttonsRoll: number[];
  47695. /**
  47696. * Detect if any button is being pressed while mouse is moved.
  47697. * -1 = Mouse locked.
  47698. * 0 = Left button.
  47699. * 1 = Middle Button.
  47700. * 2 = Right Button.
  47701. */
  47702. activeButton: number;
  47703. /**
  47704. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47705. * Higher values reduce its sensitivity.
  47706. */
  47707. angularSensibility: number;
  47708. private _observer;
  47709. private _rollObserver;
  47710. private previousPosition;
  47711. private noPreventDefault;
  47712. private element;
  47713. /**
  47714. * Listen to mouse events to control the camera.
  47715. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47716. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47717. */
  47718. constructor(touchEnabled?: boolean);
  47719. /**
  47720. * Attach the mouse control to the HTML DOM element.
  47721. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47722. */
  47723. attachControl(noPreventDefault?: boolean): void;
  47724. /**
  47725. * Detach the current controls from the specified dom element.
  47726. */
  47727. detachControl(): void;
  47728. /**
  47729. * Gets the class name of the current input.
  47730. * @returns the class name.
  47731. */
  47732. getClassName(): string;
  47733. /**
  47734. * Get the friendly name associated with the input class.
  47735. * @returns the input's friendly name.
  47736. */
  47737. getSimpleName(): string;
  47738. private _pointerInput;
  47739. private _onMouseMove;
  47740. /**
  47741. * Rotate camera by mouse offset.
  47742. */
  47743. private rotateCamera;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * Default Inputs manager for the FlyCamera.
  47749. * It groups all the default supported inputs for ease of use.
  47750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47751. */
  47752. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47753. /**
  47754. * Instantiates a new FlyCameraInputsManager.
  47755. * @param camera Defines the camera the inputs belong to.
  47756. */
  47757. constructor(camera: FlyCamera);
  47758. /**
  47759. * Add keyboard input support to the input manager.
  47760. * @returns the new FlyCameraKeyboardMoveInput().
  47761. */
  47762. addKeyboard(): FlyCameraInputsManager;
  47763. /**
  47764. * Add mouse input support to the input manager.
  47765. * @param touchEnabled Enable touch screen support.
  47766. * @returns the new FlyCameraMouseInput().
  47767. */
  47768. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47769. }
  47770. }
  47771. declare module BABYLON {
  47772. /**
  47773. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47774. * such as in a 3D Space Shooter or a Flight Simulator.
  47775. */
  47776. export class FlyCamera extends TargetCamera {
  47777. /**
  47778. * Define the collision ellipsoid of the camera.
  47779. * This is helpful for simulating a camera body, like a player's body.
  47780. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47781. */
  47782. ellipsoid: Vector3;
  47783. /**
  47784. * Define an offset for the position of the ellipsoid around the camera.
  47785. * This can be helpful if the camera is attached away from the player's body center,
  47786. * such as at its head.
  47787. */
  47788. ellipsoidOffset: Vector3;
  47789. /**
  47790. * Enable or disable collisions of the camera with the rest of the scene objects.
  47791. */
  47792. checkCollisions: boolean;
  47793. /**
  47794. * Enable or disable gravity on the camera.
  47795. */
  47796. applyGravity: boolean;
  47797. /**
  47798. * Define the current direction the camera is moving to.
  47799. */
  47800. cameraDirection: Vector3;
  47801. /**
  47802. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47803. * This overrides and empties cameraRotation.
  47804. */
  47805. rotationQuaternion: Quaternion;
  47806. /**
  47807. * Track Roll to maintain the wanted Rolling when looking around.
  47808. */
  47809. _trackRoll: number;
  47810. /**
  47811. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47812. */
  47813. rollCorrect: number;
  47814. /**
  47815. * Mimic a banked turn, Rolling the camera when Yawing.
  47816. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47817. */
  47818. bankedTurn: boolean;
  47819. /**
  47820. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47821. */
  47822. bankedTurnLimit: number;
  47823. /**
  47824. * Value of 0 disables the banked Roll.
  47825. * Value of 1 is equal to the Yaw angle in radians.
  47826. */
  47827. bankedTurnMultiplier: number;
  47828. /**
  47829. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47830. */
  47831. inputs: FlyCameraInputsManager;
  47832. /**
  47833. * Gets the input sensibility for mouse input.
  47834. * Higher values reduce sensitivity.
  47835. */
  47836. get angularSensibility(): number;
  47837. /**
  47838. * Sets the input sensibility for a mouse input.
  47839. * Higher values reduce sensitivity.
  47840. */
  47841. set angularSensibility(value: number);
  47842. /**
  47843. * Get the keys for camera movement forward.
  47844. */
  47845. get keysForward(): number[];
  47846. /**
  47847. * Set the keys for camera movement forward.
  47848. */
  47849. set keysForward(value: number[]);
  47850. /**
  47851. * Get the keys for camera movement backward.
  47852. */
  47853. get keysBackward(): number[];
  47854. set keysBackward(value: number[]);
  47855. /**
  47856. * Get the keys for camera movement up.
  47857. */
  47858. get keysUp(): number[];
  47859. /**
  47860. * Set the keys for camera movement up.
  47861. */
  47862. set keysUp(value: number[]);
  47863. /**
  47864. * Get the keys for camera movement down.
  47865. */
  47866. get keysDown(): number[];
  47867. /**
  47868. * Set the keys for camera movement down.
  47869. */
  47870. set keysDown(value: number[]);
  47871. /**
  47872. * Get the keys for camera movement left.
  47873. */
  47874. get keysLeft(): number[];
  47875. /**
  47876. * Set the keys for camera movement left.
  47877. */
  47878. set keysLeft(value: number[]);
  47879. /**
  47880. * Set the keys for camera movement right.
  47881. */
  47882. get keysRight(): number[];
  47883. /**
  47884. * Set the keys for camera movement right.
  47885. */
  47886. set keysRight(value: number[]);
  47887. /**
  47888. * Event raised when the camera collides with a mesh in the scene.
  47889. */
  47890. onCollide: (collidedMesh: AbstractMesh) => void;
  47891. private _collider;
  47892. private _needMoveForGravity;
  47893. private _oldPosition;
  47894. private _diffPosition;
  47895. private _newPosition;
  47896. /** @hidden */
  47897. _localDirection: Vector3;
  47898. /** @hidden */
  47899. _transformedDirection: Vector3;
  47900. /**
  47901. * Instantiates a FlyCamera.
  47902. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47903. * such as in a 3D Space Shooter or a Flight Simulator.
  47904. * @param name Define the name of the camera in the scene.
  47905. * @param position Define the starting position of the camera in the scene.
  47906. * @param scene Define the scene the camera belongs to.
  47907. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47908. */
  47909. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47910. /**
  47911. * Attach the input controls to a specific dom element to get the input from.
  47912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47913. */
  47914. attachControl(noPreventDefault?: boolean): void;
  47915. /**
  47916. * Detach a control from the HTML DOM element.
  47917. * The camera will stop reacting to that input.
  47918. */
  47919. detachControl(): void;
  47920. private _collisionMask;
  47921. /**
  47922. * Get the mask that the camera ignores in collision events.
  47923. */
  47924. get collisionMask(): number;
  47925. /**
  47926. * Set the mask that the camera ignores in collision events.
  47927. */
  47928. set collisionMask(mask: number);
  47929. /** @hidden */
  47930. _collideWithWorld(displacement: Vector3): void;
  47931. /** @hidden */
  47932. private _onCollisionPositionChange;
  47933. /** @hidden */
  47934. _checkInputs(): void;
  47935. /** @hidden */
  47936. _decideIfNeedsToMove(): boolean;
  47937. /** @hidden */
  47938. _updatePosition(): void;
  47939. /**
  47940. * Restore the Roll to its target value at the rate specified.
  47941. * @param rate - Higher means slower restoring.
  47942. * @hidden
  47943. */
  47944. restoreRoll(rate: number): void;
  47945. /**
  47946. * Destroy the camera and release the current resources held by it.
  47947. */
  47948. dispose(): void;
  47949. /**
  47950. * Get the current object class name.
  47951. * @returns the class name.
  47952. */
  47953. getClassName(): string;
  47954. }
  47955. }
  47956. declare module BABYLON {
  47957. /**
  47958. * Listen to keyboard events to control the camera.
  47959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47960. */
  47961. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47962. /**
  47963. * Defines the camera the input is attached to.
  47964. */
  47965. camera: FlyCamera;
  47966. /**
  47967. * The list of keyboard keys used to control the forward move of the camera.
  47968. */
  47969. keysForward: number[];
  47970. /**
  47971. * The list of keyboard keys used to control the backward move of the camera.
  47972. */
  47973. keysBackward: number[];
  47974. /**
  47975. * The list of keyboard keys used to control the forward move of the camera.
  47976. */
  47977. keysUp: number[];
  47978. /**
  47979. * The list of keyboard keys used to control the backward move of the camera.
  47980. */
  47981. keysDown: number[];
  47982. /**
  47983. * The list of keyboard keys used to control the right strafe move of the camera.
  47984. */
  47985. keysRight: number[];
  47986. /**
  47987. * The list of keyboard keys used to control the left strafe move of the camera.
  47988. */
  47989. keysLeft: number[];
  47990. private _keys;
  47991. private _onCanvasBlurObserver;
  47992. private _onKeyboardObserver;
  47993. private _engine;
  47994. private _scene;
  47995. /**
  47996. * Attach the input controls to a specific dom element to get the input from.
  47997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47998. */
  47999. attachControl(noPreventDefault?: boolean): void;
  48000. /**
  48001. * Detach the current controls from the specified dom element.
  48002. */
  48003. detachControl(): void;
  48004. /**
  48005. * Gets the class name of the current intput.
  48006. * @returns the class name
  48007. */
  48008. getClassName(): string;
  48009. /** @hidden */
  48010. _onLostFocus(e: FocusEvent): void;
  48011. /**
  48012. * Get the friendly name associated with the input class.
  48013. * @returns the input friendly name
  48014. */
  48015. getSimpleName(): string;
  48016. /**
  48017. * Update the current camera state depending on the inputs that have been used this frame.
  48018. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48019. */
  48020. checkInputs(): void;
  48021. }
  48022. }
  48023. declare module BABYLON {
  48024. /**
  48025. * Manage the mouse wheel inputs to control a follow camera.
  48026. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48027. */
  48028. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48029. /**
  48030. * Defines the camera the input is attached to.
  48031. */
  48032. camera: FollowCamera;
  48033. /**
  48034. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48035. */
  48036. axisControlRadius: boolean;
  48037. /**
  48038. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48039. */
  48040. axisControlHeight: boolean;
  48041. /**
  48042. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48043. */
  48044. axisControlRotation: boolean;
  48045. /**
  48046. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48047. * relation to mouseWheel events.
  48048. */
  48049. wheelPrecision: number;
  48050. /**
  48051. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48052. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48053. */
  48054. wheelDeltaPercentage: number;
  48055. private _wheel;
  48056. private _observer;
  48057. /**
  48058. * Attach the input controls to a specific dom element to get the input from.
  48059. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48060. */
  48061. attachControl(noPreventDefault?: boolean): void;
  48062. /**
  48063. * Detach the current controls from the specified dom element.
  48064. */
  48065. detachControl(): void;
  48066. /**
  48067. * Gets the class name of the current intput.
  48068. * @returns the class name
  48069. */
  48070. getClassName(): string;
  48071. /**
  48072. * Get the friendly name associated with the input class.
  48073. * @returns the input friendly name
  48074. */
  48075. getSimpleName(): string;
  48076. }
  48077. }
  48078. declare module BABYLON {
  48079. /**
  48080. * Manage the pointers inputs to control an follow camera.
  48081. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48082. */
  48083. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48084. /**
  48085. * Defines the camera the input is attached to.
  48086. */
  48087. camera: FollowCamera;
  48088. /**
  48089. * Gets the class name of the current input.
  48090. * @returns the class name
  48091. */
  48092. getClassName(): string;
  48093. /**
  48094. * Defines the pointer angular sensibility along the X axis or how fast is
  48095. * the camera rotating.
  48096. * A negative number will reverse the axis direction.
  48097. */
  48098. angularSensibilityX: number;
  48099. /**
  48100. * Defines the pointer angular sensibility along the Y axis or how fast is
  48101. * the camera rotating.
  48102. * A negative number will reverse the axis direction.
  48103. */
  48104. angularSensibilityY: number;
  48105. /**
  48106. * Defines the pointer pinch precision or how fast is the camera zooming.
  48107. * A negative number will reverse the axis direction.
  48108. */
  48109. pinchPrecision: number;
  48110. /**
  48111. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48112. * from 0.
  48113. * It defines the percentage of current camera.radius to use as delta when
  48114. * pinch zoom is used.
  48115. */
  48116. pinchDeltaPercentage: number;
  48117. /**
  48118. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48119. */
  48120. axisXControlRadius: boolean;
  48121. /**
  48122. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48123. */
  48124. axisXControlHeight: boolean;
  48125. /**
  48126. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48127. */
  48128. axisXControlRotation: boolean;
  48129. /**
  48130. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48131. */
  48132. axisYControlRadius: boolean;
  48133. /**
  48134. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48135. */
  48136. axisYControlHeight: boolean;
  48137. /**
  48138. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48139. */
  48140. axisYControlRotation: boolean;
  48141. /**
  48142. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48143. */
  48144. axisPinchControlRadius: boolean;
  48145. /**
  48146. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48147. */
  48148. axisPinchControlHeight: boolean;
  48149. /**
  48150. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48151. */
  48152. axisPinchControlRotation: boolean;
  48153. /**
  48154. * Log error messages if basic misconfiguration has occurred.
  48155. */
  48156. warningEnable: boolean;
  48157. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48159. private _warningCounter;
  48160. private _warning;
  48161. }
  48162. }
  48163. declare module BABYLON {
  48164. /**
  48165. * Default Inputs manager for the FollowCamera.
  48166. * It groups all the default supported inputs for ease of use.
  48167. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48168. */
  48169. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48170. /**
  48171. * Instantiates a new FollowCameraInputsManager.
  48172. * @param camera Defines the camera the inputs belong to
  48173. */
  48174. constructor(camera: FollowCamera);
  48175. /**
  48176. * Add keyboard input support to the input manager.
  48177. * @returns the current input manager
  48178. */
  48179. addKeyboard(): FollowCameraInputsManager;
  48180. /**
  48181. * Add mouse wheel input support to the input manager.
  48182. * @returns the current input manager
  48183. */
  48184. addMouseWheel(): FollowCameraInputsManager;
  48185. /**
  48186. * Add pointers input support to the input manager.
  48187. * @returns the current input manager
  48188. */
  48189. addPointers(): FollowCameraInputsManager;
  48190. /**
  48191. * Add orientation input support to the input manager.
  48192. * @returns the current input manager
  48193. */
  48194. addVRDeviceOrientation(): FollowCameraInputsManager;
  48195. }
  48196. }
  48197. declare module BABYLON {
  48198. /**
  48199. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48200. * an arc rotate version arcFollowCamera are available.
  48201. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48202. */
  48203. export class FollowCamera extends TargetCamera {
  48204. /**
  48205. * Distance the follow camera should follow an object at
  48206. */
  48207. radius: number;
  48208. /**
  48209. * Minimum allowed distance of the camera to the axis of rotation
  48210. * (The camera can not get closer).
  48211. * This can help limiting how the Camera is able to move in the scene.
  48212. */
  48213. lowerRadiusLimit: Nullable<number>;
  48214. /**
  48215. * Maximum allowed distance of the camera to the axis of rotation
  48216. * (The camera can not get further).
  48217. * This can help limiting how the Camera is able to move in the scene.
  48218. */
  48219. upperRadiusLimit: Nullable<number>;
  48220. /**
  48221. * Define a rotation offset between the camera and the object it follows
  48222. */
  48223. rotationOffset: number;
  48224. /**
  48225. * Minimum allowed angle to camera position relative to target object.
  48226. * This can help limiting how the Camera is able to move in the scene.
  48227. */
  48228. lowerRotationOffsetLimit: Nullable<number>;
  48229. /**
  48230. * Maximum allowed angle to camera position relative to target object.
  48231. * This can help limiting how the Camera is able to move in the scene.
  48232. */
  48233. upperRotationOffsetLimit: Nullable<number>;
  48234. /**
  48235. * Define a height offset between the camera and the object it follows.
  48236. * It can help following an object from the top (like a car chaing a plane)
  48237. */
  48238. heightOffset: number;
  48239. /**
  48240. * Minimum allowed height of camera position relative to target object.
  48241. * This can help limiting how the Camera is able to move in the scene.
  48242. */
  48243. lowerHeightOffsetLimit: Nullable<number>;
  48244. /**
  48245. * Maximum allowed height of camera position relative to target object.
  48246. * This can help limiting how the Camera is able to move in the scene.
  48247. */
  48248. upperHeightOffsetLimit: Nullable<number>;
  48249. /**
  48250. * Define how fast the camera can accelerate to follow it s target.
  48251. */
  48252. cameraAcceleration: number;
  48253. /**
  48254. * Define the speed limit of the camera following an object.
  48255. */
  48256. maxCameraSpeed: number;
  48257. /**
  48258. * Define the target of the camera.
  48259. */
  48260. lockedTarget: Nullable<AbstractMesh>;
  48261. /**
  48262. * Defines the input associated with the camera.
  48263. */
  48264. inputs: FollowCameraInputsManager;
  48265. /**
  48266. * Instantiates the follow camera.
  48267. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48268. * @param name Define the name of the camera in the scene
  48269. * @param position Define the position of the camera
  48270. * @param scene Define the scene the camera belong to
  48271. * @param lockedTarget Define the target of the camera
  48272. */
  48273. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48274. private _follow;
  48275. /**
  48276. * Attach the input controls to a specific dom element to get the input from.
  48277. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48278. */
  48279. attachControl(noPreventDefault?: boolean): void;
  48280. /**
  48281. * Detach the current controls from the specified dom element.
  48282. */
  48283. detachControl(): void;
  48284. /** @hidden */
  48285. _checkInputs(): void;
  48286. private _checkLimits;
  48287. /**
  48288. * Gets the camera class name.
  48289. * @returns the class name
  48290. */
  48291. getClassName(): string;
  48292. }
  48293. /**
  48294. * Arc Rotate version of the follow camera.
  48295. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48296. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48297. */
  48298. export class ArcFollowCamera extends TargetCamera {
  48299. /** The longitudinal angle of the camera */
  48300. alpha: number;
  48301. /** The latitudinal angle of the camera */
  48302. beta: number;
  48303. /** The radius of the camera from its target */
  48304. radius: number;
  48305. private _cartesianCoordinates;
  48306. /** Define the camera target (the mesh it should follow) */
  48307. private _meshTarget;
  48308. /**
  48309. * Instantiates a new ArcFollowCamera
  48310. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48311. * @param name Define the name of the camera
  48312. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48313. * @param beta Define the rotation angle of the camera around the elevation axis
  48314. * @param radius Define the radius of the camera from its target point
  48315. * @param target Define the target of the camera
  48316. * @param scene Define the scene the camera belongs to
  48317. */
  48318. constructor(name: string,
  48319. /** The longitudinal angle of the camera */
  48320. alpha: number,
  48321. /** The latitudinal angle of the camera */
  48322. beta: number,
  48323. /** The radius of the camera from its target */
  48324. radius: number,
  48325. /** Define the camera target (the mesh it should follow) */
  48326. target: Nullable<AbstractMesh>, scene: Scene);
  48327. private _follow;
  48328. /** @hidden */
  48329. _checkInputs(): void;
  48330. /**
  48331. * Returns the class name of the object.
  48332. * It is mostly used internally for serialization purposes.
  48333. */
  48334. getClassName(): string;
  48335. }
  48336. }
  48337. declare module BABYLON {
  48338. /**
  48339. * Manage the keyboard inputs to control the movement of a follow camera.
  48340. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48341. */
  48342. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48343. /**
  48344. * Defines the camera the input is attached to.
  48345. */
  48346. camera: FollowCamera;
  48347. /**
  48348. * Defines the list of key codes associated with the up action (increase heightOffset)
  48349. */
  48350. keysHeightOffsetIncr: number[];
  48351. /**
  48352. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48353. */
  48354. keysHeightOffsetDecr: number[];
  48355. /**
  48356. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48357. */
  48358. keysHeightOffsetModifierAlt: boolean;
  48359. /**
  48360. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48361. */
  48362. keysHeightOffsetModifierCtrl: boolean;
  48363. /**
  48364. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48365. */
  48366. keysHeightOffsetModifierShift: boolean;
  48367. /**
  48368. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48369. */
  48370. keysRotationOffsetIncr: number[];
  48371. /**
  48372. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48373. */
  48374. keysRotationOffsetDecr: number[];
  48375. /**
  48376. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48377. */
  48378. keysRotationOffsetModifierAlt: boolean;
  48379. /**
  48380. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48381. */
  48382. keysRotationOffsetModifierCtrl: boolean;
  48383. /**
  48384. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48385. */
  48386. keysRotationOffsetModifierShift: boolean;
  48387. /**
  48388. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48389. */
  48390. keysRadiusIncr: number[];
  48391. /**
  48392. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48393. */
  48394. keysRadiusDecr: number[];
  48395. /**
  48396. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48397. */
  48398. keysRadiusModifierAlt: boolean;
  48399. /**
  48400. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48401. */
  48402. keysRadiusModifierCtrl: boolean;
  48403. /**
  48404. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48405. */
  48406. keysRadiusModifierShift: boolean;
  48407. /**
  48408. * Defines the rate of change of heightOffset.
  48409. */
  48410. heightSensibility: number;
  48411. /**
  48412. * Defines the rate of change of rotationOffset.
  48413. */
  48414. rotationSensibility: number;
  48415. /**
  48416. * Defines the rate of change of radius.
  48417. */
  48418. radiusSensibility: number;
  48419. private _keys;
  48420. private _ctrlPressed;
  48421. private _altPressed;
  48422. private _shiftPressed;
  48423. private _onCanvasBlurObserver;
  48424. private _onKeyboardObserver;
  48425. private _engine;
  48426. private _scene;
  48427. /**
  48428. * Attach the input controls to a specific dom element to get the input from.
  48429. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48430. */
  48431. attachControl(noPreventDefault?: boolean): void;
  48432. /**
  48433. * Detach the current controls from the specified dom element.
  48434. */
  48435. detachControl(): void;
  48436. /**
  48437. * Update the current camera state depending on the inputs that have been used this frame.
  48438. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48439. */
  48440. checkInputs(): void;
  48441. /**
  48442. * Gets the class name of the current input.
  48443. * @returns the class name
  48444. */
  48445. getClassName(): string;
  48446. /**
  48447. * Get the friendly name associated with the input class.
  48448. * @returns the input friendly name
  48449. */
  48450. getSimpleName(): string;
  48451. /**
  48452. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48453. * allow modification of the heightOffset value.
  48454. */
  48455. private _modifierHeightOffset;
  48456. /**
  48457. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48458. * allow modification of the rotationOffset value.
  48459. */
  48460. private _modifierRotationOffset;
  48461. /**
  48462. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48463. * allow modification of the radius value.
  48464. */
  48465. private _modifierRadius;
  48466. }
  48467. }
  48468. declare module BABYLON {
  48469. interface FreeCameraInputsManager {
  48470. /**
  48471. * @hidden
  48472. */
  48473. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48474. /**
  48475. * Add orientation input support to the input manager.
  48476. * @returns the current input manager
  48477. */
  48478. addDeviceOrientation(): FreeCameraInputsManager;
  48479. }
  48480. /**
  48481. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48482. * Screen rotation is taken into account.
  48483. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48484. */
  48485. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48486. private _camera;
  48487. private _screenOrientationAngle;
  48488. private _constantTranform;
  48489. private _screenQuaternion;
  48490. private _alpha;
  48491. private _beta;
  48492. private _gamma;
  48493. /**
  48494. * Can be used to detect if a device orientation sensor is available on a device
  48495. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48496. * @returns a promise that will resolve on orientation change
  48497. */
  48498. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48499. /**
  48500. * @hidden
  48501. */
  48502. _onDeviceOrientationChangedObservable: Observable<void>;
  48503. /**
  48504. * Instantiates a new input
  48505. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48506. */
  48507. constructor();
  48508. /**
  48509. * Define the camera controlled by the input.
  48510. */
  48511. get camera(): FreeCamera;
  48512. set camera(camera: FreeCamera);
  48513. /**
  48514. * Attach the input controls to a specific dom element to get the input from.
  48515. */
  48516. attachControl(): void;
  48517. private _orientationChanged;
  48518. private _deviceOrientation;
  48519. /**
  48520. * Detach the current controls from the specified dom element.
  48521. */
  48522. detachControl(): void;
  48523. /**
  48524. * Update the current camera state depending on the inputs that have been used this frame.
  48525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48526. */
  48527. checkInputs(): void;
  48528. /**
  48529. * Gets the class name of the current intput.
  48530. * @returns the class name
  48531. */
  48532. getClassName(): string;
  48533. /**
  48534. * Get the friendly name associated with the input class.
  48535. * @returns the input friendly name
  48536. */
  48537. getSimpleName(): string;
  48538. }
  48539. }
  48540. declare module BABYLON {
  48541. /**
  48542. * Manage the gamepad inputs to control a free camera.
  48543. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48544. */
  48545. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48546. /**
  48547. * Define the camera the input is attached to.
  48548. */
  48549. camera: FreeCamera;
  48550. /**
  48551. * Define the Gamepad controlling the input
  48552. */
  48553. gamepad: Nullable<Gamepad>;
  48554. /**
  48555. * Defines the gamepad rotation sensiblity.
  48556. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48557. */
  48558. gamepadAngularSensibility: number;
  48559. /**
  48560. * Defines the gamepad move sensiblity.
  48561. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48562. */
  48563. gamepadMoveSensibility: number;
  48564. private _yAxisScale;
  48565. /**
  48566. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48567. */
  48568. get invertYAxis(): boolean;
  48569. set invertYAxis(value: boolean);
  48570. private _onGamepadConnectedObserver;
  48571. private _onGamepadDisconnectedObserver;
  48572. private _cameraTransform;
  48573. private _deltaTransform;
  48574. private _vector3;
  48575. private _vector2;
  48576. /**
  48577. * Attach the input controls to a specific dom element to get the input from.
  48578. */
  48579. attachControl(): void;
  48580. /**
  48581. * Detach the current controls from the specified dom element.
  48582. */
  48583. detachControl(): void;
  48584. /**
  48585. * Update the current camera state depending on the inputs that have been used this frame.
  48586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48587. */
  48588. checkInputs(): void;
  48589. /**
  48590. * Gets the class name of the current intput.
  48591. * @returns the class name
  48592. */
  48593. getClassName(): string;
  48594. /**
  48595. * Get the friendly name associated with the input class.
  48596. * @returns the input friendly name
  48597. */
  48598. getSimpleName(): string;
  48599. }
  48600. }
  48601. declare module BABYLON {
  48602. /**
  48603. * Defines the potential axis of a Joystick
  48604. */
  48605. export enum JoystickAxis {
  48606. /** X axis */
  48607. X = 0,
  48608. /** Y axis */
  48609. Y = 1,
  48610. /** Z axis */
  48611. Z = 2
  48612. }
  48613. /**
  48614. * Represents the different customization options available
  48615. * for VirtualJoystick
  48616. */
  48617. interface VirtualJoystickCustomizations {
  48618. /**
  48619. * Size of the joystick's puck
  48620. */
  48621. puckSize: number;
  48622. /**
  48623. * Size of the joystick's container
  48624. */
  48625. containerSize: number;
  48626. /**
  48627. * Color of the joystick && puck
  48628. */
  48629. color: string;
  48630. /**
  48631. * Image URL for the joystick's puck
  48632. */
  48633. puckImage?: string;
  48634. /**
  48635. * Image URL for the joystick's container
  48636. */
  48637. containerImage?: string;
  48638. /**
  48639. * Defines the unmoving position of the joystick container
  48640. */
  48641. position?: {
  48642. x: number;
  48643. y: number;
  48644. };
  48645. /**
  48646. * Defines whether or not the joystick container is always visible
  48647. */
  48648. alwaysVisible: boolean;
  48649. /**
  48650. * Defines whether or not to limit the movement of the puck to the joystick's container
  48651. */
  48652. limitToContainer: boolean;
  48653. }
  48654. /**
  48655. * Class used to define virtual joystick (used in touch mode)
  48656. */
  48657. export class VirtualJoystick {
  48658. /**
  48659. * Gets or sets a boolean indicating that left and right values must be inverted
  48660. */
  48661. reverseLeftRight: boolean;
  48662. /**
  48663. * Gets or sets a boolean indicating that up and down values must be inverted
  48664. */
  48665. reverseUpDown: boolean;
  48666. /**
  48667. * Gets the offset value for the position (ie. the change of the position value)
  48668. */
  48669. deltaPosition: Vector3;
  48670. /**
  48671. * Gets a boolean indicating if the virtual joystick was pressed
  48672. */
  48673. pressed: boolean;
  48674. /**
  48675. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48676. */
  48677. static Canvas: Nullable<HTMLCanvasElement>;
  48678. /**
  48679. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48680. */
  48681. limitToContainer: boolean;
  48682. private static _globalJoystickIndex;
  48683. private static _alwaysVisibleSticks;
  48684. private static vjCanvasContext;
  48685. private static vjCanvasWidth;
  48686. private static vjCanvasHeight;
  48687. private static halfWidth;
  48688. private static _GetDefaultOptions;
  48689. private _action;
  48690. private _axisTargetedByLeftAndRight;
  48691. private _axisTargetedByUpAndDown;
  48692. private _joystickSensibility;
  48693. private _inversedSensibility;
  48694. private _joystickPointerID;
  48695. private _joystickColor;
  48696. private _joystickPointerPos;
  48697. private _joystickPreviousPointerPos;
  48698. private _joystickPointerStartPos;
  48699. private _deltaJoystickVector;
  48700. private _leftJoystick;
  48701. private _touches;
  48702. private _joystickPosition;
  48703. private _alwaysVisible;
  48704. private _puckImage;
  48705. private _containerImage;
  48706. private _joystickPuckSize;
  48707. private _joystickContainerSize;
  48708. private _clearPuckSize;
  48709. private _clearContainerSize;
  48710. private _clearPuckSizeOffset;
  48711. private _clearContainerSizeOffset;
  48712. private _onPointerDownHandlerRef;
  48713. private _onPointerMoveHandlerRef;
  48714. private _onPointerUpHandlerRef;
  48715. private _onResize;
  48716. /**
  48717. * Creates a new virtual joystick
  48718. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48719. * @param customizations Defines the options we want to customize the VirtualJoystick
  48720. */
  48721. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48722. /**
  48723. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48724. * @param newJoystickSensibility defines the new sensibility
  48725. */
  48726. setJoystickSensibility(newJoystickSensibility: number): void;
  48727. private _onPointerDown;
  48728. private _onPointerMove;
  48729. private _onPointerUp;
  48730. /**
  48731. * Change the color of the virtual joystick
  48732. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48733. */
  48734. setJoystickColor(newColor: string): void;
  48735. /**
  48736. * Size of the joystick's container
  48737. */
  48738. set containerSize(newSize: number);
  48739. get containerSize(): number;
  48740. /**
  48741. * Size of the joystick's puck
  48742. */
  48743. set puckSize(newSize: number);
  48744. get puckSize(): number;
  48745. /**
  48746. * Clears the set position of the joystick
  48747. */
  48748. clearPosition(): void;
  48749. /**
  48750. * Defines whether or not the joystick container is always visible
  48751. */
  48752. set alwaysVisible(value: boolean);
  48753. get alwaysVisible(): boolean;
  48754. /**
  48755. * Sets the constant position of the Joystick container
  48756. * @param x X axis coordinate
  48757. * @param y Y axis coordinate
  48758. */
  48759. setPosition(x: number, y: number): void;
  48760. /**
  48761. * Defines a callback to call when the joystick is touched
  48762. * @param action defines the callback
  48763. */
  48764. setActionOnTouch(action: () => any): void;
  48765. /**
  48766. * Defines which axis you'd like to control for left & right
  48767. * @param axis defines the axis to use
  48768. */
  48769. setAxisForLeftRight(axis: JoystickAxis): void;
  48770. /**
  48771. * Defines which axis you'd like to control for up & down
  48772. * @param axis defines the axis to use
  48773. */
  48774. setAxisForUpDown(axis: JoystickAxis): void;
  48775. /**
  48776. * Clears the canvas from the previous puck / container draw
  48777. */
  48778. private _clearPreviousDraw;
  48779. /**
  48780. * Loads `urlPath` to be used for the container's image
  48781. * @param urlPath defines the urlPath of an image to use
  48782. */
  48783. setContainerImage(urlPath: string): void;
  48784. /**
  48785. * Loads `urlPath` to be used for the puck's image
  48786. * @param urlPath defines the urlPath of an image to use
  48787. */
  48788. setPuckImage(urlPath: string): void;
  48789. /**
  48790. * Draws the Virtual Joystick's container
  48791. */
  48792. private _drawContainer;
  48793. /**
  48794. * Draws the Virtual Joystick's puck
  48795. */
  48796. private _drawPuck;
  48797. private _drawVirtualJoystick;
  48798. /**
  48799. * Release internal HTML canvas
  48800. */
  48801. releaseCanvas(): void;
  48802. }
  48803. }
  48804. declare module BABYLON {
  48805. interface FreeCameraInputsManager {
  48806. /**
  48807. * Add virtual joystick input support to the input manager.
  48808. * @returns the current input manager
  48809. */
  48810. addVirtualJoystick(): FreeCameraInputsManager;
  48811. }
  48812. /**
  48813. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48815. */
  48816. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48817. /**
  48818. * Defines the camera the input is attached to.
  48819. */
  48820. camera: FreeCamera;
  48821. private _leftjoystick;
  48822. private _rightjoystick;
  48823. /**
  48824. * Gets the left stick of the virtual joystick.
  48825. * @returns The virtual Joystick
  48826. */
  48827. getLeftJoystick(): VirtualJoystick;
  48828. /**
  48829. * Gets the right stick of the virtual joystick.
  48830. * @returns The virtual Joystick
  48831. */
  48832. getRightJoystick(): VirtualJoystick;
  48833. /**
  48834. * Update the current camera state depending on the inputs that have been used this frame.
  48835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48836. */
  48837. checkInputs(): void;
  48838. /**
  48839. * Attach the input controls to a specific dom element to get the input from.
  48840. */
  48841. attachControl(): void;
  48842. /**
  48843. * Detach the current controls from the specified dom element.
  48844. */
  48845. detachControl(): void;
  48846. /**
  48847. * Gets the class name of the current intput.
  48848. * @returns the class name
  48849. */
  48850. getClassName(): string;
  48851. /**
  48852. * Get the friendly name associated with the input class.
  48853. * @returns the input friendly name
  48854. */
  48855. getSimpleName(): string;
  48856. }
  48857. }
  48858. declare module BABYLON {
  48859. /**
  48860. * This represents a FPS type of camera controlled by touch.
  48861. * This is like a universal camera minus the Gamepad controls.
  48862. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48863. */
  48864. export class TouchCamera extends FreeCamera {
  48865. /**
  48866. * Defines the touch sensibility for rotation.
  48867. * The higher the faster.
  48868. */
  48869. get touchAngularSensibility(): number;
  48870. set touchAngularSensibility(value: number);
  48871. /**
  48872. * Defines the touch sensibility for move.
  48873. * The higher the faster.
  48874. */
  48875. get touchMoveSensibility(): number;
  48876. set touchMoveSensibility(value: number);
  48877. /**
  48878. * Instantiates a new touch camera.
  48879. * This represents a FPS type of camera controlled by touch.
  48880. * This is like a universal camera minus the Gamepad controls.
  48881. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48882. * @param name Define the name of the camera in the scene
  48883. * @param position Define the start position of the camera in the scene
  48884. * @param scene Define the scene the camera belongs to
  48885. */
  48886. constructor(name: string, position: Vector3, scene: Scene);
  48887. /**
  48888. * Gets the current object class name.
  48889. * @return the class name
  48890. */
  48891. getClassName(): string;
  48892. /** @hidden */
  48893. _setupInputs(): void;
  48894. }
  48895. }
  48896. declare module BABYLON {
  48897. /**
  48898. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48899. * being tilted forward or back and left or right.
  48900. */
  48901. export class DeviceOrientationCamera extends FreeCamera {
  48902. private _initialQuaternion;
  48903. private _quaternionCache;
  48904. private _tmpDragQuaternion;
  48905. private _disablePointerInputWhenUsingDeviceOrientation;
  48906. /**
  48907. * Creates a new device orientation camera
  48908. * @param name The name of the camera
  48909. * @param position The start position camera
  48910. * @param scene The scene the camera belongs to
  48911. */
  48912. constructor(name: string, position: Vector3, scene: Scene);
  48913. /**
  48914. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48915. */
  48916. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48917. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48918. private _dragFactor;
  48919. /**
  48920. * Enabled turning on the y axis when the orientation sensor is active
  48921. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48922. */
  48923. enableHorizontalDragging(dragFactor?: number): void;
  48924. /**
  48925. * Gets the current instance class name ("DeviceOrientationCamera").
  48926. * This helps avoiding instanceof at run time.
  48927. * @returns the class name
  48928. */
  48929. getClassName(): string;
  48930. /**
  48931. * @hidden
  48932. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48933. */
  48934. _checkInputs(): void;
  48935. /**
  48936. * Reset the camera to its default orientation on the specified axis only.
  48937. * @param axis The axis to reset
  48938. */
  48939. resetToCurrentRotation(axis?: Axis): void;
  48940. }
  48941. }
  48942. declare module BABYLON {
  48943. /**
  48944. * Defines supported buttons for XBox360 compatible gamepads
  48945. */
  48946. export enum Xbox360Button {
  48947. /** A */
  48948. A = 0,
  48949. /** B */
  48950. B = 1,
  48951. /** X */
  48952. X = 2,
  48953. /** Y */
  48954. Y = 3,
  48955. /** Left button */
  48956. LB = 4,
  48957. /** Right button */
  48958. RB = 5,
  48959. /** Back */
  48960. Back = 8,
  48961. /** Start */
  48962. Start = 9,
  48963. /** Left stick */
  48964. LeftStick = 10,
  48965. /** Right stick */
  48966. RightStick = 11
  48967. }
  48968. /** Defines values for XBox360 DPad */
  48969. export enum Xbox360Dpad {
  48970. /** Up */
  48971. Up = 12,
  48972. /** Down */
  48973. Down = 13,
  48974. /** Left */
  48975. Left = 14,
  48976. /** Right */
  48977. Right = 15
  48978. }
  48979. /**
  48980. * Defines a XBox360 gamepad
  48981. */
  48982. export class Xbox360Pad extends Gamepad {
  48983. private _leftTrigger;
  48984. private _rightTrigger;
  48985. private _onlefttriggerchanged;
  48986. private _onrighttriggerchanged;
  48987. private _onbuttondown;
  48988. private _onbuttonup;
  48989. private _ondpaddown;
  48990. private _ondpadup;
  48991. /** Observable raised when a button is pressed */
  48992. onButtonDownObservable: Observable<Xbox360Button>;
  48993. /** Observable raised when a button is released */
  48994. onButtonUpObservable: Observable<Xbox360Button>;
  48995. /** Observable raised when a pad is pressed */
  48996. onPadDownObservable: Observable<Xbox360Dpad>;
  48997. /** Observable raised when a pad is released */
  48998. onPadUpObservable: Observable<Xbox360Dpad>;
  48999. private _buttonA;
  49000. private _buttonB;
  49001. private _buttonX;
  49002. private _buttonY;
  49003. private _buttonBack;
  49004. private _buttonStart;
  49005. private _buttonLB;
  49006. private _buttonRB;
  49007. private _buttonLeftStick;
  49008. private _buttonRightStick;
  49009. private _dPadUp;
  49010. private _dPadDown;
  49011. private _dPadLeft;
  49012. private _dPadRight;
  49013. private _isXboxOnePad;
  49014. /**
  49015. * Creates a new XBox360 gamepad object
  49016. * @param id defines the id of this gamepad
  49017. * @param index defines its index
  49018. * @param gamepad defines the internal HTML gamepad object
  49019. * @param xboxOne defines if it is a XBox One gamepad
  49020. */
  49021. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49022. /**
  49023. * Defines the callback to call when left trigger is pressed
  49024. * @param callback defines the callback to use
  49025. */
  49026. onlefttriggerchanged(callback: (value: number) => void): void;
  49027. /**
  49028. * Defines the callback to call when right trigger is pressed
  49029. * @param callback defines the callback to use
  49030. */
  49031. onrighttriggerchanged(callback: (value: number) => void): void;
  49032. /**
  49033. * Gets the left trigger value
  49034. */
  49035. get leftTrigger(): number;
  49036. /**
  49037. * Sets the left trigger value
  49038. */
  49039. set leftTrigger(newValue: number);
  49040. /**
  49041. * Gets the right trigger value
  49042. */
  49043. get rightTrigger(): number;
  49044. /**
  49045. * Sets the right trigger value
  49046. */
  49047. set rightTrigger(newValue: number);
  49048. /**
  49049. * Defines the callback to call when a button is pressed
  49050. * @param callback defines the callback to use
  49051. */
  49052. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49053. /**
  49054. * Defines the callback to call when a button is released
  49055. * @param callback defines the callback to use
  49056. */
  49057. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49058. /**
  49059. * Defines the callback to call when a pad is pressed
  49060. * @param callback defines the callback to use
  49061. */
  49062. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49063. /**
  49064. * Defines the callback to call when a pad is released
  49065. * @param callback defines the callback to use
  49066. */
  49067. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49068. private _setButtonValue;
  49069. private _setDPadValue;
  49070. /**
  49071. * Gets the value of the `A` button
  49072. */
  49073. get buttonA(): number;
  49074. /**
  49075. * Sets the value of the `A` button
  49076. */
  49077. set buttonA(value: number);
  49078. /**
  49079. * Gets the value of the `B` button
  49080. */
  49081. get buttonB(): number;
  49082. /**
  49083. * Sets the value of the `B` button
  49084. */
  49085. set buttonB(value: number);
  49086. /**
  49087. * Gets the value of the `X` button
  49088. */
  49089. get buttonX(): number;
  49090. /**
  49091. * Sets the value of the `X` button
  49092. */
  49093. set buttonX(value: number);
  49094. /**
  49095. * Gets the value of the `Y` button
  49096. */
  49097. get buttonY(): number;
  49098. /**
  49099. * Sets the value of the `Y` button
  49100. */
  49101. set buttonY(value: number);
  49102. /**
  49103. * Gets the value of the `Start` button
  49104. */
  49105. get buttonStart(): number;
  49106. /**
  49107. * Sets the value of the `Start` button
  49108. */
  49109. set buttonStart(value: number);
  49110. /**
  49111. * Gets the value of the `Back` button
  49112. */
  49113. get buttonBack(): number;
  49114. /**
  49115. * Sets the value of the `Back` button
  49116. */
  49117. set buttonBack(value: number);
  49118. /**
  49119. * Gets the value of the `Left` button
  49120. */
  49121. get buttonLB(): number;
  49122. /**
  49123. * Sets the value of the `Left` button
  49124. */
  49125. set buttonLB(value: number);
  49126. /**
  49127. * Gets the value of the `Right` button
  49128. */
  49129. get buttonRB(): number;
  49130. /**
  49131. * Sets the value of the `Right` button
  49132. */
  49133. set buttonRB(value: number);
  49134. /**
  49135. * Gets the value of the Left joystick
  49136. */
  49137. get buttonLeftStick(): number;
  49138. /**
  49139. * Sets the value of the Left joystick
  49140. */
  49141. set buttonLeftStick(value: number);
  49142. /**
  49143. * Gets the value of the Right joystick
  49144. */
  49145. get buttonRightStick(): number;
  49146. /**
  49147. * Sets the value of the Right joystick
  49148. */
  49149. set buttonRightStick(value: number);
  49150. /**
  49151. * Gets the value of D-pad up
  49152. */
  49153. get dPadUp(): number;
  49154. /**
  49155. * Sets the value of D-pad up
  49156. */
  49157. set dPadUp(value: number);
  49158. /**
  49159. * Gets the value of D-pad down
  49160. */
  49161. get dPadDown(): number;
  49162. /**
  49163. * Sets the value of D-pad down
  49164. */
  49165. set dPadDown(value: number);
  49166. /**
  49167. * Gets the value of D-pad left
  49168. */
  49169. get dPadLeft(): number;
  49170. /**
  49171. * Sets the value of D-pad left
  49172. */
  49173. set dPadLeft(value: number);
  49174. /**
  49175. * Gets the value of D-pad right
  49176. */
  49177. get dPadRight(): number;
  49178. /**
  49179. * Sets the value of D-pad right
  49180. */
  49181. set dPadRight(value: number);
  49182. /**
  49183. * Force the gamepad to synchronize with device values
  49184. */
  49185. update(): void;
  49186. /**
  49187. * Disposes the gamepad
  49188. */
  49189. dispose(): void;
  49190. }
  49191. }
  49192. declare module BABYLON {
  49193. /**
  49194. * Defines supported buttons for DualShock compatible gamepads
  49195. */
  49196. export enum DualShockButton {
  49197. /** Cross */
  49198. Cross = 0,
  49199. /** Circle */
  49200. Circle = 1,
  49201. /** Square */
  49202. Square = 2,
  49203. /** Triangle */
  49204. Triangle = 3,
  49205. /** L1 */
  49206. L1 = 4,
  49207. /** R1 */
  49208. R1 = 5,
  49209. /** Share */
  49210. Share = 8,
  49211. /** Options */
  49212. Options = 9,
  49213. /** Left stick */
  49214. LeftStick = 10,
  49215. /** Right stick */
  49216. RightStick = 11
  49217. }
  49218. /** Defines values for DualShock DPad */
  49219. export enum DualShockDpad {
  49220. /** Up */
  49221. Up = 12,
  49222. /** Down */
  49223. Down = 13,
  49224. /** Left */
  49225. Left = 14,
  49226. /** Right */
  49227. Right = 15
  49228. }
  49229. /**
  49230. * Defines a DualShock gamepad
  49231. */
  49232. export class DualShockPad extends Gamepad {
  49233. private _leftTrigger;
  49234. private _rightTrigger;
  49235. private _onlefttriggerchanged;
  49236. private _onrighttriggerchanged;
  49237. private _onbuttondown;
  49238. private _onbuttonup;
  49239. private _ondpaddown;
  49240. private _ondpadup;
  49241. /** Observable raised when a button is pressed */
  49242. onButtonDownObservable: Observable<DualShockButton>;
  49243. /** Observable raised when a button is released */
  49244. onButtonUpObservable: Observable<DualShockButton>;
  49245. /** Observable raised when a pad is pressed */
  49246. onPadDownObservable: Observable<DualShockDpad>;
  49247. /** Observable raised when a pad is released */
  49248. onPadUpObservable: Observable<DualShockDpad>;
  49249. private _buttonCross;
  49250. private _buttonCircle;
  49251. private _buttonSquare;
  49252. private _buttonTriangle;
  49253. private _buttonShare;
  49254. private _buttonOptions;
  49255. private _buttonL1;
  49256. private _buttonR1;
  49257. private _buttonLeftStick;
  49258. private _buttonRightStick;
  49259. private _dPadUp;
  49260. private _dPadDown;
  49261. private _dPadLeft;
  49262. private _dPadRight;
  49263. /**
  49264. * Creates a new DualShock gamepad object
  49265. * @param id defines the id of this gamepad
  49266. * @param index defines its index
  49267. * @param gamepad defines the internal HTML gamepad object
  49268. */
  49269. constructor(id: string, index: number, gamepad: any);
  49270. /**
  49271. * Defines the callback to call when left trigger is pressed
  49272. * @param callback defines the callback to use
  49273. */
  49274. onlefttriggerchanged(callback: (value: number) => void): void;
  49275. /**
  49276. * Defines the callback to call when right trigger is pressed
  49277. * @param callback defines the callback to use
  49278. */
  49279. onrighttriggerchanged(callback: (value: number) => void): void;
  49280. /**
  49281. * Gets the left trigger value
  49282. */
  49283. get leftTrigger(): number;
  49284. /**
  49285. * Sets the left trigger value
  49286. */
  49287. set leftTrigger(newValue: number);
  49288. /**
  49289. * Gets the right trigger value
  49290. */
  49291. get rightTrigger(): number;
  49292. /**
  49293. * Sets the right trigger value
  49294. */
  49295. set rightTrigger(newValue: number);
  49296. /**
  49297. * Defines the callback to call when a button is pressed
  49298. * @param callback defines the callback to use
  49299. */
  49300. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49301. /**
  49302. * Defines the callback to call when a button is released
  49303. * @param callback defines the callback to use
  49304. */
  49305. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49306. /**
  49307. * Defines the callback to call when a pad is pressed
  49308. * @param callback defines the callback to use
  49309. */
  49310. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49311. /**
  49312. * Defines the callback to call when a pad is released
  49313. * @param callback defines the callback to use
  49314. */
  49315. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49316. private _setButtonValue;
  49317. private _setDPadValue;
  49318. /**
  49319. * Gets the value of the `Cross` button
  49320. */
  49321. get buttonCross(): number;
  49322. /**
  49323. * Sets the value of the `Cross` button
  49324. */
  49325. set buttonCross(value: number);
  49326. /**
  49327. * Gets the value of the `Circle` button
  49328. */
  49329. get buttonCircle(): number;
  49330. /**
  49331. * Sets the value of the `Circle` button
  49332. */
  49333. set buttonCircle(value: number);
  49334. /**
  49335. * Gets the value of the `Square` button
  49336. */
  49337. get buttonSquare(): number;
  49338. /**
  49339. * Sets the value of the `Square` button
  49340. */
  49341. set buttonSquare(value: number);
  49342. /**
  49343. * Gets the value of the `Triangle` button
  49344. */
  49345. get buttonTriangle(): number;
  49346. /**
  49347. * Sets the value of the `Triangle` button
  49348. */
  49349. set buttonTriangle(value: number);
  49350. /**
  49351. * Gets the value of the `Options` button
  49352. */
  49353. get buttonOptions(): number;
  49354. /**
  49355. * Sets the value of the `Options` button
  49356. */
  49357. set buttonOptions(value: number);
  49358. /**
  49359. * Gets the value of the `Share` button
  49360. */
  49361. get buttonShare(): number;
  49362. /**
  49363. * Sets the value of the `Share` button
  49364. */
  49365. set buttonShare(value: number);
  49366. /**
  49367. * Gets the value of the `L1` button
  49368. */
  49369. get buttonL1(): number;
  49370. /**
  49371. * Sets the value of the `L1` button
  49372. */
  49373. set buttonL1(value: number);
  49374. /**
  49375. * Gets the value of the `R1` button
  49376. */
  49377. get buttonR1(): number;
  49378. /**
  49379. * Sets the value of the `R1` button
  49380. */
  49381. set buttonR1(value: number);
  49382. /**
  49383. * Gets the value of the Left joystick
  49384. */
  49385. get buttonLeftStick(): number;
  49386. /**
  49387. * Sets the value of the Left joystick
  49388. */
  49389. set buttonLeftStick(value: number);
  49390. /**
  49391. * Gets the value of the Right joystick
  49392. */
  49393. get buttonRightStick(): number;
  49394. /**
  49395. * Sets the value of the Right joystick
  49396. */
  49397. set buttonRightStick(value: number);
  49398. /**
  49399. * Gets the value of D-pad up
  49400. */
  49401. get dPadUp(): number;
  49402. /**
  49403. * Sets the value of D-pad up
  49404. */
  49405. set dPadUp(value: number);
  49406. /**
  49407. * Gets the value of D-pad down
  49408. */
  49409. get dPadDown(): number;
  49410. /**
  49411. * Sets the value of D-pad down
  49412. */
  49413. set dPadDown(value: number);
  49414. /**
  49415. * Gets the value of D-pad left
  49416. */
  49417. get dPadLeft(): number;
  49418. /**
  49419. * Sets the value of D-pad left
  49420. */
  49421. set dPadLeft(value: number);
  49422. /**
  49423. * Gets the value of D-pad right
  49424. */
  49425. get dPadRight(): number;
  49426. /**
  49427. * Sets the value of D-pad right
  49428. */
  49429. set dPadRight(value: number);
  49430. /**
  49431. * Force the gamepad to synchronize with device values
  49432. */
  49433. update(): void;
  49434. /**
  49435. * Disposes the gamepad
  49436. */
  49437. dispose(): void;
  49438. }
  49439. }
  49440. declare module BABYLON {
  49441. /**
  49442. * Manager for handling gamepads
  49443. */
  49444. export class GamepadManager {
  49445. private _scene?;
  49446. private _babylonGamepads;
  49447. private _oneGamepadConnected;
  49448. /** @hidden */
  49449. _isMonitoring: boolean;
  49450. private _gamepadEventSupported;
  49451. private _gamepadSupport?;
  49452. /**
  49453. * observable to be triggered when the gamepad controller has been connected
  49454. */
  49455. onGamepadConnectedObservable: Observable<Gamepad>;
  49456. /**
  49457. * observable to be triggered when the gamepad controller has been disconnected
  49458. */
  49459. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49460. private _onGamepadConnectedEvent;
  49461. private _onGamepadDisconnectedEvent;
  49462. /**
  49463. * Initializes the gamepad manager
  49464. * @param _scene BabylonJS scene
  49465. */
  49466. constructor(_scene?: Scene | undefined);
  49467. /**
  49468. * The gamepads in the game pad manager
  49469. */
  49470. get gamepads(): Gamepad[];
  49471. /**
  49472. * Get the gamepad controllers based on type
  49473. * @param type The type of gamepad controller
  49474. * @returns Nullable gamepad
  49475. */
  49476. getGamepadByType(type?: number): Nullable<Gamepad>;
  49477. /**
  49478. * Disposes the gamepad manager
  49479. */
  49480. dispose(): void;
  49481. private _addNewGamepad;
  49482. private _startMonitoringGamepads;
  49483. private _stopMonitoringGamepads;
  49484. /** @hidden */
  49485. _checkGamepadsStatus(): void;
  49486. private _updateGamepadObjects;
  49487. }
  49488. }
  49489. declare module BABYLON {
  49490. interface Scene {
  49491. /** @hidden */
  49492. _gamepadManager: Nullable<GamepadManager>;
  49493. /**
  49494. * Gets the gamepad manager associated with the scene
  49495. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49496. */
  49497. gamepadManager: GamepadManager;
  49498. }
  49499. /**
  49500. * Interface representing a free camera inputs manager
  49501. */
  49502. interface FreeCameraInputsManager {
  49503. /**
  49504. * Adds gamepad input support to the FreeCameraInputsManager.
  49505. * @returns the FreeCameraInputsManager
  49506. */
  49507. addGamepad(): FreeCameraInputsManager;
  49508. }
  49509. /**
  49510. * Interface representing an arc rotate camera inputs manager
  49511. */
  49512. interface ArcRotateCameraInputsManager {
  49513. /**
  49514. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49515. * @returns the camera inputs manager
  49516. */
  49517. addGamepad(): ArcRotateCameraInputsManager;
  49518. }
  49519. /**
  49520. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49521. */
  49522. export class GamepadSystemSceneComponent implements ISceneComponent {
  49523. /**
  49524. * The component name helpfull to identify the component in the list of scene components.
  49525. */
  49526. readonly name: string;
  49527. /**
  49528. * The scene the component belongs to.
  49529. */
  49530. scene: Scene;
  49531. /**
  49532. * Creates a new instance of the component for the given scene
  49533. * @param scene Defines the scene to register the component in
  49534. */
  49535. constructor(scene: Scene);
  49536. /**
  49537. * Registers the component in a given scene
  49538. */
  49539. register(): void;
  49540. /**
  49541. * Rebuilds the elements related to this component in case of
  49542. * context lost for instance.
  49543. */
  49544. rebuild(): void;
  49545. /**
  49546. * Disposes the component and the associated ressources
  49547. */
  49548. dispose(): void;
  49549. private _beforeCameraUpdate;
  49550. }
  49551. }
  49552. declare module BABYLON {
  49553. /**
  49554. * 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,
  49555. * which still works and will still be found in many Playgrounds.
  49556. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49557. */
  49558. export class UniversalCamera extends TouchCamera {
  49559. /**
  49560. * Defines the gamepad rotation sensiblity.
  49561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49562. */
  49563. get gamepadAngularSensibility(): number;
  49564. set gamepadAngularSensibility(value: number);
  49565. /**
  49566. * Defines the gamepad move sensiblity.
  49567. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49568. */
  49569. get gamepadMoveSensibility(): number;
  49570. set gamepadMoveSensibility(value: number);
  49571. /**
  49572. * 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,
  49573. * which still works and will still be found in many Playgrounds.
  49574. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49575. * @param name Define the name of the camera in the scene
  49576. * @param position Define the start position of the camera in the scene
  49577. * @param scene Define the scene the camera belongs to
  49578. */
  49579. constructor(name: string, position: Vector3, scene: Scene);
  49580. /**
  49581. * Gets the current object class name.
  49582. * @return the class name
  49583. */
  49584. getClassName(): string;
  49585. }
  49586. }
  49587. declare module BABYLON {
  49588. /**
  49589. * This represents a FPS type of camera. This is only here for back compat purpose.
  49590. * Please use the UniversalCamera instead as both are identical.
  49591. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49592. */
  49593. export class GamepadCamera extends UniversalCamera {
  49594. /**
  49595. * Instantiates a new Gamepad Camera
  49596. * This represents a FPS type of camera. This is only here for back compat purpose.
  49597. * Please use the UniversalCamera instead as both are identical.
  49598. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49599. * @param name Define the name of the camera in the scene
  49600. * @param position Define the start position of the camera in the scene
  49601. * @param scene Define the scene the camera belongs to
  49602. */
  49603. constructor(name: string, position: Vector3, scene: Scene);
  49604. /**
  49605. * Gets the current object class name.
  49606. * @return the class name
  49607. */
  49608. getClassName(): string;
  49609. }
  49610. }
  49611. declare module BABYLON {
  49612. /** @hidden */
  49613. export var passPixelShader: {
  49614. name: string;
  49615. shader: string;
  49616. };
  49617. }
  49618. declare module BABYLON {
  49619. /** @hidden */
  49620. export var passCubePixelShader: {
  49621. name: string;
  49622. shader: string;
  49623. };
  49624. }
  49625. declare module BABYLON {
  49626. /**
  49627. * PassPostProcess which produces an output the same as it's input
  49628. */
  49629. export class PassPostProcess extends PostProcess {
  49630. /**
  49631. * Gets a string identifying the name of the class
  49632. * @returns "PassPostProcess" string
  49633. */
  49634. getClassName(): string;
  49635. /**
  49636. * Creates the PassPostProcess
  49637. * @param name The name of the effect.
  49638. * @param options The required width/height ratio to downsize to before computing the render pass.
  49639. * @param camera The camera to apply the render pass to.
  49640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49641. * @param engine The engine which the post process will be applied. (default: current engine)
  49642. * @param reusable If the post process can be reused on the same frame. (default: false)
  49643. * @param textureType The type of texture to be used when performing the post processing.
  49644. * @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)
  49645. */
  49646. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49647. /** @hidden */
  49648. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49649. }
  49650. /**
  49651. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49652. */
  49653. export class PassCubePostProcess extends PostProcess {
  49654. private _face;
  49655. /**
  49656. * Gets or sets the cube face to display.
  49657. * * 0 is +X
  49658. * * 1 is -X
  49659. * * 2 is +Y
  49660. * * 3 is -Y
  49661. * * 4 is +Z
  49662. * * 5 is -Z
  49663. */
  49664. get face(): number;
  49665. set face(value: number);
  49666. /**
  49667. * Gets a string identifying the name of the class
  49668. * @returns "PassCubePostProcess" string
  49669. */
  49670. getClassName(): string;
  49671. /**
  49672. * Creates the PassCubePostProcess
  49673. * @param name The name of the effect.
  49674. * @param options The required width/height ratio to downsize to before computing the render pass.
  49675. * @param camera The camera to apply the render pass to.
  49676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49677. * @param engine The engine which the post process will be applied. (default: current engine)
  49678. * @param reusable If the post process can be reused on the same frame. (default: false)
  49679. * @param textureType The type of texture to be used when performing the post processing.
  49680. * @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)
  49681. */
  49682. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49683. /** @hidden */
  49684. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49685. }
  49686. }
  49687. declare module BABYLON {
  49688. /** @hidden */
  49689. export var anaglyphPixelShader: {
  49690. name: string;
  49691. shader: string;
  49692. };
  49693. }
  49694. declare module BABYLON {
  49695. /**
  49696. * Postprocess used to generate anaglyphic rendering
  49697. */
  49698. export class AnaglyphPostProcess extends PostProcess {
  49699. private _passedProcess;
  49700. /**
  49701. * Gets a string identifying the name of the class
  49702. * @returns "AnaglyphPostProcess" string
  49703. */
  49704. getClassName(): string;
  49705. /**
  49706. * Creates a new AnaglyphPostProcess
  49707. * @param name defines postprocess name
  49708. * @param options defines creation options or target ratio scale
  49709. * @param rigCameras defines cameras using this postprocess
  49710. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49711. * @param engine defines hosting engine
  49712. * @param reusable defines if the postprocess will be reused multiple times per frame
  49713. */
  49714. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49715. }
  49716. }
  49717. declare module BABYLON {
  49718. /**
  49719. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49720. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49721. */
  49722. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49723. /**
  49724. * Creates a new AnaglyphArcRotateCamera
  49725. * @param name defines camera name
  49726. * @param alpha defines alpha angle (in radians)
  49727. * @param beta defines beta angle (in radians)
  49728. * @param radius defines radius
  49729. * @param target defines camera target
  49730. * @param interaxialDistance defines distance between each color axis
  49731. * @param scene defines the hosting scene
  49732. */
  49733. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49734. /**
  49735. * Gets camera class name
  49736. * @returns AnaglyphArcRotateCamera
  49737. */
  49738. getClassName(): string;
  49739. }
  49740. }
  49741. declare module BABYLON {
  49742. /**
  49743. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49744. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49745. */
  49746. export class AnaglyphFreeCamera extends FreeCamera {
  49747. /**
  49748. * Creates a new AnaglyphFreeCamera
  49749. * @param name defines camera name
  49750. * @param position defines initial position
  49751. * @param interaxialDistance defines distance between each color axis
  49752. * @param scene defines the hosting scene
  49753. */
  49754. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49755. /**
  49756. * Gets camera class name
  49757. * @returns AnaglyphFreeCamera
  49758. */
  49759. getClassName(): string;
  49760. }
  49761. }
  49762. declare module BABYLON {
  49763. /**
  49764. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49765. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49766. */
  49767. export class AnaglyphGamepadCamera extends GamepadCamera {
  49768. /**
  49769. * Creates a new AnaglyphGamepadCamera
  49770. * @param name defines camera name
  49771. * @param position defines initial position
  49772. * @param interaxialDistance defines distance between each color axis
  49773. * @param scene defines the hosting scene
  49774. */
  49775. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49776. /**
  49777. * Gets camera class name
  49778. * @returns AnaglyphGamepadCamera
  49779. */
  49780. getClassName(): string;
  49781. }
  49782. }
  49783. declare module BABYLON {
  49784. /**
  49785. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49786. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49787. */
  49788. export class AnaglyphUniversalCamera extends UniversalCamera {
  49789. /**
  49790. * Creates a new AnaglyphUniversalCamera
  49791. * @param name defines camera name
  49792. * @param position defines initial position
  49793. * @param interaxialDistance defines distance between each color axis
  49794. * @param scene defines the hosting scene
  49795. */
  49796. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49797. /**
  49798. * Gets camera class name
  49799. * @returns AnaglyphUniversalCamera
  49800. */
  49801. getClassName(): string;
  49802. }
  49803. }
  49804. declare module BABYLON {
  49805. /**
  49806. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49807. * @see https://doc.babylonjs.com/features/cameras
  49808. */
  49809. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49810. /**
  49811. * Creates a new StereoscopicArcRotateCamera
  49812. * @param name defines camera name
  49813. * @param alpha defines alpha angle (in radians)
  49814. * @param beta defines beta angle (in radians)
  49815. * @param radius defines radius
  49816. * @param target defines camera target
  49817. * @param interaxialDistance defines distance between each color axis
  49818. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49819. * @param scene defines the hosting scene
  49820. */
  49821. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49822. /**
  49823. * Gets camera class name
  49824. * @returns StereoscopicArcRotateCamera
  49825. */
  49826. getClassName(): string;
  49827. }
  49828. }
  49829. declare module BABYLON {
  49830. /**
  49831. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49832. * @see https://doc.babylonjs.com/features/cameras
  49833. */
  49834. export class StereoscopicFreeCamera extends FreeCamera {
  49835. /**
  49836. * Creates a new StereoscopicFreeCamera
  49837. * @param name defines camera name
  49838. * @param position defines initial position
  49839. * @param interaxialDistance defines distance between each color axis
  49840. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49841. * @param scene defines the hosting scene
  49842. */
  49843. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49844. /**
  49845. * Gets camera class name
  49846. * @returns StereoscopicFreeCamera
  49847. */
  49848. getClassName(): string;
  49849. }
  49850. }
  49851. declare module BABYLON {
  49852. /**
  49853. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49854. * @see https://doc.babylonjs.com/features/cameras
  49855. */
  49856. export class StereoscopicGamepadCamera extends GamepadCamera {
  49857. /**
  49858. * Creates a new StereoscopicGamepadCamera
  49859. * @param name defines camera name
  49860. * @param position defines initial position
  49861. * @param interaxialDistance defines distance between each color axis
  49862. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49863. * @param scene defines the hosting scene
  49864. */
  49865. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49866. /**
  49867. * Gets camera class name
  49868. * @returns StereoscopicGamepadCamera
  49869. */
  49870. getClassName(): string;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49876. * @see https://doc.babylonjs.com/features/cameras
  49877. */
  49878. export class StereoscopicUniversalCamera extends UniversalCamera {
  49879. /**
  49880. * Creates a new StereoscopicUniversalCamera
  49881. * @param name defines camera name
  49882. * @param position defines initial position
  49883. * @param interaxialDistance defines distance between each color axis
  49884. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49885. * @param scene defines the hosting scene
  49886. */
  49887. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49888. /**
  49889. * Gets camera class name
  49890. * @returns StereoscopicUniversalCamera
  49891. */
  49892. getClassName(): string;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49898. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49899. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49900. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49901. */
  49902. export class VirtualJoysticksCamera extends FreeCamera {
  49903. /**
  49904. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49905. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49906. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49907. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49908. * @param name Define the name of the camera in the scene
  49909. * @param position Define the start position of the camera in the scene
  49910. * @param scene Define the scene the camera belongs to
  49911. */
  49912. constructor(name: string, position: Vector3, scene: Scene);
  49913. /**
  49914. * Gets the current object class name.
  49915. * @return the class name
  49916. */
  49917. getClassName(): string;
  49918. }
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * This represents all the required metrics to create a VR camera.
  49923. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49924. */
  49925. export class VRCameraMetrics {
  49926. /**
  49927. * Define the horizontal resolution off the screen.
  49928. */
  49929. hResolution: number;
  49930. /**
  49931. * Define the vertical resolution off the screen.
  49932. */
  49933. vResolution: number;
  49934. /**
  49935. * Define the horizontal screen size.
  49936. */
  49937. hScreenSize: number;
  49938. /**
  49939. * Define the vertical screen size.
  49940. */
  49941. vScreenSize: number;
  49942. /**
  49943. * Define the vertical screen center position.
  49944. */
  49945. vScreenCenter: number;
  49946. /**
  49947. * Define the distance of the eyes to the screen.
  49948. */
  49949. eyeToScreenDistance: number;
  49950. /**
  49951. * Define the distance between both lenses
  49952. */
  49953. lensSeparationDistance: number;
  49954. /**
  49955. * Define the distance between both viewer's eyes.
  49956. */
  49957. interpupillaryDistance: number;
  49958. /**
  49959. * Define the distortion factor of the VR postprocess.
  49960. * Please, touch with care.
  49961. */
  49962. distortionK: number[];
  49963. /**
  49964. * Define the chromatic aberration correction factors for the VR post process.
  49965. */
  49966. chromaAbCorrection: number[];
  49967. /**
  49968. * Define the scale factor of the post process.
  49969. * The smaller the better but the slower.
  49970. */
  49971. postProcessScaleFactor: number;
  49972. /**
  49973. * Define an offset for the lens center.
  49974. */
  49975. lensCenterOffset: number;
  49976. /**
  49977. * Define if the current vr camera should compensate the distortion of the lense or not.
  49978. */
  49979. compensateDistortion: boolean;
  49980. /**
  49981. * Defines if multiview should be enabled when rendering (Default: false)
  49982. */
  49983. multiviewEnabled: boolean;
  49984. /**
  49985. * Gets the rendering aspect ratio based on the provided resolutions.
  49986. */
  49987. get aspectRatio(): number;
  49988. /**
  49989. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49990. */
  49991. get aspectRatioFov(): number;
  49992. /**
  49993. * @hidden
  49994. */
  49995. get leftHMatrix(): Matrix;
  49996. /**
  49997. * @hidden
  49998. */
  49999. get rightHMatrix(): Matrix;
  50000. /**
  50001. * @hidden
  50002. */
  50003. get leftPreViewMatrix(): Matrix;
  50004. /**
  50005. * @hidden
  50006. */
  50007. get rightPreViewMatrix(): Matrix;
  50008. /**
  50009. * Get the default VRMetrics based on the most generic setup.
  50010. * @returns the default vr metrics
  50011. */
  50012. static GetDefault(): VRCameraMetrics;
  50013. }
  50014. }
  50015. declare module BABYLON {
  50016. /** @hidden */
  50017. export var vrDistortionCorrectionPixelShader: {
  50018. name: string;
  50019. shader: string;
  50020. };
  50021. }
  50022. declare module BABYLON {
  50023. /**
  50024. * VRDistortionCorrectionPostProcess used for mobile VR
  50025. */
  50026. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50027. private _isRightEye;
  50028. private _distortionFactors;
  50029. private _postProcessScaleFactor;
  50030. private _lensCenterOffset;
  50031. private _scaleIn;
  50032. private _scaleFactor;
  50033. private _lensCenter;
  50034. /**
  50035. * Gets a string identifying the name of the class
  50036. * @returns "VRDistortionCorrectionPostProcess" string
  50037. */
  50038. getClassName(): string;
  50039. /**
  50040. * Initializes the VRDistortionCorrectionPostProcess
  50041. * @param name The name of the effect.
  50042. * @param camera The camera to apply the render pass to.
  50043. * @param isRightEye If this is for the right eye distortion
  50044. * @param vrMetrics All the required metrics for the VR camera
  50045. */
  50046. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50047. }
  50048. }
  50049. declare module BABYLON {
  50050. /**
  50051. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50052. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50053. */
  50054. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50055. /**
  50056. * Creates a new VRDeviceOrientationArcRotateCamera
  50057. * @param name defines camera name
  50058. * @param alpha defines the camera rotation along the logitudinal axis
  50059. * @param beta defines the camera rotation along the latitudinal axis
  50060. * @param radius defines the camera distance from its target
  50061. * @param target defines the camera target
  50062. * @param scene defines the scene the camera belongs to
  50063. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50064. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50065. */
  50066. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50067. /**
  50068. * Gets camera class name
  50069. * @returns VRDeviceOrientationArcRotateCamera
  50070. */
  50071. getClassName(): string;
  50072. }
  50073. }
  50074. declare module BABYLON {
  50075. /**
  50076. * Camera used to simulate VR rendering (based on FreeCamera)
  50077. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50078. */
  50079. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50080. /**
  50081. * Creates a new VRDeviceOrientationFreeCamera
  50082. * @param name defines camera name
  50083. * @param position defines the start position of the camera
  50084. * @param scene defines the scene the camera belongs to
  50085. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50086. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50087. */
  50088. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50089. /**
  50090. * Gets camera class name
  50091. * @returns VRDeviceOrientationFreeCamera
  50092. */
  50093. getClassName(): string;
  50094. }
  50095. }
  50096. declare module BABYLON {
  50097. /**
  50098. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50099. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50100. */
  50101. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50102. /**
  50103. * Creates a new VRDeviceOrientationGamepadCamera
  50104. * @param name defines camera name
  50105. * @param position defines the start position of the camera
  50106. * @param scene defines the scene the camera belongs to
  50107. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50108. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50109. */
  50110. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50111. /**
  50112. * Gets camera class name
  50113. * @returns VRDeviceOrientationGamepadCamera
  50114. */
  50115. getClassName(): string;
  50116. }
  50117. }
  50118. declare module BABYLON {
  50119. /**
  50120. * A class extending Texture allowing drawing on a texture
  50121. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50122. */
  50123. export class DynamicTexture extends Texture {
  50124. private _generateMipMaps;
  50125. private _canvas;
  50126. private _context;
  50127. /**
  50128. * Creates a DynamicTexture
  50129. * @param name defines the name of the texture
  50130. * @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
  50131. * @param scene defines the scene where you want the texture
  50132. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50133. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50134. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50135. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50136. */
  50137. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50138. /**
  50139. * Get the current class name of the texture useful for serialization or dynamic coding.
  50140. * @returns "DynamicTexture"
  50141. */
  50142. getClassName(): string;
  50143. /**
  50144. * Gets the current state of canRescale
  50145. */
  50146. get canRescale(): boolean;
  50147. private _recreate;
  50148. /**
  50149. * Scales the texture
  50150. * @param ratio the scale factor to apply to both width and height
  50151. */
  50152. scale(ratio: number): void;
  50153. /**
  50154. * Resizes the texture
  50155. * @param width the new width
  50156. * @param height the new height
  50157. */
  50158. scaleTo(width: number, height: number): void;
  50159. /**
  50160. * Gets the context of the canvas used by the texture
  50161. * @returns the canvas context of the dynamic texture
  50162. */
  50163. getContext(): CanvasRenderingContext2D;
  50164. /**
  50165. * Clears the texture
  50166. */
  50167. clear(): void;
  50168. /**
  50169. * Updates the texture
  50170. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50171. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50172. */
  50173. update(invertY?: boolean, premulAlpha?: boolean): void;
  50174. /**
  50175. * Draws text onto the texture
  50176. * @param text defines the text to be drawn
  50177. * @param x defines the placement of the text from the left
  50178. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50179. * @param font defines the font to be used with font-style, font-size, font-name
  50180. * @param color defines the color used for the text
  50181. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50182. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50183. * @param update defines whether texture is immediately update (default is true)
  50184. */
  50185. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50186. /**
  50187. * Clones the texture
  50188. * @returns the clone of the texture.
  50189. */
  50190. clone(): DynamicTexture;
  50191. /**
  50192. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50193. * @returns a serialized dynamic texture object
  50194. */
  50195. serialize(): any;
  50196. private _IsCanvasElement;
  50197. /** @hidden */
  50198. _rebuild(): void;
  50199. }
  50200. }
  50201. declare module BABYLON {
  50202. /**
  50203. * Class containing static functions to help procedurally build meshes
  50204. */
  50205. export class GroundBuilder {
  50206. /**
  50207. * Creates a ground mesh
  50208. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50209. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50210. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50211. * @param name defines the name of the mesh
  50212. * @param options defines the options used to create the mesh
  50213. * @param scene defines the hosting scene
  50214. * @returns the ground mesh
  50215. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50216. */
  50217. static CreateGround(name: string, options: {
  50218. width?: number;
  50219. height?: number;
  50220. subdivisions?: number;
  50221. subdivisionsX?: number;
  50222. subdivisionsY?: number;
  50223. updatable?: boolean;
  50224. }, scene: any): Mesh;
  50225. /**
  50226. * Creates a tiled ground mesh
  50227. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50228. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50229. * * 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
  50230. * * 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
  50231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50232. * @param name defines the name of the mesh
  50233. * @param options defines the options used to create the mesh
  50234. * @param scene defines the hosting scene
  50235. * @returns the tiled ground mesh
  50236. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50237. */
  50238. static CreateTiledGround(name: string, options: {
  50239. xmin: number;
  50240. zmin: number;
  50241. xmax: number;
  50242. zmax: number;
  50243. subdivisions?: {
  50244. w: number;
  50245. h: number;
  50246. };
  50247. precision?: {
  50248. w: number;
  50249. h: number;
  50250. };
  50251. updatable?: boolean;
  50252. }, scene?: Nullable<Scene>): Mesh;
  50253. /**
  50254. * Creates a ground mesh from a height map
  50255. * * The parameter `url` sets the URL of the height map image resource.
  50256. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50257. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50258. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50259. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50260. * * 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.
  50261. * * 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).
  50262. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50264. * @param name defines the name of the mesh
  50265. * @param url defines the url to the height map
  50266. * @param options defines the options used to create the mesh
  50267. * @param scene defines the hosting scene
  50268. * @returns the ground mesh
  50269. * @see https://doc.babylonjs.com/babylon101/height_map
  50270. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50271. */
  50272. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50273. width?: number;
  50274. height?: number;
  50275. subdivisions?: number;
  50276. minHeight?: number;
  50277. maxHeight?: number;
  50278. colorFilter?: Color3;
  50279. alphaFilter?: number;
  50280. updatable?: boolean;
  50281. onReady?: (mesh: GroundMesh) => void;
  50282. }, scene?: Nullable<Scene>): GroundMesh;
  50283. }
  50284. }
  50285. declare module BABYLON {
  50286. /**
  50287. * Class containing static functions to help procedurally build meshes
  50288. */
  50289. export class TorusBuilder {
  50290. /**
  50291. * Creates a torus mesh
  50292. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50293. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50294. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50296. * * 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
  50297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50298. * @param name defines the name of the mesh
  50299. * @param options defines the options used to create the mesh
  50300. * @param scene defines the hosting scene
  50301. * @returns the torus mesh
  50302. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50303. */
  50304. static CreateTorus(name: string, options: {
  50305. diameter?: number;
  50306. thickness?: number;
  50307. tessellation?: number;
  50308. updatable?: boolean;
  50309. sideOrientation?: number;
  50310. frontUVs?: Vector4;
  50311. backUVs?: Vector4;
  50312. }, scene: any): Mesh;
  50313. }
  50314. }
  50315. declare module BABYLON {
  50316. /**
  50317. * Class containing static functions to help procedurally build meshes
  50318. */
  50319. export class CylinderBuilder {
  50320. /**
  50321. * Creates a cylinder or a cone mesh
  50322. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50323. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50324. * * 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.
  50325. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50326. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50327. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50328. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50329. * * 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).
  50330. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50331. * * 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).
  50332. * * 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
  50333. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50334. * * 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
  50335. * * 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.
  50336. * * If `enclose` is false, a ring surface is one element.
  50337. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50338. * * 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
  50339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50340. * * 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
  50341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50342. * @param name defines the name of the mesh
  50343. * @param options defines the options used to create the mesh
  50344. * @param scene defines the hosting scene
  50345. * @returns the cylinder mesh
  50346. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50347. */
  50348. static CreateCylinder(name: string, options: {
  50349. height?: number;
  50350. diameterTop?: number;
  50351. diameterBottom?: number;
  50352. diameter?: number;
  50353. tessellation?: number;
  50354. subdivisions?: number;
  50355. arc?: number;
  50356. faceColors?: Color4[];
  50357. faceUV?: Vector4[];
  50358. updatable?: boolean;
  50359. hasRings?: boolean;
  50360. enclose?: boolean;
  50361. cap?: number;
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. }, scene: any): Mesh;
  50366. }
  50367. }
  50368. declare module BABYLON {
  50369. /**
  50370. * States of the webXR experience
  50371. */
  50372. export enum WebXRState {
  50373. /**
  50374. * Transitioning to being in XR mode
  50375. */
  50376. ENTERING_XR = 0,
  50377. /**
  50378. * Transitioning to non XR mode
  50379. */
  50380. EXITING_XR = 1,
  50381. /**
  50382. * In XR mode and presenting
  50383. */
  50384. IN_XR = 2,
  50385. /**
  50386. * Not entered XR mode
  50387. */
  50388. NOT_IN_XR = 3
  50389. }
  50390. /**
  50391. * The state of the XR camera's tracking
  50392. */
  50393. export enum WebXRTrackingState {
  50394. /**
  50395. * No transformation received, device is not being tracked
  50396. */
  50397. NOT_TRACKING = 0,
  50398. /**
  50399. * Tracking lost - using emulated position
  50400. */
  50401. TRACKING_LOST = 1,
  50402. /**
  50403. * Transformation tracking works normally
  50404. */
  50405. TRACKING = 2
  50406. }
  50407. /**
  50408. * Abstraction of the XR render target
  50409. */
  50410. export interface WebXRRenderTarget extends IDisposable {
  50411. /**
  50412. * xrpresent context of the canvas which can be used to display/mirror xr content
  50413. */
  50414. canvasContext: WebGLRenderingContext;
  50415. /**
  50416. * xr layer for the canvas
  50417. */
  50418. xrLayer: Nullable<XRWebGLLayer>;
  50419. /**
  50420. * Initializes the xr layer for the session
  50421. * @param xrSession xr session
  50422. * @returns a promise that will resolve once the XR Layer has been created
  50423. */
  50424. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50425. }
  50426. }
  50427. declare module BABYLON {
  50428. /**
  50429. * COnfiguration object for WebXR output canvas
  50430. */
  50431. export class WebXRManagedOutputCanvasOptions {
  50432. /**
  50433. * An optional canvas in case you wish to create it yourself and provide it here.
  50434. * If not provided, a new canvas will be created
  50435. */
  50436. canvasElement?: HTMLCanvasElement;
  50437. /**
  50438. * Options for this XR Layer output
  50439. */
  50440. canvasOptions?: XRWebGLLayerInit;
  50441. /**
  50442. * CSS styling for a newly created canvas (if not provided)
  50443. */
  50444. newCanvasCssStyle?: string;
  50445. /**
  50446. * Get the default values of the configuration object
  50447. * @param engine defines the engine to use (can be null)
  50448. * @returns default values of this configuration object
  50449. */
  50450. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50451. }
  50452. /**
  50453. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50454. */
  50455. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50456. private _options;
  50457. private _canvas;
  50458. private _engine;
  50459. private _originalCanvasSize;
  50460. /**
  50461. * Rendering context of the canvas which can be used to display/mirror xr content
  50462. */
  50463. canvasContext: WebGLRenderingContext;
  50464. /**
  50465. * xr layer for the canvas
  50466. */
  50467. xrLayer: Nullable<XRWebGLLayer>;
  50468. /**
  50469. * Obseervers registered here will be triggered when the xr layer was initialized
  50470. */
  50471. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50472. /**
  50473. * Initializes the canvas to be added/removed upon entering/exiting xr
  50474. * @param _xrSessionManager The XR Session manager
  50475. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50476. */
  50477. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50478. /**
  50479. * Disposes of the object
  50480. */
  50481. dispose(): void;
  50482. /**
  50483. * Initializes the xr layer for the session
  50484. * @param xrSession xr session
  50485. * @returns a promise that will resolve once the XR Layer has been created
  50486. */
  50487. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50488. private _addCanvas;
  50489. private _removeCanvas;
  50490. private _setCanvasSize;
  50491. private _setManagedOutputCanvas;
  50492. }
  50493. }
  50494. declare module BABYLON {
  50495. /**
  50496. * Manages an XRSession to work with Babylon's engine
  50497. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50498. */
  50499. export class WebXRSessionManager implements IDisposable {
  50500. /** The scene which the session should be created for */
  50501. scene: Scene;
  50502. private _referenceSpace;
  50503. private _rttProvider;
  50504. private _sessionEnded;
  50505. private _xrNavigator;
  50506. private baseLayer;
  50507. /**
  50508. * The base reference space from which the session started. good if you want to reset your
  50509. * reference space
  50510. */
  50511. baseReferenceSpace: XRReferenceSpace;
  50512. /**
  50513. * Current XR frame
  50514. */
  50515. currentFrame: Nullable<XRFrame>;
  50516. /** WebXR timestamp updated every frame */
  50517. currentTimestamp: number;
  50518. /**
  50519. * Used just in case of a failure to initialize an immersive session.
  50520. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50521. */
  50522. defaultHeightCompensation: number;
  50523. /**
  50524. * Fires every time a new xrFrame arrives which can be used to update the camera
  50525. */
  50526. onXRFrameObservable: Observable<XRFrame>;
  50527. /**
  50528. * Fires when the reference space changed
  50529. */
  50530. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50531. /**
  50532. * Fires when the xr session is ended either by the device or manually done
  50533. */
  50534. onXRSessionEnded: Observable<any>;
  50535. /**
  50536. * Fires when the xr session is ended either by the device or manually done
  50537. */
  50538. onXRSessionInit: Observable<XRSession>;
  50539. /**
  50540. * Underlying xr session
  50541. */
  50542. session: XRSession;
  50543. /**
  50544. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50545. * or get the offset the player is currently at.
  50546. */
  50547. viewerReferenceSpace: XRReferenceSpace;
  50548. /**
  50549. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50550. * @param scene The scene which the session should be created for
  50551. */
  50552. constructor(
  50553. /** The scene which the session should be created for */
  50554. scene: Scene);
  50555. /**
  50556. * The current reference space used in this session. This reference space can constantly change!
  50557. * It is mainly used to offset the camera's position.
  50558. */
  50559. get referenceSpace(): XRReferenceSpace;
  50560. /**
  50561. * Set a new reference space and triggers the observable
  50562. */
  50563. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50564. /**
  50565. * Disposes of the session manager
  50566. */
  50567. dispose(): void;
  50568. /**
  50569. * Stops the xrSession and restores the render loop
  50570. * @returns Promise which resolves after it exits XR
  50571. */
  50572. exitXRAsync(): Promise<void>;
  50573. /**
  50574. * Gets the correct render target texture to be rendered this frame for this eye
  50575. * @param eye the eye for which to get the render target
  50576. * @returns the render target for the specified eye
  50577. */
  50578. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50579. /**
  50580. * Creates a WebXRRenderTarget object for the XR session
  50581. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50582. * @param options optional options to provide when creating a new render target
  50583. * @returns a WebXR render target to which the session can render
  50584. */
  50585. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50586. /**
  50587. * Initializes the manager
  50588. * After initialization enterXR can be called to start an XR session
  50589. * @returns Promise which resolves after it is initialized
  50590. */
  50591. initializeAsync(): Promise<void>;
  50592. /**
  50593. * Initializes an xr session
  50594. * @param xrSessionMode mode to initialize
  50595. * @param xrSessionInit defines optional and required values to pass to the session builder
  50596. * @returns a promise which will resolve once the session has been initialized
  50597. */
  50598. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50599. /**
  50600. * Checks if a session would be supported for the creation options specified
  50601. * @param sessionMode session mode to check if supported eg. immersive-vr
  50602. * @returns A Promise that resolves to true if supported and false if not
  50603. */
  50604. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50605. /**
  50606. * Resets the reference space to the one started the session
  50607. */
  50608. resetReferenceSpace(): void;
  50609. /**
  50610. * Starts rendering to the xr layer
  50611. */
  50612. runXRRenderLoop(): void;
  50613. /**
  50614. * Sets the reference space on the xr session
  50615. * @param referenceSpaceType space to set
  50616. * @returns a promise that will resolve once the reference space has been set
  50617. */
  50618. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50619. /**
  50620. * Updates the render state of the session
  50621. * @param state state to set
  50622. * @returns a promise that resolves once the render state has been updated
  50623. */
  50624. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50625. /**
  50626. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50627. * @param sessionMode defines the session to test
  50628. * @returns a promise with boolean as final value
  50629. */
  50630. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50631. private _createRenderTargetTexture;
  50632. }
  50633. }
  50634. declare module BABYLON {
  50635. /**
  50636. * WebXR Camera which holds the views for the xrSession
  50637. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50638. */
  50639. export class WebXRCamera extends FreeCamera {
  50640. private _xrSessionManager;
  50641. private _firstFrame;
  50642. private _referenceQuaternion;
  50643. private _referencedPosition;
  50644. private _xrInvPositionCache;
  50645. private _xrInvQuaternionCache;
  50646. private _trackingState;
  50647. /**
  50648. * Observable raised before camera teleportation
  50649. */
  50650. onBeforeCameraTeleport: Observable<Vector3>;
  50651. /**
  50652. * Observable raised after camera teleportation
  50653. */
  50654. onAfterCameraTeleport: Observable<Vector3>;
  50655. /**
  50656. * Notifies when the camera's tracking state has changed.
  50657. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50658. */
  50659. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50660. /**
  50661. * Should position compensation execute on first frame.
  50662. * This is used when copying the position from a native (non XR) camera
  50663. */
  50664. compensateOnFirstFrame: boolean;
  50665. /**
  50666. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50667. * @param name the name of the camera
  50668. * @param scene the scene to add the camera to
  50669. * @param _xrSessionManager a constructed xr session manager
  50670. */
  50671. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50672. /**
  50673. * Get the current XR tracking state of the camera
  50674. */
  50675. get trackingState(): WebXRTrackingState;
  50676. private _setTrackingState;
  50677. /**
  50678. * Return the user's height, unrelated to the current ground.
  50679. * This will be the y position of this camera, when ground level is 0.
  50680. */
  50681. get realWorldHeight(): number;
  50682. /** @hidden */
  50683. _updateForDualEyeDebugging(): void;
  50684. /**
  50685. * Sets this camera's transformation based on a non-vr camera
  50686. * @param otherCamera the non-vr camera to copy the transformation from
  50687. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50688. */
  50689. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50690. /**
  50691. * Gets the current instance class name ("WebXRCamera").
  50692. * @returns the class name
  50693. */
  50694. getClassName(): string;
  50695. private _rotate180;
  50696. private _updateFromXRSession;
  50697. private _updateNumberOfRigCameras;
  50698. private _updateReferenceSpace;
  50699. private _updateReferenceSpaceOffset;
  50700. }
  50701. }
  50702. declare module BABYLON {
  50703. /**
  50704. * Defining the interface required for a (webxr) feature
  50705. */
  50706. export interface IWebXRFeature extends IDisposable {
  50707. /**
  50708. * Is this feature attached
  50709. */
  50710. attached: boolean;
  50711. /**
  50712. * Should auto-attach be disabled?
  50713. */
  50714. disableAutoAttach: boolean;
  50715. /**
  50716. * Attach the feature to the session
  50717. * Will usually be called by the features manager
  50718. *
  50719. * @param force should attachment be forced (even when already attached)
  50720. * @returns true if successful.
  50721. */
  50722. attach(force?: boolean): boolean;
  50723. /**
  50724. * Detach the feature from the session
  50725. * Will usually be called by the features manager
  50726. *
  50727. * @returns true if successful.
  50728. */
  50729. detach(): boolean;
  50730. /**
  50731. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50732. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50733. *
  50734. * @returns whether or not the feature is compatible in this environment
  50735. */
  50736. isCompatible(): boolean;
  50737. /**
  50738. * Was this feature disposed;
  50739. */
  50740. isDisposed: boolean;
  50741. /**
  50742. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50743. */
  50744. xrNativeFeatureName?: string;
  50745. /**
  50746. * A list of (Babylon WebXR) features this feature depends on
  50747. */
  50748. dependsOn?: string[];
  50749. }
  50750. /**
  50751. * A list of the currently available features without referencing them
  50752. */
  50753. export class WebXRFeatureName {
  50754. /**
  50755. * The name of the anchor system feature
  50756. */
  50757. static readonly ANCHOR_SYSTEM: string;
  50758. /**
  50759. * The name of the background remover feature
  50760. */
  50761. static readonly BACKGROUND_REMOVER: string;
  50762. /**
  50763. * The name of the hit test feature
  50764. */
  50765. static readonly HIT_TEST: string;
  50766. /**
  50767. * physics impostors for xr controllers feature
  50768. */
  50769. static readonly PHYSICS_CONTROLLERS: string;
  50770. /**
  50771. * The name of the plane detection feature
  50772. */
  50773. static readonly PLANE_DETECTION: string;
  50774. /**
  50775. * The name of the pointer selection feature
  50776. */
  50777. static readonly POINTER_SELECTION: string;
  50778. /**
  50779. * The name of the teleportation feature
  50780. */
  50781. static readonly TELEPORTATION: string;
  50782. /**
  50783. * The name of the feature points feature.
  50784. */
  50785. static readonly FEATURE_POINTS: string;
  50786. /**
  50787. * The name of the hand tracking feature.
  50788. */
  50789. static readonly HAND_TRACKING: string;
  50790. }
  50791. /**
  50792. * Defining the constructor of a feature. Used to register the modules.
  50793. */
  50794. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50795. /**
  50796. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50797. * It is mainly used in AR sessions.
  50798. *
  50799. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50800. */
  50801. export class WebXRFeaturesManager implements IDisposable {
  50802. private _xrSessionManager;
  50803. private static readonly _AvailableFeatures;
  50804. private _features;
  50805. /**
  50806. * constructs a new features manages.
  50807. *
  50808. * @param _xrSessionManager an instance of WebXRSessionManager
  50809. */
  50810. constructor(_xrSessionManager: WebXRSessionManager);
  50811. /**
  50812. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50813. * Mainly used internally.
  50814. *
  50815. * @param featureName the name of the feature to register
  50816. * @param constructorFunction the function used to construct the module
  50817. * @param version the (babylon) version of the module
  50818. * @param stable is that a stable version of this module
  50819. */
  50820. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50821. /**
  50822. * Returns a constructor of a specific feature.
  50823. *
  50824. * @param featureName the name of the feature to construct
  50825. * @param version the version of the feature to load
  50826. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50827. * @param options optional options provided to the module.
  50828. * @returns a function that, when called, will return a new instance of this feature
  50829. */
  50830. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50831. /**
  50832. * Can be used to return the list of features currently registered
  50833. *
  50834. * @returns an Array of available features
  50835. */
  50836. static GetAvailableFeatures(): string[];
  50837. /**
  50838. * Gets the versions available for a specific feature
  50839. * @param featureName the name of the feature
  50840. * @returns an array with the available versions
  50841. */
  50842. static GetAvailableVersions(featureName: string): string[];
  50843. /**
  50844. * Return the latest unstable version of this feature
  50845. * @param featureName the name of the feature to search
  50846. * @returns the version number. if not found will return -1
  50847. */
  50848. static GetLatestVersionOfFeature(featureName: string): number;
  50849. /**
  50850. * Return the latest stable version of this feature
  50851. * @param featureName the name of the feature to search
  50852. * @returns the version number. if not found will return -1
  50853. */
  50854. static GetStableVersionOfFeature(featureName: string): number;
  50855. /**
  50856. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50857. * Can be used during a session to start a feature
  50858. * @param featureName the name of feature to attach
  50859. */
  50860. attachFeature(featureName: string): void;
  50861. /**
  50862. * Can be used inside a session or when the session ends to detach a specific feature
  50863. * @param featureName the name of the feature to detach
  50864. */
  50865. detachFeature(featureName: string): void;
  50866. /**
  50867. * Used to disable an already-enabled feature
  50868. * The feature will be disposed and will be recreated once enabled.
  50869. * @param featureName the feature to disable
  50870. * @returns true if disable was successful
  50871. */
  50872. disableFeature(featureName: string | {
  50873. Name: string;
  50874. }): boolean;
  50875. /**
  50876. * dispose this features manager
  50877. */
  50878. dispose(): void;
  50879. /**
  50880. * 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.
  50881. * 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.
  50882. *
  50883. * @param featureName the name of the feature to load or the class of the feature
  50884. * @param version optional version to load. if not provided the latest version will be enabled
  50885. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50886. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50887. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50888. * @returns a new constructed feature or throws an error if feature not found.
  50889. */
  50890. enableFeature(featureName: string | {
  50891. Name: string;
  50892. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50893. /**
  50894. * get the implementation of an enabled feature.
  50895. * @param featureName the name of the feature to load
  50896. * @returns the feature class, if found
  50897. */
  50898. getEnabledFeature(featureName: string): IWebXRFeature;
  50899. /**
  50900. * Get the list of enabled features
  50901. * @returns an array of enabled features
  50902. */
  50903. getEnabledFeatures(): string[];
  50904. /**
  50905. * This function will exten the session creation configuration object with enabled features.
  50906. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50907. * according to the defined "required" variable, provided during enableFeature call
  50908. * @param xrSessionInit the xr Session init object to extend
  50909. *
  50910. * @returns an extended XRSessionInit object
  50911. */
  50912. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50913. }
  50914. }
  50915. declare module BABYLON {
  50916. /**
  50917. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50918. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50919. */
  50920. export class WebXRExperienceHelper implements IDisposable {
  50921. private scene;
  50922. private _nonVRCamera;
  50923. private _originalSceneAutoClear;
  50924. private _supported;
  50925. /**
  50926. * Camera used to render xr content
  50927. */
  50928. camera: WebXRCamera;
  50929. /** A features manager for this xr session */
  50930. featuresManager: WebXRFeaturesManager;
  50931. /**
  50932. * Observers registered here will be triggered after the camera's initial transformation is set
  50933. * This can be used to set a different ground level or an extra rotation.
  50934. *
  50935. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50936. * to the position set after this observable is done executing.
  50937. */
  50938. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50939. /**
  50940. * Fires when the state of the experience helper has changed
  50941. */
  50942. onStateChangedObservable: Observable<WebXRState>;
  50943. /** Session manager used to keep track of xr session */
  50944. sessionManager: WebXRSessionManager;
  50945. /**
  50946. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50947. */
  50948. state: WebXRState;
  50949. /**
  50950. * Creates a WebXRExperienceHelper
  50951. * @param scene The scene the helper should be created in
  50952. */
  50953. private constructor();
  50954. /**
  50955. * Creates the experience helper
  50956. * @param scene the scene to attach the experience helper to
  50957. * @returns a promise for the experience helper
  50958. */
  50959. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50960. /**
  50961. * Disposes of the experience helper
  50962. */
  50963. dispose(): void;
  50964. /**
  50965. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50966. * @param sessionMode options for the XR session
  50967. * @param referenceSpaceType frame of reference of the XR session
  50968. * @param renderTarget the output canvas that will be used to enter XR mode
  50969. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50970. * @returns promise that resolves after xr mode has entered
  50971. */
  50972. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50973. /**
  50974. * Exits XR mode and returns the scene to its original state
  50975. * @returns promise that resolves after xr mode has exited
  50976. */
  50977. exitXRAsync(): Promise<void>;
  50978. private _nonXRToXRCamera;
  50979. private _setState;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /**
  50984. * X-Y values for axes in WebXR
  50985. */
  50986. export interface IWebXRMotionControllerAxesValue {
  50987. /**
  50988. * The value of the x axis
  50989. */
  50990. x: number;
  50991. /**
  50992. * The value of the y-axis
  50993. */
  50994. y: number;
  50995. }
  50996. /**
  50997. * changed / previous values for the values of this component
  50998. */
  50999. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51000. /**
  51001. * current (this frame) value
  51002. */
  51003. current: T;
  51004. /**
  51005. * previous (last change) value
  51006. */
  51007. previous: T;
  51008. }
  51009. /**
  51010. * Represents changes in the component between current frame and last values recorded
  51011. */
  51012. export interface IWebXRMotionControllerComponentChanges {
  51013. /**
  51014. * will be populated with previous and current values if axes changed
  51015. */
  51016. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51017. /**
  51018. * will be populated with previous and current values if pressed changed
  51019. */
  51020. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51021. /**
  51022. * will be populated with previous and current values if touched changed
  51023. */
  51024. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51025. /**
  51026. * will be populated with previous and current values if value changed
  51027. */
  51028. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51029. }
  51030. /**
  51031. * This class represents a single component (for example button or thumbstick) of a motion controller
  51032. */
  51033. export class WebXRControllerComponent implements IDisposable {
  51034. /**
  51035. * the id of this component
  51036. */
  51037. id: string;
  51038. /**
  51039. * the type of the component
  51040. */
  51041. type: MotionControllerComponentType;
  51042. private _buttonIndex;
  51043. private _axesIndices;
  51044. private _axes;
  51045. private _changes;
  51046. private _currentValue;
  51047. private _hasChanges;
  51048. private _pressed;
  51049. private _touched;
  51050. /**
  51051. * button component type
  51052. */
  51053. static BUTTON_TYPE: MotionControllerComponentType;
  51054. /**
  51055. * squeeze component type
  51056. */
  51057. static SQUEEZE_TYPE: MotionControllerComponentType;
  51058. /**
  51059. * Thumbstick component type
  51060. */
  51061. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51062. /**
  51063. * Touchpad component type
  51064. */
  51065. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51066. /**
  51067. * trigger component type
  51068. */
  51069. static TRIGGER_TYPE: MotionControllerComponentType;
  51070. /**
  51071. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51072. * the axes data changes
  51073. */
  51074. onAxisValueChangedObservable: Observable<{
  51075. x: number;
  51076. y: number;
  51077. }>;
  51078. /**
  51079. * Observers registered here will be triggered when the state of a button changes
  51080. * State change is either pressed / touched / value
  51081. */
  51082. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51083. /**
  51084. * Creates a new component for a motion controller.
  51085. * It is created by the motion controller itself
  51086. *
  51087. * @param id the id of this component
  51088. * @param type the type of the component
  51089. * @param _buttonIndex index in the buttons array of the gamepad
  51090. * @param _axesIndices indices of the values in the axes array of the gamepad
  51091. */
  51092. constructor(
  51093. /**
  51094. * the id of this component
  51095. */
  51096. id: string,
  51097. /**
  51098. * the type of the component
  51099. */
  51100. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51101. /**
  51102. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51103. */
  51104. get axes(): IWebXRMotionControllerAxesValue;
  51105. /**
  51106. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51107. */
  51108. get changes(): IWebXRMotionControllerComponentChanges;
  51109. /**
  51110. * Return whether or not the component changed the last frame
  51111. */
  51112. get hasChanges(): boolean;
  51113. /**
  51114. * is the button currently pressed
  51115. */
  51116. get pressed(): boolean;
  51117. /**
  51118. * is the button currently touched
  51119. */
  51120. get touched(): boolean;
  51121. /**
  51122. * Get the current value of this component
  51123. */
  51124. get value(): number;
  51125. /**
  51126. * Dispose this component
  51127. */
  51128. dispose(): void;
  51129. /**
  51130. * Are there axes correlating to this component
  51131. * @return true is axes data is available
  51132. */
  51133. isAxes(): boolean;
  51134. /**
  51135. * Is this component a button (hence - pressable)
  51136. * @returns true if can be pressed
  51137. */
  51138. isButton(): boolean;
  51139. /**
  51140. * update this component using the gamepad object it is in. Called on every frame
  51141. * @param nativeController the native gamepad controller object
  51142. */
  51143. update(nativeController: IMinimalMotionControllerObject): void;
  51144. }
  51145. }
  51146. declare module BABYLON {
  51147. /**
  51148. * Interface used to represent data loading progression
  51149. */
  51150. export interface ISceneLoaderProgressEvent {
  51151. /**
  51152. * Defines if data length to load can be evaluated
  51153. */
  51154. readonly lengthComputable: boolean;
  51155. /**
  51156. * Defines the loaded data length
  51157. */
  51158. readonly loaded: number;
  51159. /**
  51160. * Defines the data length to load
  51161. */
  51162. readonly total: number;
  51163. }
  51164. /**
  51165. * Interface used by SceneLoader plugins to define supported file extensions
  51166. */
  51167. export interface ISceneLoaderPluginExtensions {
  51168. /**
  51169. * Defines the list of supported extensions
  51170. */
  51171. [extension: string]: {
  51172. isBinary: boolean;
  51173. };
  51174. }
  51175. /**
  51176. * Interface used by SceneLoader plugin factory
  51177. */
  51178. export interface ISceneLoaderPluginFactory {
  51179. /**
  51180. * Defines the name of the factory
  51181. */
  51182. name: string;
  51183. /**
  51184. * Function called to create a new plugin
  51185. * @return the new plugin
  51186. */
  51187. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51188. /**
  51189. * The callback that returns true if the data can be directly loaded.
  51190. * @param data string containing the file data
  51191. * @returns if the data can be loaded directly
  51192. */
  51193. canDirectLoad?(data: string): boolean;
  51194. }
  51195. /**
  51196. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51197. */
  51198. export interface ISceneLoaderPluginBase {
  51199. /**
  51200. * The friendly name of this plugin.
  51201. */
  51202. name: string;
  51203. /**
  51204. * The file extensions supported by this plugin.
  51205. */
  51206. extensions: string | ISceneLoaderPluginExtensions;
  51207. /**
  51208. * The callback called when loading from a url.
  51209. * @param scene scene loading this url
  51210. * @param url url to load
  51211. * @param onSuccess callback called when the file successfully loads
  51212. * @param onProgress callback called while file is loading (if the server supports this mode)
  51213. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51214. * @param onError callback called when the file fails to load
  51215. * @returns a file request object
  51216. */
  51217. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51218. /**
  51219. * The callback called when loading from a file object.
  51220. * @param scene scene loading this file
  51221. * @param file defines the file to load
  51222. * @param onSuccess defines the callback to call when data is loaded
  51223. * @param onProgress defines the callback to call during loading process
  51224. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51225. * @param onError defines the callback to call when an error occurs
  51226. * @returns a file request object
  51227. */
  51228. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51229. /**
  51230. * The callback that returns true if the data can be directly loaded.
  51231. * @param data string containing the file data
  51232. * @returns if the data can be loaded directly
  51233. */
  51234. canDirectLoad?(data: string): boolean;
  51235. /**
  51236. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51237. * @param scene scene loading this data
  51238. * @param data string containing the data
  51239. * @returns data to pass to the plugin
  51240. */
  51241. directLoad?(scene: Scene, data: string): any;
  51242. /**
  51243. * The callback that allows custom handling of the root url based on the response url.
  51244. * @param rootUrl the original root url
  51245. * @param responseURL the response url if available
  51246. * @returns the new root url
  51247. */
  51248. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51249. }
  51250. /**
  51251. * Interface used to define a SceneLoader plugin
  51252. */
  51253. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51254. /**
  51255. * Import meshes into a scene.
  51256. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51257. * @param scene The scene to import into
  51258. * @param data The data to import
  51259. * @param rootUrl The root url for scene and resources
  51260. * @param meshes The meshes array to import into
  51261. * @param particleSystems The particle systems array to import into
  51262. * @param skeletons The skeletons array to import into
  51263. * @param onError The callback when import fails
  51264. * @returns True if successful or false otherwise
  51265. */
  51266. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51267. /**
  51268. * Load into a scene.
  51269. * @param scene The scene to load into
  51270. * @param data The data to import
  51271. * @param rootUrl The root url for scene and resources
  51272. * @param onError The callback when import fails
  51273. * @returns True if successful or false otherwise
  51274. */
  51275. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51276. /**
  51277. * Load into an asset container.
  51278. * @param scene The scene to load into
  51279. * @param data The data to import
  51280. * @param rootUrl The root url for scene and resources
  51281. * @param onError The callback when import fails
  51282. * @returns The loaded asset container
  51283. */
  51284. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51285. }
  51286. /**
  51287. * Interface used to define an async SceneLoader plugin
  51288. */
  51289. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51290. /**
  51291. * Import meshes into a scene.
  51292. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51293. * @param scene The scene to import into
  51294. * @param data The data to import
  51295. * @param rootUrl The root url for scene and resources
  51296. * @param onProgress The callback when the load progresses
  51297. * @param fileName Defines the name of the file to load
  51298. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51299. */
  51300. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51301. meshes: AbstractMesh[];
  51302. particleSystems: IParticleSystem[];
  51303. skeletons: Skeleton[];
  51304. animationGroups: AnimationGroup[];
  51305. }>;
  51306. /**
  51307. * Load into a scene.
  51308. * @param scene The scene to load into
  51309. * @param data The data to import
  51310. * @param rootUrl The root url for scene and resources
  51311. * @param onProgress The callback when the load progresses
  51312. * @param fileName Defines the name of the file to load
  51313. * @returns Nothing
  51314. */
  51315. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51316. /**
  51317. * Load into an asset container.
  51318. * @param scene The scene to load into
  51319. * @param data The data to import
  51320. * @param rootUrl The root url for scene and resources
  51321. * @param onProgress The callback when the load progresses
  51322. * @param fileName Defines the name of the file to load
  51323. * @returns The loaded asset container
  51324. */
  51325. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51326. }
  51327. /**
  51328. * Mode that determines how to handle old animation groups before loading new ones.
  51329. */
  51330. export enum SceneLoaderAnimationGroupLoadingMode {
  51331. /**
  51332. * Reset all old animations to initial state then dispose them.
  51333. */
  51334. Clean = 0,
  51335. /**
  51336. * Stop all old animations.
  51337. */
  51338. Stop = 1,
  51339. /**
  51340. * Restart old animations from first frame.
  51341. */
  51342. Sync = 2,
  51343. /**
  51344. * Old animations remains untouched.
  51345. */
  51346. NoSync = 3
  51347. }
  51348. /**
  51349. * Defines a plugin registered by the SceneLoader
  51350. */
  51351. interface IRegisteredPlugin {
  51352. /**
  51353. * Defines the plugin to use
  51354. */
  51355. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51356. /**
  51357. * Defines if the plugin supports binary data
  51358. */
  51359. isBinary: boolean;
  51360. }
  51361. /**
  51362. * Class used to load scene from various file formats using registered plugins
  51363. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51364. */
  51365. export class SceneLoader {
  51366. /**
  51367. * No logging while loading
  51368. */
  51369. static readonly NO_LOGGING: number;
  51370. /**
  51371. * Minimal logging while loading
  51372. */
  51373. static readonly MINIMAL_LOGGING: number;
  51374. /**
  51375. * Summary logging while loading
  51376. */
  51377. static readonly SUMMARY_LOGGING: number;
  51378. /**
  51379. * Detailled logging while loading
  51380. */
  51381. static readonly DETAILED_LOGGING: number;
  51382. /**
  51383. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51384. */
  51385. static get ForceFullSceneLoadingForIncremental(): boolean;
  51386. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51387. /**
  51388. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51389. */
  51390. static get ShowLoadingScreen(): boolean;
  51391. static set ShowLoadingScreen(value: boolean);
  51392. /**
  51393. * Defines the current logging level (while loading the scene)
  51394. * @ignorenaming
  51395. */
  51396. static get loggingLevel(): number;
  51397. static set loggingLevel(value: number);
  51398. /**
  51399. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51400. */
  51401. static get CleanBoneMatrixWeights(): boolean;
  51402. static set CleanBoneMatrixWeights(value: boolean);
  51403. /**
  51404. * Event raised when a plugin is used to load a scene
  51405. */
  51406. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51407. private static _registeredPlugins;
  51408. private static _showingLoadingScreen;
  51409. /**
  51410. * Gets the default plugin (used to load Babylon files)
  51411. * @returns the .babylon plugin
  51412. */
  51413. static GetDefaultPlugin(): IRegisteredPlugin;
  51414. private static _GetPluginForExtension;
  51415. private static _GetPluginForDirectLoad;
  51416. private static _GetPluginForFilename;
  51417. private static _GetDirectLoad;
  51418. private static _LoadData;
  51419. private static _GetFileInfo;
  51420. /**
  51421. * Gets a plugin that can load the given extension
  51422. * @param extension defines the extension to load
  51423. * @returns a plugin or null if none works
  51424. */
  51425. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51426. /**
  51427. * Gets a boolean indicating that the given extension can be loaded
  51428. * @param extension defines the extension to load
  51429. * @returns true if the extension is supported
  51430. */
  51431. static IsPluginForExtensionAvailable(extension: string): boolean;
  51432. /**
  51433. * Adds a new plugin to the list of registered plugins
  51434. * @param plugin defines the plugin to add
  51435. */
  51436. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51437. /**
  51438. * Import meshes into a scene
  51439. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51440. * @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)
  51441. * @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)
  51442. * @param scene the instance of BABYLON.Scene to append to
  51443. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51444. * @param onProgress a callback with a progress event for each file being loaded
  51445. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51446. * @param pluginExtension the extension used to determine the plugin
  51447. * @returns The loaded plugin
  51448. */
  51449. 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>;
  51450. /**
  51451. * Import meshes into a scene
  51452. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51453. * @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)
  51454. * @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)
  51455. * @param scene the instance of BABYLON.Scene to append to
  51456. * @param onProgress a callback with a progress event for each file being loaded
  51457. * @param pluginExtension the extension used to determine the plugin
  51458. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51459. */
  51460. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51461. meshes: AbstractMesh[];
  51462. particleSystems: IParticleSystem[];
  51463. skeletons: Skeleton[];
  51464. animationGroups: AnimationGroup[];
  51465. }>;
  51466. /**
  51467. * Load a scene
  51468. * @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)
  51469. * @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)
  51470. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51471. * @param onSuccess a callback with the scene when import succeeds
  51472. * @param onProgress a callback with a progress event for each file being loaded
  51473. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51474. * @param pluginExtension the extension used to determine the plugin
  51475. * @returns The loaded plugin
  51476. */
  51477. 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>;
  51478. /**
  51479. * Load a scene
  51480. * @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)
  51481. * @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)
  51482. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51483. * @param onProgress a callback with a progress event for each file being loaded
  51484. * @param pluginExtension the extension used to determine the plugin
  51485. * @returns The loaded scene
  51486. */
  51487. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51488. /**
  51489. * Append a scene
  51490. * @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)
  51491. * @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)
  51492. * @param scene is the instance of BABYLON.Scene to append to
  51493. * @param onSuccess a callback with the scene when import succeeds
  51494. * @param onProgress a callback with a progress event for each file being loaded
  51495. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51496. * @param pluginExtension the extension used to determine the plugin
  51497. * @returns The loaded plugin
  51498. */
  51499. 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>;
  51500. /**
  51501. * Append a scene
  51502. * @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)
  51503. * @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)
  51504. * @param scene is the instance of BABYLON.Scene to append to
  51505. * @param onProgress a callback with a progress event for each file being loaded
  51506. * @param pluginExtension the extension used to determine the plugin
  51507. * @returns The given scene
  51508. */
  51509. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51510. /**
  51511. * Load a scene into an asset container
  51512. * @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)
  51513. * @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)
  51514. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51515. * @param onSuccess a callback with the scene when import succeeds
  51516. * @param onProgress a callback with a progress event for each file being loaded
  51517. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51518. * @param pluginExtension the extension used to determine the plugin
  51519. * @returns The loaded plugin
  51520. */
  51521. 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>;
  51522. /**
  51523. * Load a scene into an asset container
  51524. * @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)
  51525. * @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)
  51526. * @param scene is the instance of Scene to append to
  51527. * @param onProgress a callback with a progress event for each file being loaded
  51528. * @param pluginExtension the extension used to determine the plugin
  51529. * @returns The loaded asset container
  51530. */
  51531. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51532. /**
  51533. * Import animations from a file into a scene
  51534. * @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)
  51535. * @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)
  51536. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51537. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51538. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51539. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51540. * @param onSuccess a callback with the scene when import succeeds
  51541. * @param onProgress a callback with a progress event for each file being loaded
  51542. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51543. * @param pluginExtension the extension used to determine the plugin
  51544. */
  51545. 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;
  51546. /**
  51547. * Import animations from a file into a scene
  51548. * @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)
  51549. * @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)
  51550. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51551. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51552. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51553. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51554. * @param onSuccess a callback with the scene when import succeeds
  51555. * @param onProgress a callback with a progress event for each file being loaded
  51556. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51557. * @param pluginExtension the extension used to determine the plugin
  51558. * @returns the updated scene with imported animations
  51559. */
  51560. 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>;
  51561. }
  51562. }
  51563. declare module BABYLON {
  51564. /**
  51565. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51566. */
  51567. export type MotionControllerHandedness = "none" | "left" | "right";
  51568. /**
  51569. * The type of components available in motion controllers.
  51570. * This is not the name of the component.
  51571. */
  51572. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51573. /**
  51574. * The state of a controller component
  51575. */
  51576. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51577. /**
  51578. * The schema of motion controller layout.
  51579. * No object will be initialized using this interface
  51580. * This is used just to define the profile.
  51581. */
  51582. export interface IMotionControllerLayout {
  51583. /**
  51584. * Path to load the assets. Usually relative to the base path
  51585. */
  51586. assetPath: string;
  51587. /**
  51588. * Available components (unsorted)
  51589. */
  51590. components: {
  51591. /**
  51592. * A map of component Ids
  51593. */
  51594. [componentId: string]: {
  51595. /**
  51596. * The type of input the component outputs
  51597. */
  51598. type: MotionControllerComponentType;
  51599. /**
  51600. * The indices of this component in the gamepad object
  51601. */
  51602. gamepadIndices: {
  51603. /**
  51604. * Index of button
  51605. */
  51606. button?: number;
  51607. /**
  51608. * If available, index of x-axis
  51609. */
  51610. xAxis?: number;
  51611. /**
  51612. * If available, index of y-axis
  51613. */
  51614. yAxis?: number;
  51615. };
  51616. /**
  51617. * The mesh's root node name
  51618. */
  51619. rootNodeName: string;
  51620. /**
  51621. * Animation definitions for this model
  51622. */
  51623. visualResponses: {
  51624. [stateKey: string]: {
  51625. /**
  51626. * What property will be animated
  51627. */
  51628. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51629. /**
  51630. * What states influence this visual response
  51631. */
  51632. states: MotionControllerComponentStateType[];
  51633. /**
  51634. * Type of animation - movement or visibility
  51635. */
  51636. valueNodeProperty: "transform" | "visibility";
  51637. /**
  51638. * Base node name to move. Its position will be calculated according to the min and max nodes
  51639. */
  51640. valueNodeName?: string;
  51641. /**
  51642. * Minimum movement node
  51643. */
  51644. minNodeName?: string;
  51645. /**
  51646. * Max movement node
  51647. */
  51648. maxNodeName?: string;
  51649. };
  51650. };
  51651. /**
  51652. * If touch enabled, what is the name of node to display user feedback
  51653. */
  51654. touchPointNodeName?: string;
  51655. };
  51656. };
  51657. /**
  51658. * Is it xr standard mapping or not
  51659. */
  51660. gamepadMapping: "" | "xr-standard";
  51661. /**
  51662. * Base root node of this entire model
  51663. */
  51664. rootNodeName: string;
  51665. /**
  51666. * Defines the main button component id
  51667. */
  51668. selectComponentId: string;
  51669. }
  51670. /**
  51671. * A definition for the layout map in the input profile
  51672. */
  51673. export interface IMotionControllerLayoutMap {
  51674. /**
  51675. * Layouts with handedness type as a key
  51676. */
  51677. [handedness: string]: IMotionControllerLayout;
  51678. }
  51679. /**
  51680. * The XR Input profile schema
  51681. * Profiles can be found here:
  51682. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51683. */
  51684. export interface IMotionControllerProfile {
  51685. /**
  51686. * fallback profiles for this profileId
  51687. */
  51688. fallbackProfileIds: string[];
  51689. /**
  51690. * The layout map, with handedness as key
  51691. */
  51692. layouts: IMotionControllerLayoutMap;
  51693. /**
  51694. * The id of this profile
  51695. * correlates to the profile(s) in the xrInput.profiles array
  51696. */
  51697. profileId: string;
  51698. }
  51699. /**
  51700. * A helper-interface for the 3 meshes needed for controller button animation
  51701. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51702. */
  51703. export interface IMotionControllerButtonMeshMap {
  51704. /**
  51705. * the mesh that defines the pressed value mesh position.
  51706. * This is used to find the max-position of this button
  51707. */
  51708. pressedMesh: AbstractMesh;
  51709. /**
  51710. * the mesh that defines the unpressed value mesh position.
  51711. * This is used to find the min (or initial) position of this button
  51712. */
  51713. unpressedMesh: AbstractMesh;
  51714. /**
  51715. * The mesh that will be changed when value changes
  51716. */
  51717. valueMesh: AbstractMesh;
  51718. }
  51719. /**
  51720. * A helper-interface for the 3 meshes needed for controller axis animation.
  51721. * This will be expanded when touchpad animations are fully supported
  51722. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51723. */
  51724. export interface IMotionControllerMeshMap {
  51725. /**
  51726. * the mesh that defines the maximum value mesh position.
  51727. */
  51728. maxMesh?: AbstractMesh;
  51729. /**
  51730. * the mesh that defines the minimum value mesh position.
  51731. */
  51732. minMesh?: AbstractMesh;
  51733. /**
  51734. * The mesh that will be changed when axis value changes
  51735. */
  51736. valueMesh?: AbstractMesh;
  51737. }
  51738. /**
  51739. * The elements needed for change-detection of the gamepad objects in motion controllers
  51740. */
  51741. export interface IMinimalMotionControllerObject {
  51742. /**
  51743. * Available axes of this controller
  51744. */
  51745. axes: number[];
  51746. /**
  51747. * An array of available buttons
  51748. */
  51749. buttons: Array<{
  51750. /**
  51751. * Value of the button/trigger
  51752. */
  51753. value: number;
  51754. /**
  51755. * If the button/trigger is currently touched
  51756. */
  51757. touched: boolean;
  51758. /**
  51759. * If the button/trigger is currently pressed
  51760. */
  51761. pressed: boolean;
  51762. }>;
  51763. /**
  51764. * EXPERIMENTAL haptic support.
  51765. */
  51766. hapticActuators?: Array<{
  51767. pulse: (value: number, duration: number) => Promise<boolean>;
  51768. }>;
  51769. }
  51770. /**
  51771. * An Abstract Motion controller
  51772. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51773. * Each component has an observable to check for changes in value and state
  51774. */
  51775. export abstract class WebXRAbstractMotionController implements IDisposable {
  51776. protected scene: Scene;
  51777. protected layout: IMotionControllerLayout;
  51778. /**
  51779. * The gamepad object correlating to this controller
  51780. */
  51781. gamepadObject: IMinimalMotionControllerObject;
  51782. /**
  51783. * handedness (left/right/none) of this controller
  51784. */
  51785. handedness: MotionControllerHandedness;
  51786. private _initComponent;
  51787. private _modelReady;
  51788. /**
  51789. * A map of components (WebXRControllerComponent) in this motion controller
  51790. * Components have a ComponentType and can also have both button and axis definitions
  51791. */
  51792. readonly components: {
  51793. [id: string]: WebXRControllerComponent;
  51794. };
  51795. /**
  51796. * Disable the model's animation. Can be set at any time.
  51797. */
  51798. disableAnimation: boolean;
  51799. /**
  51800. * Observers registered here will be triggered when the model of this controller is done loading
  51801. */
  51802. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51803. /**
  51804. * The profile id of this motion controller
  51805. */
  51806. abstract profileId: string;
  51807. /**
  51808. * The root mesh of the model. It is null if the model was not yet initialized
  51809. */
  51810. rootMesh: Nullable<AbstractMesh>;
  51811. /**
  51812. * constructs a new abstract motion controller
  51813. * @param scene the scene to which the model of the controller will be added
  51814. * @param layout The profile layout to load
  51815. * @param gamepadObject The gamepad object correlating to this controller
  51816. * @param handedness handedness (left/right/none) of this controller
  51817. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51818. */
  51819. constructor(scene: Scene, layout: IMotionControllerLayout,
  51820. /**
  51821. * The gamepad object correlating to this controller
  51822. */
  51823. gamepadObject: IMinimalMotionControllerObject,
  51824. /**
  51825. * handedness (left/right/none) of this controller
  51826. */
  51827. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51828. /**
  51829. * Dispose this controller, the model mesh and all its components
  51830. */
  51831. dispose(): void;
  51832. /**
  51833. * Returns all components of specific type
  51834. * @param type the type to search for
  51835. * @return an array of components with this type
  51836. */
  51837. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51838. /**
  51839. * get a component based an its component id as defined in layout.components
  51840. * @param id the id of the component
  51841. * @returns the component correlates to the id or undefined if not found
  51842. */
  51843. getComponent(id: string): WebXRControllerComponent;
  51844. /**
  51845. * Get the list of components available in this motion controller
  51846. * @returns an array of strings correlating to available components
  51847. */
  51848. getComponentIds(): string[];
  51849. /**
  51850. * Get the first component of specific type
  51851. * @param type type of component to find
  51852. * @return a controller component or null if not found
  51853. */
  51854. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51855. /**
  51856. * Get the main (Select) component of this controller as defined in the layout
  51857. * @returns the main component of this controller
  51858. */
  51859. getMainComponent(): WebXRControllerComponent;
  51860. /**
  51861. * Loads the model correlating to this controller
  51862. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51863. * @returns A promise fulfilled with the result of the model loading
  51864. */
  51865. loadModel(): Promise<boolean>;
  51866. /**
  51867. * Update this model using the current XRFrame
  51868. * @param xrFrame the current xr frame to use and update the model
  51869. */
  51870. updateFromXRFrame(xrFrame: XRFrame): void;
  51871. /**
  51872. * Backwards compatibility due to a deeply-integrated typo
  51873. */
  51874. get handness(): XREye;
  51875. /**
  51876. * Pulse (vibrate) this controller
  51877. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51878. * Consecutive calls to this function will cancel the last pulse call
  51879. *
  51880. * @param value the strength of the pulse in 0.0...1.0 range
  51881. * @param duration Duration of the pulse in milliseconds
  51882. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51883. * @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
  51884. */
  51885. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51886. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51887. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51888. /**
  51889. * Moves the axis on the controller mesh based on its current state
  51890. * @param axis the index of the axis
  51891. * @param axisValue the value of the axis which determines the meshes new position
  51892. * @hidden
  51893. */
  51894. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51895. /**
  51896. * Update the model itself with the current frame data
  51897. * @param xrFrame the frame to use for updating the model mesh
  51898. */
  51899. protected updateModel(xrFrame: XRFrame): void;
  51900. /**
  51901. * Get the filename and path for this controller's model
  51902. * @returns a map of filename and path
  51903. */
  51904. protected abstract _getFilenameAndPath(): {
  51905. filename: string;
  51906. path: string;
  51907. };
  51908. /**
  51909. * This function is called before the mesh is loaded. It checks for loading constraints.
  51910. * For example, this function can check if the GLB loader is available
  51911. * If this function returns false, the generic controller will be loaded instead
  51912. * @returns Is the client ready to load the mesh
  51913. */
  51914. protected abstract _getModelLoadingConstraints(): boolean;
  51915. /**
  51916. * This function will be called after the model was successfully loaded and can be used
  51917. * for mesh transformations before it is available for the user
  51918. * @param meshes the loaded meshes
  51919. */
  51920. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51921. /**
  51922. * Set the root mesh for this controller. Important for the WebXR controller class
  51923. * @param meshes the loaded meshes
  51924. */
  51925. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51926. /**
  51927. * A function executed each frame that updates the mesh (if needed)
  51928. * @param xrFrame the current xrFrame
  51929. */
  51930. protected abstract _updateModel(xrFrame: XRFrame): void;
  51931. private _getGenericFilenameAndPath;
  51932. private _getGenericParentMesh;
  51933. }
  51934. }
  51935. declare module BABYLON {
  51936. /**
  51937. * A generic trigger-only motion controller for WebXR
  51938. */
  51939. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51940. /**
  51941. * Static version of the profile id of this controller
  51942. */
  51943. static ProfileId: string;
  51944. profileId: string;
  51945. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51946. protected _getFilenameAndPath(): {
  51947. filename: string;
  51948. path: string;
  51949. };
  51950. protected _getModelLoadingConstraints(): boolean;
  51951. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51952. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51953. protected _updateModel(): void;
  51954. }
  51955. }
  51956. declare module BABYLON {
  51957. /**
  51958. * Class containing static functions to help procedurally build meshes
  51959. */
  51960. export class SphereBuilder {
  51961. /**
  51962. * Creates a sphere mesh
  51963. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51964. * * 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`)
  51965. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51966. * * 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
  51967. * * 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)
  51968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51969. * * 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
  51970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51971. * @param name defines the name of the mesh
  51972. * @param options defines the options used to create the mesh
  51973. * @param scene defines the hosting scene
  51974. * @returns the sphere mesh
  51975. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51976. */
  51977. static CreateSphere(name: string, options: {
  51978. segments?: number;
  51979. diameter?: number;
  51980. diameterX?: number;
  51981. diameterY?: number;
  51982. diameterZ?: number;
  51983. arc?: number;
  51984. slice?: number;
  51985. sideOrientation?: number;
  51986. frontUVs?: Vector4;
  51987. backUVs?: Vector4;
  51988. updatable?: boolean;
  51989. }, scene?: Nullable<Scene>): Mesh;
  51990. }
  51991. }
  51992. declare module BABYLON {
  51993. /**
  51994. * A profiled motion controller has its profile loaded from an online repository.
  51995. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51996. */
  51997. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51998. private _repositoryUrl;
  51999. private _buttonMeshMapping;
  52000. private _touchDots;
  52001. /**
  52002. * The profile ID of this controller. Will be populated when the controller initializes.
  52003. */
  52004. profileId: string;
  52005. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52006. dispose(): void;
  52007. protected _getFilenameAndPath(): {
  52008. filename: string;
  52009. path: string;
  52010. };
  52011. protected _getModelLoadingConstraints(): boolean;
  52012. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52013. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52014. protected _updateModel(_xrFrame: XRFrame): void;
  52015. }
  52016. }
  52017. declare module BABYLON {
  52018. /**
  52019. * A construction function type to create a new controller based on an xrInput object
  52020. */
  52021. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52022. /**
  52023. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52024. *
  52025. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52026. * it should be replaced with auto-loaded controllers.
  52027. *
  52028. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52029. */
  52030. export class WebXRMotionControllerManager {
  52031. private static _AvailableControllers;
  52032. private static _Fallbacks;
  52033. private static _ProfileLoadingPromises;
  52034. private static _ProfilesList;
  52035. /**
  52036. * The base URL of the online controller repository. Can be changed at any time.
  52037. */
  52038. static BaseRepositoryUrl: string;
  52039. /**
  52040. * Which repository gets priority - local or online
  52041. */
  52042. static PrioritizeOnlineRepository: boolean;
  52043. /**
  52044. * Use the online repository, or use only locally-defined controllers
  52045. */
  52046. static UseOnlineRepository: boolean;
  52047. /**
  52048. * Clear the cache used for profile loading and reload when requested again
  52049. */
  52050. static ClearProfilesCache(): void;
  52051. /**
  52052. * Register the default fallbacks.
  52053. * This function is called automatically when this file is imported.
  52054. */
  52055. static DefaultFallbacks(): void;
  52056. /**
  52057. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52058. * @param profileId the profile to which a fallback needs to be found
  52059. * @return an array with corresponding fallback profiles
  52060. */
  52061. static FindFallbackWithProfileId(profileId: string): string[];
  52062. /**
  52063. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52064. * The order of search:
  52065. *
  52066. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52067. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52068. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52069. * 4) return the generic trigger controller if none were found
  52070. *
  52071. * @param xrInput the xrInput to which a new controller is initialized
  52072. * @param scene the scene to which the model will be added
  52073. * @param forceProfile force a certain profile for this controller
  52074. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52075. */
  52076. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52077. /**
  52078. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52079. *
  52080. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52081. *
  52082. * @param type the profile type to register
  52083. * @param constructFunction the function to be called when loading this profile
  52084. */
  52085. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52086. /**
  52087. * Register a fallback to a specific profile.
  52088. * @param profileId the profileId that will receive the fallbacks
  52089. * @param fallbacks A list of fallback profiles
  52090. */
  52091. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52092. /**
  52093. * Will update the list of profiles available in the repository
  52094. * @return a promise that resolves to a map of profiles available online
  52095. */
  52096. static UpdateProfilesList(): Promise<{
  52097. [profile: string]: string;
  52098. }>;
  52099. private static _LoadProfileFromRepository;
  52100. private static _LoadProfilesFromAvailableControllers;
  52101. }
  52102. }
  52103. declare module BABYLON {
  52104. /**
  52105. * Configuration options for the WebXR controller creation
  52106. */
  52107. export interface IWebXRControllerOptions {
  52108. /**
  52109. * Should the controller mesh be animated when a user interacts with it
  52110. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52111. */
  52112. disableMotionControllerAnimation?: boolean;
  52113. /**
  52114. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52115. */
  52116. doNotLoadControllerMesh?: boolean;
  52117. /**
  52118. * Force a specific controller type for this controller.
  52119. * This can be used when creating your own profile or when testing different controllers
  52120. */
  52121. forceControllerProfile?: string;
  52122. /**
  52123. * Defines a rendering group ID for meshes that will be loaded.
  52124. * This is for the default controllers only.
  52125. */
  52126. renderingGroupId?: number;
  52127. }
  52128. /**
  52129. * Represents an XR controller
  52130. */
  52131. export class WebXRInputSource {
  52132. private _scene;
  52133. /** The underlying input source for the controller */
  52134. inputSource: XRInputSource;
  52135. private _options;
  52136. private _tmpVector;
  52137. private _uniqueId;
  52138. private _disposed;
  52139. /**
  52140. * 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
  52141. */
  52142. grip?: AbstractMesh;
  52143. /**
  52144. * If available, this is the gamepad object related to this controller.
  52145. * Using this object it is possible to get click events and trackpad changes of the
  52146. * webxr controller that is currently being used.
  52147. */
  52148. motionController?: WebXRAbstractMotionController;
  52149. /**
  52150. * Event that fires when the controller is removed/disposed.
  52151. * The object provided as event data is this controller, after associated assets were disposed.
  52152. * uniqueId is still available.
  52153. */
  52154. onDisposeObservable: Observable<WebXRInputSource>;
  52155. /**
  52156. * Will be triggered when the mesh associated with the motion controller is done loading.
  52157. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52158. * A shortened version of controller -> motion controller -> on mesh loaded.
  52159. */
  52160. onMeshLoadedObservable: Observable<AbstractMesh>;
  52161. /**
  52162. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52163. */
  52164. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52165. /**
  52166. * Pointer which can be used to select objects or attach a visible laser to
  52167. */
  52168. pointer: AbstractMesh;
  52169. /**
  52170. * Creates the input source object
  52171. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52172. * @param _scene the scene which the controller should be associated to
  52173. * @param inputSource the underlying input source for the controller
  52174. * @param _options options for this controller creation
  52175. */
  52176. constructor(_scene: Scene,
  52177. /** The underlying input source for the controller */
  52178. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52179. /**
  52180. * Get this controllers unique id
  52181. */
  52182. get uniqueId(): string;
  52183. /**
  52184. * Disposes of the object
  52185. */
  52186. dispose(): void;
  52187. /**
  52188. * Gets a world space ray coming from the pointer or grip
  52189. * @param result the resulting ray
  52190. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52191. */
  52192. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52193. /**
  52194. * Updates the controller pose based on the given XRFrame
  52195. * @param xrFrame xr frame to update the pose with
  52196. * @param referenceSpace reference space to use
  52197. */
  52198. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52199. }
  52200. }
  52201. declare module BABYLON {
  52202. /**
  52203. * The schema for initialization options of the XR Input class
  52204. */
  52205. export interface IWebXRInputOptions {
  52206. /**
  52207. * If set to true no model will be automatically loaded
  52208. */
  52209. doNotLoadControllerMeshes?: boolean;
  52210. /**
  52211. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52212. * If not found, the xr input profile data will be used.
  52213. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52214. */
  52215. forceInputProfile?: string;
  52216. /**
  52217. * Do not send a request to the controller repository to load the profile.
  52218. *
  52219. * Instead, use the controllers available in babylon itself.
  52220. */
  52221. disableOnlineControllerRepository?: boolean;
  52222. /**
  52223. * A custom URL for the controllers repository
  52224. */
  52225. customControllersRepositoryURL?: string;
  52226. /**
  52227. * Should the controller model's components not move according to the user input
  52228. */
  52229. disableControllerAnimation?: boolean;
  52230. /**
  52231. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52232. */
  52233. controllerOptions?: IWebXRControllerOptions;
  52234. }
  52235. /**
  52236. * XR input used to track XR inputs such as controllers/rays
  52237. */
  52238. export class WebXRInput implements IDisposable {
  52239. /**
  52240. * the xr session manager for this session
  52241. */
  52242. xrSessionManager: WebXRSessionManager;
  52243. /**
  52244. * the WebXR camera for this session. Mainly used for teleportation
  52245. */
  52246. xrCamera: WebXRCamera;
  52247. private readonly options;
  52248. /**
  52249. * XR controllers being tracked
  52250. */
  52251. controllers: Array<WebXRInputSource>;
  52252. private _frameObserver;
  52253. private _sessionEndedObserver;
  52254. private _sessionInitObserver;
  52255. /**
  52256. * Event when a controller has been connected/added
  52257. */
  52258. onControllerAddedObservable: Observable<WebXRInputSource>;
  52259. /**
  52260. * Event when a controller has been removed/disconnected
  52261. */
  52262. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52263. /**
  52264. * Initializes the WebXRInput
  52265. * @param xrSessionManager the xr session manager for this session
  52266. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52267. * @param options = initialization options for this xr input
  52268. */
  52269. constructor(
  52270. /**
  52271. * the xr session manager for this session
  52272. */
  52273. xrSessionManager: WebXRSessionManager,
  52274. /**
  52275. * the WebXR camera for this session. Mainly used for teleportation
  52276. */
  52277. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52278. private _onInputSourcesChange;
  52279. private _addAndRemoveControllers;
  52280. /**
  52281. * Disposes of the object
  52282. */
  52283. dispose(): void;
  52284. }
  52285. }
  52286. declare module BABYLON {
  52287. /**
  52288. * This is the base class for all WebXR features.
  52289. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52290. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52291. */
  52292. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52293. protected _xrSessionManager: WebXRSessionManager;
  52294. private _attached;
  52295. private _removeOnDetach;
  52296. /**
  52297. * Is this feature disposed?
  52298. */
  52299. isDisposed: boolean;
  52300. /**
  52301. * Should auto-attach be disabled?
  52302. */
  52303. disableAutoAttach: boolean;
  52304. /**
  52305. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52306. */
  52307. xrNativeFeatureName: string;
  52308. /**
  52309. * Construct a new (abstract) WebXR feature
  52310. * @param _xrSessionManager the xr session manager for this feature
  52311. */
  52312. constructor(_xrSessionManager: WebXRSessionManager);
  52313. /**
  52314. * Is this feature attached
  52315. */
  52316. get attached(): boolean;
  52317. /**
  52318. * attach this feature
  52319. *
  52320. * @param force should attachment be forced (even when already attached)
  52321. * @returns true if successful, false is failed or already attached
  52322. */
  52323. attach(force?: boolean): boolean;
  52324. /**
  52325. * detach this feature.
  52326. *
  52327. * @returns true if successful, false if failed or already detached
  52328. */
  52329. detach(): boolean;
  52330. /**
  52331. * Dispose this feature and all of the resources attached
  52332. */
  52333. dispose(): void;
  52334. /**
  52335. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52336. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52337. *
  52338. * @returns whether or not the feature is compatible in this environment
  52339. */
  52340. isCompatible(): boolean;
  52341. /**
  52342. * This is used to register callbacks that will automatically be removed when detach is called.
  52343. * @param observable the observable to which the observer will be attached
  52344. * @param callback the callback to register
  52345. */
  52346. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52347. /**
  52348. * Code in this function will be executed on each xrFrame received from the browser.
  52349. * This function will not execute after the feature is detached.
  52350. * @param _xrFrame the current frame
  52351. */
  52352. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52353. }
  52354. }
  52355. declare module BABYLON {
  52356. /**
  52357. * Renders a layer on top of an existing scene
  52358. */
  52359. export class UtilityLayerRenderer implements IDisposable {
  52360. /** the original scene that will be rendered on top of */
  52361. originalScene: Scene;
  52362. private _pointerCaptures;
  52363. private _lastPointerEvents;
  52364. private static _DefaultUtilityLayer;
  52365. private static _DefaultKeepDepthUtilityLayer;
  52366. private _sharedGizmoLight;
  52367. private _renderCamera;
  52368. /**
  52369. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52370. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52371. * @returns the camera that is used when rendering the utility layer
  52372. */
  52373. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52374. /**
  52375. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52376. * @param cam the camera that should be used when rendering the utility layer
  52377. */
  52378. setRenderCamera(cam: Nullable<Camera>): void;
  52379. /**
  52380. * @hidden
  52381. * Light which used by gizmos to get light shading
  52382. */
  52383. _getSharedGizmoLight(): HemisphericLight;
  52384. /**
  52385. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52386. */
  52387. pickUtilitySceneFirst: boolean;
  52388. /**
  52389. * 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)
  52390. */
  52391. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52392. /**
  52393. * 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)
  52394. */
  52395. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52396. /**
  52397. * The scene that is rendered on top of the original scene
  52398. */
  52399. utilityLayerScene: Scene;
  52400. /**
  52401. * If the utility layer should automatically be rendered on top of existing scene
  52402. */
  52403. shouldRender: boolean;
  52404. /**
  52405. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52406. */
  52407. onlyCheckPointerDownEvents: boolean;
  52408. /**
  52409. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52410. */
  52411. processAllEvents: boolean;
  52412. /**
  52413. * Observable raised when the pointer move from the utility layer scene to the main scene
  52414. */
  52415. onPointerOutObservable: Observable<number>;
  52416. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52417. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52418. private _afterRenderObserver;
  52419. private _sceneDisposeObserver;
  52420. private _originalPointerObserver;
  52421. /**
  52422. * Instantiates a UtilityLayerRenderer
  52423. * @param originalScene the original scene that will be rendered on top of
  52424. * @param handleEvents boolean indicating if the utility layer should handle events
  52425. */
  52426. constructor(
  52427. /** the original scene that will be rendered on top of */
  52428. originalScene: Scene, handleEvents?: boolean);
  52429. private _notifyObservers;
  52430. /**
  52431. * Renders the utility layers scene on top of the original scene
  52432. */
  52433. render(): void;
  52434. /**
  52435. * Disposes of the renderer
  52436. */
  52437. dispose(): void;
  52438. private _updateCamera;
  52439. }
  52440. }
  52441. declare module BABYLON {
  52442. /**
  52443. * Options interface for the pointer selection module
  52444. */
  52445. export interface IWebXRControllerPointerSelectionOptions {
  52446. /**
  52447. * if provided, this scene will be used to render meshes.
  52448. */
  52449. customUtilityLayerScene?: Scene;
  52450. /**
  52451. * 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)
  52452. * If not disabled, the last picked point will be used to execute a pointer up event
  52453. * If disabled, pointer up event will be triggered right after the pointer down event.
  52454. * Used in screen and gaze target ray mode only
  52455. */
  52456. disablePointerUpOnTouchOut: boolean;
  52457. /**
  52458. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52459. */
  52460. forceGazeMode: boolean;
  52461. /**
  52462. * 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
  52463. * to start a new countdown to the pointer down event.
  52464. * Defaults to 1.
  52465. */
  52466. gazeModePointerMovedFactor?: number;
  52467. /**
  52468. * Different button type to use instead of the main component
  52469. */
  52470. overrideButtonId?: string;
  52471. /**
  52472. * use this rendering group id for the meshes (optional)
  52473. */
  52474. renderingGroupId?: number;
  52475. /**
  52476. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52477. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52478. * 3000 means 3 seconds between pointing at something and selecting it
  52479. */
  52480. timeToSelect?: number;
  52481. /**
  52482. * Should meshes created here be added to a utility layer or the main scene
  52483. */
  52484. useUtilityLayer?: boolean;
  52485. /**
  52486. * Optional WebXR camera to be used for gaze selection
  52487. */
  52488. gazeCamera?: WebXRCamera;
  52489. /**
  52490. * the xr input to use with this pointer selection
  52491. */
  52492. xrInput: WebXRInput;
  52493. /**
  52494. * Should the scene pointerX and pointerY update be disabled
  52495. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52496. * Disable in VR, if not needed.
  52497. * The first rig camera (left eye) will be used to calculate the projection
  52498. */
  52499. disableScenePointerVectorUpdate: boolean;
  52500. /**
  52501. * Enable pointer selection on all controllers instead of switching between them
  52502. */
  52503. enablePointerSelectionOnAllControllers?: boolean;
  52504. /**
  52505. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52506. * If switch is enabled, it will still allow the user to switch between the different controllers
  52507. */
  52508. preferredHandedness?: XRHandedness;
  52509. /**
  52510. * Disable switching the pointer selection from one controller to the other.
  52511. * 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
  52512. */
  52513. disableSwitchOnClick?: boolean;
  52514. /**
  52515. * The maximum distance of the pointer selection feature. Defaults to 100.
  52516. */
  52517. maxPointerDistance?: number;
  52518. }
  52519. /**
  52520. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52521. */
  52522. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52523. private readonly _options;
  52524. private static _idCounter;
  52525. private _attachController;
  52526. private _controllers;
  52527. private _scene;
  52528. private _tmpVectorForPickCompare;
  52529. private _attachedController;
  52530. /**
  52531. * The module's name
  52532. */
  52533. static readonly Name: string;
  52534. /**
  52535. * The (Babylon) version of this module.
  52536. * This is an integer representing the implementation version.
  52537. * This number does not correspond to the WebXR specs version
  52538. */
  52539. static readonly Version: number;
  52540. /**
  52541. * Disable lighting on the laser pointer (so it will always be visible)
  52542. */
  52543. disablePointerLighting: boolean;
  52544. /**
  52545. * Disable lighting on the selection mesh (so it will always be visible)
  52546. */
  52547. disableSelectionMeshLighting: boolean;
  52548. /**
  52549. * Should the laser pointer be displayed
  52550. */
  52551. displayLaserPointer: boolean;
  52552. /**
  52553. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52554. */
  52555. displaySelectionMesh: boolean;
  52556. /**
  52557. * This color will be set to the laser pointer when selection is triggered
  52558. */
  52559. laserPointerPickedColor: Color3;
  52560. /**
  52561. * Default color of the laser pointer
  52562. */
  52563. laserPointerDefaultColor: Color3;
  52564. /**
  52565. * default color of the selection ring
  52566. */
  52567. selectionMeshDefaultColor: Color3;
  52568. /**
  52569. * This color will be applied to the selection ring when selection is triggered
  52570. */
  52571. selectionMeshPickedColor: Color3;
  52572. /**
  52573. * Optional filter to be used for ray selection. This predicate shares behavior with
  52574. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52575. */
  52576. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52577. /**
  52578. * constructs a new background remover module
  52579. * @param _xrSessionManager the session manager for this module
  52580. * @param _options read-only options to be used in this module
  52581. */
  52582. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52583. /**
  52584. * attach this feature
  52585. * Will usually be called by the features manager
  52586. *
  52587. * @returns true if successful.
  52588. */
  52589. attach(): boolean;
  52590. /**
  52591. * detach this feature.
  52592. * Will usually be called by the features manager
  52593. *
  52594. * @returns true if successful.
  52595. */
  52596. detach(): boolean;
  52597. /**
  52598. * Will get the mesh under a specific pointer.
  52599. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52600. * @param controllerId the controllerId to check
  52601. * @returns The mesh under pointer or null if no mesh is under the pointer
  52602. */
  52603. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52604. /**
  52605. * Get the xr controller that correlates to the pointer id in the pointer event
  52606. *
  52607. * @param id the pointer id to search for
  52608. * @returns the controller that correlates to this id or null if not found
  52609. */
  52610. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52611. private _identityMatrix;
  52612. private _screenCoordinatesRef;
  52613. private _viewportRef;
  52614. protected _onXRFrame(_xrFrame: XRFrame): void;
  52615. private _attachGazeMode;
  52616. private _attachScreenRayMode;
  52617. private _attachTrackedPointerRayMode;
  52618. private _convertNormalToDirectionOfRay;
  52619. private _detachController;
  52620. private _generateNewMeshPair;
  52621. private _pickingMoved;
  52622. private _updatePointerDistance;
  52623. /** @hidden */
  52624. get lasterPointerDefaultColor(): Color3;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Button which can be used to enter a different mode of XR
  52630. */
  52631. export class WebXREnterExitUIButton {
  52632. /** button element */
  52633. element: HTMLElement;
  52634. /** XR initialization options for the button */
  52635. sessionMode: XRSessionMode;
  52636. /** Reference space type */
  52637. referenceSpaceType: XRReferenceSpaceType;
  52638. /**
  52639. * Creates a WebXREnterExitUIButton
  52640. * @param element button element
  52641. * @param sessionMode XR initialization session mode
  52642. * @param referenceSpaceType the type of reference space to be used
  52643. */
  52644. constructor(
  52645. /** button element */
  52646. element: HTMLElement,
  52647. /** XR initialization options for the button */
  52648. sessionMode: XRSessionMode,
  52649. /** Reference space type */
  52650. referenceSpaceType: XRReferenceSpaceType);
  52651. /**
  52652. * Extendable function which can be used to update the button's visuals when the state changes
  52653. * @param activeButton the current active button in the UI
  52654. */
  52655. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52656. }
  52657. /**
  52658. * Options to create the webXR UI
  52659. */
  52660. export class WebXREnterExitUIOptions {
  52661. /**
  52662. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52663. */
  52664. customButtons?: Array<WebXREnterExitUIButton>;
  52665. /**
  52666. * A reference space type to use when creating the default button.
  52667. * Default is local-floor
  52668. */
  52669. referenceSpaceType?: XRReferenceSpaceType;
  52670. /**
  52671. * Context to enter xr with
  52672. */
  52673. renderTarget?: Nullable<WebXRRenderTarget>;
  52674. /**
  52675. * A session mode to use when creating the default button.
  52676. * Default is immersive-vr
  52677. */
  52678. sessionMode?: XRSessionMode;
  52679. /**
  52680. * A list of optional features to init the session with
  52681. */
  52682. optionalFeatures?: string[];
  52683. /**
  52684. * A list of optional features to init the session with
  52685. */
  52686. requiredFeatures?: string[];
  52687. /**
  52688. * If defined, this function will be executed if the UI encounters an error when entering XR
  52689. */
  52690. onError?: (error: any) => void;
  52691. }
  52692. /**
  52693. * UI to allow the user to enter/exit XR mode
  52694. */
  52695. export class WebXREnterExitUI implements IDisposable {
  52696. private scene;
  52697. /** version of the options passed to this UI */
  52698. options: WebXREnterExitUIOptions;
  52699. private _activeButton;
  52700. private _buttons;
  52701. /**
  52702. * The HTML Div Element to which buttons are added.
  52703. */
  52704. readonly overlay: HTMLDivElement;
  52705. /**
  52706. * Fired every time the active button is changed.
  52707. *
  52708. * When xr is entered via a button that launches xr that button will be the callback parameter
  52709. *
  52710. * When exiting xr the callback parameter will be null)
  52711. */
  52712. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52713. /**
  52714. *
  52715. * @param scene babylon scene object to use
  52716. * @param options (read-only) version of the options passed to this UI
  52717. */
  52718. private constructor();
  52719. /**
  52720. * Creates UI to allow the user to enter/exit XR mode
  52721. * @param scene the scene to add the ui to
  52722. * @param helper the xr experience helper to enter/exit xr with
  52723. * @param options options to configure the UI
  52724. * @returns the created ui
  52725. */
  52726. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52727. /**
  52728. * Disposes of the XR UI component
  52729. */
  52730. dispose(): void;
  52731. private _updateButtons;
  52732. }
  52733. }
  52734. declare module BABYLON {
  52735. /**
  52736. * Class containing static functions to help procedurally build meshes
  52737. */
  52738. export class LinesBuilder {
  52739. /**
  52740. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52741. * * 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
  52742. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52743. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52744. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52745. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52746. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52747. * * 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
  52748. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52751. * @param name defines the name of the new line system
  52752. * @param options defines the options used to create the line system
  52753. * @param scene defines the hosting scene
  52754. * @returns a new line system mesh
  52755. */
  52756. static CreateLineSystem(name: string, options: {
  52757. lines: Vector3[][];
  52758. updatable?: boolean;
  52759. instance?: Nullable<LinesMesh>;
  52760. colors?: Nullable<Color4[][]>;
  52761. useVertexAlpha?: boolean;
  52762. }, scene: Nullable<Scene>): LinesMesh;
  52763. /**
  52764. * Creates a line mesh
  52765. * 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
  52766. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52767. * * The parameter `points` is an array successive Vector3
  52768. * * 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
  52769. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52770. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52771. * * When updating an instance, remember that only point positions can change, not the number of points
  52772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52773. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52774. * @param name defines the name of the new line system
  52775. * @param options defines the options used to create the line system
  52776. * @param scene defines the hosting scene
  52777. * @returns a new line mesh
  52778. */
  52779. static CreateLines(name: string, options: {
  52780. points: Vector3[];
  52781. updatable?: boolean;
  52782. instance?: Nullable<LinesMesh>;
  52783. colors?: Color4[];
  52784. useVertexAlpha?: boolean;
  52785. }, scene?: Nullable<Scene>): LinesMesh;
  52786. /**
  52787. * Creates a dashed line mesh
  52788. * * 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
  52789. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52790. * * The parameter `points` is an array successive Vector3
  52791. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52792. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52793. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52794. * * 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
  52795. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52796. * * When updating an instance, remember that only point positions can change, not the number of points
  52797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52798. * @param name defines the name of the mesh
  52799. * @param options defines the options used to create the mesh
  52800. * @param scene defines the hosting scene
  52801. * @returns the dashed line mesh
  52802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52803. */
  52804. static CreateDashedLines(name: string, options: {
  52805. points: Vector3[];
  52806. dashSize?: number;
  52807. gapSize?: number;
  52808. dashNb?: number;
  52809. updatable?: boolean;
  52810. instance?: LinesMesh;
  52811. useVertexAlpha?: boolean;
  52812. }, scene?: Nullable<Scene>): LinesMesh;
  52813. }
  52814. }
  52815. declare module BABYLON {
  52816. /**
  52817. * Construction options for a timer
  52818. */
  52819. export interface ITimerOptions<T> {
  52820. /**
  52821. * Time-to-end
  52822. */
  52823. timeout: number;
  52824. /**
  52825. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52826. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52827. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52828. */
  52829. contextObservable: Observable<T>;
  52830. /**
  52831. * Optional parameters when adding an observer to the observable
  52832. */
  52833. observableParameters?: {
  52834. mask?: number;
  52835. insertFirst?: boolean;
  52836. scope?: any;
  52837. };
  52838. /**
  52839. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52840. */
  52841. breakCondition?: (data?: ITimerData<T>) => boolean;
  52842. /**
  52843. * Will be triggered when the time condition has met
  52844. */
  52845. onEnded?: (data: ITimerData<any>) => void;
  52846. /**
  52847. * Will be triggered when the break condition has met (prematurely ended)
  52848. */
  52849. onAborted?: (data: ITimerData<any>) => void;
  52850. /**
  52851. * Optional function to execute on each tick (or count)
  52852. */
  52853. onTick?: (data: ITimerData<any>) => void;
  52854. }
  52855. /**
  52856. * An interface defining the data sent by the timer
  52857. */
  52858. export interface ITimerData<T> {
  52859. /**
  52860. * When did it start
  52861. */
  52862. startTime: number;
  52863. /**
  52864. * Time now
  52865. */
  52866. currentTime: number;
  52867. /**
  52868. * Time passed since started
  52869. */
  52870. deltaTime: number;
  52871. /**
  52872. * How much is completed, in [0.0...1.0].
  52873. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52874. */
  52875. completeRate: number;
  52876. /**
  52877. * What the registered observable sent in the last count
  52878. */
  52879. payload: T;
  52880. }
  52881. /**
  52882. * The current state of the timer
  52883. */
  52884. export enum TimerState {
  52885. /**
  52886. * Timer initialized, not yet started
  52887. */
  52888. INIT = 0,
  52889. /**
  52890. * Timer started and counting
  52891. */
  52892. STARTED = 1,
  52893. /**
  52894. * Timer ended (whether aborted or time reached)
  52895. */
  52896. ENDED = 2
  52897. }
  52898. /**
  52899. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52900. *
  52901. * @param options options with which to initialize this timer
  52902. */
  52903. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52904. /**
  52905. * An advanced implementation of a timer class
  52906. */
  52907. export class AdvancedTimer<T = any> implements IDisposable {
  52908. /**
  52909. * Will notify each time the timer calculates the remaining time
  52910. */
  52911. onEachCountObservable: Observable<ITimerData<T>>;
  52912. /**
  52913. * Will trigger when the timer was aborted due to the break condition
  52914. */
  52915. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52916. /**
  52917. * Will trigger when the timer ended successfully
  52918. */
  52919. onTimerEndedObservable: Observable<ITimerData<T>>;
  52920. /**
  52921. * Will trigger when the timer state has changed
  52922. */
  52923. onStateChangedObservable: Observable<TimerState>;
  52924. private _observer;
  52925. private _contextObservable;
  52926. private _observableParameters;
  52927. private _startTime;
  52928. private _timer;
  52929. private _state;
  52930. private _breakCondition;
  52931. private _timeToEnd;
  52932. private _breakOnNextTick;
  52933. /**
  52934. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52935. * @param options construction options for this advanced timer
  52936. */
  52937. constructor(options: ITimerOptions<T>);
  52938. /**
  52939. * set a breaking condition for this timer. Default is to never break during count
  52940. * @param predicate the new break condition. Returns true to break, false otherwise
  52941. */
  52942. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52943. /**
  52944. * Reset ALL associated observables in this advanced timer
  52945. */
  52946. clearObservables(): void;
  52947. /**
  52948. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52949. *
  52950. * @param timeToEnd how much time to measure until timer ended
  52951. */
  52952. start(timeToEnd?: number): void;
  52953. /**
  52954. * Will force a stop on the next tick.
  52955. */
  52956. stop(): void;
  52957. /**
  52958. * Dispose this timer, clearing all resources
  52959. */
  52960. dispose(): void;
  52961. private _setState;
  52962. private _tick;
  52963. private _stop;
  52964. }
  52965. }
  52966. declare module BABYLON {
  52967. /**
  52968. * The options container for the teleportation module
  52969. */
  52970. export interface IWebXRTeleportationOptions {
  52971. /**
  52972. * if provided, this scene will be used to render meshes.
  52973. */
  52974. customUtilityLayerScene?: Scene;
  52975. /**
  52976. * Values to configure the default target mesh
  52977. */
  52978. defaultTargetMeshOptions?: {
  52979. /**
  52980. * Fill color of the teleportation area
  52981. */
  52982. teleportationFillColor?: string;
  52983. /**
  52984. * Border color for the teleportation area
  52985. */
  52986. teleportationBorderColor?: string;
  52987. /**
  52988. * Disable the mesh's animation sequence
  52989. */
  52990. disableAnimation?: boolean;
  52991. /**
  52992. * Disable lighting on the material or the ring and arrow
  52993. */
  52994. disableLighting?: boolean;
  52995. /**
  52996. * Override the default material of the torus and arrow
  52997. */
  52998. torusArrowMaterial?: Material;
  52999. };
  53000. /**
  53001. * A list of meshes to use as floor meshes.
  53002. * Meshes can be added and removed after initializing the feature using the
  53003. * addFloorMesh and removeFloorMesh functions
  53004. * If empty, rotation will still work
  53005. */
  53006. floorMeshes?: AbstractMesh[];
  53007. /**
  53008. * use this rendering group id for the meshes (optional)
  53009. */
  53010. renderingGroupId?: number;
  53011. /**
  53012. * Should teleportation move only to snap points
  53013. */
  53014. snapPointsOnly?: boolean;
  53015. /**
  53016. * An array of points to which the teleportation will snap to.
  53017. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53018. */
  53019. snapPositions?: Vector3[];
  53020. /**
  53021. * How close should the teleportation ray be in order to snap to position.
  53022. * Default to 0.8 units (meters)
  53023. */
  53024. snapToPositionRadius?: number;
  53025. /**
  53026. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53027. * If you want to support rotation, make sure your mesh has a direction indicator.
  53028. *
  53029. * When left untouched, the default mesh will be initialized.
  53030. */
  53031. teleportationTargetMesh?: AbstractMesh;
  53032. /**
  53033. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53034. */
  53035. timeToTeleport?: number;
  53036. /**
  53037. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53038. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53039. */
  53040. useMainComponentOnly?: boolean;
  53041. /**
  53042. * Should meshes created here be added to a utility layer or the main scene
  53043. */
  53044. useUtilityLayer?: boolean;
  53045. /**
  53046. * Babylon XR Input class for controller
  53047. */
  53048. xrInput: WebXRInput;
  53049. /**
  53050. * Meshes that the teleportation ray cannot go through
  53051. */
  53052. pickBlockerMeshes?: AbstractMesh[];
  53053. }
  53054. /**
  53055. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53056. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53057. * the input of the attached controllers.
  53058. */
  53059. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53060. private _options;
  53061. private _controllers;
  53062. private _currentTeleportationControllerId;
  53063. private _floorMeshes;
  53064. private _quadraticBezierCurve;
  53065. private _selectionFeature;
  53066. private _snapToPositions;
  53067. private _snappedToPoint;
  53068. private _teleportationRingMaterial?;
  53069. private _tmpRay;
  53070. private _tmpVector;
  53071. private _tmpQuaternion;
  53072. /**
  53073. * The module's name
  53074. */
  53075. static readonly Name: string;
  53076. /**
  53077. * The (Babylon) version of this module.
  53078. * This is an integer representing the implementation version.
  53079. * This number does not correspond to the webxr specs version
  53080. */
  53081. static readonly Version: number;
  53082. /**
  53083. * Is movement backwards enabled
  53084. */
  53085. backwardsMovementEnabled: boolean;
  53086. /**
  53087. * Distance to travel when moving backwards
  53088. */
  53089. backwardsTeleportationDistance: number;
  53090. /**
  53091. * The distance from the user to the inspection point in the direction of the controller
  53092. * A higher number will allow the user to move further
  53093. * defaults to 5 (meters, in xr units)
  53094. */
  53095. parabolicCheckRadius: number;
  53096. /**
  53097. * Should the module support parabolic ray on top of direct ray
  53098. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53099. * Very helpful when moving between floors / different heights
  53100. */
  53101. parabolicRayEnabled: boolean;
  53102. /**
  53103. * How much rotation should be applied when rotating right and left
  53104. */
  53105. rotationAngle: number;
  53106. /**
  53107. * Is rotation enabled when moving forward?
  53108. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53109. */
  53110. rotationEnabled: boolean;
  53111. /**
  53112. * constructs a new anchor system
  53113. * @param _xrSessionManager an instance of WebXRSessionManager
  53114. * @param _options configuration object for this feature
  53115. */
  53116. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53117. /**
  53118. * Get the snapPointsOnly flag
  53119. */
  53120. get snapPointsOnly(): boolean;
  53121. /**
  53122. * Sets the snapPointsOnly flag
  53123. * @param snapToPoints should teleportation be exclusively to snap points
  53124. */
  53125. set snapPointsOnly(snapToPoints: boolean);
  53126. /**
  53127. * Add a new mesh to the floor meshes array
  53128. * @param mesh the mesh to use as floor mesh
  53129. */
  53130. addFloorMesh(mesh: AbstractMesh): void;
  53131. /**
  53132. * Add a new snap-to point to fix teleportation to this position
  53133. * @param newSnapPoint The new Snap-To point
  53134. */
  53135. addSnapPoint(newSnapPoint: Vector3): void;
  53136. attach(): boolean;
  53137. detach(): boolean;
  53138. dispose(): void;
  53139. /**
  53140. * Remove a mesh from the floor meshes array
  53141. * @param mesh the mesh to remove
  53142. */
  53143. removeFloorMesh(mesh: AbstractMesh): void;
  53144. /**
  53145. * Remove a mesh from the floor meshes array using its name
  53146. * @param name the mesh name to remove
  53147. */
  53148. removeFloorMeshByName(name: string): void;
  53149. /**
  53150. * 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
  53151. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53152. * @returns was the point found and removed or not
  53153. */
  53154. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53155. /**
  53156. * This function sets a selection feature that will be disabled when
  53157. * the forward ray is shown and will be reattached when hidden.
  53158. * This is used to remove the selection rays when moving.
  53159. * @param selectionFeature the feature to disable when forward movement is enabled
  53160. */
  53161. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53162. protected _onXRFrame(_xrFrame: XRFrame): void;
  53163. private _attachController;
  53164. private _createDefaultTargetMesh;
  53165. private _detachController;
  53166. private _findClosestSnapPointWithRadius;
  53167. private _setTargetMeshPosition;
  53168. private _setTargetMeshVisibility;
  53169. private _showParabolicPath;
  53170. private _teleportForward;
  53171. }
  53172. }
  53173. declare module BABYLON {
  53174. /**
  53175. * Options for the default xr helper
  53176. */
  53177. export class WebXRDefaultExperienceOptions {
  53178. /**
  53179. * Enable or disable default UI to enter XR
  53180. */
  53181. disableDefaultUI?: boolean;
  53182. /**
  53183. * Should teleportation not initialize. defaults to false.
  53184. */
  53185. disableTeleportation?: boolean;
  53186. /**
  53187. * Floor meshes that will be used for teleport
  53188. */
  53189. floorMeshes?: Array<AbstractMesh>;
  53190. /**
  53191. * If set to true, the first frame will not be used to reset position
  53192. * The first frame is mainly used when copying transformation from the old camera
  53193. * Mainly used in AR
  53194. */
  53195. ignoreNativeCameraTransformation?: boolean;
  53196. /**
  53197. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53198. */
  53199. inputOptions?: IWebXRInputOptions;
  53200. /**
  53201. * optional configuration for the output canvas
  53202. */
  53203. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53204. /**
  53205. * optional UI options. This can be used among other to change session mode and reference space type
  53206. */
  53207. uiOptions?: WebXREnterExitUIOptions;
  53208. /**
  53209. * When loading teleportation and pointer select, use stable versions instead of latest.
  53210. */
  53211. useStablePlugins?: boolean;
  53212. /**
  53213. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53214. */
  53215. renderingGroupId?: number;
  53216. /**
  53217. * A list of optional features to init the session with
  53218. * If set to true, all features we support will be added
  53219. */
  53220. optionalFeatures?: boolean | string[];
  53221. }
  53222. /**
  53223. * Default experience which provides a similar setup to the previous webVRExperience
  53224. */
  53225. export class WebXRDefaultExperience {
  53226. /**
  53227. * Base experience
  53228. */
  53229. baseExperience: WebXRExperienceHelper;
  53230. /**
  53231. * Enables ui for entering/exiting xr
  53232. */
  53233. enterExitUI: WebXREnterExitUI;
  53234. /**
  53235. * Input experience extension
  53236. */
  53237. input: WebXRInput;
  53238. /**
  53239. * Enables laser pointer and selection
  53240. */
  53241. pointerSelection: WebXRControllerPointerSelection;
  53242. /**
  53243. * Default target xr should render to
  53244. */
  53245. renderTarget: WebXRRenderTarget;
  53246. /**
  53247. * Enables teleportation
  53248. */
  53249. teleportation: WebXRMotionControllerTeleportation;
  53250. private constructor();
  53251. /**
  53252. * Creates the default xr experience
  53253. * @param scene scene
  53254. * @param options options for basic configuration
  53255. * @returns resulting WebXRDefaultExperience
  53256. */
  53257. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53258. /**
  53259. * DIsposes of the experience helper
  53260. */
  53261. dispose(): void;
  53262. }
  53263. }
  53264. declare module BABYLON {
  53265. /**
  53266. * Options to modify the vr teleportation behavior.
  53267. */
  53268. export interface VRTeleportationOptions {
  53269. /**
  53270. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53271. */
  53272. floorMeshName?: string;
  53273. /**
  53274. * A list of meshes to be used as the teleportation floor. (default: empty)
  53275. */
  53276. floorMeshes?: Mesh[];
  53277. /**
  53278. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53279. */
  53280. teleportationMode?: number;
  53281. /**
  53282. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53283. */
  53284. teleportationTime?: number;
  53285. /**
  53286. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53287. */
  53288. teleportationSpeed?: number;
  53289. /**
  53290. * The easing function used in the animation or null for Linear. (default CircleEase)
  53291. */
  53292. easingFunction?: EasingFunction;
  53293. }
  53294. /**
  53295. * Options to modify the vr experience helper's behavior.
  53296. */
  53297. export interface VRExperienceHelperOptions extends WebVROptions {
  53298. /**
  53299. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53300. */
  53301. createDeviceOrientationCamera?: boolean;
  53302. /**
  53303. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53304. */
  53305. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53306. /**
  53307. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53308. */
  53309. laserToggle?: boolean;
  53310. /**
  53311. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53312. */
  53313. floorMeshes?: Mesh[];
  53314. /**
  53315. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53316. */
  53317. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53318. /**
  53319. * Defines if WebXR should be used instead of WebVR (if available)
  53320. */
  53321. useXR?: boolean;
  53322. }
  53323. /**
  53324. * Event containing information after VR has been entered
  53325. */
  53326. export class OnAfterEnteringVRObservableEvent {
  53327. /**
  53328. * If entering vr was successful
  53329. */
  53330. success: boolean;
  53331. }
  53332. /**
  53333. * Helps to quickly add VR support to an existing scene.
  53334. * See https://doc.babylonjs.com/how_to/webvr_helper
  53335. */
  53336. export class VRExperienceHelper {
  53337. /** Options to modify the vr experience helper's behavior. */
  53338. webVROptions: VRExperienceHelperOptions;
  53339. private _scene;
  53340. private _position;
  53341. private _btnVR;
  53342. private _btnVRDisplayed;
  53343. private _webVRsupported;
  53344. private _webVRready;
  53345. private _webVRrequesting;
  53346. private _webVRpresenting;
  53347. private _hasEnteredVR;
  53348. private _fullscreenVRpresenting;
  53349. private _inputElement;
  53350. private _webVRCamera;
  53351. private _vrDeviceOrientationCamera;
  53352. private _deviceOrientationCamera;
  53353. private _existingCamera;
  53354. private _onKeyDown;
  53355. private _onVrDisplayPresentChange;
  53356. private _onVRDisplayChanged;
  53357. private _onVRRequestPresentStart;
  53358. private _onVRRequestPresentComplete;
  53359. /**
  53360. * 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)
  53361. */
  53362. enableGazeEvenWhenNoPointerLock: boolean;
  53363. /**
  53364. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53365. */
  53366. exitVROnDoubleTap: boolean;
  53367. /**
  53368. * Observable raised right before entering VR.
  53369. */
  53370. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53371. /**
  53372. * Observable raised when entering VR has completed.
  53373. */
  53374. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53375. /**
  53376. * Observable raised when exiting VR.
  53377. */
  53378. onExitingVRObservable: Observable<VRExperienceHelper>;
  53379. /**
  53380. * Observable raised when controller mesh is loaded.
  53381. */
  53382. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53383. /** Return this.onEnteringVRObservable
  53384. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53385. */
  53386. get onEnteringVR(): Observable<VRExperienceHelper>;
  53387. /** Return this.onExitingVRObservable
  53388. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53389. */
  53390. get onExitingVR(): Observable<VRExperienceHelper>;
  53391. /** Return this.onControllerMeshLoadedObservable
  53392. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53393. */
  53394. get onControllerMeshLoaded(): Observable<WebVRController>;
  53395. private _rayLength;
  53396. private _useCustomVRButton;
  53397. private _teleportationRequested;
  53398. private _teleportActive;
  53399. private _floorMeshName;
  53400. private _floorMeshesCollection;
  53401. private _teleportationMode;
  53402. private _teleportationTime;
  53403. private _teleportationSpeed;
  53404. private _teleportationEasing;
  53405. private _rotationAllowed;
  53406. private _teleportBackwardsVector;
  53407. private _teleportationTarget;
  53408. private _isDefaultTeleportationTarget;
  53409. private _postProcessMove;
  53410. private _teleportationFillColor;
  53411. private _teleportationBorderColor;
  53412. private _rotationAngle;
  53413. private _haloCenter;
  53414. private _cameraGazer;
  53415. private _padSensibilityUp;
  53416. private _padSensibilityDown;
  53417. private _leftController;
  53418. private _rightController;
  53419. private _gazeColor;
  53420. private _laserColor;
  53421. private _pickedLaserColor;
  53422. private _pickedGazeColor;
  53423. /**
  53424. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53425. */
  53426. onNewMeshSelected: Observable<AbstractMesh>;
  53427. /**
  53428. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53429. * This observable will provide the mesh and the controller used to select the mesh
  53430. */
  53431. onMeshSelectedWithController: Observable<{
  53432. mesh: AbstractMesh;
  53433. controller: WebVRController;
  53434. }>;
  53435. /**
  53436. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53437. */
  53438. onNewMeshPicked: Observable<PickingInfo>;
  53439. private _circleEase;
  53440. /**
  53441. * Observable raised before camera teleportation
  53442. */
  53443. onBeforeCameraTeleport: Observable<Vector3>;
  53444. /**
  53445. * Observable raised after camera teleportation
  53446. */
  53447. onAfterCameraTeleport: Observable<Vector3>;
  53448. /**
  53449. * Observable raised when current selected mesh gets unselected
  53450. */
  53451. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53452. private _raySelectionPredicate;
  53453. /**
  53454. * To be optionaly changed by user to define custom ray selection
  53455. */
  53456. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53457. /**
  53458. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53459. */
  53460. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53461. /**
  53462. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53463. */
  53464. teleportationEnabled: boolean;
  53465. private _defaultHeight;
  53466. private _teleportationInitialized;
  53467. private _interactionsEnabled;
  53468. private _interactionsRequested;
  53469. private _displayGaze;
  53470. private _displayLaserPointer;
  53471. /**
  53472. * The mesh used to display where the user is going to teleport.
  53473. */
  53474. get teleportationTarget(): Mesh;
  53475. /**
  53476. * Sets the mesh to be used to display where the user is going to teleport.
  53477. */
  53478. set teleportationTarget(value: Mesh);
  53479. /**
  53480. * 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
  53481. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53482. * See https://doc.babylonjs.com/resources/baking_transformations
  53483. */
  53484. get gazeTrackerMesh(): Mesh;
  53485. set gazeTrackerMesh(value: Mesh);
  53486. /**
  53487. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53488. */
  53489. updateGazeTrackerScale: boolean;
  53490. /**
  53491. * If the gaze trackers color should be updated when selecting meshes
  53492. */
  53493. updateGazeTrackerColor: boolean;
  53494. /**
  53495. * If the controller laser color should be updated when selecting meshes
  53496. */
  53497. updateControllerLaserColor: boolean;
  53498. /**
  53499. * The gaze tracking mesh corresponding to the left controller
  53500. */
  53501. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53502. /**
  53503. * The gaze tracking mesh corresponding to the right controller
  53504. */
  53505. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53506. /**
  53507. * If the ray of the gaze should be displayed.
  53508. */
  53509. get displayGaze(): boolean;
  53510. /**
  53511. * Sets if the ray of the gaze should be displayed.
  53512. */
  53513. set displayGaze(value: boolean);
  53514. /**
  53515. * If the ray of the LaserPointer should be displayed.
  53516. */
  53517. get displayLaserPointer(): boolean;
  53518. /**
  53519. * Sets if the ray of the LaserPointer should be displayed.
  53520. */
  53521. set displayLaserPointer(value: boolean);
  53522. /**
  53523. * The deviceOrientationCamera used as the camera when not in VR.
  53524. */
  53525. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53526. /**
  53527. * Based on the current WebVR support, returns the current VR camera used.
  53528. */
  53529. get currentVRCamera(): Nullable<Camera>;
  53530. /**
  53531. * The webVRCamera which is used when in VR.
  53532. */
  53533. get webVRCamera(): WebVRFreeCamera;
  53534. /**
  53535. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53536. */
  53537. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53538. /**
  53539. * The html button that is used to trigger entering into VR.
  53540. */
  53541. get vrButton(): Nullable<HTMLButtonElement>;
  53542. private get _teleportationRequestInitiated();
  53543. /**
  53544. * Defines whether or not Pointer lock should be requested when switching to
  53545. * full screen.
  53546. */
  53547. requestPointerLockOnFullScreen: boolean;
  53548. /**
  53549. * If asking to force XR, this will be populated with the default xr experience
  53550. */
  53551. xr: WebXRDefaultExperience;
  53552. /**
  53553. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53554. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53555. */
  53556. xrTestDone: boolean;
  53557. /**
  53558. * Instantiates a VRExperienceHelper.
  53559. * Helps to quickly add VR support to an existing scene.
  53560. * @param scene The scene the VRExperienceHelper belongs to.
  53561. * @param webVROptions Options to modify the vr experience helper's behavior.
  53562. */
  53563. constructor(scene: Scene,
  53564. /** Options to modify the vr experience helper's behavior. */
  53565. webVROptions?: VRExperienceHelperOptions);
  53566. private completeVRInit;
  53567. private _onDefaultMeshLoaded;
  53568. private _onResize;
  53569. private _onFullscreenChange;
  53570. /**
  53571. * Gets a value indicating if we are currently in VR mode.
  53572. */
  53573. get isInVRMode(): boolean;
  53574. private onVrDisplayPresentChange;
  53575. private onVRDisplayChanged;
  53576. private moveButtonToBottomRight;
  53577. private displayVRButton;
  53578. private updateButtonVisibility;
  53579. private _cachedAngularSensibility;
  53580. /**
  53581. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53582. * Otherwise, will use the fullscreen API.
  53583. */
  53584. enterVR(): void;
  53585. /**
  53586. * Attempt to exit VR, or fullscreen.
  53587. */
  53588. exitVR(): void;
  53589. /**
  53590. * The position of the vr experience helper.
  53591. */
  53592. get position(): Vector3;
  53593. /**
  53594. * Sets the position of the vr experience helper.
  53595. */
  53596. set position(value: Vector3);
  53597. /**
  53598. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53599. */
  53600. enableInteractions(): void;
  53601. private get _noControllerIsActive();
  53602. private beforeRender;
  53603. private _isTeleportationFloor;
  53604. /**
  53605. * Adds a floor mesh to be used for teleportation.
  53606. * @param floorMesh the mesh to be used for teleportation.
  53607. */
  53608. addFloorMesh(floorMesh: Mesh): void;
  53609. /**
  53610. * Removes a floor mesh from being used for teleportation.
  53611. * @param floorMesh the mesh to be removed.
  53612. */
  53613. removeFloorMesh(floorMesh: Mesh): void;
  53614. /**
  53615. * Enables interactions and teleportation using the VR controllers and gaze.
  53616. * @param vrTeleportationOptions options to modify teleportation behavior.
  53617. */
  53618. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53619. private _onNewGamepadConnected;
  53620. private _tryEnableInteractionOnController;
  53621. private _onNewGamepadDisconnected;
  53622. private _enableInteractionOnController;
  53623. private _checkTeleportWithRay;
  53624. private _checkRotate;
  53625. private _checkTeleportBackwards;
  53626. private _enableTeleportationOnController;
  53627. private _createTeleportationCircles;
  53628. private _displayTeleportationTarget;
  53629. private _hideTeleportationTarget;
  53630. private _rotateCamera;
  53631. private _moveTeleportationSelectorTo;
  53632. private _workingVector;
  53633. private _workingQuaternion;
  53634. private _workingMatrix;
  53635. /**
  53636. * Time Constant Teleportation Mode
  53637. */
  53638. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53639. /**
  53640. * Speed Constant Teleportation Mode
  53641. */
  53642. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53643. /**
  53644. * Teleports the users feet to the desired location
  53645. * @param location The location where the user's feet should be placed
  53646. */
  53647. teleportCamera(location: Vector3): void;
  53648. private _convertNormalToDirectionOfRay;
  53649. private _castRayAndSelectObject;
  53650. private _notifySelectedMeshUnselected;
  53651. /**
  53652. * Permanently set new colors for the laser pointer
  53653. * @param color the new laser color
  53654. * @param pickedColor the new laser color when picked mesh detected
  53655. */
  53656. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53657. /**
  53658. * Set lighting enabled / disabled on the laser pointer of both controllers
  53659. * @param enabled should the lighting be enabled on the laser pointer
  53660. */
  53661. setLaserLightingState(enabled?: boolean): void;
  53662. /**
  53663. * Permanently set new colors for the gaze pointer
  53664. * @param color the new gaze color
  53665. * @param pickedColor the new gaze color when picked mesh detected
  53666. */
  53667. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53668. /**
  53669. * Sets the color of the laser ray from the vr controllers.
  53670. * @param color new color for the ray.
  53671. */
  53672. changeLaserColor(color: Color3): void;
  53673. /**
  53674. * Sets the color of the ray from the vr headsets gaze.
  53675. * @param color new color for the ray.
  53676. */
  53677. changeGazeColor(color: Color3): void;
  53678. /**
  53679. * Exits VR and disposes of the vr experience helper
  53680. */
  53681. dispose(): void;
  53682. /**
  53683. * Gets the name of the VRExperienceHelper class
  53684. * @returns "VRExperienceHelper"
  53685. */
  53686. getClassName(): string;
  53687. }
  53688. }
  53689. declare module BABYLON {
  53690. /**
  53691. * Contains an array of blocks representing the octree
  53692. */
  53693. export interface IOctreeContainer<T> {
  53694. /**
  53695. * Blocks within the octree
  53696. */
  53697. blocks: Array<OctreeBlock<T>>;
  53698. }
  53699. /**
  53700. * Class used to store a cell in an octree
  53701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53702. */
  53703. export class OctreeBlock<T> {
  53704. /**
  53705. * Gets the content of the current block
  53706. */
  53707. entries: T[];
  53708. /**
  53709. * Gets the list of block children
  53710. */
  53711. blocks: Array<OctreeBlock<T>>;
  53712. private _depth;
  53713. private _maxDepth;
  53714. private _capacity;
  53715. private _minPoint;
  53716. private _maxPoint;
  53717. private _boundingVectors;
  53718. private _creationFunc;
  53719. /**
  53720. * Creates a new block
  53721. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53722. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53723. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53724. * @param depth defines the current depth of this block in the octree
  53725. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53726. * @param creationFunc defines a callback to call when an element is added to the block
  53727. */
  53728. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53729. /**
  53730. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53731. */
  53732. get capacity(): number;
  53733. /**
  53734. * Gets the minimum vector (in world space) of the block's bounding box
  53735. */
  53736. get minPoint(): Vector3;
  53737. /**
  53738. * Gets the maximum vector (in world space) of the block's bounding box
  53739. */
  53740. get maxPoint(): Vector3;
  53741. /**
  53742. * Add a new element to this block
  53743. * @param entry defines the element to add
  53744. */
  53745. addEntry(entry: T): void;
  53746. /**
  53747. * Remove an element from this block
  53748. * @param entry defines the element to remove
  53749. */
  53750. removeEntry(entry: T): void;
  53751. /**
  53752. * Add an array of elements to this block
  53753. * @param entries defines the array of elements to add
  53754. */
  53755. addEntries(entries: T[]): void;
  53756. /**
  53757. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53758. * @param frustumPlanes defines the frustum planes to test
  53759. * @param selection defines the array to store current content if selection is positive
  53760. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53761. */
  53762. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53763. /**
  53764. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53765. * @param sphereCenter defines the bounding sphere center
  53766. * @param sphereRadius defines the bounding sphere radius
  53767. * @param selection defines the array to store current content if selection is positive
  53768. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53769. */
  53770. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53771. /**
  53772. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53773. * @param ray defines the ray to test with
  53774. * @param selection defines the array to store current content if selection is positive
  53775. */
  53776. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53777. /**
  53778. * Subdivide the content into child blocks (this block will then be empty)
  53779. */
  53780. createInnerBlocks(): void;
  53781. /**
  53782. * @hidden
  53783. */
  53784. 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;
  53785. }
  53786. }
  53787. declare module BABYLON {
  53788. /**
  53789. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53790. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53791. */
  53792. export class Octree<T> {
  53793. /** 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.) */
  53794. maxDepth: number;
  53795. /**
  53796. * Blocks within the octree containing objects
  53797. */
  53798. blocks: Array<OctreeBlock<T>>;
  53799. /**
  53800. * Content stored in the octree
  53801. */
  53802. dynamicContent: T[];
  53803. private _maxBlockCapacity;
  53804. private _selectionContent;
  53805. private _creationFunc;
  53806. /**
  53807. * Creates a octree
  53808. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53809. * @param creationFunc function to be used to instatiate the octree
  53810. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53811. * @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.)
  53812. */
  53813. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53814. /** 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.) */
  53815. maxDepth?: number);
  53816. /**
  53817. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53818. * @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);
  53819. * @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);
  53820. * @param entries meshes to be added to the octree blocks
  53821. */
  53822. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53823. /**
  53824. * Adds a mesh to the octree
  53825. * @param entry Mesh to add to the octree
  53826. */
  53827. addMesh(entry: T): void;
  53828. /**
  53829. * Remove an element from the octree
  53830. * @param entry defines the element to remove
  53831. */
  53832. removeMesh(entry: T): void;
  53833. /**
  53834. * Selects an array of meshes within the frustum
  53835. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53836. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53837. * @returns array of meshes within the frustum
  53838. */
  53839. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53840. /**
  53841. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53842. * @param sphereCenter defines the bounding sphere center
  53843. * @param sphereRadius defines the bounding sphere radius
  53844. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53845. * @returns an array of objects that intersect the sphere
  53846. */
  53847. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53848. /**
  53849. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53850. * @param ray defines the ray to test with
  53851. * @returns array of intersected objects
  53852. */
  53853. intersectsRay(ray: Ray): SmartArray<T>;
  53854. /**
  53855. * Adds a mesh into the octree block if it intersects the block
  53856. */
  53857. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53858. /**
  53859. * Adds a submesh into the octree block if it intersects the block
  53860. */
  53861. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53862. }
  53863. }
  53864. declare module BABYLON {
  53865. interface Scene {
  53866. /**
  53867. * @hidden
  53868. * Backing Filed
  53869. */
  53870. _selectionOctree: Octree<AbstractMesh>;
  53871. /**
  53872. * Gets the octree used to boost mesh selection (picking)
  53873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53874. */
  53875. selectionOctree: Octree<AbstractMesh>;
  53876. /**
  53877. * Creates or updates the octree used to boost selection (picking)
  53878. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53879. * @param maxCapacity defines the maximum capacity per leaf
  53880. * @param maxDepth defines the maximum depth of the octree
  53881. * @returns an octree of AbstractMesh
  53882. */
  53883. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53884. }
  53885. interface AbstractMesh {
  53886. /**
  53887. * @hidden
  53888. * Backing Field
  53889. */
  53890. _submeshesOctree: Octree<SubMesh>;
  53891. /**
  53892. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53893. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53894. * @param maxCapacity defines the maximum size of each block (64 by default)
  53895. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53896. * @returns the new octree
  53897. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53898. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53899. */
  53900. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53901. }
  53902. /**
  53903. * Defines the octree scene component responsible to manage any octrees
  53904. * in a given scene.
  53905. */
  53906. export class OctreeSceneComponent {
  53907. /**
  53908. * The component name help to identify the component in the list of scene components.
  53909. */
  53910. readonly name: string;
  53911. /**
  53912. * The scene the component belongs to.
  53913. */
  53914. scene: Scene;
  53915. /**
  53916. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53917. */
  53918. readonly checksIsEnabled: boolean;
  53919. /**
  53920. * Creates a new instance of the component for the given scene
  53921. * @param scene Defines the scene to register the component in
  53922. */
  53923. constructor(scene: Scene);
  53924. /**
  53925. * Registers the component in a given scene
  53926. */
  53927. register(): void;
  53928. /**
  53929. * Return the list of active meshes
  53930. * @returns the list of active meshes
  53931. */
  53932. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53933. /**
  53934. * Return the list of active sub meshes
  53935. * @param mesh The mesh to get the candidates sub meshes from
  53936. * @returns the list of active sub meshes
  53937. */
  53938. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53939. private _tempRay;
  53940. /**
  53941. * Return the list of sub meshes intersecting with a given local ray
  53942. * @param mesh defines the mesh to find the submesh for
  53943. * @param localRay defines the ray in local space
  53944. * @returns the list of intersecting sub meshes
  53945. */
  53946. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53947. /**
  53948. * Return the list of sub meshes colliding with a collider
  53949. * @param mesh defines the mesh to find the submesh for
  53950. * @param collider defines the collider to evaluate the collision against
  53951. * @returns the list of colliding sub meshes
  53952. */
  53953. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53954. /**
  53955. * Rebuilds the elements related to this component in case of
  53956. * context lost for instance.
  53957. */
  53958. rebuild(): void;
  53959. /**
  53960. * Disposes the component and the associated ressources.
  53961. */
  53962. dispose(): void;
  53963. }
  53964. }
  53965. declare module BABYLON {
  53966. /**
  53967. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  53968. */
  53969. export interface GizmoAxisCache {
  53970. /** Mesh used to runder the Gizmo */
  53971. gizmoMeshes: Mesh[];
  53972. /** Mesh used to detect user interaction with Gizmo */
  53973. colliderMeshes: Mesh[];
  53974. /** Material used to inicate color of gizmo mesh */
  53975. material: StandardMaterial;
  53976. /** Material used to inicate hover state of the Gizmo */
  53977. hoverMaterial: StandardMaterial;
  53978. /** Material used to inicate disabled state of the Gizmo */
  53979. disableMaterial: StandardMaterial;
  53980. /** Used to indicate Active state of the Gizmo */
  53981. active: boolean;
  53982. }
  53983. /**
  53984. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53985. */
  53986. export class Gizmo implements IDisposable {
  53987. /** The utility layer the gizmo will be added to */
  53988. gizmoLayer: UtilityLayerRenderer;
  53989. /**
  53990. * The root mesh of the gizmo
  53991. */
  53992. _rootMesh: Mesh;
  53993. private _attachedMesh;
  53994. private _attachedNode;
  53995. /**
  53996. * Ratio for the scale of the gizmo (Default: 1)
  53997. */
  53998. protected _scaleRatio: number;
  53999. /**
  54000. * boolean updated by pointermove when a gizmo mesh is hovered
  54001. */
  54002. protected _isHovered: boolean;
  54003. /**
  54004. * Ratio for the scale of the gizmo (Default: 1)
  54005. */
  54006. set scaleRatio(value: number);
  54007. get scaleRatio(): number;
  54008. /**
  54009. * True when the mouse pointer is hovered a gizmo mesh
  54010. */
  54011. get isHovered(): boolean;
  54012. /**
  54013. * If a custom mesh has been set (Default: false)
  54014. */
  54015. protected _customMeshSet: boolean;
  54016. /**
  54017. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54018. * * When set, interactions will be enabled
  54019. */
  54020. get attachedMesh(): Nullable<AbstractMesh>;
  54021. set attachedMesh(value: Nullable<AbstractMesh>);
  54022. /**
  54023. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54024. * * When set, interactions will be enabled
  54025. */
  54026. get attachedNode(): Nullable<Node>;
  54027. set attachedNode(value: Nullable<Node>);
  54028. /**
  54029. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54030. * @param mesh The mesh to replace the default mesh of the gizmo
  54031. */
  54032. setCustomMesh(mesh: Mesh): void;
  54033. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54034. /**
  54035. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54036. */
  54037. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54038. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54039. /**
  54040. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54041. */
  54042. updateGizmoPositionToMatchAttachedMesh: boolean;
  54043. /**
  54044. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54045. */
  54046. updateScale: boolean;
  54047. protected _interactionsEnabled: boolean;
  54048. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54049. private _beforeRenderObserver;
  54050. private _tempQuaternion;
  54051. private _tempVector;
  54052. private _tempVector2;
  54053. private _tempMatrix1;
  54054. private _tempMatrix2;
  54055. private _rightHandtoLeftHandMatrix;
  54056. /**
  54057. * Creates a gizmo
  54058. * @param gizmoLayer The utility layer the gizmo will be added to
  54059. */
  54060. constructor(
  54061. /** The utility layer the gizmo will be added to */
  54062. gizmoLayer?: UtilityLayerRenderer);
  54063. /**
  54064. * Updates the gizmo to match the attached mesh's position/rotation
  54065. */
  54066. protected _update(): void;
  54067. /**
  54068. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54069. * @param value Node, TransformNode or mesh
  54070. */
  54071. protected _matrixChanged(): void;
  54072. /**
  54073. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54074. * @param gizmoLayer The utility layer the gizmo will be added to
  54075. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54076. * @returns {Observer<PointerInfo>} pointerObserver
  54077. */
  54078. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54079. /**
  54080. * Disposes of the gizmo
  54081. */
  54082. dispose(): void;
  54083. }
  54084. }
  54085. declare module BABYLON {
  54086. /**
  54087. * Single plane drag gizmo
  54088. */
  54089. export class PlaneDragGizmo extends Gizmo {
  54090. /**
  54091. * Drag behavior responsible for the gizmos dragging interactions
  54092. */
  54093. dragBehavior: PointerDragBehavior;
  54094. private _pointerObserver;
  54095. /**
  54096. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54097. */
  54098. snapDistance: number;
  54099. /**
  54100. * Event that fires each time the gizmo snaps to a new location.
  54101. * * snapDistance is the the change in distance
  54102. */
  54103. onSnapObservable: Observable<{
  54104. snapDistance: number;
  54105. }>;
  54106. private _gizmoMesh;
  54107. private _coloredMaterial;
  54108. private _hoverMaterial;
  54109. private _disableMaterial;
  54110. private _isEnabled;
  54111. private _parent;
  54112. private _dragging;
  54113. /** @hidden */
  54114. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54115. /**
  54116. * Creates a PlaneDragGizmo
  54117. * @param gizmoLayer The utility layer the gizmo will be added to
  54118. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54119. * @param color The color of the gizmo
  54120. */
  54121. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54122. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54123. /**
  54124. * If the gizmo is enabled
  54125. */
  54126. set isEnabled(value: boolean);
  54127. get isEnabled(): boolean;
  54128. /**
  54129. * Disposes of the gizmo
  54130. */
  54131. dispose(): void;
  54132. }
  54133. }
  54134. declare module BABYLON {
  54135. /**
  54136. * Single plane rotation gizmo
  54137. */
  54138. export class PlaneRotationGizmo extends Gizmo {
  54139. /**
  54140. * Drag behavior responsible for the gizmos dragging interactions
  54141. */
  54142. dragBehavior: PointerDragBehavior;
  54143. private _pointerObserver;
  54144. /**
  54145. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54146. */
  54147. snapDistance: number;
  54148. /**
  54149. * Event that fires each time the gizmo snaps to a new location.
  54150. * * snapDistance is the the change in distance
  54151. */
  54152. onSnapObservable: Observable<{
  54153. snapDistance: number;
  54154. }>;
  54155. private _isEnabled;
  54156. private _parent;
  54157. private _coloredMaterial;
  54158. private _hoverMaterial;
  54159. private _disableMaterial;
  54160. private _gizmoMesh;
  54161. private _rotationCircle;
  54162. private _dragging;
  54163. private static _CircleConstants;
  54164. /**
  54165. * Creates a PlaneRotationGizmo
  54166. * @param gizmoLayer The utility layer the gizmo will be added to
  54167. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54168. * @param color The color of the gizmo
  54169. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54170. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54171. * @param thickness display gizmo axis thickness
  54172. */
  54173. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54174. /** Create Geometry for Gizmo */
  54175. private _createGizmoMesh;
  54176. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54177. private setupRotationCircle;
  54178. private updateRotationPath;
  54179. private updateRotationCircle;
  54180. /**
  54181. * If the gizmo is enabled
  54182. */
  54183. set isEnabled(value: boolean);
  54184. get isEnabled(): boolean;
  54185. /**
  54186. * Disposes of the gizmo
  54187. */
  54188. dispose(): void;
  54189. }
  54190. }
  54191. declare module BABYLON {
  54192. /**
  54193. * Gizmo that enables rotating a mesh along 3 axis
  54194. */
  54195. export class RotationGizmo extends Gizmo {
  54196. /**
  54197. * Internal gizmo used for interactions on the x axis
  54198. */
  54199. xGizmo: PlaneRotationGizmo;
  54200. /**
  54201. * Internal gizmo used for interactions on the y axis
  54202. */
  54203. yGizmo: PlaneRotationGizmo;
  54204. /**
  54205. * Internal gizmo used for interactions on the z axis
  54206. */
  54207. zGizmo: PlaneRotationGizmo;
  54208. /** Fires an event when any of it's sub gizmos are dragged */
  54209. onDragStartObservable: Observable<unknown>;
  54210. /** Fires an event when any of it's sub gizmos are released from dragging */
  54211. onDragEndObservable: Observable<unknown>;
  54212. private _meshAttached;
  54213. private _nodeAttached;
  54214. private _observables;
  54215. /** Node Caching for quick lookup */
  54216. private _gizmoAxisCache;
  54217. get attachedMesh(): Nullable<AbstractMesh>;
  54218. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54219. get attachedNode(): Nullable<Node>;
  54220. set attachedNode(node: Nullable<Node>);
  54221. protected _checkBillboardTransform(): void;
  54222. /**
  54223. * True when the mouse pointer is hovering a gizmo mesh
  54224. */
  54225. get isHovered(): boolean;
  54226. /**
  54227. * Creates a RotationGizmo
  54228. * @param gizmoLayer The utility layer the gizmo will be added to
  54229. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54230. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54231. * @param thickness display gizmo axis thickness
  54232. */
  54233. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54234. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54235. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54236. /**
  54237. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54238. */
  54239. set snapDistance(value: number);
  54240. get snapDistance(): number;
  54241. /**
  54242. * Ratio for the scale of the gizmo (Default: 1)
  54243. */
  54244. set scaleRatio(value: number);
  54245. get scaleRatio(): number;
  54246. /**
  54247. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54248. * @param mesh Axis gizmo mesh
  54249. * @param cache Gizmo axis definition used for reactive gizmo UI
  54250. */
  54251. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54252. /**
  54253. * Disposes of the gizmo
  54254. */
  54255. dispose(): void;
  54256. /**
  54257. * CustomMeshes are not supported by this gizmo
  54258. * @param mesh The mesh to replace the default mesh of the gizmo
  54259. */
  54260. setCustomMesh(mesh: Mesh): void;
  54261. }
  54262. }
  54263. declare module BABYLON {
  54264. /**
  54265. * Class containing static functions to help procedurally build meshes
  54266. */
  54267. export class PolyhedronBuilder {
  54268. /**
  54269. * Creates a polyhedron mesh
  54270. * * 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
  54271. * * The parameter `size` (positive float, default 1) sets the polygon size
  54272. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54273. * * 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`
  54274. * * 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
  54275. * * 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)`)
  54276. * * 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
  54277. * * 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
  54278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54279. * * 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
  54280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54281. * @param name defines the name of the mesh
  54282. * @param options defines the options used to create the mesh
  54283. * @param scene defines the hosting scene
  54284. * @returns the polyhedron mesh
  54285. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54286. */
  54287. static CreatePolyhedron(name: string, options: {
  54288. type?: number;
  54289. size?: number;
  54290. sizeX?: number;
  54291. sizeY?: number;
  54292. sizeZ?: number;
  54293. custom?: any;
  54294. faceUV?: Vector4[];
  54295. faceColors?: Color4[];
  54296. flat?: boolean;
  54297. updatable?: boolean;
  54298. sideOrientation?: number;
  54299. frontUVs?: Vector4;
  54300. backUVs?: Vector4;
  54301. }, scene?: Nullable<Scene>): Mesh;
  54302. }
  54303. }
  54304. declare module BABYLON {
  54305. /**
  54306. * Class containing static functions to help procedurally build meshes
  54307. */
  54308. export class BoxBuilder {
  54309. /**
  54310. * Creates a box mesh
  54311. * * The parameter `size` sets the size (float) of each box side (default 1)
  54312. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54313. * * 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)
  54314. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54316. * * 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
  54317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54318. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54319. * @param name defines the name of the mesh
  54320. * @param options defines the options used to create the mesh
  54321. * @param scene defines the hosting scene
  54322. * @returns the box mesh
  54323. */
  54324. static CreateBox(name: string, options: {
  54325. size?: number;
  54326. width?: number;
  54327. height?: number;
  54328. depth?: number;
  54329. faceUV?: Vector4[];
  54330. faceColors?: Color4[];
  54331. sideOrientation?: number;
  54332. frontUVs?: Vector4;
  54333. backUVs?: Vector4;
  54334. wrap?: boolean;
  54335. topBaseAt?: number;
  54336. bottomBaseAt?: number;
  54337. updatable?: boolean;
  54338. }, scene?: Nullable<Scene>): Mesh;
  54339. }
  54340. }
  54341. declare module BABYLON {
  54342. /**
  54343. * Single axis scale gizmo
  54344. */
  54345. export class AxisScaleGizmo extends Gizmo {
  54346. /**
  54347. * Drag behavior responsible for the gizmos dragging interactions
  54348. */
  54349. dragBehavior: PointerDragBehavior;
  54350. private _pointerObserver;
  54351. /**
  54352. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54353. */
  54354. snapDistance: number;
  54355. /**
  54356. * Event that fires each time the gizmo snaps to a new location.
  54357. * * snapDistance is the the change in distance
  54358. */
  54359. onSnapObservable: Observable<{
  54360. snapDistance: number;
  54361. }>;
  54362. /**
  54363. * If the scaling operation should be done on all axis (default: false)
  54364. */
  54365. uniformScaling: boolean;
  54366. /**
  54367. * Custom sensitivity value for the drag strength
  54368. */
  54369. sensitivity: number;
  54370. private _isEnabled;
  54371. private _parent;
  54372. private _gizmoMesh;
  54373. private _coloredMaterial;
  54374. private _hoverMaterial;
  54375. private _disableMaterial;
  54376. private _dragging;
  54377. /**
  54378. * Creates an AxisScaleGizmo
  54379. * @param gizmoLayer The utility layer the gizmo will be added to
  54380. * @param dragAxis The axis which the gizmo will be able to scale on
  54381. * @param color The color of the gizmo
  54382. * @param thickness display gizmo axis thickness
  54383. */
  54384. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54385. /** Create Geometry for Gizmo */
  54386. private _createGizmoMesh;
  54387. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54388. /**
  54389. * If the gizmo is enabled
  54390. */
  54391. set isEnabled(value: boolean);
  54392. get isEnabled(): boolean;
  54393. /**
  54394. * Disposes of the gizmo
  54395. */
  54396. dispose(): void;
  54397. /**
  54398. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54399. * @param mesh The mesh to replace the default mesh of the gizmo
  54400. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54401. */
  54402. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Gizmo that enables scaling a mesh along 3 axis
  54408. */
  54409. export class ScaleGizmo extends Gizmo {
  54410. /**
  54411. * Internal gizmo used for interactions on the x axis
  54412. */
  54413. xGizmo: AxisScaleGizmo;
  54414. /**
  54415. * Internal gizmo used for interactions on the y axis
  54416. */
  54417. yGizmo: AxisScaleGizmo;
  54418. /**
  54419. * Internal gizmo used for interactions on the z axis
  54420. */
  54421. zGizmo: AxisScaleGizmo;
  54422. /**
  54423. * Internal gizmo used to scale all axis equally
  54424. */
  54425. uniformScaleGizmo: AxisScaleGizmo;
  54426. private _meshAttached;
  54427. private _nodeAttached;
  54428. private _snapDistance;
  54429. private _uniformScalingMesh;
  54430. private _octahedron;
  54431. private _sensitivity;
  54432. private _coloredMaterial;
  54433. private _hoverMaterial;
  54434. private _disableMaterial;
  54435. private _observables;
  54436. /** Node Caching for quick lookup */
  54437. private _gizmoAxisCache;
  54438. /** Fires an event when any of it's sub gizmos are dragged */
  54439. onDragStartObservable: Observable<unknown>;
  54440. /** Fires an event when any of it's sub gizmos are released from dragging */
  54441. onDragEndObservable: Observable<unknown>;
  54442. get attachedMesh(): Nullable<AbstractMesh>;
  54443. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54444. get attachedNode(): Nullable<Node>;
  54445. set attachedNode(node: Nullable<Node>);
  54446. /**
  54447. * True when the mouse pointer is hovering a gizmo mesh
  54448. */
  54449. get isHovered(): boolean;
  54450. /**
  54451. * Creates a ScaleGizmo
  54452. * @param gizmoLayer The utility layer the gizmo will be added to
  54453. * @param thickness display gizmo axis thickness
  54454. */
  54455. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54456. /** Create Geometry for Gizmo */
  54457. private _createUniformScaleMesh;
  54458. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54459. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54460. /**
  54461. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54462. */
  54463. set snapDistance(value: number);
  54464. get snapDistance(): number;
  54465. /**
  54466. * Ratio for the scale of the gizmo (Default: 1)
  54467. */
  54468. set scaleRatio(value: number);
  54469. get scaleRatio(): number;
  54470. /**
  54471. * Sensitivity factor for dragging (Default: 1)
  54472. */
  54473. set sensitivity(value: number);
  54474. get sensitivity(): number;
  54475. /**
  54476. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54477. * @param mesh Axis gizmo mesh
  54478. * @param cache Gizmo axis definition used for reactive gizmo UI
  54479. */
  54480. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54481. /**
  54482. * Disposes of the gizmo
  54483. */
  54484. dispose(): void;
  54485. }
  54486. }
  54487. declare module BABYLON {
  54488. /**
  54489. * Bounding box gizmo
  54490. */
  54491. export class BoundingBoxGizmo extends Gizmo {
  54492. private _lineBoundingBox;
  54493. private _rotateSpheresParent;
  54494. private _scaleBoxesParent;
  54495. private _boundingDimensions;
  54496. private _renderObserver;
  54497. private _pointerObserver;
  54498. private _scaleDragSpeed;
  54499. private _tmpQuaternion;
  54500. private _tmpVector;
  54501. private _tmpRotationMatrix;
  54502. /**
  54503. * 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)
  54504. */
  54505. ignoreChildren: boolean;
  54506. /**
  54507. * 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)
  54508. */
  54509. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54510. /**
  54511. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54512. */
  54513. rotationSphereSize: number;
  54514. /**
  54515. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54516. */
  54517. scaleBoxSize: number;
  54518. /**
  54519. * 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)
  54520. */
  54521. fixedDragMeshScreenSize: boolean;
  54522. /**
  54523. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54524. */
  54525. fixedDragMeshScreenSizeDistanceFactor: number;
  54526. /**
  54527. * Fired when a rotation sphere or scale box is dragged
  54528. */
  54529. onDragStartObservable: Observable<{}>;
  54530. /**
  54531. * Fired when a scale box is dragged
  54532. */
  54533. onScaleBoxDragObservable: Observable<{}>;
  54534. /**
  54535. * Fired when a scale box drag is ended
  54536. */
  54537. onScaleBoxDragEndObservable: Observable<{}>;
  54538. /**
  54539. * Fired when a rotation sphere is dragged
  54540. */
  54541. onRotationSphereDragObservable: Observable<{}>;
  54542. /**
  54543. * Fired when a rotation sphere drag is ended
  54544. */
  54545. onRotationSphereDragEndObservable: Observable<{}>;
  54546. /**
  54547. * 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)
  54548. */
  54549. scalePivot: Nullable<Vector3>;
  54550. /**
  54551. * Mesh used as a pivot to rotate the attached node
  54552. */
  54553. private _anchorMesh;
  54554. private _existingMeshScale;
  54555. private _dragMesh;
  54556. private pointerDragBehavior;
  54557. private coloredMaterial;
  54558. private hoverColoredMaterial;
  54559. /**
  54560. * Sets the color of the bounding box gizmo
  54561. * @param color the color to set
  54562. */
  54563. setColor(color: Color3): void;
  54564. /**
  54565. * Creates an BoundingBoxGizmo
  54566. * @param gizmoLayer The utility layer the gizmo will be added to
  54567. * @param color The color of the gizmo
  54568. */
  54569. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54570. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54571. private _selectNode;
  54572. /**
  54573. * Updates the bounding box information for the Gizmo
  54574. */
  54575. updateBoundingBox(): void;
  54576. private _updateRotationSpheres;
  54577. private _updateScaleBoxes;
  54578. /**
  54579. * Enables rotation on the specified axis and disables rotation on the others
  54580. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54581. */
  54582. setEnabledRotationAxis(axis: string): void;
  54583. /**
  54584. * Enables/disables scaling
  54585. * @param enable if scaling should be enabled
  54586. * @param homogeneousScaling defines if scaling should only be homogeneous
  54587. */
  54588. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54589. private _updateDummy;
  54590. /**
  54591. * Enables a pointer drag behavior on the bounding box of the gizmo
  54592. */
  54593. enableDragBehavior(): void;
  54594. /**
  54595. * Disposes of the gizmo
  54596. */
  54597. dispose(): void;
  54598. /**
  54599. * 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)
  54600. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54601. * @returns the bounding box mesh with the passed in mesh as a child
  54602. */
  54603. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54604. /**
  54605. * CustomMeshes are not supported by this gizmo
  54606. * @param mesh The mesh to replace the default mesh of the gizmo
  54607. */
  54608. setCustomMesh(mesh: Mesh): void;
  54609. }
  54610. }
  54611. declare module BABYLON {
  54612. /**
  54613. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54614. */
  54615. export class GizmoManager implements IDisposable {
  54616. private scene;
  54617. /**
  54618. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54619. */
  54620. gizmos: {
  54621. positionGizmo: Nullable<PositionGizmo>;
  54622. rotationGizmo: Nullable<RotationGizmo>;
  54623. scaleGizmo: Nullable<ScaleGizmo>;
  54624. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54625. };
  54626. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54627. clearGizmoOnEmptyPointerEvent: boolean;
  54628. /** Fires an event when the manager is attached to a mesh */
  54629. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54630. /** Fires an event when the manager is attached to a node */
  54631. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54632. private _gizmosEnabled;
  54633. private _pointerObservers;
  54634. private _attachedMesh;
  54635. private _attachedNode;
  54636. private _boundingBoxColor;
  54637. private _defaultUtilityLayer;
  54638. private _defaultKeepDepthUtilityLayer;
  54639. private _thickness;
  54640. /** Node Caching for quick lookup */
  54641. private _gizmoAxisCache;
  54642. /**
  54643. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54644. */
  54645. boundingBoxDragBehavior: SixDofDragBehavior;
  54646. /**
  54647. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54648. */
  54649. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54650. /**
  54651. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54652. */
  54653. attachableNodes: Nullable<Array<Node>>;
  54654. /**
  54655. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54656. */
  54657. usePointerToAttachGizmos: boolean;
  54658. /**
  54659. * Utility layer that the bounding box gizmo belongs to
  54660. */
  54661. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54662. /**
  54663. * Utility layer that all gizmos besides bounding box belong to
  54664. */
  54665. get utilityLayer(): UtilityLayerRenderer;
  54666. /**
  54667. * True when the mouse pointer is hovering a gizmo mesh
  54668. */
  54669. get isHovered(): boolean;
  54670. /**
  54671. * Instatiates a gizmo manager
  54672. * @param scene the scene to overlay the gizmos on top of
  54673. * @param thickness display gizmo axis thickness
  54674. */
  54675. constructor(scene: Scene, thickness?: number);
  54676. /**
  54677. * Subscribes to pointer down events, for attaching and detaching mesh
  54678. * @param scene The sceme layer the observer will be added to
  54679. */
  54680. private _attachToMeshPointerObserver;
  54681. /**
  54682. * Attaches a set of gizmos to the specified mesh
  54683. * @param mesh The mesh the gizmo's should be attached to
  54684. */
  54685. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54686. /**
  54687. * Attaches a set of gizmos to the specified node
  54688. * @param node The node the gizmo's should be attached to
  54689. */
  54690. attachToNode(node: Nullable<Node>): void;
  54691. /**
  54692. * If the position gizmo is enabled
  54693. */
  54694. set positionGizmoEnabled(value: boolean);
  54695. get positionGizmoEnabled(): boolean;
  54696. /**
  54697. * If the rotation gizmo is enabled
  54698. */
  54699. set rotationGizmoEnabled(value: boolean);
  54700. get rotationGizmoEnabled(): boolean;
  54701. /**
  54702. * If the scale gizmo is enabled
  54703. */
  54704. set scaleGizmoEnabled(value: boolean);
  54705. get scaleGizmoEnabled(): boolean;
  54706. /**
  54707. * If the boundingBox gizmo is enabled
  54708. */
  54709. set boundingBoxGizmoEnabled(value: boolean);
  54710. get boundingBoxGizmoEnabled(): boolean;
  54711. /**
  54712. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54713. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54714. */
  54715. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54716. /**
  54717. * Disposes of the gizmo manager
  54718. */
  54719. dispose(): void;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /**
  54724. * Gizmo that enables dragging a mesh along 3 axis
  54725. */
  54726. export class PositionGizmo extends Gizmo {
  54727. /**
  54728. * Internal gizmo used for interactions on the x axis
  54729. */
  54730. xGizmo: AxisDragGizmo;
  54731. /**
  54732. * Internal gizmo used for interactions on the y axis
  54733. */
  54734. yGizmo: AxisDragGizmo;
  54735. /**
  54736. * Internal gizmo used for interactions on the z axis
  54737. */
  54738. zGizmo: AxisDragGizmo;
  54739. /**
  54740. * Internal gizmo used for interactions on the yz plane
  54741. */
  54742. xPlaneGizmo: PlaneDragGizmo;
  54743. /**
  54744. * Internal gizmo used for interactions on the xz plane
  54745. */
  54746. yPlaneGizmo: PlaneDragGizmo;
  54747. /**
  54748. * Internal gizmo used for interactions on the xy plane
  54749. */
  54750. zPlaneGizmo: PlaneDragGizmo;
  54751. /**
  54752. * private variables
  54753. */
  54754. private _meshAttached;
  54755. private _nodeAttached;
  54756. private _snapDistance;
  54757. private _observables;
  54758. /** Node Caching for quick lookup */
  54759. private _gizmoAxisCache;
  54760. /** Fires an event when any of it's sub gizmos are dragged */
  54761. onDragStartObservable: Observable<unknown>;
  54762. /** Fires an event when any of it's sub gizmos are released from dragging */
  54763. onDragEndObservable: Observable<unknown>;
  54764. /**
  54765. * If set to true, planar drag is enabled
  54766. */
  54767. private _planarGizmoEnabled;
  54768. get attachedMesh(): Nullable<AbstractMesh>;
  54769. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54770. get attachedNode(): Nullable<Node>;
  54771. set attachedNode(node: Nullable<Node>);
  54772. /**
  54773. * True when the mouse pointer is hovering a gizmo mesh
  54774. */
  54775. get isHovered(): boolean;
  54776. /**
  54777. * Creates a PositionGizmo
  54778. * @param gizmoLayer The utility layer the gizmo will be added to
  54779. @param thickness display gizmo axis thickness
  54780. */
  54781. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54782. /**
  54783. * If the planar drag gizmo is enabled
  54784. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54785. */
  54786. set planarGizmoEnabled(value: boolean);
  54787. get planarGizmoEnabled(): boolean;
  54788. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54789. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54790. /**
  54791. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54792. */
  54793. set snapDistance(value: number);
  54794. get snapDistance(): number;
  54795. /**
  54796. * Ratio for the scale of the gizmo (Default: 1)
  54797. */
  54798. set scaleRatio(value: number);
  54799. get scaleRatio(): number;
  54800. /**
  54801. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54802. * @param mesh Axis gizmo mesh
  54803. * @param cache Gizmo axis definition used for reactive gizmo UI
  54804. */
  54805. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54806. /**
  54807. * Disposes of the gizmo
  54808. */
  54809. dispose(): void;
  54810. /**
  54811. * CustomMeshes are not supported by this gizmo
  54812. * @param mesh The mesh to replace the default mesh of the gizmo
  54813. */
  54814. setCustomMesh(mesh: Mesh): void;
  54815. }
  54816. }
  54817. declare module BABYLON {
  54818. /**
  54819. * Single axis drag gizmo
  54820. */
  54821. export class AxisDragGizmo extends Gizmo {
  54822. /**
  54823. * Drag behavior responsible for the gizmos dragging interactions
  54824. */
  54825. dragBehavior: PointerDragBehavior;
  54826. private _pointerObserver;
  54827. /**
  54828. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54829. */
  54830. snapDistance: number;
  54831. /**
  54832. * Event that fires each time the gizmo snaps to a new location.
  54833. * * snapDistance is the the change in distance
  54834. */
  54835. onSnapObservable: Observable<{
  54836. snapDistance: number;
  54837. }>;
  54838. private _isEnabled;
  54839. private _parent;
  54840. private _gizmoMesh;
  54841. private _coloredMaterial;
  54842. private _hoverMaterial;
  54843. private _disableMaterial;
  54844. private _dragging;
  54845. /** @hidden */
  54846. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54847. /** @hidden */
  54848. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54849. /**
  54850. * Creates an AxisDragGizmo
  54851. * @param gizmoLayer The utility layer the gizmo will be added to
  54852. * @param dragAxis The axis which the gizmo will be able to drag on
  54853. * @param color The color of the gizmo
  54854. * @param thickness display gizmo axis thickness
  54855. */
  54856. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54857. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54858. /**
  54859. * If the gizmo is enabled
  54860. */
  54861. set isEnabled(value: boolean);
  54862. get isEnabled(): boolean;
  54863. /**
  54864. * Disposes of the gizmo
  54865. */
  54866. dispose(): void;
  54867. }
  54868. }
  54869. declare module BABYLON.Debug {
  54870. /**
  54871. * The Axes viewer will show 3 axes in a specific point in space
  54872. */
  54873. export class AxesViewer {
  54874. private _xAxis;
  54875. private _yAxis;
  54876. private _zAxis;
  54877. private _scaleLinesFactor;
  54878. private _instanced;
  54879. /**
  54880. * Gets the hosting scene
  54881. */
  54882. scene: Nullable<Scene>;
  54883. /**
  54884. * Gets or sets a number used to scale line length
  54885. */
  54886. scaleLines: number;
  54887. /** Gets the node hierarchy used to render x-axis */
  54888. get xAxis(): TransformNode;
  54889. /** Gets the node hierarchy used to render y-axis */
  54890. get yAxis(): TransformNode;
  54891. /** Gets the node hierarchy used to render z-axis */
  54892. get zAxis(): TransformNode;
  54893. /**
  54894. * Creates a new AxesViewer
  54895. * @param scene defines the hosting scene
  54896. * @param scaleLines defines a number used to scale line length (1 by default)
  54897. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54898. * @param xAxis defines the node hierarchy used to render the x-axis
  54899. * @param yAxis defines the node hierarchy used to render the y-axis
  54900. * @param zAxis defines the node hierarchy used to render the z-axis
  54901. */
  54902. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54903. /**
  54904. * Force the viewer to update
  54905. * @param position defines the position of the viewer
  54906. * @param xaxis defines the x axis of the viewer
  54907. * @param yaxis defines the y axis of the viewer
  54908. * @param zaxis defines the z axis of the viewer
  54909. */
  54910. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54911. /**
  54912. * Creates an instance of this axes viewer.
  54913. * @returns a new axes viewer with instanced meshes
  54914. */
  54915. createInstance(): AxesViewer;
  54916. /** Releases resources */
  54917. dispose(): void;
  54918. private static _SetRenderingGroupId;
  54919. }
  54920. }
  54921. declare module BABYLON.Debug {
  54922. /**
  54923. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54924. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54925. */
  54926. export class BoneAxesViewer extends AxesViewer {
  54927. /**
  54928. * Gets or sets the target mesh where to display the axes viewer
  54929. */
  54930. mesh: Nullable<Mesh>;
  54931. /**
  54932. * Gets or sets the target bone where to display the axes viewer
  54933. */
  54934. bone: Nullable<Bone>;
  54935. /** Gets current position */
  54936. pos: Vector3;
  54937. /** Gets direction of X axis */
  54938. xaxis: Vector3;
  54939. /** Gets direction of Y axis */
  54940. yaxis: Vector3;
  54941. /** Gets direction of Z axis */
  54942. zaxis: Vector3;
  54943. /**
  54944. * Creates a new BoneAxesViewer
  54945. * @param scene defines the hosting scene
  54946. * @param bone defines the target bone
  54947. * @param mesh defines the target mesh
  54948. * @param scaleLines defines a scaling factor for line length (1 by default)
  54949. */
  54950. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54951. /**
  54952. * Force the viewer to update
  54953. */
  54954. update(): void;
  54955. /** Releases resources */
  54956. dispose(): void;
  54957. }
  54958. }
  54959. declare module BABYLON {
  54960. /**
  54961. * Interface used to define scene explorer extensibility option
  54962. */
  54963. export interface IExplorerExtensibilityOption {
  54964. /**
  54965. * Define the option label
  54966. */
  54967. label: string;
  54968. /**
  54969. * Defines the action to execute on click
  54970. */
  54971. action: (entity: any) => void;
  54972. }
  54973. /**
  54974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54975. */
  54976. export interface IExplorerExtensibilityGroup {
  54977. /**
  54978. * Defines a predicate to test if a given type mut be extended
  54979. */
  54980. predicate: (entity: any) => boolean;
  54981. /**
  54982. * Gets the list of options added to a type
  54983. */
  54984. entries: IExplorerExtensibilityOption[];
  54985. }
  54986. /**
  54987. * Interface used to define the options to use to create the Inspector
  54988. */
  54989. export interface IInspectorOptions {
  54990. /**
  54991. * Display in overlay mode (default: false)
  54992. */
  54993. overlay?: boolean;
  54994. /**
  54995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54996. */
  54997. globalRoot?: HTMLElement;
  54998. /**
  54999. * Display the Scene explorer
  55000. */
  55001. showExplorer?: boolean;
  55002. /**
  55003. * Display the property inspector
  55004. */
  55005. showInspector?: boolean;
  55006. /**
  55007. * Display in embed mode (both panes on the right)
  55008. */
  55009. embedMode?: boolean;
  55010. /**
  55011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55012. */
  55013. handleResize?: boolean;
  55014. /**
  55015. * Allow the panes to popup (default: true)
  55016. */
  55017. enablePopup?: boolean;
  55018. /**
  55019. * Allow the panes to be closed by users (default: true)
  55020. */
  55021. enableClose?: boolean;
  55022. /**
  55023. * Optional list of extensibility entries
  55024. */
  55025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55026. /**
  55027. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55028. */
  55029. inspectorURL?: string;
  55030. /**
  55031. * Optional initial tab (default to DebugLayerTab.Properties)
  55032. */
  55033. initialTab?: DebugLayerTab;
  55034. }
  55035. interface Scene {
  55036. /**
  55037. * @hidden
  55038. * Backing field
  55039. */
  55040. _debugLayer: DebugLayer;
  55041. /**
  55042. * Gets the debug layer (aka Inspector) associated with the scene
  55043. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55044. */
  55045. debugLayer: DebugLayer;
  55046. }
  55047. /**
  55048. * Enum of inspector action tab
  55049. */
  55050. export enum DebugLayerTab {
  55051. /**
  55052. * Properties tag (default)
  55053. */
  55054. Properties = 0,
  55055. /**
  55056. * Debug tab
  55057. */
  55058. Debug = 1,
  55059. /**
  55060. * Statistics tab
  55061. */
  55062. Statistics = 2,
  55063. /**
  55064. * Tools tab
  55065. */
  55066. Tools = 3,
  55067. /**
  55068. * Settings tab
  55069. */
  55070. Settings = 4
  55071. }
  55072. /**
  55073. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55074. * what is happening in your scene
  55075. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55076. */
  55077. export class DebugLayer {
  55078. /**
  55079. * Define the url to get the inspector script from.
  55080. * By default it uses the babylonjs CDN.
  55081. * @ignoreNaming
  55082. */
  55083. static InspectorURL: string;
  55084. private _scene;
  55085. private BJSINSPECTOR;
  55086. private _onPropertyChangedObservable?;
  55087. /**
  55088. * Observable triggered when a property is changed through the inspector.
  55089. */
  55090. get onPropertyChangedObservable(): any;
  55091. /**
  55092. * Instantiates a new debug layer.
  55093. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55094. * what is happening in your scene
  55095. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55096. * @param scene Defines the scene to inspect
  55097. */
  55098. constructor(scene: Scene);
  55099. /** Creates the inspector window. */
  55100. private _createInspector;
  55101. /**
  55102. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55103. * @param entity defines the entity to select
  55104. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55105. */
  55106. select(entity: any, lineContainerTitles?: string | string[]): void;
  55107. /** Get the inspector from bundle or global */
  55108. private _getGlobalInspector;
  55109. /**
  55110. * Get if the inspector is visible or not.
  55111. * @returns true if visible otherwise, false
  55112. */
  55113. isVisible(): boolean;
  55114. /**
  55115. * Hide the inspector and close its window.
  55116. */
  55117. hide(): void;
  55118. /**
  55119. * Update the scene in the inspector
  55120. */
  55121. setAsActiveScene(): void;
  55122. /**
  55123. * Launch the debugLayer.
  55124. * @param config Define the configuration of the inspector
  55125. * @return a promise fulfilled when the debug layer is visible
  55126. */
  55127. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55128. }
  55129. }
  55130. declare module BABYLON.Debug {
  55131. /**
  55132. * Used to show the physics impostor around the specific mesh
  55133. */
  55134. export class PhysicsViewer {
  55135. /** @hidden */
  55136. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55137. /** @hidden */
  55138. protected _meshes: Array<Nullable<AbstractMesh>>;
  55139. /** @hidden */
  55140. protected _scene: Nullable<Scene>;
  55141. /** @hidden */
  55142. protected _numMeshes: number;
  55143. /** @hidden */
  55144. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55145. private _renderFunction;
  55146. private _utilityLayer;
  55147. private _debugBoxMesh;
  55148. private _debugSphereMesh;
  55149. private _debugCylinderMesh;
  55150. private _debugMaterial;
  55151. private _debugMeshMeshes;
  55152. /**
  55153. * Creates a new PhysicsViewer
  55154. * @param scene defines the hosting scene
  55155. */
  55156. constructor(scene: Scene);
  55157. /** @hidden */
  55158. protected _updateDebugMeshes(): void;
  55159. /**
  55160. * Renders a specified physic impostor
  55161. * @param impostor defines the impostor to render
  55162. * @param targetMesh defines the mesh represented by the impostor
  55163. * @returns the new debug mesh used to render the impostor
  55164. */
  55165. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55166. /**
  55167. * Hides a specified physic impostor
  55168. * @param impostor defines the impostor to hide
  55169. */
  55170. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55171. private _getDebugMaterial;
  55172. private _getDebugBoxMesh;
  55173. private _getDebugSphereMesh;
  55174. private _getDebugCylinderMesh;
  55175. private _getDebugMeshMesh;
  55176. private _getDebugMesh;
  55177. /** Releases all resources */
  55178. dispose(): void;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55184. * in order to better appreciate the issue one might have.
  55185. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55186. */
  55187. export class RayHelper {
  55188. /**
  55189. * Defines the ray we are currently tryin to visualize.
  55190. */
  55191. ray: Nullable<Ray>;
  55192. private _renderPoints;
  55193. private _renderLine;
  55194. private _renderFunction;
  55195. private _scene;
  55196. private _onAfterRenderObserver;
  55197. private _onAfterStepObserver;
  55198. private _attachedToMesh;
  55199. private _meshSpaceDirection;
  55200. private _meshSpaceOrigin;
  55201. /**
  55202. * Helper function to create a colored helper in a scene in one line.
  55203. * @param ray Defines the ray we are currently tryin to visualize
  55204. * @param scene Defines the scene the ray is used in
  55205. * @param color Defines the color we want to see the ray in
  55206. * @returns The newly created ray helper.
  55207. */
  55208. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55209. /**
  55210. * Instantiate a new ray helper.
  55211. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55212. * in order to better appreciate the issue one might have.
  55213. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55214. * @param ray Defines the ray we are currently tryin to visualize
  55215. */
  55216. constructor(ray: Ray);
  55217. /**
  55218. * Shows the ray we are willing to debug.
  55219. * @param scene Defines the scene the ray needs to be rendered in
  55220. * @param color Defines the color the ray needs to be rendered in
  55221. */
  55222. show(scene: Scene, color?: Color3): void;
  55223. /**
  55224. * Hides the ray we are debugging.
  55225. */
  55226. hide(): void;
  55227. private _render;
  55228. /**
  55229. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55230. * @param mesh Defines the mesh we want the helper attached to
  55231. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55232. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55233. * @param length Defines the length of the ray
  55234. */
  55235. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55236. /**
  55237. * Detach the ray helper from the mesh it has previously been attached to.
  55238. */
  55239. detachFromMesh(): void;
  55240. private _updateToMesh;
  55241. /**
  55242. * Dispose the helper and release its associated resources.
  55243. */
  55244. dispose(): void;
  55245. }
  55246. }
  55247. declare module BABYLON {
  55248. /**
  55249. * Defines the options associated with the creation of a SkeletonViewer.
  55250. */
  55251. export interface ISkeletonViewerOptions {
  55252. /** Should the system pause animations before building the Viewer? */
  55253. pauseAnimations: boolean;
  55254. /** Should the system return the skeleton to rest before building? */
  55255. returnToRest: boolean;
  55256. /** public Display Mode of the Viewer */
  55257. displayMode: number;
  55258. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55259. displayOptions: ISkeletonViewerDisplayOptions;
  55260. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55261. computeBonesUsingShaders: boolean;
  55262. /** Flag ignore non weighted bones */
  55263. useAllBones: boolean;
  55264. }
  55265. /**
  55266. * Defines how to display the various bone meshes for the viewer.
  55267. */
  55268. export interface ISkeletonViewerDisplayOptions {
  55269. /** How far down to start tapering the bone spurs */
  55270. midStep?: number;
  55271. /** How big is the midStep? */
  55272. midStepFactor?: number;
  55273. /** Base for the Sphere Size */
  55274. sphereBaseSize?: number;
  55275. /** The ratio of the sphere to the longest bone in units */
  55276. sphereScaleUnit?: number;
  55277. /** Ratio for the Sphere Size */
  55278. sphereFactor?: number;
  55279. /** Whether a spur should attach its far end to the child bone position */
  55280. spurFollowsChild?: boolean;
  55281. /** Whether to show local axes or not */
  55282. showLocalAxes?: boolean;
  55283. /** Length of each local axis */
  55284. localAxesSize?: number;
  55285. }
  55286. /**
  55287. * Defines the constructor options for the BoneWeight Shader.
  55288. */
  55289. export interface IBoneWeightShaderOptions {
  55290. /** Skeleton to Map */
  55291. skeleton: Skeleton;
  55292. /** Colors for Uninfluenced bones */
  55293. colorBase?: Color3;
  55294. /** Colors for 0.0-0.25 Weight bones */
  55295. colorZero?: Color3;
  55296. /** Color for 0.25-0.5 Weight Influence */
  55297. colorQuarter?: Color3;
  55298. /** Color for 0.5-0.75 Weight Influence */
  55299. colorHalf?: Color3;
  55300. /** Color for 0.75-1 Weight Influence */
  55301. colorFull?: Color3;
  55302. /** Color for Zero Weight Influence */
  55303. targetBoneIndex?: number;
  55304. }
  55305. /**
  55306. * Simple structure of the gradient steps for the Color Map.
  55307. */
  55308. export interface ISkeletonMapShaderColorMapKnot {
  55309. /** Color of the Knot */
  55310. color: Color3;
  55311. /** Location of the Knot */
  55312. location: number;
  55313. }
  55314. /**
  55315. * Defines the constructor options for the SkeletonMap Shader.
  55316. */
  55317. export interface ISkeletonMapShaderOptions {
  55318. /** Skeleton to Map */
  55319. skeleton: Skeleton;
  55320. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55321. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55322. }
  55323. }
  55324. declare module BABYLON {
  55325. /**
  55326. * Class containing static functions to help procedurally build meshes
  55327. */
  55328. export class RibbonBuilder {
  55329. /**
  55330. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55331. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55332. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55333. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55334. * * 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
  55335. * * 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
  55336. * * 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
  55337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55338. * * 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
  55339. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55340. * * 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
  55341. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55342. * * 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
  55343. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55345. * @param name defines the name of the mesh
  55346. * @param options defines the options used to create the mesh
  55347. * @param scene defines the hosting scene
  55348. * @returns the ribbon mesh
  55349. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55351. */
  55352. static CreateRibbon(name: string, options: {
  55353. pathArray: Vector3[][];
  55354. closeArray?: boolean;
  55355. closePath?: boolean;
  55356. offset?: number;
  55357. updatable?: boolean;
  55358. sideOrientation?: number;
  55359. frontUVs?: Vector4;
  55360. backUVs?: Vector4;
  55361. instance?: Mesh;
  55362. invertUV?: boolean;
  55363. uvs?: Vector2[];
  55364. colors?: Color4[];
  55365. }, scene?: Nullable<Scene>): Mesh;
  55366. }
  55367. }
  55368. declare module BABYLON {
  55369. /**
  55370. * Class containing static functions to help procedurally build meshes
  55371. */
  55372. export class ShapeBuilder {
  55373. /**
  55374. * 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.
  55375. * * 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.
  55376. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55377. * * 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.
  55378. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55379. * * 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
  55380. * * 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
  55381. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55386. * @param name defines the name of the mesh
  55387. * @param options defines the options used to create the mesh
  55388. * @param scene defines the hosting scene
  55389. * @returns the extruded shape mesh
  55390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55392. */
  55393. static ExtrudeShape(name: string, options: {
  55394. shape: Vector3[];
  55395. path: Vector3[];
  55396. scale?: number;
  55397. rotation?: number;
  55398. cap?: number;
  55399. updatable?: boolean;
  55400. sideOrientation?: number;
  55401. frontUVs?: Vector4;
  55402. backUVs?: Vector4;
  55403. instance?: Mesh;
  55404. invertUV?: boolean;
  55405. }, scene?: Nullable<Scene>): Mesh;
  55406. /**
  55407. * Creates an custom extruded shape mesh.
  55408. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55409. * * 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.
  55410. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55411. * * 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
  55412. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55413. * * 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
  55414. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55415. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55416. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55417. * * 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
  55418. * * 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
  55419. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55421. * * 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
  55422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55424. * @param name defines the name of the mesh
  55425. * @param options defines the options used to create the mesh
  55426. * @param scene defines the hosting scene
  55427. * @returns the custom extruded shape mesh
  55428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55429. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55431. */
  55432. static ExtrudeShapeCustom(name: string, options: {
  55433. shape: Vector3[];
  55434. path: Vector3[];
  55435. scaleFunction?: any;
  55436. rotationFunction?: any;
  55437. ribbonCloseArray?: boolean;
  55438. ribbonClosePath?: boolean;
  55439. cap?: number;
  55440. updatable?: boolean;
  55441. sideOrientation?: number;
  55442. frontUVs?: Vector4;
  55443. backUVs?: Vector4;
  55444. instance?: Mesh;
  55445. invertUV?: boolean;
  55446. }, scene?: Nullable<Scene>): Mesh;
  55447. private static _ExtrudeShapeGeneric;
  55448. }
  55449. }
  55450. declare module BABYLON.Debug {
  55451. /**
  55452. * Class used to render a debug view of a given skeleton
  55453. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55454. */
  55455. export class SkeletonViewer {
  55456. /** defines the skeleton to render */
  55457. skeleton: Skeleton;
  55458. /** defines the mesh attached to the skeleton */
  55459. mesh: AbstractMesh;
  55460. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55461. autoUpdateBonesMatrices: boolean;
  55462. /** defines the rendering group id to use with the viewer */
  55463. renderingGroupId: number;
  55464. /** is the options for the viewer */
  55465. options: Partial<ISkeletonViewerOptions>;
  55466. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55467. static readonly DISPLAY_LINES: number;
  55468. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55469. static readonly DISPLAY_SPHERES: number;
  55470. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55471. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55472. /** public static method to create a BoneWeight Shader
  55473. * @param options The constructor options
  55474. * @param scene The scene that the shader is scoped to
  55475. * @returns The created ShaderMaterial
  55476. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55477. */
  55478. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55479. /** public static method to create a BoneWeight Shader
  55480. * @param options The constructor options
  55481. * @param scene The scene that the shader is scoped to
  55482. * @returns The created ShaderMaterial
  55483. */
  55484. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55485. /** private static method to create a BoneWeight Shader
  55486. * @param size The size of the buffer to create (usually the bone count)
  55487. * @param colorMap The gradient data to generate
  55488. * @param scene The scene that the shader is scoped to
  55489. * @returns an Array of floats from the color gradient values
  55490. */
  55491. private static _CreateBoneMapColorBuffer;
  55492. /** If SkeletonViewer scene scope. */
  55493. private _scene;
  55494. /** Gets or sets the color used to render the skeleton */
  55495. color: Color3;
  55496. /** Array of the points of the skeleton fo the line view. */
  55497. private _debugLines;
  55498. /** The SkeletonViewers Mesh. */
  55499. private _debugMesh;
  55500. /** The local axes Meshes. */
  55501. private _localAxes;
  55502. /** If SkeletonViewer is enabled. */
  55503. private _isEnabled;
  55504. /** If SkeletonViewer is ready. */
  55505. private _ready;
  55506. /** SkeletonViewer render observable. */
  55507. private _obs;
  55508. /** The Utility Layer to render the gizmos in. */
  55509. private _utilityLayer;
  55510. private _boneIndices;
  55511. /** Gets the Scene. */
  55512. get scene(): Scene;
  55513. /** Gets the utilityLayer. */
  55514. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55515. /** Checks Ready Status. */
  55516. get isReady(): Boolean;
  55517. /** Sets Ready Status. */
  55518. set ready(value: boolean);
  55519. /** Gets the debugMesh */
  55520. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55521. /** Sets the debugMesh */
  55522. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55523. /** Gets the displayMode */
  55524. get displayMode(): number;
  55525. /** Sets the displayMode */
  55526. set displayMode(value: number);
  55527. /**
  55528. * Creates a new SkeletonViewer
  55529. * @param skeleton defines the skeleton to render
  55530. * @param mesh defines the mesh attached to the skeleton
  55531. * @param scene defines the hosting scene
  55532. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55533. * @param renderingGroupId defines the rendering group id to use with the viewer
  55534. * @param options All of the extra constructor options for the SkeletonViewer
  55535. */
  55536. constructor(
  55537. /** defines the skeleton to render */
  55538. skeleton: Skeleton,
  55539. /** defines the mesh attached to the skeleton */
  55540. mesh: AbstractMesh,
  55541. /** The Scene scope*/
  55542. scene: Scene,
  55543. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55544. autoUpdateBonesMatrices?: boolean,
  55545. /** defines the rendering group id to use with the viewer */
  55546. renderingGroupId?: number,
  55547. /** is the options for the viewer */
  55548. options?: Partial<ISkeletonViewerOptions>);
  55549. /** The Dynamic bindings for the update functions */
  55550. private _bindObs;
  55551. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55552. update(): void;
  55553. /** Gets or sets a boolean indicating if the viewer is enabled */
  55554. set isEnabled(value: boolean);
  55555. get isEnabled(): boolean;
  55556. private _getBonePosition;
  55557. private _getLinesForBonesWithLength;
  55558. private _getLinesForBonesNoLength;
  55559. /** function to revert the mesh and scene back to the initial state. */
  55560. private _revert;
  55561. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55562. private _getAbsoluteBindPoseToRef;
  55563. /** function to build and bind sphere joint points and spur bone representations. */
  55564. private _buildSpheresAndSpurs;
  55565. private _buildLocalAxes;
  55566. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55567. private _displayLinesUpdate;
  55568. /** Changes the displayMode of the skeleton viewer
  55569. * @param mode The displayMode numerical value
  55570. */
  55571. changeDisplayMode(mode: number): void;
  55572. /** Sets a display option of the skeleton viewer
  55573. *
  55574. * | Option | Type | Default | Description |
  55575. * | ---------------- | ------- | ------- | ----------- |
  55576. * | 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`. |
  55577. * | 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`. |
  55578. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55579. * | 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`. |
  55580. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55581. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55582. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55583. *
  55584. * @param option String of the option name
  55585. * @param value The numerical option value
  55586. */
  55587. changeDisplayOptions(option: string, value: number): void;
  55588. /** Release associated resources */
  55589. dispose(): void;
  55590. }
  55591. }
  55592. declare module BABYLON {
  55593. /**
  55594. * Enum for Device Types
  55595. */
  55596. export enum DeviceType {
  55597. /** Generic */
  55598. Generic = 0,
  55599. /** Keyboard */
  55600. Keyboard = 1,
  55601. /** Mouse */
  55602. Mouse = 2,
  55603. /** Touch Pointers */
  55604. Touch = 3,
  55605. /** PS4 Dual Shock */
  55606. DualShock = 4,
  55607. /** Xbox */
  55608. Xbox = 5,
  55609. /** Switch Controller */
  55610. Switch = 6
  55611. }
  55612. /**
  55613. * Enum for All Pointers (Touch/Mouse)
  55614. */
  55615. export enum PointerInput {
  55616. /** Horizontal Axis */
  55617. Horizontal = 0,
  55618. /** Vertical Axis */
  55619. Vertical = 1,
  55620. /** Left Click or Touch */
  55621. LeftClick = 2,
  55622. /** Middle Click */
  55623. MiddleClick = 3,
  55624. /** Right Click */
  55625. RightClick = 4,
  55626. /** Browser Back */
  55627. BrowserBack = 5,
  55628. /** Browser Forward */
  55629. BrowserForward = 6
  55630. }
  55631. /**
  55632. * Enum for Dual Shock Gamepad
  55633. */
  55634. export enum DualShockInput {
  55635. /** Cross */
  55636. Cross = 0,
  55637. /** Circle */
  55638. Circle = 1,
  55639. /** Square */
  55640. Square = 2,
  55641. /** Triangle */
  55642. Triangle = 3,
  55643. /** L1 */
  55644. L1 = 4,
  55645. /** R1 */
  55646. R1 = 5,
  55647. /** L2 */
  55648. L2 = 6,
  55649. /** R2 */
  55650. R2 = 7,
  55651. /** Share */
  55652. Share = 8,
  55653. /** Options */
  55654. Options = 9,
  55655. /** L3 */
  55656. L3 = 10,
  55657. /** R3 */
  55658. R3 = 11,
  55659. /** DPadUp */
  55660. DPadUp = 12,
  55661. /** DPadDown */
  55662. DPadDown = 13,
  55663. /** DPadLeft */
  55664. DPadLeft = 14,
  55665. /** DRight */
  55666. DPadRight = 15,
  55667. /** Home */
  55668. Home = 16,
  55669. /** TouchPad */
  55670. TouchPad = 17,
  55671. /** LStickXAxis */
  55672. LStickXAxis = 18,
  55673. /** LStickYAxis */
  55674. LStickYAxis = 19,
  55675. /** RStickXAxis */
  55676. RStickXAxis = 20,
  55677. /** RStickYAxis */
  55678. RStickYAxis = 21
  55679. }
  55680. /**
  55681. * Enum for Xbox Gamepad
  55682. */
  55683. export enum XboxInput {
  55684. /** A */
  55685. A = 0,
  55686. /** B */
  55687. B = 1,
  55688. /** X */
  55689. X = 2,
  55690. /** Y */
  55691. Y = 3,
  55692. /** LB */
  55693. LB = 4,
  55694. /** RB */
  55695. RB = 5,
  55696. /** LT */
  55697. LT = 6,
  55698. /** RT */
  55699. RT = 7,
  55700. /** Back */
  55701. Back = 8,
  55702. /** Start */
  55703. Start = 9,
  55704. /** LS */
  55705. LS = 10,
  55706. /** RS */
  55707. RS = 11,
  55708. /** DPadUp */
  55709. DPadUp = 12,
  55710. /** DPadDown */
  55711. DPadDown = 13,
  55712. /** DPadLeft */
  55713. DPadLeft = 14,
  55714. /** DRight */
  55715. DPadRight = 15,
  55716. /** Home */
  55717. Home = 16,
  55718. /** LStickXAxis */
  55719. LStickXAxis = 17,
  55720. /** LStickYAxis */
  55721. LStickYAxis = 18,
  55722. /** RStickXAxis */
  55723. RStickXAxis = 19,
  55724. /** RStickYAxis */
  55725. RStickYAxis = 20
  55726. }
  55727. /**
  55728. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55729. */
  55730. export enum SwitchInput {
  55731. /** B */
  55732. B = 0,
  55733. /** A */
  55734. A = 1,
  55735. /** Y */
  55736. Y = 2,
  55737. /** X */
  55738. X = 3,
  55739. /** L */
  55740. L = 4,
  55741. /** R */
  55742. R = 5,
  55743. /** ZL */
  55744. ZL = 6,
  55745. /** ZR */
  55746. ZR = 7,
  55747. /** Minus */
  55748. Minus = 8,
  55749. /** Plus */
  55750. Plus = 9,
  55751. /** LS */
  55752. LS = 10,
  55753. /** RS */
  55754. RS = 11,
  55755. /** DPadUp */
  55756. DPadUp = 12,
  55757. /** DPadDown */
  55758. DPadDown = 13,
  55759. /** DPadLeft */
  55760. DPadLeft = 14,
  55761. /** DRight */
  55762. DPadRight = 15,
  55763. /** Home */
  55764. Home = 16,
  55765. /** Capture */
  55766. Capture = 17,
  55767. /** LStickXAxis */
  55768. LStickXAxis = 18,
  55769. /** LStickYAxis */
  55770. LStickYAxis = 19,
  55771. /** RStickXAxis */
  55772. RStickXAxis = 20,
  55773. /** RStickYAxis */
  55774. RStickYAxis = 21
  55775. }
  55776. }
  55777. declare module BABYLON {
  55778. /**
  55779. * This class will take all inputs from Keyboard, Pointer, and
  55780. * any Gamepads and provide a polling system that all devices
  55781. * will use. This class assumes that there will only be one
  55782. * pointer device and one keyboard.
  55783. */
  55784. export class DeviceInputSystem implements IDisposable {
  55785. /**
  55786. * Returns onDeviceConnected callback property
  55787. * @returns Callback with function to execute when a device is connected
  55788. */
  55789. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55790. /**
  55791. * Sets callback function when a device is connected and executes against all connected devices
  55792. * @param callback Function to execute when a device is connected
  55793. */
  55794. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55795. /**
  55796. * Callback to be triggered when a device is disconnected
  55797. */
  55798. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55799. /**
  55800. * Callback to be triggered when event driven input is updated
  55801. */
  55802. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55803. private _inputs;
  55804. private _gamepads;
  55805. private _keyboardActive;
  55806. private _pointerActive;
  55807. private _elementToAttachTo;
  55808. private _keyboardDownEvent;
  55809. private _keyboardUpEvent;
  55810. private _pointerMoveEvent;
  55811. private _pointerDownEvent;
  55812. private _pointerUpEvent;
  55813. private _gamepadConnectedEvent;
  55814. private _gamepadDisconnectedEvent;
  55815. private _onDeviceConnected;
  55816. private static _MAX_KEYCODES;
  55817. private static _MAX_POINTER_INPUTS;
  55818. private constructor();
  55819. /**
  55820. * Creates a new DeviceInputSystem instance
  55821. * @param engine Engine to pull input element from
  55822. * @returns The new instance
  55823. */
  55824. static Create(engine: Engine): DeviceInputSystem;
  55825. /**
  55826. * Checks for current device input value, given an id and input index
  55827. * @param deviceName Id of connected device
  55828. * @param inputIndex Index of device input
  55829. * @returns Current value of input
  55830. */
  55831. /**
  55832. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55833. * @param deviceType Enum specifiying device type
  55834. * @param deviceSlot "Slot" or index that device is referenced in
  55835. * @param inputIndex Id of input to be checked
  55836. * @returns Current value of input
  55837. */
  55838. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55839. /**
  55840. * Dispose of all the eventlisteners
  55841. */
  55842. dispose(): void;
  55843. /**
  55844. * Checks for existing connections to devices and register them, if necessary
  55845. * Currently handles gamepads and mouse
  55846. */
  55847. private _checkForConnectedDevices;
  55848. /**
  55849. * Add a gamepad to the DeviceInputSystem
  55850. * @param gamepad A single DOM Gamepad object
  55851. */
  55852. private _addGamePad;
  55853. /**
  55854. * Add pointer device to DeviceInputSystem
  55855. * @param deviceType Type of Pointer to add
  55856. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55857. * @param currentX Current X at point of adding
  55858. * @param currentY Current Y at point of adding
  55859. */
  55860. private _addPointerDevice;
  55861. /**
  55862. * Add device and inputs to device array
  55863. * @param deviceType Enum specifiying device type
  55864. * @param deviceSlot "Slot" or index that device is referenced in
  55865. * @param numberOfInputs Number of input entries to create for given device
  55866. */
  55867. private _registerDevice;
  55868. /**
  55869. * Given a specific device name, remove that device from the device map
  55870. * @param deviceType Enum specifiying device type
  55871. * @param deviceSlot "Slot" or index that device is referenced in
  55872. */
  55873. private _unregisterDevice;
  55874. /**
  55875. * Handle all actions that come from keyboard interaction
  55876. */
  55877. private _handleKeyActions;
  55878. /**
  55879. * Handle all actions that come from pointer interaction
  55880. */
  55881. private _handlePointerActions;
  55882. /**
  55883. * Handle all actions that come from gamepad interaction
  55884. */
  55885. private _handleGamepadActions;
  55886. /**
  55887. * Update all non-event based devices with each frame
  55888. * @param deviceType Enum specifiying device type
  55889. * @param deviceSlot "Slot" or index that device is referenced in
  55890. * @param inputIndex Id of input to be checked
  55891. */
  55892. private _updateDevice;
  55893. /**
  55894. * Gets DeviceType from the device name
  55895. * @param deviceName Name of Device from DeviceInputSystem
  55896. * @returns DeviceType enum value
  55897. */
  55898. private _getGamepadDeviceType;
  55899. }
  55900. }
  55901. declare module BABYLON {
  55902. /**
  55903. * Type to handle enforcement of inputs
  55904. */
  55905. 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;
  55906. }
  55907. declare module BABYLON {
  55908. /**
  55909. * Class that handles all input for a specific device
  55910. */
  55911. export class DeviceSource<T extends DeviceType> {
  55912. /** Type of device */
  55913. readonly deviceType: DeviceType;
  55914. /** "Slot" or index that device is referenced in */
  55915. readonly deviceSlot: number;
  55916. /**
  55917. * Observable to handle device input changes per device
  55918. */
  55919. readonly onInputChangedObservable: Observable<{
  55920. inputIndex: DeviceInput<T>;
  55921. previousState: Nullable<number>;
  55922. currentState: Nullable<number>;
  55923. }>;
  55924. private readonly _deviceInputSystem;
  55925. /**
  55926. * Default Constructor
  55927. * @param deviceInputSystem Reference to DeviceInputSystem
  55928. * @param deviceType Type of device
  55929. * @param deviceSlot "Slot" or index that device is referenced in
  55930. */
  55931. constructor(deviceInputSystem: DeviceInputSystem,
  55932. /** Type of device */
  55933. deviceType: DeviceType,
  55934. /** "Slot" or index that device is referenced in */
  55935. deviceSlot?: number);
  55936. /**
  55937. * Get input for specific input
  55938. * @param inputIndex index of specific input on device
  55939. * @returns Input value from DeviceInputSystem
  55940. */
  55941. getInput(inputIndex: DeviceInput<T>): number;
  55942. }
  55943. /**
  55944. * Class to keep track of devices
  55945. */
  55946. export class DeviceSourceManager implements IDisposable {
  55947. /**
  55948. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  55949. */
  55950. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  55951. /**
  55952. * Observable to be triggered when after a device is disconnected
  55953. */
  55954. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  55955. private readonly _devices;
  55956. private readonly _firstDevice;
  55957. private readonly _deviceInputSystem;
  55958. /**
  55959. * Default Constructor
  55960. * @param engine engine to pull input element from
  55961. */
  55962. constructor(engine: Engine);
  55963. /**
  55964. * Gets a DeviceSource, given a type and slot
  55965. * @param deviceType Enum specifying device type
  55966. * @param deviceSlot "Slot" or index that device is referenced in
  55967. * @returns DeviceSource object
  55968. */
  55969. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55970. /**
  55971. * Gets an array of DeviceSource objects for a given device type
  55972. * @param deviceType Enum specifying device type
  55973. * @returns Array of DeviceSource objects
  55974. */
  55975. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55976. /**
  55977. * Returns a read-only list of all available devices
  55978. * @returns Read-only array with active devices
  55979. */
  55980. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  55981. /**
  55982. * Dispose of DeviceInputSystem and other parts
  55983. */
  55984. dispose(): void;
  55985. /**
  55986. * Function to add device name to device list
  55987. * @param deviceType Enum specifying device type
  55988. * @param deviceSlot "Slot" or index that device is referenced in
  55989. */
  55990. private _addDevice;
  55991. /**
  55992. * Function to remove device name to device list
  55993. * @param deviceType Enum specifying device type
  55994. * @param deviceSlot "Slot" or index that device is referenced in
  55995. */
  55996. private _removeDevice;
  55997. /**
  55998. * Updates array storing first connected device of each type
  55999. * @param type Type of Device
  56000. */
  56001. private _updateFirstDevices;
  56002. }
  56003. }
  56004. declare module BABYLON {
  56005. /**
  56006. * Options to create the null engine
  56007. */
  56008. export class NullEngineOptions {
  56009. /**
  56010. * Render width (Default: 512)
  56011. */
  56012. renderWidth: number;
  56013. /**
  56014. * Render height (Default: 256)
  56015. */
  56016. renderHeight: number;
  56017. /**
  56018. * Texture size (Default: 512)
  56019. */
  56020. textureSize: number;
  56021. /**
  56022. * If delta time between frames should be constant
  56023. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56024. */
  56025. deterministicLockstep: boolean;
  56026. /**
  56027. * Maximum about of steps between frames (Default: 4)
  56028. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56029. */
  56030. lockstepMaxSteps: number;
  56031. /**
  56032. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56033. */
  56034. useHighPrecisionMatrix?: boolean;
  56035. }
  56036. /**
  56037. * The null engine class provides support for headless version of babylon.js.
  56038. * This can be used in server side scenario or for testing purposes
  56039. */
  56040. export class NullEngine extends Engine {
  56041. private _options;
  56042. /**
  56043. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56044. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56045. * @returns true if engine is in deterministic lock step mode
  56046. */
  56047. isDeterministicLockStep(): boolean;
  56048. /**
  56049. * Gets the max steps when engine is running in deterministic lock step
  56050. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56051. * @returns the max steps
  56052. */
  56053. getLockstepMaxSteps(): number;
  56054. /**
  56055. * Gets the current hardware scaling level.
  56056. * By default the hardware scaling level is computed from the window device ratio.
  56057. * 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.
  56058. * @returns a number indicating the current hardware scaling level
  56059. */
  56060. getHardwareScalingLevel(): number;
  56061. constructor(options?: NullEngineOptions);
  56062. /**
  56063. * Creates a vertex buffer
  56064. * @param vertices the data for the vertex buffer
  56065. * @returns the new WebGL static buffer
  56066. */
  56067. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56068. /**
  56069. * Creates a new index buffer
  56070. * @param indices defines the content of the index buffer
  56071. * @param updatable defines if the index buffer must be updatable
  56072. * @returns a new webGL buffer
  56073. */
  56074. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56075. /**
  56076. * Clear the current render buffer or the current render target (if any is set up)
  56077. * @param color defines the color to use
  56078. * @param backBuffer defines if the back buffer must be cleared
  56079. * @param depth defines if the depth buffer must be cleared
  56080. * @param stencil defines if the stencil buffer must be cleared
  56081. */
  56082. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56083. /**
  56084. * Gets the current render width
  56085. * @param useScreen defines if screen size must be used (or the current render target if any)
  56086. * @returns a number defining the current render width
  56087. */
  56088. getRenderWidth(useScreen?: boolean): number;
  56089. /**
  56090. * Gets the current render height
  56091. * @param useScreen defines if screen size must be used (or the current render target if any)
  56092. * @returns a number defining the current render height
  56093. */
  56094. getRenderHeight(useScreen?: boolean): number;
  56095. /**
  56096. * Set the WebGL's viewport
  56097. * @param viewport defines the viewport element to be used
  56098. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56099. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56100. */
  56101. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56102. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56103. /**
  56104. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56105. * @param pipelineContext defines the pipeline context to use
  56106. * @param uniformsNames defines the list of uniform names
  56107. * @returns an array of webGL uniform locations
  56108. */
  56109. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56110. /**
  56111. * Gets the lsit of active attributes for a given webGL program
  56112. * @param pipelineContext defines the pipeline context to use
  56113. * @param attributesNames defines the list of attribute names to get
  56114. * @returns an array of indices indicating the offset of each attribute
  56115. */
  56116. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56117. /**
  56118. * Binds an effect to the webGL context
  56119. * @param effect defines the effect to bind
  56120. */
  56121. bindSamplers(effect: Effect): void;
  56122. /**
  56123. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56124. * @param effect defines the effect to activate
  56125. */
  56126. enableEffect(effect: Effect): void;
  56127. /**
  56128. * Set various states to the webGL context
  56129. * @param culling defines backface culling state
  56130. * @param zOffset defines the value to apply to zOffset (0 by default)
  56131. * @param force defines if states must be applied even if cache is up to date
  56132. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56133. */
  56134. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56135. /**
  56136. * Set the value of an uniform to an array of int32
  56137. * @param uniform defines the webGL uniform location where to store the value
  56138. * @param array defines the array of int32 to store
  56139. * @returns true if value was set
  56140. */
  56141. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56142. /**
  56143. * Set the value of an uniform to an array of int32 (stored as vec2)
  56144. * @param uniform defines the webGL uniform location where to store the value
  56145. * @param array defines the array of int32 to store
  56146. * @returns true if value was set
  56147. */
  56148. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56149. /**
  56150. * Set the value of an uniform to an array of int32 (stored as vec3)
  56151. * @param uniform defines the webGL uniform location where to store the value
  56152. * @param array defines the array of int32 to store
  56153. * @returns true if value was set
  56154. */
  56155. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56156. /**
  56157. * Set the value of an uniform to an array of int32 (stored as vec4)
  56158. * @param uniform defines the webGL uniform location where to store the value
  56159. * @param array defines the array of int32 to store
  56160. * @returns true if value was set
  56161. */
  56162. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56163. /**
  56164. * Set the value of an uniform to an array of float32
  56165. * @param uniform defines the webGL uniform location where to store the value
  56166. * @param array defines the array of float32 to store
  56167. * @returns true if value was set
  56168. */
  56169. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56170. /**
  56171. * Set the value of an uniform to an array of float32 (stored as vec2)
  56172. * @param uniform defines the webGL uniform location where to store the value
  56173. * @param array defines the array of float32 to store
  56174. * @returns true if value was set
  56175. */
  56176. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56177. /**
  56178. * Set the value of an uniform to an array of float32 (stored as vec3)
  56179. * @param uniform defines the webGL uniform location where to store the value
  56180. * @param array defines the array of float32 to store
  56181. * @returns true if value was set
  56182. */
  56183. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56184. /**
  56185. * Set the value of an uniform to an array of float32 (stored as vec4)
  56186. * @param uniform defines the webGL uniform location where to store the value
  56187. * @param array defines the array of float32 to store
  56188. * @returns true if value was set
  56189. */
  56190. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56191. /**
  56192. * Set the value of an uniform to an array of number
  56193. * @param uniform defines the webGL uniform location where to store the value
  56194. * @param array defines the array of number to store
  56195. * @returns true if value was set
  56196. */
  56197. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56198. /**
  56199. * Set the value of an uniform to an array of number (stored as vec2)
  56200. * @param uniform defines the webGL uniform location where to store the value
  56201. * @param array defines the array of number to store
  56202. * @returns true if value was set
  56203. */
  56204. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56205. /**
  56206. * Set the value of an uniform to an array of number (stored as vec3)
  56207. * @param uniform defines the webGL uniform location where to store the value
  56208. * @param array defines the array of number to store
  56209. * @returns true if value was set
  56210. */
  56211. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56212. /**
  56213. * Set the value of an uniform to an array of number (stored as vec4)
  56214. * @param uniform defines the webGL uniform location where to store the value
  56215. * @param array defines the array of number to store
  56216. * @returns true if value was set
  56217. */
  56218. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56219. /**
  56220. * Set the value of an uniform to an array of float32 (stored as matrices)
  56221. * @param uniform defines the webGL uniform location where to store the value
  56222. * @param matrices defines the array of float32 to store
  56223. * @returns true if value was set
  56224. */
  56225. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56226. /**
  56227. * Set the value of an uniform to a matrix (3x3)
  56228. * @param uniform defines the webGL uniform location where to store the value
  56229. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56230. * @returns true if value was set
  56231. */
  56232. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56233. /**
  56234. * Set the value of an uniform to a matrix (2x2)
  56235. * @param uniform defines the webGL uniform location where to store the value
  56236. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56237. * @returns true if value was set
  56238. */
  56239. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56240. /**
  56241. * Set the value of an uniform to a number (float)
  56242. * @param uniform defines the webGL uniform location where to store the value
  56243. * @param value defines the float number to store
  56244. * @returns true if value was set
  56245. */
  56246. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56247. /**
  56248. * Set the value of an uniform to a vec2
  56249. * @param uniform defines the webGL uniform location where to store the value
  56250. * @param x defines the 1st component of the value
  56251. * @param y defines the 2nd component of the value
  56252. * @returns true if value was set
  56253. */
  56254. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56255. /**
  56256. * Set the value of an uniform to a vec3
  56257. * @param uniform defines the webGL uniform location where to store the value
  56258. * @param x defines the 1st component of the value
  56259. * @param y defines the 2nd component of the value
  56260. * @param z defines the 3rd component of the value
  56261. * @returns true if value was set
  56262. */
  56263. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56264. /**
  56265. * Set the value of an uniform to a boolean
  56266. * @param uniform defines the webGL uniform location where to store the value
  56267. * @param bool defines the boolean to store
  56268. * @returns true if value was set
  56269. */
  56270. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56271. /**
  56272. * Set the value of an uniform to a vec4
  56273. * @param uniform defines the webGL uniform location where to store the value
  56274. * @param x defines the 1st component of the value
  56275. * @param y defines the 2nd component of the value
  56276. * @param z defines the 3rd component of the value
  56277. * @param w defines the 4th component of the value
  56278. * @returns true if value was set
  56279. */
  56280. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56281. /**
  56282. * Sets the current alpha mode
  56283. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56284. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56285. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56286. */
  56287. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56288. /**
  56289. * Bind webGl buffers directly to the webGL context
  56290. * @param vertexBuffers defines the vertex buffer to bind
  56291. * @param indexBuffer defines the index buffer to bind
  56292. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56293. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56294. * @param effect defines the effect associated with the vertex buffer
  56295. */
  56296. bindBuffers(vertexBuffers: {
  56297. [key: string]: VertexBuffer;
  56298. }, indexBuffer: DataBuffer, effect: Effect): void;
  56299. /**
  56300. * Force the entire cache to be cleared
  56301. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56302. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56303. */
  56304. wipeCaches(bruteForce?: boolean): void;
  56305. /**
  56306. * Send a draw order
  56307. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56308. * @param indexStart defines the starting index
  56309. * @param indexCount defines the number of index to draw
  56310. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56311. */
  56312. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56313. /**
  56314. * Draw a list of indexed primitives
  56315. * @param fillMode defines the primitive to use
  56316. * @param indexStart defines the starting index
  56317. * @param indexCount defines the number of index to draw
  56318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56319. */
  56320. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56321. /**
  56322. * Draw a list of unindexed primitives
  56323. * @param fillMode defines the primitive to use
  56324. * @param verticesStart defines the index of first vertex to draw
  56325. * @param verticesCount defines the count of vertices to draw
  56326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56327. */
  56328. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56329. /** @hidden */
  56330. _createTexture(): WebGLTexture;
  56331. /** @hidden */
  56332. _releaseTexture(texture: InternalTexture): void;
  56333. /**
  56334. * Usually called from Texture.ts.
  56335. * Passed information to create a WebGLTexture
  56336. * @param urlArg defines a value which contains one of the following:
  56337. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56338. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56339. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56340. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56341. * @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)
  56342. * @param scene needed for loading to the correct scene
  56343. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56344. * @param onLoad optional callback to be called upon successful completion
  56345. * @param onError optional callback to be called upon failure
  56346. * @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
  56347. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56348. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56349. * @param forcedExtension defines the extension to use to pick the right loader
  56350. * @param mimeType defines an optional mime type
  56351. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56352. */
  56353. 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;
  56354. /**
  56355. * Creates a new render target texture
  56356. * @param size defines the size of the texture
  56357. * @param options defines the options used to create the texture
  56358. * @returns a new render target texture stored in an InternalTexture
  56359. */
  56360. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56361. /**
  56362. * Update the sampling mode of a given texture
  56363. * @param samplingMode defines the required sampling mode
  56364. * @param texture defines the texture to update
  56365. */
  56366. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56367. /**
  56368. * Binds the frame buffer to the specified texture.
  56369. * @param texture The texture to render to or null for the default canvas
  56370. * @param faceIndex The face of the texture to render to in case of cube texture
  56371. * @param requiredWidth The width of the target to render to
  56372. * @param requiredHeight The height of the target to render to
  56373. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56374. * @param lodLevel defines le lod level to bind to the frame buffer
  56375. */
  56376. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56377. /**
  56378. * Unbind the current render target texture from the webGL context
  56379. * @param texture defines the render target texture to unbind
  56380. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56381. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56382. */
  56383. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56384. /**
  56385. * Creates a dynamic vertex buffer
  56386. * @param vertices the data for the dynamic vertex buffer
  56387. * @returns the new WebGL dynamic buffer
  56388. */
  56389. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56390. /**
  56391. * Update the content of a dynamic texture
  56392. * @param texture defines the texture to update
  56393. * @param canvas defines the canvas containing the source
  56394. * @param invertY defines if data must be stored with Y axis inverted
  56395. * @param premulAlpha defines if alpha is stored as premultiplied
  56396. * @param format defines the format of the data
  56397. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56398. */
  56399. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56400. /**
  56401. * Gets a boolean indicating if all created effects are ready
  56402. * @returns true if all effects are ready
  56403. */
  56404. areAllEffectsReady(): boolean;
  56405. /**
  56406. * @hidden
  56407. * Get the current error code of the webGL context
  56408. * @returns the error code
  56409. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56410. */
  56411. getError(): number;
  56412. /** @hidden */
  56413. _getUnpackAlignement(): number;
  56414. /** @hidden */
  56415. _unpackFlipY(value: boolean): void;
  56416. /**
  56417. * Update a dynamic index buffer
  56418. * @param indexBuffer defines the target index buffer
  56419. * @param indices defines the data to update
  56420. * @param offset defines the offset in the target index buffer where update should start
  56421. */
  56422. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56423. /**
  56424. * Updates a dynamic vertex buffer.
  56425. * @param vertexBuffer the vertex buffer to update
  56426. * @param vertices the data used to update the vertex buffer
  56427. * @param byteOffset the byte offset of the data (optional)
  56428. * @param byteLength the byte length of the data (optional)
  56429. */
  56430. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56431. /** @hidden */
  56432. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56433. /** @hidden */
  56434. _bindTexture(channel: number, texture: InternalTexture): void;
  56435. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56436. /**
  56437. * 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
  56438. */
  56439. releaseEffects(): void;
  56440. displayLoadingUI(): void;
  56441. hideLoadingUI(): void;
  56442. /** @hidden */
  56443. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56444. /** @hidden */
  56445. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56446. /** @hidden */
  56447. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56448. /** @hidden */
  56449. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56450. }
  56451. }
  56452. declare module BABYLON {
  56453. /**
  56454. * @hidden
  56455. **/
  56456. export class _TimeToken {
  56457. _startTimeQuery: Nullable<WebGLQuery>;
  56458. _endTimeQuery: Nullable<WebGLQuery>;
  56459. _timeElapsedQuery: Nullable<WebGLQuery>;
  56460. _timeElapsedQueryEnded: boolean;
  56461. }
  56462. }
  56463. declare module BABYLON {
  56464. /** @hidden */
  56465. export class _OcclusionDataStorage {
  56466. /** @hidden */
  56467. occlusionInternalRetryCounter: number;
  56468. /** @hidden */
  56469. isOcclusionQueryInProgress: boolean;
  56470. /** @hidden */
  56471. isOccluded: boolean;
  56472. /** @hidden */
  56473. occlusionRetryCount: number;
  56474. /** @hidden */
  56475. occlusionType: number;
  56476. /** @hidden */
  56477. occlusionQueryAlgorithmType: number;
  56478. }
  56479. interface Engine {
  56480. /**
  56481. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56482. * @return the new query
  56483. */
  56484. createQuery(): WebGLQuery;
  56485. /**
  56486. * Delete and release a webGL query
  56487. * @param query defines the query to delete
  56488. * @return the current engine
  56489. */
  56490. deleteQuery(query: WebGLQuery): Engine;
  56491. /**
  56492. * Check if a given query has resolved and got its value
  56493. * @param query defines the query to check
  56494. * @returns true if the query got its value
  56495. */
  56496. isQueryResultAvailable(query: WebGLQuery): boolean;
  56497. /**
  56498. * Gets the value of a given query
  56499. * @param query defines the query to check
  56500. * @returns the value of the query
  56501. */
  56502. getQueryResult(query: WebGLQuery): number;
  56503. /**
  56504. * Initiates an occlusion query
  56505. * @param algorithmType defines the algorithm to use
  56506. * @param query defines the query to use
  56507. * @returns the current engine
  56508. * @see https://doc.babylonjs.com/features/occlusionquery
  56509. */
  56510. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56511. /**
  56512. * Ends an occlusion query
  56513. * @see https://doc.babylonjs.com/features/occlusionquery
  56514. * @param algorithmType defines the algorithm to use
  56515. * @returns the current engine
  56516. */
  56517. endOcclusionQuery(algorithmType: number): Engine;
  56518. /**
  56519. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56520. * Please note that only one query can be issued at a time
  56521. * @returns a time token used to track the time span
  56522. */
  56523. startTimeQuery(): Nullable<_TimeToken>;
  56524. /**
  56525. * Ends a time query
  56526. * @param token defines the token used to measure the time span
  56527. * @returns the time spent (in ns)
  56528. */
  56529. endTimeQuery(token: _TimeToken): int;
  56530. /** @hidden */
  56531. _currentNonTimestampToken: Nullable<_TimeToken>;
  56532. /** @hidden */
  56533. _createTimeQuery(): WebGLQuery;
  56534. /** @hidden */
  56535. _deleteTimeQuery(query: WebGLQuery): void;
  56536. /** @hidden */
  56537. _getGlAlgorithmType(algorithmType: number): number;
  56538. /** @hidden */
  56539. _getTimeQueryResult(query: WebGLQuery): any;
  56540. /** @hidden */
  56541. _getTimeQueryAvailability(query: WebGLQuery): any;
  56542. }
  56543. interface AbstractMesh {
  56544. /**
  56545. * Backing filed
  56546. * @hidden
  56547. */
  56548. __occlusionDataStorage: _OcclusionDataStorage;
  56549. /**
  56550. * Access property
  56551. * @hidden
  56552. */
  56553. _occlusionDataStorage: _OcclusionDataStorage;
  56554. /**
  56555. * 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.
  56556. * The default value is -1 which means don't break the query and wait till the result
  56557. * @see https://doc.babylonjs.com/features/occlusionquery
  56558. */
  56559. occlusionRetryCount: number;
  56560. /**
  56561. * 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:
  56562. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56563. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56564. * * 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.
  56565. * @see https://doc.babylonjs.com/features/occlusionquery
  56566. */
  56567. occlusionType: number;
  56568. /**
  56569. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56570. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56571. * * 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.
  56572. * @see https://doc.babylonjs.com/features/occlusionquery
  56573. */
  56574. occlusionQueryAlgorithmType: number;
  56575. /**
  56576. * 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
  56577. * @see https://doc.babylonjs.com/features/occlusionquery
  56578. */
  56579. isOccluded: boolean;
  56580. /**
  56581. * Flag to check the progress status of the query
  56582. * @see https://doc.babylonjs.com/features/occlusionquery
  56583. */
  56584. isOcclusionQueryInProgress: boolean;
  56585. }
  56586. }
  56587. declare module BABYLON {
  56588. /** @hidden */
  56589. export var _forceTransformFeedbackToBundle: boolean;
  56590. interface Engine {
  56591. /**
  56592. * Creates a webGL transform feedback object
  56593. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56594. * @returns the webGL transform feedback object
  56595. */
  56596. createTransformFeedback(): WebGLTransformFeedback;
  56597. /**
  56598. * Delete a webGL transform feedback object
  56599. * @param value defines the webGL transform feedback object to delete
  56600. */
  56601. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56602. /**
  56603. * Bind a webGL transform feedback object to the webgl context
  56604. * @param value defines the webGL transform feedback object to bind
  56605. */
  56606. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56607. /**
  56608. * Begins a transform feedback operation
  56609. * @param usePoints defines if points or triangles must be used
  56610. */
  56611. beginTransformFeedback(usePoints: boolean): void;
  56612. /**
  56613. * Ends a transform feedback operation
  56614. */
  56615. endTransformFeedback(): void;
  56616. /**
  56617. * Specify the varyings to use with transform feedback
  56618. * @param program defines the associated webGL program
  56619. * @param value defines the list of strings representing the varying names
  56620. */
  56621. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56622. /**
  56623. * Bind a webGL buffer for a transform feedback operation
  56624. * @param value defines the webGL buffer to bind
  56625. */
  56626. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56627. }
  56628. }
  56629. declare module BABYLON {
  56630. /**
  56631. * Class used to define an additional view for the engine
  56632. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56633. */
  56634. export class EngineView {
  56635. /** Defines the canvas where to render the view */
  56636. target: HTMLCanvasElement;
  56637. /** Defines an optional camera used to render the view (will use active camera else) */
  56638. camera?: Camera;
  56639. }
  56640. interface Engine {
  56641. /**
  56642. * Gets or sets the HTML element to use for attaching events
  56643. */
  56644. inputElement: Nullable<HTMLElement>;
  56645. /**
  56646. * Gets the current engine view
  56647. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56648. */
  56649. activeView: Nullable<EngineView>;
  56650. /** Gets or sets the list of views */
  56651. views: EngineView[];
  56652. /**
  56653. * Register a new child canvas
  56654. * @param canvas defines the canvas to register
  56655. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56656. * @returns the associated view
  56657. */
  56658. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56659. /**
  56660. * Remove a registered child canvas
  56661. * @param canvas defines the canvas to remove
  56662. * @returns the current engine
  56663. */
  56664. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56665. }
  56666. }
  56667. declare module BABYLON {
  56668. interface Engine {
  56669. /** @hidden */
  56670. _excludedCompressedTextures: string[];
  56671. /** @hidden */
  56672. _textureFormatInUse: string;
  56673. /**
  56674. * Gets the list of texture formats supported
  56675. */
  56676. readonly texturesSupported: Array<string>;
  56677. /**
  56678. * Gets the texture format in use
  56679. */
  56680. readonly textureFormatInUse: Nullable<string>;
  56681. /**
  56682. * Set the compressed texture extensions or file names to skip.
  56683. *
  56684. * @param skippedFiles defines the list of those texture files you want to skip
  56685. * Example: [".dds", ".env", "myfile.png"]
  56686. */
  56687. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56688. /**
  56689. * Set the compressed texture format to use, based on the formats you have, and the formats
  56690. * supported by the hardware / browser.
  56691. *
  56692. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56693. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56694. * to API arguments needed to compressed textures. This puts the burden on the container
  56695. * generator to house the arcane code for determining these for current & future formats.
  56696. *
  56697. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56698. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56699. *
  56700. * Note: The result of this call is not taken into account when a texture is base64.
  56701. *
  56702. * @param formatsAvailable defines the list of those format families you have created
  56703. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56704. *
  56705. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56706. * @returns The extension selected.
  56707. */
  56708. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56709. }
  56710. }
  56711. declare module BABYLON {
  56712. /** @hidden */
  56713. export var rgbdEncodePixelShader: {
  56714. name: string;
  56715. shader: string;
  56716. };
  56717. }
  56718. declare module BABYLON {
  56719. /**
  56720. * Raw texture data and descriptor sufficient for WebGL texture upload
  56721. */
  56722. export interface EnvironmentTextureInfo {
  56723. /**
  56724. * Version of the environment map
  56725. */
  56726. version: number;
  56727. /**
  56728. * Width of image
  56729. */
  56730. width: number;
  56731. /**
  56732. * Irradiance information stored in the file.
  56733. */
  56734. irradiance: any;
  56735. /**
  56736. * Specular information stored in the file.
  56737. */
  56738. specular: any;
  56739. }
  56740. /**
  56741. * Defines One Image in the file. It requires only the position in the file
  56742. * as well as the length.
  56743. */
  56744. interface BufferImageData {
  56745. /**
  56746. * Length of the image data.
  56747. */
  56748. length: number;
  56749. /**
  56750. * Position of the data from the null terminator delimiting the end of the JSON.
  56751. */
  56752. position: number;
  56753. }
  56754. /**
  56755. * Defines the specular data enclosed in the file.
  56756. * This corresponds to the version 1 of the data.
  56757. */
  56758. export interface EnvironmentTextureSpecularInfoV1 {
  56759. /**
  56760. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56761. */
  56762. specularDataPosition?: number;
  56763. /**
  56764. * This contains all the images data needed to reconstruct the cubemap.
  56765. */
  56766. mipmaps: Array<BufferImageData>;
  56767. /**
  56768. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56769. */
  56770. lodGenerationScale: number;
  56771. }
  56772. /**
  56773. * Sets of helpers addressing the serialization and deserialization of environment texture
  56774. * stored in a BabylonJS env file.
  56775. * Those files are usually stored as .env files.
  56776. */
  56777. export class EnvironmentTextureTools {
  56778. /**
  56779. * Magic number identifying the env file.
  56780. */
  56781. private static _MagicBytes;
  56782. /**
  56783. * Gets the environment info from an env file.
  56784. * @param data The array buffer containing the .env bytes.
  56785. * @returns the environment file info (the json header) if successfully parsed.
  56786. */
  56787. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56788. /**
  56789. * Creates an environment texture from a loaded cube texture.
  56790. * @param texture defines the cube texture to convert in env file
  56791. * @return a promise containing the environment data if succesfull.
  56792. */
  56793. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56794. /**
  56795. * Creates a JSON representation of the spherical data.
  56796. * @param texture defines the texture containing the polynomials
  56797. * @return the JSON representation of the spherical info
  56798. */
  56799. private static _CreateEnvTextureIrradiance;
  56800. /**
  56801. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56802. * @param data the image data
  56803. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56804. * @return the views described by info providing access to the underlying buffer
  56805. */
  56806. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56807. /**
  56808. * Uploads the texture info contained in the env file to the GPU.
  56809. * @param texture defines the internal texture to upload to
  56810. * @param data defines the data to load
  56811. * @param info defines the texture info retrieved through the GetEnvInfo method
  56812. * @returns a promise
  56813. */
  56814. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56815. private static _OnImageReadyAsync;
  56816. /**
  56817. * Uploads the levels of image data to the GPU.
  56818. * @param texture defines the internal texture to upload to
  56819. * @param imageData defines the array buffer views of image data [mipmap][face]
  56820. * @returns a promise
  56821. */
  56822. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56823. /**
  56824. * Uploads spherical polynomials information to the texture.
  56825. * @param texture defines the texture we are trying to upload the information to
  56826. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56827. */
  56828. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56829. /** @hidden */
  56830. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56831. }
  56832. }
  56833. declare module BABYLON {
  56834. /**
  56835. * Class used to inline functions in shader code
  56836. */
  56837. export class ShaderCodeInliner {
  56838. private static readonly _RegexpFindFunctionNameAndType;
  56839. private _sourceCode;
  56840. private _functionDescr;
  56841. private _numMaxIterations;
  56842. /** Gets or sets the token used to mark the functions to inline */
  56843. inlineToken: string;
  56844. /** Gets or sets the debug mode */
  56845. debug: boolean;
  56846. /** Gets the code after the inlining process */
  56847. get code(): string;
  56848. /**
  56849. * Initializes the inliner
  56850. * @param sourceCode shader code source to inline
  56851. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56852. */
  56853. constructor(sourceCode: string, numMaxIterations?: number);
  56854. /**
  56855. * Start the processing of the shader code
  56856. */
  56857. processCode(): void;
  56858. private _collectFunctions;
  56859. private _processInlining;
  56860. private _extractBetweenMarkers;
  56861. private _skipWhitespaces;
  56862. private _removeComments;
  56863. private _replaceFunctionCallsByCode;
  56864. private _findBackward;
  56865. private _escapeRegExp;
  56866. private _replaceNames;
  56867. }
  56868. }
  56869. declare module BABYLON {
  56870. /**
  56871. * Container for accessors for natively-stored mesh data buffers.
  56872. */
  56873. class NativeDataBuffer extends DataBuffer {
  56874. /**
  56875. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56876. */
  56877. nativeIndexBuffer?: any;
  56878. /**
  56879. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56880. */
  56881. nativeVertexBuffer?: any;
  56882. }
  56883. /** @hidden */
  56884. class NativeTexture extends InternalTexture {
  56885. getInternalTexture(): InternalTexture;
  56886. getViewCount(): number;
  56887. }
  56888. /** @hidden */
  56889. export class NativeEngine extends Engine {
  56890. private readonly _native;
  56891. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56892. private readonly INVALID_HANDLE;
  56893. private _boundBuffersVertexArray;
  56894. private _currentDepthTest;
  56895. getHardwareScalingLevel(): number;
  56896. constructor();
  56897. dispose(): void;
  56898. /**
  56899. * Can be used to override the current requestAnimationFrame requester.
  56900. * @hidden
  56901. */
  56902. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56903. /**
  56904. * Override default engine behavior.
  56905. * @param color
  56906. * @param backBuffer
  56907. * @param depth
  56908. * @param stencil
  56909. */
  56910. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56911. /**
  56912. * Gets host document
  56913. * @returns the host document object
  56914. */
  56915. getHostDocument(): Nullable<Document>;
  56916. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56917. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56918. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56919. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56920. [key: string]: VertexBuffer;
  56921. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56922. bindBuffers(vertexBuffers: {
  56923. [key: string]: VertexBuffer;
  56924. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56925. recordVertexArrayObject(vertexBuffers: {
  56926. [key: string]: VertexBuffer;
  56927. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56928. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56929. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56931. /**
  56932. * Draw a list of indexed primitives
  56933. * @param fillMode defines the primitive to use
  56934. * @param indexStart defines the starting index
  56935. * @param indexCount defines the number of index to draw
  56936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56937. */
  56938. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56939. /**
  56940. * Draw a list of unindexed primitives
  56941. * @param fillMode defines the primitive to use
  56942. * @param verticesStart defines the index of first vertex to draw
  56943. * @param verticesCount defines the count of vertices to draw
  56944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56945. */
  56946. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56947. createPipelineContext(): IPipelineContext;
  56948. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56949. /** @hidden */
  56950. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56951. /** @hidden */
  56952. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56953. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56954. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56955. protected _setProgram(program: WebGLProgram): void;
  56956. _releaseEffect(effect: Effect): void;
  56957. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56958. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56959. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56960. bindSamplers(effect: Effect): void;
  56961. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56962. getRenderWidth(useScreen?: boolean): number;
  56963. getRenderHeight(useScreen?: boolean): number;
  56964. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56965. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56966. /**
  56967. * Set the z offset to apply to current rendering
  56968. * @param value defines the offset to apply
  56969. */
  56970. setZOffset(value: number): void;
  56971. /**
  56972. * Gets the current value of the zOffset
  56973. * @returns the current zOffset state
  56974. */
  56975. getZOffset(): number;
  56976. /**
  56977. * Enable or disable depth buffering
  56978. * @param enable defines the state to set
  56979. */
  56980. setDepthBuffer(enable: boolean): void;
  56981. /**
  56982. * Gets a boolean indicating if depth writing is enabled
  56983. * @returns the current depth writing state
  56984. */
  56985. getDepthWrite(): boolean;
  56986. setDepthFunctionToGreater(): void;
  56987. setDepthFunctionToGreaterOrEqual(): void;
  56988. setDepthFunctionToLess(): void;
  56989. setDepthFunctionToLessOrEqual(): void;
  56990. /**
  56991. * Enable or disable depth writing
  56992. * @param enable defines the state to set
  56993. */
  56994. setDepthWrite(enable: boolean): void;
  56995. /**
  56996. * Enable or disable color writing
  56997. * @param enable defines the state to set
  56998. */
  56999. setColorWrite(enable: boolean): void;
  57000. /**
  57001. * Gets a boolean indicating if color writing is enabled
  57002. * @returns the current color writing state
  57003. */
  57004. getColorWrite(): boolean;
  57005. /**
  57006. * Sets alpha constants used by some alpha blending modes
  57007. * @param r defines the red component
  57008. * @param g defines the green component
  57009. * @param b defines the blue component
  57010. * @param a defines the alpha component
  57011. */
  57012. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57013. /**
  57014. * Sets the current alpha mode
  57015. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57016. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57017. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57018. */
  57019. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57020. /**
  57021. * Gets the current alpha mode
  57022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57023. * @returns the current alpha mode
  57024. */
  57025. getAlphaMode(): number;
  57026. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57027. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57028. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57029. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57030. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57031. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57032. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57033. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57034. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57035. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57036. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57037. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57038. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57039. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57040. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57041. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57042. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57043. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57044. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57045. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57046. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57047. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57048. wipeCaches(bruteForce?: boolean): void;
  57049. _createTexture(): WebGLTexture;
  57050. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57051. /**
  57052. * Update the content of a dynamic texture
  57053. * @param texture defines the texture to update
  57054. * @param canvas defines the canvas containing the source
  57055. * @param invertY defines if data must be stored with Y axis inverted
  57056. * @param premulAlpha defines if alpha is stored as premultiplied
  57057. * @param format defines the format of the data
  57058. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57059. */
  57060. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57061. /**
  57062. * Usually called from Texture.ts.
  57063. * Passed information to create a WebGLTexture
  57064. * @param url defines a value which contains one of the following:
  57065. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57066. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57067. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57068. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57069. * @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)
  57070. * @param scene needed for loading to the correct scene
  57071. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57072. * @param onLoad optional callback to be called upon successful completion
  57073. * @param onError optional callback to be called upon failure
  57074. * @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
  57075. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57076. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57077. * @param forcedExtension defines the extension to use to pick the right loader
  57078. * @param mimeType defines an optional mime type
  57079. * @param loaderOptions options to be passed to the loader
  57080. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57081. */
  57082. 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;
  57083. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57084. _releaseFramebufferObjects(texture: InternalTexture): void;
  57085. /**
  57086. * Creates a cube texture
  57087. * @param rootUrl defines the url where the files to load is located
  57088. * @param scene defines the current scene
  57089. * @param files defines the list of files to load (1 per face)
  57090. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57091. * @param onLoad defines an optional callback raised when the texture is loaded
  57092. * @param onError defines an optional callback raised if there is an issue to load the texture
  57093. * @param format defines the format of the data
  57094. * @param forcedExtension defines the extension to use to pick the right loader
  57095. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57096. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57097. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57098. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57099. * @returns the cube texture as an InternalTexture
  57100. */
  57101. 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;
  57102. createRenderTargetTexture(size: number | {
  57103. width: number;
  57104. height: number;
  57105. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57106. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57107. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57108. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57109. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57110. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57111. /**
  57112. * Updates a dynamic vertex buffer.
  57113. * @param vertexBuffer the vertex buffer to update
  57114. * @param data the data used to update the vertex buffer
  57115. * @param byteOffset the byte offset of the data (optional)
  57116. * @param byteLength the byte length of the data (optional)
  57117. */
  57118. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57119. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57120. private _updateAnisotropicLevel;
  57121. private _getAddressMode;
  57122. /** @hidden */
  57123. _bindTexture(channel: number, texture: InternalTexture): void;
  57124. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57125. releaseEffects(): void;
  57126. /** @hidden */
  57127. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57128. /** @hidden */
  57129. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57130. /** @hidden */
  57131. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57132. /** @hidden */
  57133. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57134. private _getNativeSamplingMode;
  57135. private _getNativeTextureFormat;
  57136. private _getNativeAlphaMode;
  57137. private _getNativeAttribType;
  57138. }
  57139. }
  57140. declare module BABYLON {
  57141. /**
  57142. * Gather the list of clipboard event types as constants.
  57143. */
  57144. export class ClipboardEventTypes {
  57145. /**
  57146. * The clipboard event is fired when a copy command is active (pressed).
  57147. */
  57148. static readonly COPY: number;
  57149. /**
  57150. * The clipboard event is fired when a cut command is active (pressed).
  57151. */
  57152. static readonly CUT: number;
  57153. /**
  57154. * The clipboard event is fired when a paste command is active (pressed).
  57155. */
  57156. static readonly PASTE: number;
  57157. }
  57158. /**
  57159. * This class is used to store clipboard related info for the onClipboardObservable event.
  57160. */
  57161. export class ClipboardInfo {
  57162. /**
  57163. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57164. */
  57165. type: number;
  57166. /**
  57167. * Defines the related dom event
  57168. */
  57169. event: ClipboardEvent;
  57170. /**
  57171. *Creates an instance of ClipboardInfo.
  57172. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57173. * @param event Defines the related dom event
  57174. */
  57175. constructor(
  57176. /**
  57177. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57178. */
  57179. type: number,
  57180. /**
  57181. * Defines the related dom event
  57182. */
  57183. event: ClipboardEvent);
  57184. /**
  57185. * Get the clipboard event's type from the keycode.
  57186. * @param keyCode Defines the keyCode for the current keyboard event.
  57187. * @return {number}
  57188. */
  57189. static GetTypeFromCharacter(keyCode: number): number;
  57190. }
  57191. }
  57192. declare module BABYLON {
  57193. /**
  57194. * Google Daydream controller
  57195. */
  57196. export class DaydreamController extends WebVRController {
  57197. /**
  57198. * Base Url for the controller model.
  57199. */
  57200. static MODEL_BASE_URL: string;
  57201. /**
  57202. * File name for the controller model.
  57203. */
  57204. static MODEL_FILENAME: string;
  57205. /**
  57206. * Gamepad Id prefix used to identify Daydream Controller.
  57207. */
  57208. static readonly GAMEPAD_ID_PREFIX: string;
  57209. /**
  57210. * Creates a new DaydreamController from a gamepad
  57211. * @param vrGamepad the gamepad that the controller should be created from
  57212. */
  57213. constructor(vrGamepad: any);
  57214. /**
  57215. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57216. * @param scene scene in which to add meshes
  57217. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57218. */
  57219. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57220. /**
  57221. * Called once for each button that changed state since the last frame
  57222. * @param buttonIdx Which button index changed
  57223. * @param state New state of the button
  57224. * @param changes Which properties on the state changed since last frame
  57225. */
  57226. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57227. }
  57228. }
  57229. declare module BABYLON {
  57230. /**
  57231. * Gear VR Controller
  57232. */
  57233. export class GearVRController extends WebVRController {
  57234. /**
  57235. * Base Url for the controller model.
  57236. */
  57237. static MODEL_BASE_URL: string;
  57238. /**
  57239. * File name for the controller model.
  57240. */
  57241. static MODEL_FILENAME: string;
  57242. /**
  57243. * Gamepad Id prefix used to identify this controller.
  57244. */
  57245. static readonly GAMEPAD_ID_PREFIX: string;
  57246. private readonly _buttonIndexToObservableNameMap;
  57247. /**
  57248. * Creates a new GearVRController from a gamepad
  57249. * @param vrGamepad the gamepad that the controller should be created from
  57250. */
  57251. constructor(vrGamepad: any);
  57252. /**
  57253. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57254. * @param scene scene in which to add meshes
  57255. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57256. */
  57257. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57258. /**
  57259. * Called once for each button that changed state since the last frame
  57260. * @param buttonIdx Which button index changed
  57261. * @param state New state of the button
  57262. * @param changes Which properties on the state changed since last frame
  57263. */
  57264. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57265. }
  57266. }
  57267. declare module BABYLON {
  57268. /**
  57269. * Generic Controller
  57270. */
  57271. export class GenericController extends WebVRController {
  57272. /**
  57273. * Base Url for the controller model.
  57274. */
  57275. static readonly MODEL_BASE_URL: string;
  57276. /**
  57277. * File name for the controller model.
  57278. */
  57279. static readonly MODEL_FILENAME: string;
  57280. /**
  57281. * Creates a new GenericController from a gamepad
  57282. * @param vrGamepad the gamepad that the controller should be created from
  57283. */
  57284. constructor(vrGamepad: any);
  57285. /**
  57286. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57287. * @param scene scene in which to add meshes
  57288. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57289. */
  57290. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57291. /**
  57292. * Called once for each button that changed state since the last frame
  57293. * @param buttonIdx Which button index changed
  57294. * @param state New state of the button
  57295. * @param changes Which properties on the state changed since last frame
  57296. */
  57297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57298. }
  57299. }
  57300. declare module BABYLON {
  57301. /**
  57302. * Oculus Touch Controller
  57303. */
  57304. export class OculusTouchController extends WebVRController {
  57305. /**
  57306. * Base Url for the controller model.
  57307. */
  57308. static MODEL_BASE_URL: string;
  57309. /**
  57310. * File name for the left controller model.
  57311. */
  57312. static MODEL_LEFT_FILENAME: string;
  57313. /**
  57314. * File name for the right controller model.
  57315. */
  57316. static MODEL_RIGHT_FILENAME: string;
  57317. /**
  57318. * Base Url for the Quest controller model.
  57319. */
  57320. static QUEST_MODEL_BASE_URL: string;
  57321. /**
  57322. * @hidden
  57323. * If the controllers are running on a device that needs the updated Quest controller models
  57324. */
  57325. static _IsQuest: boolean;
  57326. /**
  57327. * Fired when the secondary trigger on this controller is modified
  57328. */
  57329. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57330. /**
  57331. * Fired when the thumb rest on this controller is modified
  57332. */
  57333. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57334. /**
  57335. * Creates a new OculusTouchController from a gamepad
  57336. * @param vrGamepad the gamepad that the controller should be created from
  57337. */
  57338. constructor(vrGamepad: any);
  57339. /**
  57340. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57341. * @param scene scene in which to add meshes
  57342. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57343. */
  57344. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57345. /**
  57346. * Fired when the A button on this controller is modified
  57347. */
  57348. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57349. /**
  57350. * Fired when the B button on this controller is modified
  57351. */
  57352. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57353. /**
  57354. * Fired when the X button on this controller is modified
  57355. */
  57356. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57357. /**
  57358. * Fired when the Y button on this controller is modified
  57359. */
  57360. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57361. /**
  57362. * Called once for each button that changed state since the last frame
  57363. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57364. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57365. * 2) secondary trigger (same)
  57366. * 3) A (right) X (left), touch, pressed = value
  57367. * 4) B / Y
  57368. * 5) thumb rest
  57369. * @param buttonIdx Which button index changed
  57370. * @param state New state of the button
  57371. * @param changes Which properties on the state changed since last frame
  57372. */
  57373. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57374. }
  57375. }
  57376. declare module BABYLON {
  57377. /**
  57378. * Vive Controller
  57379. */
  57380. export class ViveController extends WebVRController {
  57381. /**
  57382. * Base Url for the controller model.
  57383. */
  57384. static MODEL_BASE_URL: string;
  57385. /**
  57386. * File name for the controller model.
  57387. */
  57388. static MODEL_FILENAME: string;
  57389. /**
  57390. * Creates a new ViveController from a gamepad
  57391. * @param vrGamepad the gamepad that the controller should be created from
  57392. */
  57393. constructor(vrGamepad: any);
  57394. /**
  57395. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57396. * @param scene scene in which to add meshes
  57397. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57398. */
  57399. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57400. /**
  57401. * Fired when the left button on this controller is modified
  57402. */
  57403. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57404. /**
  57405. * Fired when the right button on this controller is modified
  57406. */
  57407. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57408. /**
  57409. * Fired when the menu button on this controller is modified
  57410. */
  57411. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57412. /**
  57413. * Called once for each button that changed state since the last frame
  57414. * Vive mapping:
  57415. * 0: touchpad
  57416. * 1: trigger
  57417. * 2: left AND right buttons
  57418. * 3: menu button
  57419. * @param buttonIdx Which button index changed
  57420. * @param state New state of the button
  57421. * @param changes Which properties on the state changed since last frame
  57422. */
  57423. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57424. }
  57425. }
  57426. declare module BABYLON {
  57427. /**
  57428. * Defines the WindowsMotionController object that the state of the windows motion controller
  57429. */
  57430. export class WindowsMotionController extends WebVRController {
  57431. /**
  57432. * The base url used to load the left and right controller models
  57433. */
  57434. static MODEL_BASE_URL: string;
  57435. /**
  57436. * The name of the left controller model file
  57437. */
  57438. static MODEL_LEFT_FILENAME: string;
  57439. /**
  57440. * The name of the right controller model file
  57441. */
  57442. static MODEL_RIGHT_FILENAME: string;
  57443. /**
  57444. * The controller name prefix for this controller type
  57445. */
  57446. static readonly GAMEPAD_ID_PREFIX: string;
  57447. /**
  57448. * The controller id pattern for this controller type
  57449. */
  57450. private static readonly GAMEPAD_ID_PATTERN;
  57451. private _loadedMeshInfo;
  57452. protected readonly _mapping: {
  57453. buttons: string[];
  57454. buttonMeshNames: {
  57455. trigger: string;
  57456. menu: string;
  57457. grip: string;
  57458. thumbstick: string;
  57459. trackpad: string;
  57460. };
  57461. buttonObservableNames: {
  57462. trigger: string;
  57463. menu: string;
  57464. grip: string;
  57465. thumbstick: string;
  57466. trackpad: string;
  57467. };
  57468. axisMeshNames: string[];
  57469. pointingPoseMeshName: string;
  57470. };
  57471. /**
  57472. * Fired when the trackpad on this controller is clicked
  57473. */
  57474. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57475. /**
  57476. * Fired when the trackpad on this controller is modified
  57477. */
  57478. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57479. /**
  57480. * The current x and y values of this controller's trackpad
  57481. */
  57482. trackpad: StickValues;
  57483. /**
  57484. * Creates a new WindowsMotionController from a gamepad
  57485. * @param vrGamepad the gamepad that the controller should be created from
  57486. */
  57487. constructor(vrGamepad: any);
  57488. /**
  57489. * Fired when the trigger on this controller is modified
  57490. */
  57491. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57492. /**
  57493. * Fired when the menu button on this controller is modified
  57494. */
  57495. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57496. /**
  57497. * Fired when the grip button on this controller is modified
  57498. */
  57499. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57500. /**
  57501. * Fired when the thumbstick button on this controller is modified
  57502. */
  57503. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57504. /**
  57505. * Fired when the touchpad button on this controller is modified
  57506. */
  57507. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57508. /**
  57509. * Fired when the touchpad values on this controller are modified
  57510. */
  57511. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57512. protected _updateTrackpad(): void;
  57513. /**
  57514. * Called once per frame by the engine.
  57515. */
  57516. update(): void;
  57517. /**
  57518. * Called once for each button that changed state since the last frame
  57519. * @param buttonIdx Which button index changed
  57520. * @param state New state of the button
  57521. * @param changes Which properties on the state changed since last frame
  57522. */
  57523. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57524. /**
  57525. * Moves the buttons on the controller mesh based on their current state
  57526. * @param buttonName the name of the button to move
  57527. * @param buttonValue the value of the button which determines the buttons new position
  57528. */
  57529. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57530. /**
  57531. * Moves the axis on the controller mesh based on its current state
  57532. * @param axis the index of the axis
  57533. * @param axisValue the value of the axis which determines the meshes new position
  57534. * @hidden
  57535. */
  57536. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57537. /**
  57538. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57539. * @param scene scene in which to add meshes
  57540. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57541. */
  57542. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57543. /**
  57544. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57545. * can be transformed by button presses and axes values, based on this._mapping.
  57546. *
  57547. * @param scene scene in which the meshes exist
  57548. * @param meshes list of meshes that make up the controller model to process
  57549. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57550. */
  57551. private processModel;
  57552. private createMeshInfo;
  57553. /**
  57554. * Gets the ray of the controller in the direction the controller is pointing
  57555. * @param length the length the resulting ray should be
  57556. * @returns a ray in the direction the controller is pointing
  57557. */
  57558. getForwardRay(length?: number): Ray;
  57559. /**
  57560. * Disposes of the controller
  57561. */
  57562. dispose(): void;
  57563. }
  57564. /**
  57565. * This class represents a new windows motion controller in XR.
  57566. */
  57567. export class XRWindowsMotionController extends WindowsMotionController {
  57568. /**
  57569. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57570. */
  57571. protected readonly _mapping: {
  57572. buttons: string[];
  57573. buttonMeshNames: {
  57574. trigger: string;
  57575. menu: string;
  57576. grip: string;
  57577. thumbstick: string;
  57578. trackpad: string;
  57579. };
  57580. buttonObservableNames: {
  57581. trigger: string;
  57582. menu: string;
  57583. grip: string;
  57584. thumbstick: string;
  57585. trackpad: string;
  57586. };
  57587. axisMeshNames: string[];
  57588. pointingPoseMeshName: string;
  57589. };
  57590. /**
  57591. * Construct a new XR-Based windows motion controller
  57592. *
  57593. * @param gamepadInfo the gamepad object from the browser
  57594. */
  57595. constructor(gamepadInfo: any);
  57596. /**
  57597. * holds the thumbstick values (X,Y)
  57598. */
  57599. thumbstickValues: StickValues;
  57600. /**
  57601. * Fired when the thumbstick on this controller is clicked
  57602. */
  57603. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57604. /**
  57605. * Fired when the thumbstick on this controller is modified
  57606. */
  57607. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57608. /**
  57609. * Fired when the touchpad button on this controller is modified
  57610. */
  57611. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57612. /**
  57613. * Fired when the touchpad values on this controller are modified
  57614. */
  57615. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57616. /**
  57617. * Fired when the thumbstick button on this controller is modified
  57618. * here to prevent breaking changes
  57619. */
  57620. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57621. /**
  57622. * updating the thumbstick(!) and not the trackpad.
  57623. * This is named this way due to the difference between WebVR and XR and to avoid
  57624. * changing the parent class.
  57625. */
  57626. protected _updateTrackpad(): void;
  57627. /**
  57628. * Disposes the class with joy
  57629. */
  57630. dispose(): void;
  57631. }
  57632. }
  57633. declare module BABYLON {
  57634. /**
  57635. * A directional light is defined by a direction (what a surprise!).
  57636. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57637. * 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.
  57638. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57639. */
  57640. export class DirectionalLight extends ShadowLight {
  57641. private _shadowFrustumSize;
  57642. /**
  57643. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57644. */
  57645. get shadowFrustumSize(): number;
  57646. /**
  57647. * Specifies a fix frustum size for the shadow generation.
  57648. */
  57649. set shadowFrustumSize(value: number);
  57650. private _shadowOrthoScale;
  57651. /**
  57652. * Gets the shadow projection scale against the optimal computed one.
  57653. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57654. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57655. */
  57656. get shadowOrthoScale(): number;
  57657. /**
  57658. * Sets the shadow projection scale against the optimal computed one.
  57659. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57660. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57661. */
  57662. set shadowOrthoScale(value: number);
  57663. /**
  57664. * Automatically compute the projection matrix to best fit (including all the casters)
  57665. * on each frame.
  57666. */
  57667. autoUpdateExtends: boolean;
  57668. /**
  57669. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57670. * on each frame. autoUpdateExtends must be set to true for this to work
  57671. */
  57672. autoCalcShadowZBounds: boolean;
  57673. private _orthoLeft;
  57674. private _orthoRight;
  57675. private _orthoTop;
  57676. private _orthoBottom;
  57677. /**
  57678. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57679. * The directional light is emitted from everywhere in the given direction.
  57680. * It can cast shadows.
  57681. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57682. * @param name The friendly name of the light
  57683. * @param direction The direction of the light
  57684. * @param scene The scene the light belongs to
  57685. */
  57686. constructor(name: string, direction: Vector3, scene: Scene);
  57687. /**
  57688. * Returns the string "DirectionalLight".
  57689. * @return The class name
  57690. */
  57691. getClassName(): string;
  57692. /**
  57693. * Returns the integer 1.
  57694. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57695. */
  57696. getTypeID(): number;
  57697. /**
  57698. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57699. * Returns the DirectionalLight Shadow projection matrix.
  57700. */
  57701. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57702. /**
  57703. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57704. * Returns the DirectionalLight Shadow projection matrix.
  57705. */
  57706. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57707. /**
  57708. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57709. * Returns the DirectionalLight Shadow projection matrix.
  57710. */
  57711. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57712. protected _buildUniformLayout(): void;
  57713. /**
  57714. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57715. * @param effect The effect to update
  57716. * @param lightIndex The index of the light in the effect to update
  57717. * @returns The directional light
  57718. */
  57719. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57720. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57721. /**
  57722. * Gets the minZ used for shadow according to both the scene and the light.
  57723. *
  57724. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57725. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57726. * @param activeCamera The camera we are returning the min for
  57727. * @returns the depth min z
  57728. */
  57729. getDepthMinZ(activeCamera: Camera): number;
  57730. /**
  57731. * Gets the maxZ used for shadow according to both the scene and the light.
  57732. *
  57733. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57734. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57735. * @param activeCamera The camera we are returning the max for
  57736. * @returns the depth max z
  57737. */
  57738. getDepthMaxZ(activeCamera: Camera): number;
  57739. /**
  57740. * Prepares the list of defines specific to the light type.
  57741. * @param defines the list of defines
  57742. * @param lightIndex defines the index of the light for the effect
  57743. */
  57744. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57745. }
  57746. }
  57747. declare module BABYLON {
  57748. /**
  57749. * Class containing static functions to help procedurally build meshes
  57750. */
  57751. export class HemisphereBuilder {
  57752. /**
  57753. * Creates a hemisphere mesh
  57754. * @param name defines the name of the mesh
  57755. * @param options defines the options used to create the mesh
  57756. * @param scene defines the hosting scene
  57757. * @returns the hemisphere mesh
  57758. */
  57759. static CreateHemisphere(name: string, options: {
  57760. segments?: number;
  57761. diameter?: number;
  57762. sideOrientation?: number;
  57763. }, scene: any): Mesh;
  57764. }
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57769. * These values define a cone of light starting from the position, emitting toward the direction.
  57770. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57771. * and the exponent defines the speed of the decay of the light with distance (reach).
  57772. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57773. */
  57774. export class SpotLight extends ShadowLight {
  57775. private _angle;
  57776. private _innerAngle;
  57777. private _cosHalfAngle;
  57778. private _lightAngleScale;
  57779. private _lightAngleOffset;
  57780. /**
  57781. * Gets the cone angle of the spot light in Radians.
  57782. */
  57783. get angle(): number;
  57784. /**
  57785. * Sets the cone angle of the spot light in Radians.
  57786. */
  57787. set angle(value: number);
  57788. /**
  57789. * Only used in gltf falloff mode, this defines the angle where
  57790. * the directional falloff will start before cutting at angle which could be seen
  57791. * as outer angle.
  57792. */
  57793. get innerAngle(): number;
  57794. /**
  57795. * Only used in gltf falloff mode, this defines the angle where
  57796. * the directional falloff will start before cutting at angle which could be seen
  57797. * as outer angle.
  57798. */
  57799. set innerAngle(value: number);
  57800. private _shadowAngleScale;
  57801. /**
  57802. * Allows scaling the angle of the light for shadow generation only.
  57803. */
  57804. get shadowAngleScale(): number;
  57805. /**
  57806. * Allows scaling the angle of the light for shadow generation only.
  57807. */
  57808. set shadowAngleScale(value: number);
  57809. /**
  57810. * The light decay speed with the distance from the emission spot.
  57811. */
  57812. exponent: number;
  57813. private _projectionTextureMatrix;
  57814. /**
  57815. * Allows reading the projecton texture
  57816. */
  57817. get projectionTextureMatrix(): Matrix;
  57818. protected _projectionTextureLightNear: number;
  57819. /**
  57820. * Gets the near clip of the Spotlight for texture projection.
  57821. */
  57822. get projectionTextureLightNear(): number;
  57823. /**
  57824. * Sets the near clip of the Spotlight for texture projection.
  57825. */
  57826. set projectionTextureLightNear(value: number);
  57827. protected _projectionTextureLightFar: number;
  57828. /**
  57829. * Gets the far clip of the Spotlight for texture projection.
  57830. */
  57831. get projectionTextureLightFar(): number;
  57832. /**
  57833. * Sets the far clip of the Spotlight for texture projection.
  57834. */
  57835. set projectionTextureLightFar(value: number);
  57836. protected _projectionTextureUpDirection: Vector3;
  57837. /**
  57838. * Gets the Up vector of the Spotlight for texture projection.
  57839. */
  57840. get projectionTextureUpDirection(): Vector3;
  57841. /**
  57842. * Sets the Up vector of the Spotlight for texture projection.
  57843. */
  57844. set projectionTextureUpDirection(value: Vector3);
  57845. private _projectionTexture;
  57846. /**
  57847. * Gets the projection texture of the light.
  57848. */
  57849. get projectionTexture(): Nullable<BaseTexture>;
  57850. /**
  57851. * Sets the projection texture of the light.
  57852. */
  57853. set projectionTexture(value: Nullable<BaseTexture>);
  57854. private static _IsProceduralTexture;
  57855. private static _IsTexture;
  57856. private _projectionTextureViewLightDirty;
  57857. private _projectionTextureProjectionLightDirty;
  57858. private _projectionTextureDirty;
  57859. private _projectionTextureViewTargetVector;
  57860. private _projectionTextureViewLightMatrix;
  57861. private _projectionTextureProjectionLightMatrix;
  57862. private _projectionTextureScalingMatrix;
  57863. /**
  57864. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57865. * It can cast shadows.
  57866. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57867. * @param name The light friendly name
  57868. * @param position The position of the spot light in the scene
  57869. * @param direction The direction of the light in the scene
  57870. * @param angle The cone angle of the light in Radians
  57871. * @param exponent The light decay speed with the distance from the emission spot
  57872. * @param scene The scene the lights belongs to
  57873. */
  57874. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57875. /**
  57876. * Returns the string "SpotLight".
  57877. * @returns the class name
  57878. */
  57879. getClassName(): string;
  57880. /**
  57881. * Returns the integer 2.
  57882. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57883. */
  57884. getTypeID(): number;
  57885. /**
  57886. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57887. */
  57888. protected _setDirection(value: Vector3): void;
  57889. /**
  57890. * Overrides the position setter to recompute the projection texture view light Matrix.
  57891. */
  57892. protected _setPosition(value: Vector3): void;
  57893. /**
  57894. * 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.
  57895. * Returns the SpotLight.
  57896. */
  57897. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57898. protected _computeProjectionTextureViewLightMatrix(): void;
  57899. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57900. /**
  57901. * Main function for light texture projection matrix computing.
  57902. */
  57903. protected _computeProjectionTextureMatrix(): void;
  57904. protected _buildUniformLayout(): void;
  57905. private _computeAngleValues;
  57906. /**
  57907. * Sets the passed Effect "effect" with the Light textures.
  57908. * @param effect The effect to update
  57909. * @param lightIndex The index of the light in the effect to update
  57910. * @returns The light
  57911. */
  57912. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57913. /**
  57914. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57915. * @param effect The effect to update
  57916. * @param lightIndex The index of the light in the effect to update
  57917. * @returns The spot light
  57918. */
  57919. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57920. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57921. /**
  57922. * Disposes the light and the associated resources.
  57923. */
  57924. dispose(): void;
  57925. /**
  57926. * Prepares the list of defines specific to the light type.
  57927. * @param defines the list of defines
  57928. * @param lightIndex defines the index of the light for the effect
  57929. */
  57930. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57931. }
  57932. }
  57933. declare module BABYLON {
  57934. /**
  57935. * Gizmo that enables viewing a light
  57936. */
  57937. export class LightGizmo extends Gizmo {
  57938. private _lightMesh;
  57939. private _material;
  57940. private _cachedPosition;
  57941. private _cachedForward;
  57942. private _attachedMeshParent;
  57943. private _pointerObserver;
  57944. /**
  57945. * Event that fires each time the gizmo is clicked
  57946. */
  57947. onClickedObservable: Observable<Light>;
  57948. /**
  57949. * Creates a LightGizmo
  57950. * @param gizmoLayer The utility layer the gizmo will be added to
  57951. */
  57952. constructor(gizmoLayer?: UtilityLayerRenderer);
  57953. private _light;
  57954. /**
  57955. * The light that the gizmo is attached to
  57956. */
  57957. set light(light: Nullable<Light>);
  57958. get light(): Nullable<Light>;
  57959. /**
  57960. * Gets the material used to render the light gizmo
  57961. */
  57962. get material(): StandardMaterial;
  57963. /**
  57964. * @hidden
  57965. * Updates the gizmo to match the attached mesh's position/rotation
  57966. */
  57967. protected _update(): void;
  57968. private static _Scale;
  57969. /**
  57970. * Creates the lines for a light mesh
  57971. */
  57972. private static _CreateLightLines;
  57973. /**
  57974. * Disposes of the light gizmo
  57975. */
  57976. dispose(): void;
  57977. private static _CreateHemisphericLightMesh;
  57978. private static _CreatePointLightMesh;
  57979. private static _CreateSpotLightMesh;
  57980. private static _CreateDirectionalLightMesh;
  57981. }
  57982. }
  57983. declare module BABYLON {
  57984. /**
  57985. * Gizmo that enables viewing a camera
  57986. */
  57987. export class CameraGizmo extends Gizmo {
  57988. private _cameraMesh;
  57989. private _cameraLinesMesh;
  57990. private _material;
  57991. private _pointerObserver;
  57992. /**
  57993. * Event that fires each time the gizmo is clicked
  57994. */
  57995. onClickedObservable: Observable<Camera>;
  57996. /**
  57997. * Creates a CameraGizmo
  57998. * @param gizmoLayer The utility layer the gizmo will be added to
  57999. */
  58000. constructor(gizmoLayer?: UtilityLayerRenderer);
  58001. private _camera;
  58002. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58003. get displayFrustum(): boolean;
  58004. set displayFrustum(value: boolean);
  58005. /**
  58006. * The camera that the gizmo is attached to
  58007. */
  58008. set camera(camera: Nullable<Camera>);
  58009. get camera(): Nullable<Camera>;
  58010. /**
  58011. * Gets the material used to render the camera gizmo
  58012. */
  58013. get material(): StandardMaterial;
  58014. /**
  58015. * @hidden
  58016. * Updates the gizmo to match the attached mesh's position/rotation
  58017. */
  58018. protected _update(): void;
  58019. private static _Scale;
  58020. private _invProjection;
  58021. /**
  58022. * Disposes of the camera gizmo
  58023. */
  58024. dispose(): void;
  58025. private static _CreateCameraMesh;
  58026. private static _CreateCameraFrustum;
  58027. }
  58028. }
  58029. declare module BABYLON {
  58030. /** @hidden */
  58031. export var backgroundFragmentDeclaration: {
  58032. name: string;
  58033. shader: string;
  58034. };
  58035. }
  58036. declare module BABYLON {
  58037. /** @hidden */
  58038. export var backgroundUboDeclaration: {
  58039. name: string;
  58040. shader: string;
  58041. };
  58042. }
  58043. declare module BABYLON {
  58044. /** @hidden */
  58045. export var backgroundPixelShader: {
  58046. name: string;
  58047. shader: string;
  58048. };
  58049. }
  58050. declare module BABYLON {
  58051. /** @hidden */
  58052. export var backgroundVertexDeclaration: {
  58053. name: string;
  58054. shader: string;
  58055. };
  58056. }
  58057. declare module BABYLON {
  58058. /** @hidden */
  58059. export var backgroundVertexShader: {
  58060. name: string;
  58061. shader: string;
  58062. };
  58063. }
  58064. declare module BABYLON {
  58065. /**
  58066. * Background material used to create an efficient environement around your scene.
  58067. */
  58068. export class BackgroundMaterial extends PushMaterial {
  58069. /**
  58070. * Standard reflectance value at parallel view angle.
  58071. */
  58072. static StandardReflectance0: number;
  58073. /**
  58074. * Standard reflectance value at grazing angle.
  58075. */
  58076. static StandardReflectance90: number;
  58077. protected _primaryColor: Color3;
  58078. /**
  58079. * Key light Color (multiply against the environement texture)
  58080. */
  58081. primaryColor: Color3;
  58082. protected __perceptualColor: Nullable<Color3>;
  58083. /**
  58084. * Experimental Internal Use Only.
  58085. *
  58086. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58087. * This acts as a helper to set the primary color to a more "human friendly" value.
  58088. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58089. * output color as close as possible from the chosen value.
  58090. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58091. * part of lighting setup.)
  58092. */
  58093. get _perceptualColor(): Nullable<Color3>;
  58094. set _perceptualColor(value: Nullable<Color3>);
  58095. protected _primaryColorShadowLevel: float;
  58096. /**
  58097. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58098. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58099. */
  58100. get primaryColorShadowLevel(): float;
  58101. set primaryColorShadowLevel(value: float);
  58102. protected _primaryColorHighlightLevel: float;
  58103. /**
  58104. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58105. * The primary color is used at the level chosen to define what the white area would look.
  58106. */
  58107. get primaryColorHighlightLevel(): float;
  58108. set primaryColorHighlightLevel(value: float);
  58109. protected _reflectionTexture: Nullable<BaseTexture>;
  58110. /**
  58111. * Reflection Texture used in the material.
  58112. * Should be author in a specific way for the best result (refer to the documentation).
  58113. */
  58114. reflectionTexture: Nullable<BaseTexture>;
  58115. protected _reflectionBlur: float;
  58116. /**
  58117. * Reflection Texture level of blur.
  58118. *
  58119. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58120. * texture twice.
  58121. */
  58122. reflectionBlur: float;
  58123. protected _diffuseTexture: Nullable<BaseTexture>;
  58124. /**
  58125. * Diffuse Texture used in the material.
  58126. * Should be author in a specific way for the best result (refer to the documentation).
  58127. */
  58128. diffuseTexture: Nullable<BaseTexture>;
  58129. protected _shadowLights: Nullable<IShadowLight[]>;
  58130. /**
  58131. * Specify the list of lights casting shadow on the material.
  58132. * All scene shadow lights will be included if null.
  58133. */
  58134. shadowLights: Nullable<IShadowLight[]>;
  58135. protected _shadowLevel: float;
  58136. /**
  58137. * Helps adjusting the shadow to a softer level if required.
  58138. * 0 means black shadows and 1 means no shadows.
  58139. */
  58140. shadowLevel: float;
  58141. protected _sceneCenter: Vector3;
  58142. /**
  58143. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58144. * It is usually zero but might be interesting to modify according to your setup.
  58145. */
  58146. sceneCenter: Vector3;
  58147. protected _opacityFresnel: boolean;
  58148. /**
  58149. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58150. * This helps ensuring a nice transition when the camera goes under the ground.
  58151. */
  58152. opacityFresnel: boolean;
  58153. protected _reflectionFresnel: boolean;
  58154. /**
  58155. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58156. * This helps adding a mirror texture on the ground.
  58157. */
  58158. reflectionFresnel: boolean;
  58159. protected _reflectionFalloffDistance: number;
  58160. /**
  58161. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58162. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58163. */
  58164. reflectionFalloffDistance: number;
  58165. protected _reflectionAmount: number;
  58166. /**
  58167. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58168. */
  58169. reflectionAmount: number;
  58170. protected _reflectionReflectance0: number;
  58171. /**
  58172. * This specifies the weight of the reflection at grazing angle.
  58173. */
  58174. reflectionReflectance0: number;
  58175. protected _reflectionReflectance90: number;
  58176. /**
  58177. * This specifies the weight of the reflection at a perpendicular point of view.
  58178. */
  58179. reflectionReflectance90: number;
  58180. /**
  58181. * Sets the reflection reflectance fresnel values according to the default standard
  58182. * empirically know to work well :-)
  58183. */
  58184. set reflectionStandardFresnelWeight(value: number);
  58185. protected _useRGBColor: boolean;
  58186. /**
  58187. * Helps to directly use the maps channels instead of their level.
  58188. */
  58189. useRGBColor: boolean;
  58190. protected _enableNoise: boolean;
  58191. /**
  58192. * This helps reducing the banding effect that could occur on the background.
  58193. */
  58194. enableNoise: boolean;
  58195. /**
  58196. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58197. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58198. * Recommended to be keep at 1.0 except for special cases.
  58199. */
  58200. get fovMultiplier(): number;
  58201. set fovMultiplier(value: number);
  58202. private _fovMultiplier;
  58203. /**
  58204. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58205. */
  58206. useEquirectangularFOV: boolean;
  58207. private _maxSimultaneousLights;
  58208. /**
  58209. * Number of Simultaneous lights allowed on the material.
  58210. */
  58211. maxSimultaneousLights: int;
  58212. private _shadowOnly;
  58213. /**
  58214. * Make the material only render shadows
  58215. */
  58216. shadowOnly: boolean;
  58217. /**
  58218. * Default configuration related to image processing available in the Background Material.
  58219. */
  58220. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58221. /**
  58222. * Keep track of the image processing observer to allow dispose and replace.
  58223. */
  58224. private _imageProcessingObserver;
  58225. /**
  58226. * Attaches a new image processing configuration to the PBR Material.
  58227. * @param configuration (if null the scene configuration will be use)
  58228. */
  58229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58230. /**
  58231. * Gets the image processing configuration used either in this material.
  58232. */
  58233. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58234. /**
  58235. * Sets the Default image processing configuration used either in the this material.
  58236. *
  58237. * If sets to null, the scene one is in use.
  58238. */
  58239. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58240. /**
  58241. * Gets wether the color curves effect is enabled.
  58242. */
  58243. get cameraColorCurvesEnabled(): boolean;
  58244. /**
  58245. * Sets wether the color curves effect is enabled.
  58246. */
  58247. set cameraColorCurvesEnabled(value: boolean);
  58248. /**
  58249. * Gets wether the color grading effect is enabled.
  58250. */
  58251. get cameraColorGradingEnabled(): boolean;
  58252. /**
  58253. * Gets wether the color grading effect is enabled.
  58254. */
  58255. set cameraColorGradingEnabled(value: boolean);
  58256. /**
  58257. * Gets wether tonemapping is enabled or not.
  58258. */
  58259. get cameraToneMappingEnabled(): boolean;
  58260. /**
  58261. * Sets wether tonemapping is enabled or not
  58262. */
  58263. set cameraToneMappingEnabled(value: boolean);
  58264. /**
  58265. * The camera exposure used on this material.
  58266. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58267. * This corresponds to a photographic exposure.
  58268. */
  58269. get cameraExposure(): float;
  58270. /**
  58271. * The camera exposure used on this material.
  58272. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58273. * This corresponds to a photographic exposure.
  58274. */
  58275. set cameraExposure(value: float);
  58276. /**
  58277. * Gets The camera contrast used on this material.
  58278. */
  58279. get cameraContrast(): float;
  58280. /**
  58281. * Sets The camera contrast used on this material.
  58282. */
  58283. set cameraContrast(value: float);
  58284. /**
  58285. * Gets the Color Grading 2D Lookup Texture.
  58286. */
  58287. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58288. /**
  58289. * Sets the Color Grading 2D Lookup Texture.
  58290. */
  58291. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58292. /**
  58293. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58294. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58295. * 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;
  58296. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58297. */
  58298. get cameraColorCurves(): Nullable<ColorCurves>;
  58299. /**
  58300. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58301. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58302. * 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;
  58303. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58304. */
  58305. set cameraColorCurves(value: Nullable<ColorCurves>);
  58306. /**
  58307. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58308. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58309. */
  58310. switchToBGR: boolean;
  58311. private _renderTargets;
  58312. private _reflectionControls;
  58313. private _white;
  58314. private _primaryShadowColor;
  58315. private _primaryHighlightColor;
  58316. /**
  58317. * Instantiates a Background Material in the given scene
  58318. * @param name The friendly name of the material
  58319. * @param scene The scene to add the material to
  58320. */
  58321. constructor(name: string, scene: Scene);
  58322. /**
  58323. * Gets a boolean indicating that current material needs to register RTT
  58324. */
  58325. get hasRenderTargetTextures(): boolean;
  58326. /**
  58327. * The entire material has been created in order to prevent overdraw.
  58328. * @returns false
  58329. */
  58330. needAlphaTesting(): boolean;
  58331. /**
  58332. * The entire material has been created in order to prevent overdraw.
  58333. * @returns true if blending is enable
  58334. */
  58335. needAlphaBlending(): boolean;
  58336. /**
  58337. * Checks wether the material is ready to be rendered for a given mesh.
  58338. * @param mesh The mesh to render
  58339. * @param subMesh The submesh to check against
  58340. * @param useInstances Specify wether or not the material is used with instances
  58341. * @returns true if all the dependencies are ready (Textures, Effects...)
  58342. */
  58343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58344. /**
  58345. * Compute the primary color according to the chosen perceptual color.
  58346. */
  58347. private _computePrimaryColorFromPerceptualColor;
  58348. /**
  58349. * Compute the highlights and shadow colors according to their chosen levels.
  58350. */
  58351. private _computePrimaryColors;
  58352. /**
  58353. * Build the uniform buffer used in the material.
  58354. */
  58355. buildUniformLayout(): void;
  58356. /**
  58357. * Unbind the material.
  58358. */
  58359. unbind(): void;
  58360. /**
  58361. * Bind only the world matrix to the material.
  58362. * @param world The world matrix to bind.
  58363. */
  58364. bindOnlyWorldMatrix(world: Matrix): void;
  58365. /**
  58366. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58367. * @param world The world matrix to bind.
  58368. * @param subMesh The submesh to bind for.
  58369. */
  58370. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58371. /**
  58372. * Checks to see if a texture is used in the material.
  58373. * @param texture - Base texture to use.
  58374. * @returns - Boolean specifying if a texture is used in the material.
  58375. */
  58376. hasTexture(texture: BaseTexture): boolean;
  58377. /**
  58378. * Dispose the material.
  58379. * @param forceDisposeEffect Force disposal of the associated effect.
  58380. * @param forceDisposeTextures Force disposal of the associated textures.
  58381. */
  58382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58383. /**
  58384. * Clones the material.
  58385. * @param name The cloned name.
  58386. * @returns The cloned material.
  58387. */
  58388. clone(name: string): BackgroundMaterial;
  58389. /**
  58390. * Serializes the current material to its JSON representation.
  58391. * @returns The JSON representation.
  58392. */
  58393. serialize(): any;
  58394. /**
  58395. * Gets the class name of the material
  58396. * @returns "BackgroundMaterial"
  58397. */
  58398. getClassName(): string;
  58399. /**
  58400. * Parse a JSON input to create back a background material.
  58401. * @param source The JSON data to parse
  58402. * @param scene The scene to create the parsed material in
  58403. * @param rootUrl The root url of the assets the material depends upon
  58404. * @returns the instantiated BackgroundMaterial.
  58405. */
  58406. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58407. }
  58408. }
  58409. declare module BABYLON {
  58410. /**
  58411. * Represents the different options available during the creation of
  58412. * a Environment helper.
  58413. *
  58414. * This can control the default ground, skybox and image processing setup of your scene.
  58415. */
  58416. export interface IEnvironmentHelperOptions {
  58417. /**
  58418. * Specifies whether or not to create a ground.
  58419. * True by default.
  58420. */
  58421. createGround: boolean;
  58422. /**
  58423. * Specifies the ground size.
  58424. * 15 by default.
  58425. */
  58426. groundSize: number;
  58427. /**
  58428. * The texture used on the ground for the main color.
  58429. * Comes from the BabylonJS CDN by default.
  58430. *
  58431. * Remarks: Can be either a texture or a url.
  58432. */
  58433. groundTexture: string | BaseTexture;
  58434. /**
  58435. * The color mixed in the ground texture by default.
  58436. * BabylonJS clearColor by default.
  58437. */
  58438. groundColor: Color3;
  58439. /**
  58440. * Specifies the ground opacity.
  58441. * 1 by default.
  58442. */
  58443. groundOpacity: number;
  58444. /**
  58445. * Enables the ground to receive shadows.
  58446. * True by default.
  58447. */
  58448. enableGroundShadow: boolean;
  58449. /**
  58450. * Helps preventing the shadow to be fully black on the ground.
  58451. * 0.5 by default.
  58452. */
  58453. groundShadowLevel: number;
  58454. /**
  58455. * Creates a mirror texture attach to the ground.
  58456. * false by default.
  58457. */
  58458. enableGroundMirror: boolean;
  58459. /**
  58460. * Specifies the ground mirror size ratio.
  58461. * 0.3 by default as the default kernel is 64.
  58462. */
  58463. groundMirrorSizeRatio: number;
  58464. /**
  58465. * Specifies the ground mirror blur kernel size.
  58466. * 64 by default.
  58467. */
  58468. groundMirrorBlurKernel: number;
  58469. /**
  58470. * Specifies the ground mirror visibility amount.
  58471. * 1 by default
  58472. */
  58473. groundMirrorAmount: number;
  58474. /**
  58475. * Specifies the ground mirror reflectance weight.
  58476. * This uses the standard weight of the background material to setup the fresnel effect
  58477. * of the mirror.
  58478. * 1 by default.
  58479. */
  58480. groundMirrorFresnelWeight: number;
  58481. /**
  58482. * Specifies the ground mirror Falloff distance.
  58483. * This can helps reducing the size of the reflection.
  58484. * 0 by Default.
  58485. */
  58486. groundMirrorFallOffDistance: number;
  58487. /**
  58488. * Specifies the ground mirror texture type.
  58489. * Unsigned Int by Default.
  58490. */
  58491. groundMirrorTextureType: number;
  58492. /**
  58493. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58494. * the shown objects.
  58495. */
  58496. groundYBias: number;
  58497. /**
  58498. * Specifies whether or not to create a skybox.
  58499. * True by default.
  58500. */
  58501. createSkybox: boolean;
  58502. /**
  58503. * Specifies the skybox size.
  58504. * 20 by default.
  58505. */
  58506. skyboxSize: number;
  58507. /**
  58508. * The texture used on the skybox for the main color.
  58509. * Comes from the BabylonJS CDN by default.
  58510. *
  58511. * Remarks: Can be either a texture or a url.
  58512. */
  58513. skyboxTexture: string | BaseTexture;
  58514. /**
  58515. * The color mixed in the skybox texture by default.
  58516. * BabylonJS clearColor by default.
  58517. */
  58518. skyboxColor: Color3;
  58519. /**
  58520. * The background rotation around the Y axis of the scene.
  58521. * This helps aligning the key lights of your scene with the background.
  58522. * 0 by default.
  58523. */
  58524. backgroundYRotation: number;
  58525. /**
  58526. * Compute automatically the size of the elements to best fit with the scene.
  58527. */
  58528. sizeAuto: boolean;
  58529. /**
  58530. * Default position of the rootMesh if autoSize is not true.
  58531. */
  58532. rootPosition: Vector3;
  58533. /**
  58534. * Sets up the image processing in the scene.
  58535. * true by default.
  58536. */
  58537. setupImageProcessing: boolean;
  58538. /**
  58539. * The texture used as your environment texture in the scene.
  58540. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58541. *
  58542. * Remarks: Can be either a texture or a url.
  58543. */
  58544. environmentTexture: string | BaseTexture;
  58545. /**
  58546. * The value of the exposure to apply to the scene.
  58547. * 0.6 by default if setupImageProcessing is true.
  58548. */
  58549. cameraExposure: number;
  58550. /**
  58551. * The value of the contrast to apply to the scene.
  58552. * 1.6 by default if setupImageProcessing is true.
  58553. */
  58554. cameraContrast: number;
  58555. /**
  58556. * Specifies whether or not tonemapping should be enabled in the scene.
  58557. * true by default if setupImageProcessing is true.
  58558. */
  58559. toneMappingEnabled: boolean;
  58560. }
  58561. /**
  58562. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58563. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58564. * It also helps with the default setup of your imageProcessing configuration.
  58565. */
  58566. export class EnvironmentHelper {
  58567. /**
  58568. * Default ground texture URL.
  58569. */
  58570. private static _groundTextureCDNUrl;
  58571. /**
  58572. * Default skybox texture URL.
  58573. */
  58574. private static _skyboxTextureCDNUrl;
  58575. /**
  58576. * Default environment texture URL.
  58577. */
  58578. private static _environmentTextureCDNUrl;
  58579. /**
  58580. * Creates the default options for the helper.
  58581. */
  58582. private static _getDefaultOptions;
  58583. private _rootMesh;
  58584. /**
  58585. * Gets the root mesh created by the helper.
  58586. */
  58587. get rootMesh(): Mesh;
  58588. private _skybox;
  58589. /**
  58590. * Gets the skybox created by the helper.
  58591. */
  58592. get skybox(): Nullable<Mesh>;
  58593. private _skyboxTexture;
  58594. /**
  58595. * Gets the skybox texture created by the helper.
  58596. */
  58597. get skyboxTexture(): Nullable<BaseTexture>;
  58598. private _skyboxMaterial;
  58599. /**
  58600. * Gets the skybox material created by the helper.
  58601. */
  58602. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58603. private _ground;
  58604. /**
  58605. * Gets the ground mesh created by the helper.
  58606. */
  58607. get ground(): Nullable<Mesh>;
  58608. private _groundTexture;
  58609. /**
  58610. * Gets the ground texture created by the helper.
  58611. */
  58612. get groundTexture(): Nullable<BaseTexture>;
  58613. private _groundMirror;
  58614. /**
  58615. * Gets the ground mirror created by the helper.
  58616. */
  58617. get groundMirror(): Nullable<MirrorTexture>;
  58618. /**
  58619. * Gets the ground mirror render list to helps pushing the meshes
  58620. * you wish in the ground reflection.
  58621. */
  58622. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58623. private _groundMaterial;
  58624. /**
  58625. * Gets the ground material created by the helper.
  58626. */
  58627. get groundMaterial(): Nullable<BackgroundMaterial>;
  58628. /**
  58629. * Stores the creation options.
  58630. */
  58631. private readonly _scene;
  58632. private _options;
  58633. /**
  58634. * This observable will be notified with any error during the creation of the environment,
  58635. * mainly texture creation errors.
  58636. */
  58637. onErrorObservable: Observable<{
  58638. message?: string;
  58639. exception?: any;
  58640. }>;
  58641. /**
  58642. * constructor
  58643. * @param options Defines the options we want to customize the helper
  58644. * @param scene The scene to add the material to
  58645. */
  58646. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58647. /**
  58648. * Updates the background according to the new options
  58649. * @param options
  58650. */
  58651. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58652. /**
  58653. * Sets the primary color of all the available elements.
  58654. * @param color the main color to affect to the ground and the background
  58655. */
  58656. setMainColor(color: Color3): void;
  58657. /**
  58658. * Setup the image processing according to the specified options.
  58659. */
  58660. private _setupImageProcessing;
  58661. /**
  58662. * Setup the environment texture according to the specified options.
  58663. */
  58664. private _setupEnvironmentTexture;
  58665. /**
  58666. * Setup the background according to the specified options.
  58667. */
  58668. private _setupBackground;
  58669. /**
  58670. * Get the scene sizes according to the setup.
  58671. */
  58672. private _getSceneSize;
  58673. /**
  58674. * Setup the ground according to the specified options.
  58675. */
  58676. private _setupGround;
  58677. /**
  58678. * Setup the ground material according to the specified options.
  58679. */
  58680. private _setupGroundMaterial;
  58681. /**
  58682. * Setup the ground diffuse texture according to the specified options.
  58683. */
  58684. private _setupGroundDiffuseTexture;
  58685. /**
  58686. * Setup the ground mirror texture according to the specified options.
  58687. */
  58688. private _setupGroundMirrorTexture;
  58689. /**
  58690. * Setup the ground to receive the mirror texture.
  58691. */
  58692. private _setupMirrorInGroundMaterial;
  58693. /**
  58694. * Setup the skybox according to the specified options.
  58695. */
  58696. private _setupSkybox;
  58697. /**
  58698. * Setup the skybox material according to the specified options.
  58699. */
  58700. private _setupSkyboxMaterial;
  58701. /**
  58702. * Setup the skybox reflection texture according to the specified options.
  58703. */
  58704. private _setupSkyboxReflectionTexture;
  58705. private _errorHandler;
  58706. /**
  58707. * Dispose all the elements created by the Helper.
  58708. */
  58709. dispose(): void;
  58710. }
  58711. }
  58712. declare module BABYLON {
  58713. /**
  58714. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58715. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58716. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58717. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58718. */
  58719. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58720. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58721. /**
  58722. * Define the source as a Monoscopic panoramic 360/180.
  58723. */
  58724. static readonly MODE_MONOSCOPIC: number;
  58725. /**
  58726. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58727. */
  58728. static readonly MODE_TOPBOTTOM: number;
  58729. /**
  58730. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58731. */
  58732. static readonly MODE_SIDEBYSIDE: number;
  58733. private _halfDome;
  58734. private _crossEye;
  58735. protected _useDirectMapping: boolean;
  58736. /**
  58737. * The texture being displayed on the sphere
  58738. */
  58739. protected _texture: T;
  58740. /**
  58741. * Gets the texture being displayed on the sphere
  58742. */
  58743. get texture(): T;
  58744. /**
  58745. * Sets the texture being displayed on the sphere
  58746. */
  58747. set texture(newTexture: T);
  58748. /**
  58749. * The skybox material
  58750. */
  58751. protected _material: BackgroundMaterial;
  58752. /**
  58753. * The surface used for the dome
  58754. */
  58755. protected _mesh: Mesh;
  58756. /**
  58757. * Gets the mesh used for the dome.
  58758. */
  58759. get mesh(): Mesh;
  58760. /**
  58761. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58762. */
  58763. private _halfDomeMask;
  58764. /**
  58765. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58766. * Also see the options.resolution property.
  58767. */
  58768. get fovMultiplier(): number;
  58769. set fovMultiplier(value: number);
  58770. protected _textureMode: number;
  58771. /**
  58772. * Gets or set the current texture mode for the texture. It can be:
  58773. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58774. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58775. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58776. */
  58777. get textureMode(): number;
  58778. /**
  58779. * Sets the current texture mode for the texture. It can be:
  58780. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58781. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58782. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58783. */
  58784. set textureMode(value: number);
  58785. /**
  58786. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58787. */
  58788. get halfDome(): boolean;
  58789. /**
  58790. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58791. */
  58792. set halfDome(enabled: boolean);
  58793. /**
  58794. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58795. */
  58796. set crossEye(enabled: boolean);
  58797. /**
  58798. * Is it a cross-eye texture?
  58799. */
  58800. get crossEye(): boolean;
  58801. /**
  58802. * The background material of this dome.
  58803. */
  58804. get material(): BackgroundMaterial;
  58805. /**
  58806. * Oberserver used in Stereoscopic VR Mode.
  58807. */
  58808. private _onBeforeCameraRenderObserver;
  58809. /**
  58810. * Observable raised when an error occured while loading the 360 image
  58811. */
  58812. onLoadErrorObservable: Observable<string>;
  58813. /**
  58814. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58815. * @param name Element's name, child elements will append suffixes for their own names.
  58816. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58817. * @param options An object containing optional or exposed sub element properties
  58818. */
  58819. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58820. resolution?: number;
  58821. clickToPlay?: boolean;
  58822. autoPlay?: boolean;
  58823. loop?: boolean;
  58824. size?: number;
  58825. poster?: string;
  58826. faceForward?: boolean;
  58827. useDirectMapping?: boolean;
  58828. halfDomeMode?: boolean;
  58829. crossEyeMode?: boolean;
  58830. generateMipMaps?: boolean;
  58831. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58832. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58833. protected _changeTextureMode(value: number): void;
  58834. /**
  58835. * Releases resources associated with this node.
  58836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58838. */
  58839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58840. }
  58841. }
  58842. declare module BABYLON {
  58843. /**
  58844. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58845. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58846. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58847. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58848. */
  58849. export class PhotoDome extends TextureDome<Texture> {
  58850. /**
  58851. * Define the image as a Monoscopic panoramic 360 image.
  58852. */
  58853. static readonly MODE_MONOSCOPIC: number;
  58854. /**
  58855. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58856. */
  58857. static readonly MODE_TOPBOTTOM: number;
  58858. /**
  58859. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58860. */
  58861. static readonly MODE_SIDEBYSIDE: number;
  58862. /**
  58863. * Gets or sets the texture being displayed on the sphere
  58864. */
  58865. get photoTexture(): Texture;
  58866. /**
  58867. * sets the texture being displayed on the sphere
  58868. */
  58869. set photoTexture(value: Texture);
  58870. /**
  58871. * Gets the current video mode for the video. It can be:
  58872. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58873. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58874. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58875. */
  58876. get imageMode(): number;
  58877. /**
  58878. * Sets the current video mode for the video. It can be:
  58879. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58880. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58881. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58882. */
  58883. set imageMode(value: number);
  58884. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58885. }
  58886. }
  58887. declare module BABYLON {
  58888. /**
  58889. * Direct draw surface info
  58890. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58891. */
  58892. export interface DDSInfo {
  58893. /**
  58894. * Width of the texture
  58895. */
  58896. width: number;
  58897. /**
  58898. * Width of the texture
  58899. */
  58900. height: number;
  58901. /**
  58902. * Number of Mipmaps for the texture
  58903. * @see https://en.wikipedia.org/wiki/Mipmap
  58904. */
  58905. mipmapCount: number;
  58906. /**
  58907. * If the textures format is a known fourCC format
  58908. * @see https://www.fourcc.org/
  58909. */
  58910. isFourCC: boolean;
  58911. /**
  58912. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58913. */
  58914. isRGB: boolean;
  58915. /**
  58916. * If the texture is a lumincance format
  58917. */
  58918. isLuminance: boolean;
  58919. /**
  58920. * If this is a cube texture
  58921. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58922. */
  58923. isCube: boolean;
  58924. /**
  58925. * If the texture is a compressed format eg. FOURCC_DXT1
  58926. */
  58927. isCompressed: boolean;
  58928. /**
  58929. * The dxgiFormat of the texture
  58930. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58931. */
  58932. dxgiFormat: number;
  58933. /**
  58934. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58935. */
  58936. textureType: number;
  58937. /**
  58938. * Sphericle polynomial created for the dds texture
  58939. */
  58940. sphericalPolynomial?: SphericalPolynomial;
  58941. }
  58942. /**
  58943. * Class used to provide DDS decompression tools
  58944. */
  58945. export class DDSTools {
  58946. /**
  58947. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58948. */
  58949. static StoreLODInAlphaChannel: boolean;
  58950. /**
  58951. * Gets DDS information from an array buffer
  58952. * @param data defines the array buffer view to read data from
  58953. * @returns the DDS information
  58954. */
  58955. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58956. private static _FloatView;
  58957. private static _Int32View;
  58958. private static _ToHalfFloat;
  58959. private static _FromHalfFloat;
  58960. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58961. private static _GetHalfFloatRGBAArrayBuffer;
  58962. private static _GetFloatRGBAArrayBuffer;
  58963. private static _GetFloatAsUIntRGBAArrayBuffer;
  58964. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58965. private static _GetRGBAArrayBuffer;
  58966. private static _ExtractLongWordOrder;
  58967. private static _GetRGBArrayBuffer;
  58968. private static _GetLuminanceArrayBuffer;
  58969. /**
  58970. * Uploads DDS Levels to a Babylon Texture
  58971. * @hidden
  58972. */
  58973. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58974. }
  58975. interface ThinEngine {
  58976. /**
  58977. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58978. * @param rootUrl defines the url where the file to load is located
  58979. * @param scene defines the current scene
  58980. * @param lodScale defines scale to apply to the mip map selection
  58981. * @param lodOffset defines offset to apply to the mip map selection
  58982. * @param onLoad defines an optional callback raised when the texture is loaded
  58983. * @param onError defines an optional callback raised if there is an issue to load the texture
  58984. * @param format defines the format of the data
  58985. * @param forcedExtension defines the extension to use to pick the right loader
  58986. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58987. * @returns the cube texture as an InternalTexture
  58988. */
  58989. 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;
  58990. }
  58991. }
  58992. declare module BABYLON {
  58993. /**
  58994. * Implementation of the DDS Texture Loader.
  58995. * @hidden
  58996. */
  58997. export class _DDSTextureLoader implements IInternalTextureLoader {
  58998. /**
  58999. * Defines wether the loader supports cascade loading the different faces.
  59000. */
  59001. readonly supportCascades: boolean;
  59002. /**
  59003. * This returns if the loader support the current file information.
  59004. * @param extension defines the file extension of the file being loaded
  59005. * @returns true if the loader can load the specified file
  59006. */
  59007. canLoad(extension: string): boolean;
  59008. /**
  59009. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59010. * @param data contains the texture data
  59011. * @param texture defines the BabylonJS internal texture
  59012. * @param createPolynomials will be true if polynomials have been requested
  59013. * @param onLoad defines the callback to trigger once the texture is ready
  59014. * @param onError defines the callback to trigger in case of error
  59015. */
  59016. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59017. /**
  59018. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59019. * @param data contains the texture data
  59020. * @param texture defines the BabylonJS internal texture
  59021. * @param callback defines the method to call once ready to upload
  59022. */
  59023. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59024. }
  59025. }
  59026. declare module BABYLON {
  59027. /**
  59028. * Implementation of the ENV Texture Loader.
  59029. * @hidden
  59030. */
  59031. export class _ENVTextureLoader implements IInternalTextureLoader {
  59032. /**
  59033. * Defines wether the loader supports cascade loading the different faces.
  59034. */
  59035. readonly supportCascades: boolean;
  59036. /**
  59037. * This returns if the loader support the current file information.
  59038. * @param extension defines the file extension of the file being loaded
  59039. * @returns true if the loader can load the specified file
  59040. */
  59041. canLoad(extension: string): boolean;
  59042. /**
  59043. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59044. * @param data contains the texture data
  59045. * @param texture defines the BabylonJS internal texture
  59046. * @param createPolynomials will be true if polynomials have been requested
  59047. * @param onLoad defines the callback to trigger once the texture is ready
  59048. * @param onError defines the callback to trigger in case of error
  59049. */
  59050. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59051. /**
  59052. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59053. * @param data contains the texture data
  59054. * @param texture defines the BabylonJS internal texture
  59055. * @param callback defines the method to call once ready to upload
  59056. */
  59057. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59058. }
  59059. }
  59060. declare module BABYLON {
  59061. /**
  59062. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59063. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59064. */
  59065. export class KhronosTextureContainer {
  59066. /** contents of the KTX container file */
  59067. data: ArrayBufferView;
  59068. private static HEADER_LEN;
  59069. private static COMPRESSED_2D;
  59070. private static COMPRESSED_3D;
  59071. private static TEX_2D;
  59072. private static TEX_3D;
  59073. /**
  59074. * Gets the openGL type
  59075. */
  59076. glType: number;
  59077. /**
  59078. * Gets the openGL type size
  59079. */
  59080. glTypeSize: number;
  59081. /**
  59082. * Gets the openGL format
  59083. */
  59084. glFormat: number;
  59085. /**
  59086. * Gets the openGL internal format
  59087. */
  59088. glInternalFormat: number;
  59089. /**
  59090. * Gets the base internal format
  59091. */
  59092. glBaseInternalFormat: number;
  59093. /**
  59094. * Gets image width in pixel
  59095. */
  59096. pixelWidth: number;
  59097. /**
  59098. * Gets image height in pixel
  59099. */
  59100. pixelHeight: number;
  59101. /**
  59102. * Gets image depth in pixels
  59103. */
  59104. pixelDepth: number;
  59105. /**
  59106. * Gets the number of array elements
  59107. */
  59108. numberOfArrayElements: number;
  59109. /**
  59110. * Gets the number of faces
  59111. */
  59112. numberOfFaces: number;
  59113. /**
  59114. * Gets the number of mipmap levels
  59115. */
  59116. numberOfMipmapLevels: number;
  59117. /**
  59118. * Gets the bytes of key value data
  59119. */
  59120. bytesOfKeyValueData: number;
  59121. /**
  59122. * Gets the load type
  59123. */
  59124. loadType: number;
  59125. /**
  59126. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59127. */
  59128. isInvalid: boolean;
  59129. /**
  59130. * Creates a new KhronosTextureContainer
  59131. * @param data contents of the KTX container file
  59132. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59133. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59134. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59135. */
  59136. constructor(
  59137. /** contents of the KTX container file */
  59138. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59139. /**
  59140. * Uploads KTX content to a Babylon Texture.
  59141. * It is assumed that the texture has already been created & is currently bound
  59142. * @hidden
  59143. */
  59144. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59145. private _upload2DCompressedLevels;
  59146. /**
  59147. * Checks if the given data starts with a KTX file identifier.
  59148. * @param data the data to check
  59149. * @returns true if the data is a KTX file or false otherwise
  59150. */
  59151. static IsValid(data: ArrayBufferView): boolean;
  59152. }
  59153. }
  59154. declare module BABYLON {
  59155. /**
  59156. * Helper class to push actions to a pool of workers.
  59157. */
  59158. export class WorkerPool implements IDisposable {
  59159. private _workerInfos;
  59160. private _pendingActions;
  59161. /**
  59162. * Constructor
  59163. * @param workers Array of workers to use for actions
  59164. */
  59165. constructor(workers: Array<Worker>);
  59166. /**
  59167. * Terminates all workers and clears any pending actions.
  59168. */
  59169. dispose(): void;
  59170. /**
  59171. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59172. * pended until a worker has completed its action.
  59173. * @param action The action to perform. Call onComplete when the action is complete.
  59174. */
  59175. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59176. private _execute;
  59177. }
  59178. }
  59179. declare module BABYLON {
  59180. /**
  59181. * Class for loading KTX2 files
  59182. */
  59183. export class KhronosTextureContainer2 {
  59184. private static _WorkerPoolPromise?;
  59185. private static _Initialized;
  59186. private static _Ktx2Decoder;
  59187. /**
  59188. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59189. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59190. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59191. * Urls you can change:
  59192. * URLConfig.jsDecoderModule
  59193. * URLConfig.wasmUASTCToASTC
  59194. * URLConfig.wasmUASTCToBC7
  59195. * URLConfig.wasmUASTCToRGBA_UNORM
  59196. * URLConfig.wasmUASTCToRGBA_SRGB
  59197. * URLConfig.jsMSCTranscoder
  59198. * URLConfig.wasmMSCTranscoder
  59199. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59200. */
  59201. static URLConfig: {
  59202. jsDecoderModule: string;
  59203. wasmUASTCToASTC: null;
  59204. wasmUASTCToBC7: null;
  59205. wasmUASTCToRGBA_UNORM: null;
  59206. wasmUASTCToRGBA_SRGB: null;
  59207. jsMSCTranscoder: null;
  59208. wasmMSCTranscoder: null;
  59209. };
  59210. /**
  59211. * Default number of workers used to handle data decoding
  59212. */
  59213. static DefaultNumWorkers: number;
  59214. private static GetDefaultNumWorkers;
  59215. private _engine;
  59216. private static _CreateWorkerPool;
  59217. /**
  59218. * Constructor
  59219. * @param engine The engine to use
  59220. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59221. */
  59222. constructor(engine: ThinEngine, numWorkers?: number);
  59223. /** @hidden */
  59224. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59225. /**
  59226. * Stop all async operations and release resources.
  59227. */
  59228. dispose(): void;
  59229. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59230. /**
  59231. * Checks if the given data starts with a KTX2 file identifier.
  59232. * @param data the data to check
  59233. * @returns true if the data is a KTX2 file or false otherwise
  59234. */
  59235. static IsValid(data: ArrayBufferView): boolean;
  59236. }
  59237. }
  59238. declare module BABYLON {
  59239. /**
  59240. * Implementation of the KTX Texture Loader.
  59241. * @hidden
  59242. */
  59243. export class _KTXTextureLoader implements IInternalTextureLoader {
  59244. /**
  59245. * Defines wether the loader supports cascade loading the different faces.
  59246. */
  59247. readonly supportCascades: boolean;
  59248. /**
  59249. * This returns if the loader support the current file information.
  59250. * @param extension defines the file extension of the file being loaded
  59251. * @param mimeType defines the optional mime type of the file being loaded
  59252. * @returns true if the loader can load the specified file
  59253. */
  59254. canLoad(extension: string, mimeType?: string): boolean;
  59255. /**
  59256. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59257. * @param data contains the texture data
  59258. * @param texture defines the BabylonJS internal texture
  59259. * @param createPolynomials will be true if polynomials have been requested
  59260. * @param onLoad defines the callback to trigger once the texture is ready
  59261. * @param onError defines the callback to trigger in case of error
  59262. */
  59263. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59264. /**
  59265. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59266. * @param data contains the texture data
  59267. * @param texture defines the BabylonJS internal texture
  59268. * @param callback defines the method to call once ready to upload
  59269. */
  59270. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59271. }
  59272. }
  59273. declare module BABYLON {
  59274. /** @hidden */
  59275. export var _forceSceneHelpersToBundle: boolean;
  59276. interface Scene {
  59277. /**
  59278. * Creates a default light for the scene.
  59279. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59280. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59281. */
  59282. createDefaultLight(replace?: boolean): void;
  59283. /**
  59284. * Creates a default camera for the scene.
  59285. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59286. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59287. * @param replace has default false, when true replaces the active camera in the scene
  59288. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59289. */
  59290. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59291. /**
  59292. * Creates a default camera and a default light.
  59293. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59294. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59295. * @param replace has the default false, when true replaces the active camera/light in the scene
  59296. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59297. */
  59298. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59299. /**
  59300. * Creates a new sky box
  59301. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59302. * @param environmentTexture defines the texture to use as environment texture
  59303. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59304. * @param scale defines the overall scale of the skybox
  59305. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59306. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59307. * @returns a new mesh holding the sky box
  59308. */
  59309. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59310. /**
  59311. * Creates a new environment
  59312. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59313. * @param options defines the options you can use to configure the environment
  59314. * @returns the new EnvironmentHelper
  59315. */
  59316. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59317. /**
  59318. * Creates a new VREXperienceHelper
  59319. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59320. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59321. * @returns a new VREXperienceHelper
  59322. */
  59323. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59324. /**
  59325. * Creates a new WebXRDefaultExperience
  59326. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59327. * @param options experience options
  59328. * @returns a promise for a new WebXRDefaultExperience
  59329. */
  59330. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59336. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59337. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59338. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59339. */
  59340. export class VideoDome extends TextureDome<VideoTexture> {
  59341. /**
  59342. * Define the video source as a Monoscopic panoramic 360 video.
  59343. */
  59344. static readonly MODE_MONOSCOPIC: number;
  59345. /**
  59346. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59347. */
  59348. static readonly MODE_TOPBOTTOM: number;
  59349. /**
  59350. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59351. */
  59352. static readonly MODE_SIDEBYSIDE: number;
  59353. /**
  59354. * Get the video texture associated with this video dome
  59355. */
  59356. get videoTexture(): VideoTexture;
  59357. /**
  59358. * Get the video mode of this dome
  59359. */
  59360. get videoMode(): number;
  59361. /**
  59362. * Set the video mode of this dome.
  59363. * @see textureMode
  59364. */
  59365. set videoMode(value: number);
  59366. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59367. }
  59368. }
  59369. declare module BABYLON {
  59370. /**
  59371. * This class can be used to get instrumentation data from a Babylon engine
  59372. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59373. */
  59374. export class EngineInstrumentation implements IDisposable {
  59375. /**
  59376. * Define the instrumented engine.
  59377. */
  59378. engine: Engine;
  59379. private _captureGPUFrameTime;
  59380. private _gpuFrameTimeToken;
  59381. private _gpuFrameTime;
  59382. private _captureShaderCompilationTime;
  59383. private _shaderCompilationTime;
  59384. private _onBeginFrameObserver;
  59385. private _onEndFrameObserver;
  59386. private _onBeforeShaderCompilationObserver;
  59387. private _onAfterShaderCompilationObserver;
  59388. /**
  59389. * Gets the perf counter used for GPU frame time
  59390. */
  59391. get gpuFrameTimeCounter(): PerfCounter;
  59392. /**
  59393. * Gets the GPU frame time capture status
  59394. */
  59395. get captureGPUFrameTime(): boolean;
  59396. /**
  59397. * Enable or disable the GPU frame time capture
  59398. */
  59399. set captureGPUFrameTime(value: boolean);
  59400. /**
  59401. * Gets the perf counter used for shader compilation time
  59402. */
  59403. get shaderCompilationTimeCounter(): PerfCounter;
  59404. /**
  59405. * Gets the shader compilation time capture status
  59406. */
  59407. get captureShaderCompilationTime(): boolean;
  59408. /**
  59409. * Enable or disable the shader compilation time capture
  59410. */
  59411. set captureShaderCompilationTime(value: boolean);
  59412. /**
  59413. * Instantiates a new engine instrumentation.
  59414. * This class can be used to get instrumentation data from a Babylon engine
  59415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59416. * @param engine Defines the engine to instrument
  59417. */
  59418. constructor(
  59419. /**
  59420. * Define the instrumented engine.
  59421. */
  59422. engine: Engine);
  59423. /**
  59424. * Dispose and release associated resources.
  59425. */
  59426. dispose(): void;
  59427. }
  59428. }
  59429. declare module BABYLON {
  59430. /**
  59431. * This class can be used to get instrumentation data from a Babylon engine
  59432. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59433. */
  59434. export class SceneInstrumentation implements IDisposable {
  59435. /**
  59436. * Defines the scene to instrument
  59437. */
  59438. scene: Scene;
  59439. private _captureActiveMeshesEvaluationTime;
  59440. private _activeMeshesEvaluationTime;
  59441. private _captureRenderTargetsRenderTime;
  59442. private _renderTargetsRenderTime;
  59443. private _captureFrameTime;
  59444. private _frameTime;
  59445. private _captureRenderTime;
  59446. private _renderTime;
  59447. private _captureInterFrameTime;
  59448. private _interFrameTime;
  59449. private _captureParticlesRenderTime;
  59450. private _particlesRenderTime;
  59451. private _captureSpritesRenderTime;
  59452. private _spritesRenderTime;
  59453. private _capturePhysicsTime;
  59454. private _physicsTime;
  59455. private _captureAnimationsTime;
  59456. private _animationsTime;
  59457. private _captureCameraRenderTime;
  59458. private _cameraRenderTime;
  59459. private _onBeforeActiveMeshesEvaluationObserver;
  59460. private _onAfterActiveMeshesEvaluationObserver;
  59461. private _onBeforeRenderTargetsRenderObserver;
  59462. private _onAfterRenderTargetsRenderObserver;
  59463. private _onAfterRenderObserver;
  59464. private _onBeforeDrawPhaseObserver;
  59465. private _onAfterDrawPhaseObserver;
  59466. private _onBeforeAnimationsObserver;
  59467. private _onBeforeParticlesRenderingObserver;
  59468. private _onAfterParticlesRenderingObserver;
  59469. private _onBeforeSpritesRenderingObserver;
  59470. private _onAfterSpritesRenderingObserver;
  59471. private _onBeforePhysicsObserver;
  59472. private _onAfterPhysicsObserver;
  59473. private _onAfterAnimationsObserver;
  59474. private _onBeforeCameraRenderObserver;
  59475. private _onAfterCameraRenderObserver;
  59476. /**
  59477. * Gets the perf counter used for active meshes evaluation time
  59478. */
  59479. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59480. /**
  59481. * Gets the active meshes evaluation time capture status
  59482. */
  59483. get captureActiveMeshesEvaluationTime(): boolean;
  59484. /**
  59485. * Enable or disable the active meshes evaluation time capture
  59486. */
  59487. set captureActiveMeshesEvaluationTime(value: boolean);
  59488. /**
  59489. * Gets the perf counter used for render targets render time
  59490. */
  59491. get renderTargetsRenderTimeCounter(): PerfCounter;
  59492. /**
  59493. * Gets the render targets render time capture status
  59494. */
  59495. get captureRenderTargetsRenderTime(): boolean;
  59496. /**
  59497. * Enable or disable the render targets render time capture
  59498. */
  59499. set captureRenderTargetsRenderTime(value: boolean);
  59500. /**
  59501. * Gets the perf counter used for particles render time
  59502. */
  59503. get particlesRenderTimeCounter(): PerfCounter;
  59504. /**
  59505. * Gets the particles render time capture status
  59506. */
  59507. get captureParticlesRenderTime(): boolean;
  59508. /**
  59509. * Enable or disable the particles render time capture
  59510. */
  59511. set captureParticlesRenderTime(value: boolean);
  59512. /**
  59513. * Gets the perf counter used for sprites render time
  59514. */
  59515. get spritesRenderTimeCounter(): PerfCounter;
  59516. /**
  59517. * Gets the sprites render time capture status
  59518. */
  59519. get captureSpritesRenderTime(): boolean;
  59520. /**
  59521. * Enable or disable the sprites render time capture
  59522. */
  59523. set captureSpritesRenderTime(value: boolean);
  59524. /**
  59525. * Gets the perf counter used for physics time
  59526. */
  59527. get physicsTimeCounter(): PerfCounter;
  59528. /**
  59529. * Gets the physics time capture status
  59530. */
  59531. get capturePhysicsTime(): boolean;
  59532. /**
  59533. * Enable or disable the physics time capture
  59534. */
  59535. set capturePhysicsTime(value: boolean);
  59536. /**
  59537. * Gets the perf counter used for animations time
  59538. */
  59539. get animationsTimeCounter(): PerfCounter;
  59540. /**
  59541. * Gets the animations time capture status
  59542. */
  59543. get captureAnimationsTime(): boolean;
  59544. /**
  59545. * Enable or disable the animations time capture
  59546. */
  59547. set captureAnimationsTime(value: boolean);
  59548. /**
  59549. * Gets the perf counter used for frame time capture
  59550. */
  59551. get frameTimeCounter(): PerfCounter;
  59552. /**
  59553. * Gets the frame time capture status
  59554. */
  59555. get captureFrameTime(): boolean;
  59556. /**
  59557. * Enable or disable the frame time capture
  59558. */
  59559. set captureFrameTime(value: boolean);
  59560. /**
  59561. * Gets the perf counter used for inter-frames time capture
  59562. */
  59563. get interFrameTimeCounter(): PerfCounter;
  59564. /**
  59565. * Gets the inter-frames time capture status
  59566. */
  59567. get captureInterFrameTime(): boolean;
  59568. /**
  59569. * Enable or disable the inter-frames time capture
  59570. */
  59571. set captureInterFrameTime(value: boolean);
  59572. /**
  59573. * Gets the perf counter used for render time capture
  59574. */
  59575. get renderTimeCounter(): PerfCounter;
  59576. /**
  59577. * Gets the render time capture status
  59578. */
  59579. get captureRenderTime(): boolean;
  59580. /**
  59581. * Enable or disable the render time capture
  59582. */
  59583. set captureRenderTime(value: boolean);
  59584. /**
  59585. * Gets the perf counter used for camera render time capture
  59586. */
  59587. get cameraRenderTimeCounter(): PerfCounter;
  59588. /**
  59589. * Gets the camera render time capture status
  59590. */
  59591. get captureCameraRenderTime(): boolean;
  59592. /**
  59593. * Enable or disable the camera render time capture
  59594. */
  59595. set captureCameraRenderTime(value: boolean);
  59596. /**
  59597. * Gets the perf counter used for draw calls
  59598. */
  59599. get drawCallsCounter(): PerfCounter;
  59600. /**
  59601. * Instantiates a new scene instrumentation.
  59602. * This class can be used to get instrumentation data from a Babylon engine
  59603. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59604. * @param scene Defines the scene to instrument
  59605. */
  59606. constructor(
  59607. /**
  59608. * Defines the scene to instrument
  59609. */
  59610. scene: Scene);
  59611. /**
  59612. * Dispose and release associated resources.
  59613. */
  59614. dispose(): void;
  59615. }
  59616. }
  59617. declare module BABYLON {
  59618. /** @hidden */
  59619. export var glowMapGenerationPixelShader: {
  59620. name: string;
  59621. shader: string;
  59622. };
  59623. }
  59624. declare module BABYLON {
  59625. /** @hidden */
  59626. export var glowMapGenerationVertexShader: {
  59627. name: string;
  59628. shader: string;
  59629. };
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Effect layer options. This helps customizing the behaviour
  59634. * of the effect layer.
  59635. */
  59636. export interface IEffectLayerOptions {
  59637. /**
  59638. * Multiplication factor apply to the canvas size to compute the render target size
  59639. * used to generated the objects (the smaller the faster).
  59640. */
  59641. mainTextureRatio: number;
  59642. /**
  59643. * Enforces a fixed size texture to ensure effect stability across devices.
  59644. */
  59645. mainTextureFixedSize?: number;
  59646. /**
  59647. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59648. */
  59649. alphaBlendingMode: number;
  59650. /**
  59651. * The camera attached to the layer.
  59652. */
  59653. camera: Nullable<Camera>;
  59654. /**
  59655. * The rendering group to draw the layer in.
  59656. */
  59657. renderingGroupId: number;
  59658. }
  59659. /**
  59660. * The effect layer Helps adding post process effect blended with the main pass.
  59661. *
  59662. * This can be for instance use to generate glow or higlight effects on the scene.
  59663. *
  59664. * The effect layer class can not be used directly and is intented to inherited from to be
  59665. * customized per effects.
  59666. */
  59667. export abstract class EffectLayer {
  59668. private _vertexBuffers;
  59669. private _indexBuffer;
  59670. private _cachedDefines;
  59671. private _effectLayerMapGenerationEffect;
  59672. private _effectLayerOptions;
  59673. private _mergeEffect;
  59674. protected _scene: Scene;
  59675. protected _engine: Engine;
  59676. protected _maxSize: number;
  59677. protected _mainTextureDesiredSize: ISize;
  59678. protected _mainTexture: RenderTargetTexture;
  59679. protected _shouldRender: boolean;
  59680. protected _postProcesses: PostProcess[];
  59681. protected _textures: BaseTexture[];
  59682. protected _emissiveTextureAndColor: {
  59683. texture: Nullable<BaseTexture>;
  59684. color: Color4;
  59685. };
  59686. /**
  59687. * The name of the layer
  59688. */
  59689. name: string;
  59690. /**
  59691. * The clear color of the texture used to generate the glow map.
  59692. */
  59693. neutralColor: Color4;
  59694. /**
  59695. * Specifies whether the highlight layer is enabled or not.
  59696. */
  59697. isEnabled: boolean;
  59698. /**
  59699. * Gets the camera attached to the layer.
  59700. */
  59701. get camera(): Nullable<Camera>;
  59702. /**
  59703. * Gets the rendering group id the layer should render in.
  59704. */
  59705. get renderingGroupId(): number;
  59706. set renderingGroupId(renderingGroupId: number);
  59707. /**
  59708. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59709. */
  59710. disableBoundingBoxesFromEffectLayer: boolean;
  59711. /**
  59712. * An event triggered when the effect layer has been disposed.
  59713. */
  59714. onDisposeObservable: Observable<EffectLayer>;
  59715. /**
  59716. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59717. */
  59718. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59719. /**
  59720. * An event triggered when the generated texture is being merged in the scene.
  59721. */
  59722. onBeforeComposeObservable: Observable<EffectLayer>;
  59723. /**
  59724. * An event triggered when the mesh is rendered into the effect render target.
  59725. */
  59726. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59727. /**
  59728. * An event triggered after the mesh has been rendered into the effect render target.
  59729. */
  59730. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59731. /**
  59732. * An event triggered when the generated texture has been merged in the scene.
  59733. */
  59734. onAfterComposeObservable: Observable<EffectLayer>;
  59735. /**
  59736. * An event triggered when the efffect layer changes its size.
  59737. */
  59738. onSizeChangedObservable: Observable<EffectLayer>;
  59739. /** @hidden */
  59740. static _SceneComponentInitialization: (scene: Scene) => void;
  59741. /**
  59742. * Instantiates a new effect Layer and references it in the scene.
  59743. * @param name The name of the layer
  59744. * @param scene The scene to use the layer in
  59745. */
  59746. constructor(
  59747. /** The Friendly of the effect in the scene */
  59748. name: string, scene: Scene);
  59749. /**
  59750. * Get the effect name of the layer.
  59751. * @return The effect name
  59752. */
  59753. abstract getEffectName(): string;
  59754. /**
  59755. * Checks for the readiness of the element composing the layer.
  59756. * @param subMesh the mesh to check for
  59757. * @param useInstances specify whether or not to use instances to render the mesh
  59758. * @return true if ready otherwise, false
  59759. */
  59760. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59761. /**
  59762. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59763. * @returns true if the effect requires stencil during the main canvas render pass.
  59764. */
  59765. abstract needStencil(): boolean;
  59766. /**
  59767. * Create the merge effect. This is the shader use to blit the information back
  59768. * to the main canvas at the end of the scene rendering.
  59769. * @returns The effect containing the shader used to merge the effect on the main canvas
  59770. */
  59771. protected abstract _createMergeEffect(): Effect;
  59772. /**
  59773. * Creates the render target textures and post processes used in the effect layer.
  59774. */
  59775. protected abstract _createTextureAndPostProcesses(): void;
  59776. /**
  59777. * Implementation specific of rendering the generating effect on the main canvas.
  59778. * @param effect The effect used to render through
  59779. */
  59780. protected abstract _internalRender(effect: Effect): void;
  59781. /**
  59782. * Sets the required values for both the emissive texture and and the main color.
  59783. */
  59784. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59785. /**
  59786. * Free any resources and references associated to a mesh.
  59787. * Internal use
  59788. * @param mesh The mesh to free.
  59789. */
  59790. abstract _disposeMesh(mesh: Mesh): void;
  59791. /**
  59792. * Serializes this layer (Glow or Highlight for example)
  59793. * @returns a serialized layer object
  59794. */
  59795. abstract serialize?(): any;
  59796. /**
  59797. * Initializes the effect layer with the required options.
  59798. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59799. */
  59800. protected _init(options: Partial<IEffectLayerOptions>): void;
  59801. /**
  59802. * Generates the index buffer of the full screen quad blending to the main canvas.
  59803. */
  59804. private _generateIndexBuffer;
  59805. /**
  59806. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59807. */
  59808. private _generateVertexBuffer;
  59809. /**
  59810. * Sets the main texture desired size which is the closest power of two
  59811. * of the engine canvas size.
  59812. */
  59813. private _setMainTextureSize;
  59814. /**
  59815. * Creates the main texture for the effect layer.
  59816. */
  59817. protected _createMainTexture(): void;
  59818. /**
  59819. * Adds specific effects defines.
  59820. * @param defines The defines to add specifics to.
  59821. */
  59822. protected _addCustomEffectDefines(defines: string[]): void;
  59823. /**
  59824. * Checks for the readiness of the element composing the layer.
  59825. * @param subMesh the mesh to check for
  59826. * @param useInstances specify whether or not to use instances to render the mesh
  59827. * @param emissiveTexture the associated emissive texture used to generate the glow
  59828. * @return true if ready otherwise, false
  59829. */
  59830. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59831. /**
  59832. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59833. */
  59834. render(): void;
  59835. /**
  59836. * Determine if a given mesh will be used in the current effect.
  59837. * @param mesh mesh to test
  59838. * @returns true if the mesh will be used
  59839. */
  59840. hasMesh(mesh: AbstractMesh): boolean;
  59841. /**
  59842. * Returns true if the layer contains information to display, otherwise false.
  59843. * @returns true if the glow layer should be rendered
  59844. */
  59845. shouldRender(): boolean;
  59846. /**
  59847. * Returns true if the mesh should render, otherwise false.
  59848. * @param mesh The mesh to render
  59849. * @returns true if it should render otherwise false
  59850. */
  59851. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59852. /**
  59853. * Returns true if the mesh can be rendered, otherwise false.
  59854. * @param mesh The mesh to render
  59855. * @param material The material used on the mesh
  59856. * @returns true if it can be rendered otherwise false
  59857. */
  59858. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59859. /**
  59860. * Returns true if the mesh should render, otherwise false.
  59861. * @param mesh The mesh to render
  59862. * @returns true if it should render otherwise false
  59863. */
  59864. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59865. /**
  59866. * Renders the submesh passed in parameter to the generation map.
  59867. */
  59868. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59869. /**
  59870. * Defines whether the current material of the mesh should be use to render the effect.
  59871. * @param mesh defines the current mesh to render
  59872. */
  59873. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59874. /**
  59875. * Rebuild the required buffers.
  59876. * @hidden Internal use only.
  59877. */
  59878. _rebuild(): void;
  59879. /**
  59880. * Dispose only the render target textures and post process.
  59881. */
  59882. private _disposeTextureAndPostProcesses;
  59883. /**
  59884. * Dispose the highlight layer and free resources.
  59885. */
  59886. dispose(): void;
  59887. /**
  59888. * Gets the class name of the effect layer
  59889. * @returns the string with the class name of the effect layer
  59890. */
  59891. getClassName(): string;
  59892. /**
  59893. * Creates an effect layer from parsed effect layer data
  59894. * @param parsedEffectLayer defines effect layer data
  59895. * @param scene defines the current scene
  59896. * @param rootUrl defines the root URL containing the effect layer information
  59897. * @returns a parsed effect Layer
  59898. */
  59899. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59900. }
  59901. }
  59902. declare module BABYLON {
  59903. interface AbstractScene {
  59904. /**
  59905. * The list of effect layers (highlights/glow) added to the scene
  59906. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59907. * @see https://doc.babylonjs.com/how_to/glow_layer
  59908. */
  59909. effectLayers: Array<EffectLayer>;
  59910. /**
  59911. * Removes the given effect layer from this scene.
  59912. * @param toRemove defines the effect layer to remove
  59913. * @returns the index of the removed effect layer
  59914. */
  59915. removeEffectLayer(toRemove: EffectLayer): number;
  59916. /**
  59917. * Adds the given effect layer to this scene
  59918. * @param newEffectLayer defines the effect layer to add
  59919. */
  59920. addEffectLayer(newEffectLayer: EffectLayer): void;
  59921. }
  59922. /**
  59923. * Defines the layer scene component responsible to manage any effect layers
  59924. * in a given scene.
  59925. */
  59926. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59927. /**
  59928. * The component name helpfull to identify the component in the list of scene components.
  59929. */
  59930. readonly name: string;
  59931. /**
  59932. * The scene the component belongs to.
  59933. */
  59934. scene: Scene;
  59935. private _engine;
  59936. private _renderEffects;
  59937. private _needStencil;
  59938. private _previousStencilState;
  59939. /**
  59940. * Creates a new instance of the component for the given scene
  59941. * @param scene Defines the scene to register the component in
  59942. */
  59943. constructor(scene: Scene);
  59944. /**
  59945. * Registers the component in a given scene
  59946. */
  59947. register(): void;
  59948. /**
  59949. * Rebuilds the elements related to this component in case of
  59950. * context lost for instance.
  59951. */
  59952. rebuild(): void;
  59953. /**
  59954. * Serializes the component data to the specified json object
  59955. * @param serializationObject The object to serialize to
  59956. */
  59957. serialize(serializationObject: any): void;
  59958. /**
  59959. * Adds all the elements from the container to the scene
  59960. * @param container the container holding the elements
  59961. */
  59962. addFromContainer(container: AbstractScene): void;
  59963. /**
  59964. * Removes all the elements in the container from the scene
  59965. * @param container contains the elements to remove
  59966. * @param dispose if the removed element should be disposed (default: false)
  59967. */
  59968. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59969. /**
  59970. * Disposes the component and the associated ressources.
  59971. */
  59972. dispose(): void;
  59973. private _isReadyForMesh;
  59974. private _renderMainTexture;
  59975. private _setStencil;
  59976. private _setStencilBack;
  59977. private _draw;
  59978. private _drawCamera;
  59979. private _drawRenderingGroup;
  59980. }
  59981. }
  59982. declare module BABYLON {
  59983. /** @hidden */
  59984. export var glowMapMergePixelShader: {
  59985. name: string;
  59986. shader: string;
  59987. };
  59988. }
  59989. declare module BABYLON {
  59990. /** @hidden */
  59991. export var glowMapMergeVertexShader: {
  59992. name: string;
  59993. shader: string;
  59994. };
  59995. }
  59996. declare module BABYLON {
  59997. interface AbstractScene {
  59998. /**
  59999. * Return a the first highlight layer of the scene with a given name.
  60000. * @param name The name of the highlight layer to look for.
  60001. * @return The highlight layer if found otherwise null.
  60002. */
  60003. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60004. }
  60005. /**
  60006. * Glow layer options. This helps customizing the behaviour
  60007. * of the glow layer.
  60008. */
  60009. export interface IGlowLayerOptions {
  60010. /**
  60011. * Multiplication factor apply to the canvas size to compute the render target size
  60012. * used to generated the glowing objects (the smaller the faster).
  60013. */
  60014. mainTextureRatio: number;
  60015. /**
  60016. * Enforces a fixed size texture to ensure resize independant blur.
  60017. */
  60018. mainTextureFixedSize?: number;
  60019. /**
  60020. * How big is the kernel of the blur texture.
  60021. */
  60022. blurKernelSize: number;
  60023. /**
  60024. * The camera attached to the layer.
  60025. */
  60026. camera: Nullable<Camera>;
  60027. /**
  60028. * Enable MSAA by chosing the number of samples.
  60029. */
  60030. mainTextureSamples?: number;
  60031. /**
  60032. * The rendering group to draw the layer in.
  60033. */
  60034. renderingGroupId: number;
  60035. }
  60036. /**
  60037. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60038. *
  60039. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60040. *
  60041. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60042. */
  60043. export class GlowLayer extends EffectLayer {
  60044. /**
  60045. * Effect Name of the layer.
  60046. */
  60047. static readonly EffectName: string;
  60048. /**
  60049. * The default blur kernel size used for the glow.
  60050. */
  60051. static DefaultBlurKernelSize: number;
  60052. /**
  60053. * The default texture size ratio used for the glow.
  60054. */
  60055. static DefaultTextureRatio: number;
  60056. /**
  60057. * Sets the kernel size of the blur.
  60058. */
  60059. set blurKernelSize(value: number);
  60060. /**
  60061. * Gets the kernel size of the blur.
  60062. */
  60063. get blurKernelSize(): number;
  60064. /**
  60065. * Sets the glow intensity.
  60066. */
  60067. set intensity(value: number);
  60068. /**
  60069. * Gets the glow intensity.
  60070. */
  60071. get intensity(): number;
  60072. private _options;
  60073. private _intensity;
  60074. private _horizontalBlurPostprocess1;
  60075. private _verticalBlurPostprocess1;
  60076. private _horizontalBlurPostprocess2;
  60077. private _verticalBlurPostprocess2;
  60078. private _blurTexture1;
  60079. private _blurTexture2;
  60080. private _postProcesses1;
  60081. private _postProcesses2;
  60082. private _includedOnlyMeshes;
  60083. private _excludedMeshes;
  60084. private _meshesUsingTheirOwnMaterials;
  60085. /**
  60086. * Callback used to let the user override the color selection on a per mesh basis
  60087. */
  60088. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60089. /**
  60090. * Callback used to let the user override the texture selection on a per mesh basis
  60091. */
  60092. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60093. /**
  60094. * Instantiates a new glow Layer and references it to the scene.
  60095. * @param name The name of the layer
  60096. * @param scene The scene to use the layer in
  60097. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60098. */
  60099. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60100. /**
  60101. * Get the effect name of the layer.
  60102. * @return The effect name
  60103. */
  60104. getEffectName(): string;
  60105. /**
  60106. * Create the merge effect. This is the shader use to blit the information back
  60107. * to the main canvas at the end of the scene rendering.
  60108. */
  60109. protected _createMergeEffect(): Effect;
  60110. /**
  60111. * Creates the render target textures and post processes used in the glow layer.
  60112. */
  60113. protected _createTextureAndPostProcesses(): void;
  60114. /**
  60115. * Checks for the readiness of the element composing the layer.
  60116. * @param subMesh the mesh to check for
  60117. * @param useInstances specify wether or not to use instances to render the mesh
  60118. * @param emissiveTexture the associated emissive texture used to generate the glow
  60119. * @return true if ready otherwise, false
  60120. */
  60121. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60122. /**
  60123. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60124. */
  60125. needStencil(): boolean;
  60126. /**
  60127. * Returns true if the mesh can be rendered, otherwise false.
  60128. * @param mesh The mesh to render
  60129. * @param material The material used on the mesh
  60130. * @returns true if it can be rendered otherwise false
  60131. */
  60132. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60133. /**
  60134. * Implementation specific of rendering the generating effect on the main canvas.
  60135. * @param effect The effect used to render through
  60136. */
  60137. protected _internalRender(effect: Effect): void;
  60138. /**
  60139. * Sets the required values for both the emissive texture and and the main color.
  60140. */
  60141. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60142. /**
  60143. * Returns true if the mesh should render, otherwise false.
  60144. * @param mesh The mesh to render
  60145. * @returns true if it should render otherwise false
  60146. */
  60147. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60148. /**
  60149. * Adds specific effects defines.
  60150. * @param defines The defines to add specifics to.
  60151. */
  60152. protected _addCustomEffectDefines(defines: string[]): void;
  60153. /**
  60154. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60155. * @param mesh The mesh to exclude from the glow layer
  60156. */
  60157. addExcludedMesh(mesh: Mesh): void;
  60158. /**
  60159. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60160. * @param mesh The mesh to remove
  60161. */
  60162. removeExcludedMesh(mesh: Mesh): void;
  60163. /**
  60164. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60165. * @param mesh The mesh to include in the glow layer
  60166. */
  60167. addIncludedOnlyMesh(mesh: Mesh): void;
  60168. /**
  60169. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60170. * @param mesh The mesh to remove
  60171. */
  60172. removeIncludedOnlyMesh(mesh: Mesh): void;
  60173. /**
  60174. * Determine if a given mesh will be used in the glow layer
  60175. * @param mesh The mesh to test
  60176. * @returns true if the mesh will be highlighted by the current glow layer
  60177. */
  60178. hasMesh(mesh: AbstractMesh): boolean;
  60179. /**
  60180. * Defines whether the current material of the mesh should be use to render the effect.
  60181. * @param mesh defines the current mesh to render
  60182. */
  60183. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60184. /**
  60185. * Add a mesh to be rendered through its own material and not with emissive only.
  60186. * @param mesh The mesh for which we need to use its material
  60187. */
  60188. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60189. /**
  60190. * Remove a mesh from being rendered through its own material and not with emissive only.
  60191. * @param mesh The mesh for which we need to not use its material
  60192. */
  60193. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60194. /**
  60195. * Free any resources and references associated to a mesh.
  60196. * Internal use
  60197. * @param mesh The mesh to free.
  60198. * @hidden
  60199. */
  60200. _disposeMesh(mesh: Mesh): void;
  60201. /**
  60202. * Gets the class name of the effect layer
  60203. * @returns the string with the class name of the effect layer
  60204. */
  60205. getClassName(): string;
  60206. /**
  60207. * Serializes this glow layer
  60208. * @returns a serialized glow layer object
  60209. */
  60210. serialize(): any;
  60211. /**
  60212. * Creates a Glow Layer from parsed glow layer data
  60213. * @param parsedGlowLayer defines glow layer data
  60214. * @param scene defines the current scene
  60215. * @param rootUrl defines the root URL containing the glow layer information
  60216. * @returns a parsed Glow Layer
  60217. */
  60218. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60219. }
  60220. }
  60221. declare module BABYLON {
  60222. /** @hidden */
  60223. export var glowBlurPostProcessPixelShader: {
  60224. name: string;
  60225. shader: string;
  60226. };
  60227. }
  60228. declare module BABYLON {
  60229. interface AbstractScene {
  60230. /**
  60231. * Return a the first highlight layer of the scene with a given name.
  60232. * @param name The name of the highlight layer to look for.
  60233. * @return The highlight layer if found otherwise null.
  60234. */
  60235. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60236. }
  60237. /**
  60238. * Highlight layer options. This helps customizing the behaviour
  60239. * of the highlight layer.
  60240. */
  60241. export interface IHighlightLayerOptions {
  60242. /**
  60243. * Multiplication factor apply to the canvas size to compute the render target size
  60244. * used to generated the glowing objects (the smaller the faster).
  60245. */
  60246. mainTextureRatio: number;
  60247. /**
  60248. * Enforces a fixed size texture to ensure resize independant blur.
  60249. */
  60250. mainTextureFixedSize?: number;
  60251. /**
  60252. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60253. * of the picture to blur (the smaller the faster).
  60254. */
  60255. blurTextureSizeRatio: number;
  60256. /**
  60257. * How big in texel of the blur texture is the vertical blur.
  60258. */
  60259. blurVerticalSize: number;
  60260. /**
  60261. * How big in texel of the blur texture is the horizontal blur.
  60262. */
  60263. blurHorizontalSize: number;
  60264. /**
  60265. * Alpha blending mode used to apply the blur. Default is combine.
  60266. */
  60267. alphaBlendingMode: number;
  60268. /**
  60269. * The camera attached to the layer.
  60270. */
  60271. camera: Nullable<Camera>;
  60272. /**
  60273. * Should we display highlight as a solid stroke?
  60274. */
  60275. isStroke?: boolean;
  60276. /**
  60277. * The rendering group to draw the layer in.
  60278. */
  60279. renderingGroupId: number;
  60280. }
  60281. /**
  60282. * The highlight layer Helps adding a glow effect around a mesh.
  60283. *
  60284. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60285. * glowy meshes to your scene.
  60286. *
  60287. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60288. */
  60289. export class HighlightLayer extends EffectLayer {
  60290. name: string;
  60291. /**
  60292. * Effect Name of the highlight layer.
  60293. */
  60294. static readonly EffectName: string;
  60295. /**
  60296. * The neutral color used during the preparation of the glow effect.
  60297. * This is black by default as the blend operation is a blend operation.
  60298. */
  60299. static NeutralColor: Color4;
  60300. /**
  60301. * Stencil value used for glowing meshes.
  60302. */
  60303. static GlowingMeshStencilReference: number;
  60304. /**
  60305. * Stencil value used for the other meshes in the scene.
  60306. */
  60307. static NormalMeshStencilReference: number;
  60308. /**
  60309. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60310. */
  60311. innerGlow: boolean;
  60312. /**
  60313. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60314. */
  60315. outerGlow: boolean;
  60316. /**
  60317. * Specifies the horizontal size of the blur.
  60318. */
  60319. set blurHorizontalSize(value: number);
  60320. /**
  60321. * Specifies the vertical size of the blur.
  60322. */
  60323. set blurVerticalSize(value: number);
  60324. /**
  60325. * Gets the horizontal size of the blur.
  60326. */
  60327. get blurHorizontalSize(): number;
  60328. /**
  60329. * Gets the vertical size of the blur.
  60330. */
  60331. get blurVerticalSize(): number;
  60332. /**
  60333. * An event triggered when the highlight layer is being blurred.
  60334. */
  60335. onBeforeBlurObservable: Observable<HighlightLayer>;
  60336. /**
  60337. * An event triggered when the highlight layer has been blurred.
  60338. */
  60339. onAfterBlurObservable: Observable<HighlightLayer>;
  60340. private _instanceGlowingMeshStencilReference;
  60341. private _options;
  60342. private _downSamplePostprocess;
  60343. private _horizontalBlurPostprocess;
  60344. private _verticalBlurPostprocess;
  60345. private _blurTexture;
  60346. private _meshes;
  60347. private _excludedMeshes;
  60348. /**
  60349. * Instantiates a new highlight Layer and references it to the scene..
  60350. * @param name The name of the layer
  60351. * @param scene The scene to use the layer in
  60352. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60353. */
  60354. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60355. /**
  60356. * Get the effect name of the layer.
  60357. * @return The effect name
  60358. */
  60359. getEffectName(): string;
  60360. /**
  60361. * Create the merge effect. This is the shader use to blit the information back
  60362. * to the main canvas at the end of the scene rendering.
  60363. */
  60364. protected _createMergeEffect(): Effect;
  60365. /**
  60366. * Creates the render target textures and post processes used in the highlight layer.
  60367. */
  60368. protected _createTextureAndPostProcesses(): void;
  60369. /**
  60370. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60371. */
  60372. needStencil(): boolean;
  60373. /**
  60374. * Checks for the readiness of the element composing the layer.
  60375. * @param subMesh the mesh to check for
  60376. * @param useInstances specify wether or not to use instances to render the mesh
  60377. * @param emissiveTexture the associated emissive texture used to generate the glow
  60378. * @return true if ready otherwise, false
  60379. */
  60380. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60381. /**
  60382. * Implementation specific of rendering the generating effect on the main canvas.
  60383. * @param effect The effect used to render through
  60384. */
  60385. protected _internalRender(effect: Effect): void;
  60386. /**
  60387. * Returns true if the layer contains information to display, otherwise false.
  60388. */
  60389. shouldRender(): boolean;
  60390. /**
  60391. * Returns true if the mesh should render, otherwise false.
  60392. * @param mesh The mesh to render
  60393. * @returns true if it should render otherwise false
  60394. */
  60395. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60396. /**
  60397. * Returns true if the mesh can be rendered, otherwise false.
  60398. * @param mesh The mesh to render
  60399. * @param material The material used on the mesh
  60400. * @returns true if it can be rendered otherwise false
  60401. */
  60402. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60403. /**
  60404. * Adds specific effects defines.
  60405. * @param defines The defines to add specifics to.
  60406. */
  60407. protected _addCustomEffectDefines(defines: string[]): void;
  60408. /**
  60409. * Sets the required values for both the emissive texture and and the main color.
  60410. */
  60411. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60412. /**
  60413. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60414. * @param mesh The mesh to exclude from the highlight layer
  60415. */
  60416. addExcludedMesh(mesh: Mesh): void;
  60417. /**
  60418. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60419. * @param mesh The mesh to highlight
  60420. */
  60421. removeExcludedMesh(mesh: Mesh): void;
  60422. /**
  60423. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60424. * @param mesh mesh to test
  60425. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60426. */
  60427. hasMesh(mesh: AbstractMesh): boolean;
  60428. /**
  60429. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60430. * @param mesh The mesh to highlight
  60431. * @param color The color of the highlight
  60432. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60433. */
  60434. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60435. /**
  60436. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60437. * @param mesh The mesh to highlight
  60438. */
  60439. removeMesh(mesh: Mesh): void;
  60440. /**
  60441. * Remove all the meshes currently referenced in the highlight layer
  60442. */
  60443. removeAllMeshes(): void;
  60444. /**
  60445. * Force the stencil to the normal expected value for none glowing parts
  60446. */
  60447. private _defaultStencilReference;
  60448. /**
  60449. * Free any resources and references associated to a mesh.
  60450. * Internal use
  60451. * @param mesh The mesh to free.
  60452. * @hidden
  60453. */
  60454. _disposeMesh(mesh: Mesh): void;
  60455. /**
  60456. * Dispose the highlight layer and free resources.
  60457. */
  60458. dispose(): void;
  60459. /**
  60460. * Gets the class name of the effect layer
  60461. * @returns the string with the class name of the effect layer
  60462. */
  60463. getClassName(): string;
  60464. /**
  60465. * Serializes this Highlight layer
  60466. * @returns a serialized Highlight layer object
  60467. */
  60468. serialize(): any;
  60469. /**
  60470. * Creates a Highlight layer from parsed Highlight layer data
  60471. * @param parsedHightlightLayer defines the Highlight layer data
  60472. * @param scene defines the current scene
  60473. * @param rootUrl defines the root URL containing the Highlight layer information
  60474. * @returns a parsed Highlight layer
  60475. */
  60476. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60477. }
  60478. }
  60479. declare module BABYLON {
  60480. interface AbstractScene {
  60481. /**
  60482. * The list of layers (background and foreground) of the scene
  60483. */
  60484. layers: Array<Layer>;
  60485. }
  60486. /**
  60487. * Defines the layer scene component responsible to manage any layers
  60488. * in a given scene.
  60489. */
  60490. export class LayerSceneComponent implements ISceneComponent {
  60491. /**
  60492. * The component name helpfull to identify the component in the list of scene components.
  60493. */
  60494. readonly name: string;
  60495. /**
  60496. * The scene the component belongs to.
  60497. */
  60498. scene: Scene;
  60499. private _engine;
  60500. /**
  60501. * Creates a new instance of the component for the given scene
  60502. * @param scene Defines the scene to register the component in
  60503. */
  60504. constructor(scene: Scene);
  60505. /**
  60506. * Registers the component in a given scene
  60507. */
  60508. register(): void;
  60509. /**
  60510. * Rebuilds the elements related to this component in case of
  60511. * context lost for instance.
  60512. */
  60513. rebuild(): void;
  60514. /**
  60515. * Disposes the component and the associated ressources.
  60516. */
  60517. dispose(): void;
  60518. private _draw;
  60519. private _drawCameraPredicate;
  60520. private _drawCameraBackground;
  60521. private _drawCameraForeground;
  60522. private _drawRenderTargetPredicate;
  60523. private _drawRenderTargetBackground;
  60524. private _drawRenderTargetForeground;
  60525. /**
  60526. * Adds all the elements from the container to the scene
  60527. * @param container the container holding the elements
  60528. */
  60529. addFromContainer(container: AbstractScene): void;
  60530. /**
  60531. * Removes all the elements in the container from the scene
  60532. * @param container contains the elements to remove
  60533. * @param dispose if the removed element should be disposed (default: false)
  60534. */
  60535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60536. }
  60537. }
  60538. declare module BABYLON {
  60539. /** @hidden */
  60540. export var layerPixelShader: {
  60541. name: string;
  60542. shader: string;
  60543. };
  60544. }
  60545. declare module BABYLON {
  60546. /** @hidden */
  60547. export var layerVertexShader: {
  60548. name: string;
  60549. shader: string;
  60550. };
  60551. }
  60552. declare module BABYLON {
  60553. /**
  60554. * This represents a full screen 2d layer.
  60555. * This can be useful to display a picture in the background of your scene for instance.
  60556. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60557. */
  60558. export class Layer {
  60559. /**
  60560. * Define the name of the layer.
  60561. */
  60562. name: string;
  60563. /**
  60564. * Define the texture the layer should display.
  60565. */
  60566. texture: Nullable<Texture>;
  60567. /**
  60568. * Is the layer in background or foreground.
  60569. */
  60570. isBackground: boolean;
  60571. /**
  60572. * Define the color of the layer (instead of texture).
  60573. */
  60574. color: Color4;
  60575. /**
  60576. * Define the scale of the layer in order to zoom in out of the texture.
  60577. */
  60578. scale: Vector2;
  60579. /**
  60580. * Define an offset for the layer in order to shift the texture.
  60581. */
  60582. offset: Vector2;
  60583. /**
  60584. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60585. */
  60586. alphaBlendingMode: number;
  60587. /**
  60588. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60589. * Alpha test will not mix with the background color in case of transparency.
  60590. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60591. */
  60592. alphaTest: boolean;
  60593. /**
  60594. * Define a mask to restrict the layer to only some of the scene cameras.
  60595. */
  60596. layerMask: number;
  60597. /**
  60598. * Define the list of render target the layer is visible into.
  60599. */
  60600. renderTargetTextures: RenderTargetTexture[];
  60601. /**
  60602. * Define if the layer is only used in renderTarget or if it also
  60603. * renders in the main frame buffer of the canvas.
  60604. */
  60605. renderOnlyInRenderTargetTextures: boolean;
  60606. private _scene;
  60607. private _vertexBuffers;
  60608. private _indexBuffer;
  60609. private _effect;
  60610. private _previousDefines;
  60611. /**
  60612. * An event triggered when the layer is disposed.
  60613. */
  60614. onDisposeObservable: Observable<Layer>;
  60615. private _onDisposeObserver;
  60616. /**
  60617. * Back compatibility with callback before the onDisposeObservable existed.
  60618. * The set callback will be triggered when the layer has been disposed.
  60619. */
  60620. set onDispose(callback: () => void);
  60621. /**
  60622. * An event triggered before rendering the scene
  60623. */
  60624. onBeforeRenderObservable: Observable<Layer>;
  60625. private _onBeforeRenderObserver;
  60626. /**
  60627. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60628. * The set callback will be triggered just before rendering the layer.
  60629. */
  60630. set onBeforeRender(callback: () => void);
  60631. /**
  60632. * An event triggered after rendering the scene
  60633. */
  60634. onAfterRenderObservable: Observable<Layer>;
  60635. private _onAfterRenderObserver;
  60636. /**
  60637. * Back compatibility with callback before the onAfterRenderObservable existed.
  60638. * The set callback will be triggered just after rendering the layer.
  60639. */
  60640. set onAfterRender(callback: () => void);
  60641. /**
  60642. * Instantiates a new layer.
  60643. * This represents a full screen 2d layer.
  60644. * This can be useful to display a picture in the background of your scene for instance.
  60645. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60646. * @param name Define the name of the layer in the scene
  60647. * @param imgUrl Define the url of the texture to display in the layer
  60648. * @param scene Define the scene the layer belongs to
  60649. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60650. * @param color Defines a color for the layer
  60651. */
  60652. constructor(
  60653. /**
  60654. * Define the name of the layer.
  60655. */
  60656. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60657. private _createIndexBuffer;
  60658. /** @hidden */
  60659. _rebuild(): void;
  60660. /**
  60661. * Renders the layer in the scene.
  60662. */
  60663. render(): void;
  60664. /**
  60665. * Disposes and releases the associated ressources.
  60666. */
  60667. dispose(): void;
  60668. }
  60669. }
  60670. declare module BABYLON {
  60671. /** @hidden */
  60672. export var lensFlarePixelShader: {
  60673. name: string;
  60674. shader: string;
  60675. };
  60676. }
  60677. declare module BABYLON {
  60678. /** @hidden */
  60679. export var lensFlareVertexShader: {
  60680. name: string;
  60681. shader: string;
  60682. };
  60683. }
  60684. declare module BABYLON {
  60685. /**
  60686. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60687. * It is usually composed of several `lensFlare`.
  60688. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60689. */
  60690. export class LensFlareSystem {
  60691. /**
  60692. * Define the name of the lens flare system
  60693. */
  60694. name: string;
  60695. /**
  60696. * List of lens flares used in this system.
  60697. */
  60698. lensFlares: LensFlare[];
  60699. /**
  60700. * Define a limit from the border the lens flare can be visible.
  60701. */
  60702. borderLimit: number;
  60703. /**
  60704. * Define a viewport border we do not want to see the lens flare in.
  60705. */
  60706. viewportBorder: number;
  60707. /**
  60708. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60709. */
  60710. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60711. /**
  60712. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60713. */
  60714. layerMask: number;
  60715. /**
  60716. * Define the id of the lens flare system in the scene.
  60717. * (equal to name by default)
  60718. */
  60719. id: string;
  60720. private _scene;
  60721. private _emitter;
  60722. private _vertexBuffers;
  60723. private _indexBuffer;
  60724. private _effect;
  60725. private _positionX;
  60726. private _positionY;
  60727. private _isEnabled;
  60728. /** @hidden */
  60729. static _SceneComponentInitialization: (scene: Scene) => void;
  60730. /**
  60731. * Instantiates a lens flare system.
  60732. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60733. * It is usually composed of several `lensFlare`.
  60734. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60735. * @param name Define the name of the lens flare system in the scene
  60736. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60737. * @param scene Define the scene the lens flare system belongs to
  60738. */
  60739. constructor(
  60740. /**
  60741. * Define the name of the lens flare system
  60742. */
  60743. name: string, emitter: any, scene: Scene);
  60744. /**
  60745. * Define if the lens flare system is enabled.
  60746. */
  60747. get isEnabled(): boolean;
  60748. set isEnabled(value: boolean);
  60749. /**
  60750. * Get the scene the effects belongs to.
  60751. * @returns the scene holding the lens flare system
  60752. */
  60753. getScene(): Scene;
  60754. /**
  60755. * Get the emitter of the lens flare system.
  60756. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60757. * @returns the emitter of the lens flare system
  60758. */
  60759. getEmitter(): any;
  60760. /**
  60761. * Set the emitter of the lens flare system.
  60762. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60763. * @param newEmitter Define the new emitter of the system
  60764. */
  60765. setEmitter(newEmitter: any): void;
  60766. /**
  60767. * Get the lens flare system emitter position.
  60768. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60769. * @returns the position
  60770. */
  60771. getEmitterPosition(): Vector3;
  60772. /**
  60773. * @hidden
  60774. */
  60775. computeEffectivePosition(globalViewport: Viewport): boolean;
  60776. /** @hidden */
  60777. _isVisible(): boolean;
  60778. /**
  60779. * @hidden
  60780. */
  60781. render(): boolean;
  60782. /**
  60783. * Dispose and release the lens flare with its associated resources.
  60784. */
  60785. dispose(): void;
  60786. /**
  60787. * Parse a lens flare system from a JSON repressentation
  60788. * @param parsedLensFlareSystem Define the JSON to parse
  60789. * @param scene Define the scene the parsed system should be instantiated in
  60790. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60791. * @returns the parsed system
  60792. */
  60793. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60794. /**
  60795. * Serialize the current Lens Flare System into a JSON representation.
  60796. * @returns the serialized JSON
  60797. */
  60798. serialize(): any;
  60799. }
  60800. }
  60801. declare module BABYLON {
  60802. /**
  60803. * This represents one of the lens effect in a `lensFlareSystem`.
  60804. * It controls one of the indiviual texture used in the effect.
  60805. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60806. */
  60807. export class LensFlare {
  60808. /**
  60809. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60810. */
  60811. size: number;
  60812. /**
  60813. * 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.
  60814. */
  60815. position: number;
  60816. /**
  60817. * Define the lens color.
  60818. */
  60819. color: Color3;
  60820. /**
  60821. * Define the lens texture.
  60822. */
  60823. texture: Nullable<Texture>;
  60824. /**
  60825. * Define the alpha mode to render this particular lens.
  60826. */
  60827. alphaMode: number;
  60828. private _system;
  60829. /**
  60830. * Creates a new Lens Flare.
  60831. * This represents one of the lens effect in a `lensFlareSystem`.
  60832. * It controls one of the indiviual texture used in the effect.
  60833. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60834. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60835. * @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.
  60836. * @param color Define the lens color
  60837. * @param imgUrl Define the lens texture url
  60838. * @param system Define the `lensFlareSystem` this flare is part of
  60839. * @returns The newly created Lens Flare
  60840. */
  60841. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60842. /**
  60843. * Instantiates a new Lens Flare.
  60844. * This represents one of the lens effect in a `lensFlareSystem`.
  60845. * It controls one of the indiviual texture used in the effect.
  60846. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60847. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60848. * @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.
  60849. * @param color Define the lens color
  60850. * @param imgUrl Define the lens texture url
  60851. * @param system Define the `lensFlareSystem` this flare is part of
  60852. */
  60853. constructor(
  60854. /**
  60855. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60856. */
  60857. size: number,
  60858. /**
  60859. * 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.
  60860. */
  60861. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60862. /**
  60863. * Dispose and release the lens flare with its associated resources.
  60864. */
  60865. dispose(): void;
  60866. }
  60867. }
  60868. declare module BABYLON {
  60869. interface AbstractScene {
  60870. /**
  60871. * The list of lens flare system added to the scene
  60872. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60873. */
  60874. lensFlareSystems: Array<LensFlareSystem>;
  60875. /**
  60876. * Removes the given lens flare system from this scene.
  60877. * @param toRemove The lens flare system to remove
  60878. * @returns The index of the removed lens flare system
  60879. */
  60880. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60881. /**
  60882. * Adds the given lens flare system to this scene
  60883. * @param newLensFlareSystem The lens flare system to add
  60884. */
  60885. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60886. /**
  60887. * Gets a lens flare system using its name
  60888. * @param name defines the name to look for
  60889. * @returns the lens flare system or null if not found
  60890. */
  60891. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60892. /**
  60893. * Gets a lens flare system using its id
  60894. * @param id defines the id to look for
  60895. * @returns the lens flare system or null if not found
  60896. */
  60897. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60898. }
  60899. /**
  60900. * Defines the lens flare scene component responsible to manage any lens flares
  60901. * in a given scene.
  60902. */
  60903. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60904. /**
  60905. * The component name helpfull to identify the component in the list of scene components.
  60906. */
  60907. readonly name: string;
  60908. /**
  60909. * The scene the component belongs to.
  60910. */
  60911. scene: Scene;
  60912. /**
  60913. * Creates a new instance of the component for the given scene
  60914. * @param scene Defines the scene to register the component in
  60915. */
  60916. constructor(scene: Scene);
  60917. /**
  60918. * Registers the component in a given scene
  60919. */
  60920. register(): void;
  60921. /**
  60922. * Rebuilds the elements related to this component in case of
  60923. * context lost for instance.
  60924. */
  60925. rebuild(): void;
  60926. /**
  60927. * Adds all the elements from the container to the scene
  60928. * @param container the container holding the elements
  60929. */
  60930. addFromContainer(container: AbstractScene): void;
  60931. /**
  60932. * Removes all the elements in the container from the scene
  60933. * @param container contains the elements to remove
  60934. * @param dispose if the removed element should be disposed (default: false)
  60935. */
  60936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60937. /**
  60938. * Serializes the component data to the specified json object
  60939. * @param serializationObject The object to serialize to
  60940. */
  60941. serialize(serializationObject: any): void;
  60942. /**
  60943. * Disposes the component and the associated ressources.
  60944. */
  60945. dispose(): void;
  60946. private _draw;
  60947. }
  60948. }
  60949. declare module BABYLON {
  60950. /** @hidden */
  60951. export var depthPixelShader: {
  60952. name: string;
  60953. shader: string;
  60954. };
  60955. }
  60956. declare module BABYLON {
  60957. /** @hidden */
  60958. export var depthVertexShader: {
  60959. name: string;
  60960. shader: string;
  60961. };
  60962. }
  60963. declare module BABYLON {
  60964. /**
  60965. * This represents a depth renderer in Babylon.
  60966. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60967. */
  60968. export class DepthRenderer {
  60969. private _scene;
  60970. private _depthMap;
  60971. private _effect;
  60972. private readonly _storeNonLinearDepth;
  60973. private readonly _clearColor;
  60974. /** Get if the depth renderer is using packed depth or not */
  60975. readonly isPacked: boolean;
  60976. private _cachedDefines;
  60977. private _camera;
  60978. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60979. enabled: boolean;
  60980. /**
  60981. * Specifiess that the depth renderer will only be used within
  60982. * the camera it is created for.
  60983. * This can help forcing its rendering during the camera processing.
  60984. */
  60985. useOnlyInActiveCamera: boolean;
  60986. /** @hidden */
  60987. static _SceneComponentInitialization: (scene: Scene) => void;
  60988. /**
  60989. * Instantiates a depth renderer
  60990. * @param scene The scene the renderer belongs to
  60991. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60992. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60993. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60994. */
  60995. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60996. /**
  60997. * Creates the depth rendering effect and checks if the effect is ready.
  60998. * @param subMesh The submesh to be used to render the depth map of
  60999. * @param useInstances If multiple world instances should be used
  61000. * @returns if the depth renderer is ready to render the depth map
  61001. */
  61002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61003. /**
  61004. * Gets the texture which the depth map will be written to.
  61005. * @returns The depth map texture
  61006. */
  61007. getDepthMap(): RenderTargetTexture;
  61008. /**
  61009. * Disposes of the depth renderer.
  61010. */
  61011. dispose(): void;
  61012. }
  61013. }
  61014. declare module BABYLON {
  61015. /** @hidden */
  61016. export var minmaxReduxPixelShader: {
  61017. name: string;
  61018. shader: string;
  61019. };
  61020. }
  61021. declare module BABYLON {
  61022. /**
  61023. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61024. * and maximum values from all values of the texture.
  61025. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61026. * The source values are read from the red channel of the texture.
  61027. */
  61028. export class MinMaxReducer {
  61029. /**
  61030. * Observable triggered when the computation has been performed
  61031. */
  61032. onAfterReductionPerformed: Observable<{
  61033. min: number;
  61034. max: number;
  61035. }>;
  61036. protected _camera: Camera;
  61037. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61038. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61039. protected _postProcessManager: PostProcessManager;
  61040. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61041. protected _forceFullscreenViewport: boolean;
  61042. /**
  61043. * Creates a min/max reducer
  61044. * @param camera The camera to use for the post processes
  61045. */
  61046. constructor(camera: Camera);
  61047. /**
  61048. * Gets the texture used to read the values from.
  61049. */
  61050. get sourceTexture(): Nullable<RenderTargetTexture>;
  61051. /**
  61052. * Sets the source texture to read the values from.
  61053. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61054. * because in such textures '1' value must not be taken into account to compute the maximum
  61055. * as this value is used to clear the texture.
  61056. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61057. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61058. * @param depthRedux Indicates if the texture is a depth texture or not
  61059. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61060. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61061. */
  61062. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61063. /**
  61064. * Defines the refresh rate of the computation.
  61065. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61066. */
  61067. get refreshRate(): number;
  61068. set refreshRate(value: number);
  61069. protected _activated: boolean;
  61070. /**
  61071. * Gets the activation status of the reducer
  61072. */
  61073. get activated(): boolean;
  61074. /**
  61075. * Activates the reduction computation.
  61076. * When activated, the observers registered in onAfterReductionPerformed are
  61077. * called after the compuation is performed
  61078. */
  61079. activate(): void;
  61080. /**
  61081. * Deactivates the reduction computation.
  61082. */
  61083. deactivate(): void;
  61084. /**
  61085. * Disposes the min/max reducer
  61086. * @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.
  61087. */
  61088. dispose(disposeAll?: boolean): void;
  61089. }
  61090. }
  61091. declare module BABYLON {
  61092. /**
  61093. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61094. */
  61095. export class DepthReducer extends MinMaxReducer {
  61096. private _depthRenderer;
  61097. private _depthRendererId;
  61098. /**
  61099. * Gets the depth renderer used for the computation.
  61100. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61101. */
  61102. get depthRenderer(): Nullable<DepthRenderer>;
  61103. /**
  61104. * Creates a depth reducer
  61105. * @param camera The camera used to render the depth texture
  61106. */
  61107. constructor(camera: Camera);
  61108. /**
  61109. * Sets the depth renderer to use to generate the depth map
  61110. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61111. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61112. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61113. */
  61114. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61115. /** @hidden */
  61116. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61117. /**
  61118. * Activates the reduction computation.
  61119. * When activated, the observers registered in onAfterReductionPerformed are
  61120. * called after the compuation is performed
  61121. */
  61122. activate(): void;
  61123. /**
  61124. * Deactivates the reduction computation.
  61125. */
  61126. deactivate(): void;
  61127. /**
  61128. * Disposes the depth reducer
  61129. * @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.
  61130. */
  61131. dispose(disposeAll?: boolean): void;
  61132. }
  61133. }
  61134. declare module BABYLON {
  61135. /**
  61136. * A CSM implementation allowing casting shadows on large scenes.
  61137. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61138. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61139. */
  61140. export class CascadedShadowGenerator extends ShadowGenerator {
  61141. private static readonly frustumCornersNDCSpace;
  61142. /**
  61143. * Name of the CSM class
  61144. */
  61145. static CLASSNAME: string;
  61146. /**
  61147. * Defines the default number of cascades used by the CSM.
  61148. */
  61149. static readonly DEFAULT_CASCADES_COUNT: number;
  61150. /**
  61151. * Defines the minimum number of cascades used by the CSM.
  61152. */
  61153. static readonly MIN_CASCADES_COUNT: number;
  61154. /**
  61155. * Defines the maximum number of cascades used by the CSM.
  61156. */
  61157. static readonly MAX_CASCADES_COUNT: number;
  61158. protected _validateFilter(filter: number): number;
  61159. /**
  61160. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61161. */
  61162. penumbraDarkness: number;
  61163. private _numCascades;
  61164. /**
  61165. * Gets or set the number of cascades used by the CSM.
  61166. */
  61167. get numCascades(): number;
  61168. set numCascades(value: number);
  61169. /**
  61170. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61171. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61172. */
  61173. stabilizeCascades: boolean;
  61174. private _freezeShadowCastersBoundingInfo;
  61175. private _freezeShadowCastersBoundingInfoObservable;
  61176. /**
  61177. * Enables or disables the shadow casters bounding info computation.
  61178. * If your shadow casters don't move, you can disable this feature.
  61179. * If it is enabled, the bounding box computation is done every frame.
  61180. */
  61181. get freezeShadowCastersBoundingInfo(): boolean;
  61182. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61183. private _scbiMin;
  61184. private _scbiMax;
  61185. protected _computeShadowCastersBoundingInfo(): void;
  61186. protected _shadowCastersBoundingInfo: BoundingInfo;
  61187. /**
  61188. * Gets or sets the shadow casters bounding info.
  61189. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61190. * so that the system won't overwrite the bounds you provide
  61191. */
  61192. get shadowCastersBoundingInfo(): BoundingInfo;
  61193. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61194. protected _breaksAreDirty: boolean;
  61195. protected _minDistance: number;
  61196. protected _maxDistance: number;
  61197. /**
  61198. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61199. *
  61200. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61201. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61202. * @param min minimal distance for the breaks (default to 0.)
  61203. * @param max maximal distance for the breaks (default to 1.)
  61204. */
  61205. setMinMaxDistance(min: number, max: number): void;
  61206. /** Gets the minimal distance used in the cascade break computation */
  61207. get minDistance(): number;
  61208. /** Gets the maximal distance used in the cascade break computation */
  61209. get maxDistance(): number;
  61210. /**
  61211. * Gets the class name of that object
  61212. * @returns "CascadedShadowGenerator"
  61213. */
  61214. getClassName(): string;
  61215. private _cascadeMinExtents;
  61216. private _cascadeMaxExtents;
  61217. /**
  61218. * Gets a cascade minimum extents
  61219. * @param cascadeIndex index of the cascade
  61220. * @returns the minimum cascade extents
  61221. */
  61222. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61223. /**
  61224. * Gets a cascade maximum extents
  61225. * @param cascadeIndex index of the cascade
  61226. * @returns the maximum cascade extents
  61227. */
  61228. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61229. private _cascades;
  61230. private _currentLayer;
  61231. private _viewSpaceFrustumsZ;
  61232. private _viewMatrices;
  61233. private _projectionMatrices;
  61234. private _transformMatrices;
  61235. private _transformMatricesAsArray;
  61236. private _frustumLengths;
  61237. private _lightSizeUVCorrection;
  61238. private _depthCorrection;
  61239. private _frustumCornersWorldSpace;
  61240. private _frustumCenter;
  61241. private _shadowCameraPos;
  61242. private _shadowMaxZ;
  61243. /**
  61244. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61245. * It defaults to camera.maxZ
  61246. */
  61247. get shadowMaxZ(): number;
  61248. /**
  61249. * Sets the shadow max z distance.
  61250. */
  61251. set shadowMaxZ(value: number);
  61252. protected _debug: boolean;
  61253. /**
  61254. * Gets or sets the debug flag.
  61255. * When enabled, the cascades are materialized by different colors on the screen.
  61256. */
  61257. get debug(): boolean;
  61258. set debug(dbg: boolean);
  61259. private _depthClamp;
  61260. /**
  61261. * Gets or sets the depth clamping value.
  61262. *
  61263. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61264. * to account for the shadow casters far away.
  61265. *
  61266. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61267. */
  61268. get depthClamp(): boolean;
  61269. set depthClamp(value: boolean);
  61270. private _cascadeBlendPercentage;
  61271. /**
  61272. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61273. * It defaults to 0.1 (10% blending).
  61274. */
  61275. get cascadeBlendPercentage(): number;
  61276. set cascadeBlendPercentage(value: number);
  61277. private _lambda;
  61278. /**
  61279. * Gets or set the lambda parameter.
  61280. * This parameter is used to split the camera frustum and create the cascades.
  61281. * 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.
  61282. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61283. */
  61284. get lambda(): number;
  61285. set lambda(value: number);
  61286. /**
  61287. * Gets the view matrix corresponding to a given cascade
  61288. * @param cascadeNum cascade to retrieve the view matrix from
  61289. * @returns the cascade view matrix
  61290. */
  61291. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61292. /**
  61293. * Gets the projection matrix corresponding to a given cascade
  61294. * @param cascadeNum cascade to retrieve the projection matrix from
  61295. * @returns the cascade projection matrix
  61296. */
  61297. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61298. /**
  61299. * Gets the transformation matrix corresponding to a given cascade
  61300. * @param cascadeNum cascade to retrieve the transformation matrix from
  61301. * @returns the cascade transformation matrix
  61302. */
  61303. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61304. private _depthRenderer;
  61305. /**
  61306. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61307. *
  61308. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61309. *
  61310. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61311. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61312. * @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
  61313. */
  61314. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61315. private _depthReducer;
  61316. private _autoCalcDepthBounds;
  61317. /**
  61318. * Gets or sets the autoCalcDepthBounds property.
  61319. *
  61320. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61321. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61322. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61323. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61324. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61325. */
  61326. get autoCalcDepthBounds(): boolean;
  61327. set autoCalcDepthBounds(value: boolean);
  61328. /**
  61329. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61330. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61331. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61332. * for setting the refresh rate on the renderer yourself!
  61333. */
  61334. get autoCalcDepthBoundsRefreshRate(): number;
  61335. set autoCalcDepthBoundsRefreshRate(value: number);
  61336. /**
  61337. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61338. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61339. * you change the camera near/far planes!
  61340. */
  61341. splitFrustum(): void;
  61342. private _splitFrustum;
  61343. private _computeMatrices;
  61344. private _computeFrustumInWorldSpace;
  61345. private _computeCascadeFrustum;
  61346. /**
  61347. * Support test.
  61348. */
  61349. static get IsSupported(): boolean;
  61350. /** @hidden */
  61351. static _SceneComponentInitialization: (scene: Scene) => void;
  61352. /**
  61353. * Creates a Cascaded Shadow Generator object.
  61354. * A ShadowGenerator is the required tool to use the shadows.
  61355. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61356. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61357. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61358. * @param light The directional light object generating the shadows.
  61359. * @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.
  61360. */
  61361. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61362. protected _initializeGenerator(): void;
  61363. protected _createTargetRenderTexture(): void;
  61364. protected _initializeShadowMap(): void;
  61365. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61366. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61367. /**
  61368. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61369. * @param defines Defines of the material we want to update
  61370. * @param lightIndex Index of the light in the enabled light list of the material
  61371. */
  61372. prepareDefines(defines: any, lightIndex: number): void;
  61373. /**
  61374. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61375. * defined in the generator but impacting the effect).
  61376. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61377. * @param effect The effect we are binfing the information for
  61378. */
  61379. bindShadowLight(lightIndex: string, effect: Effect): void;
  61380. /**
  61381. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61382. * (eq to view projection * shadow projection matrices)
  61383. * @returns The transform matrix used to create the shadow map
  61384. */
  61385. getTransformMatrix(): Matrix;
  61386. /**
  61387. * Disposes the ShadowGenerator.
  61388. * Returns nothing.
  61389. */
  61390. dispose(): void;
  61391. /**
  61392. * Serializes the shadow generator setup to a json object.
  61393. * @returns The serialized JSON object
  61394. */
  61395. serialize(): any;
  61396. /**
  61397. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61398. * @param parsedShadowGenerator The JSON object to parse
  61399. * @param scene The scene to create the shadow map for
  61400. * @returns The parsed shadow generator
  61401. */
  61402. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61403. }
  61404. }
  61405. declare module BABYLON {
  61406. /**
  61407. * Defines the shadow generator component responsible to manage any shadow generators
  61408. * in a given scene.
  61409. */
  61410. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61411. /**
  61412. * The component name helpfull to identify the component in the list of scene components.
  61413. */
  61414. readonly name: string;
  61415. /**
  61416. * The scene the component belongs to.
  61417. */
  61418. scene: Scene;
  61419. /**
  61420. * Creates a new instance of the component for the given scene
  61421. * @param scene Defines the scene to register the component in
  61422. */
  61423. constructor(scene: Scene);
  61424. /**
  61425. * Registers the component in a given scene
  61426. */
  61427. register(): void;
  61428. /**
  61429. * Rebuilds the elements related to this component in case of
  61430. * context lost for instance.
  61431. */
  61432. rebuild(): void;
  61433. /**
  61434. * Serializes the component data to the specified json object
  61435. * @param serializationObject The object to serialize to
  61436. */
  61437. serialize(serializationObject: any): void;
  61438. /**
  61439. * Adds all the elements from the container to the scene
  61440. * @param container the container holding the elements
  61441. */
  61442. addFromContainer(container: AbstractScene): void;
  61443. /**
  61444. * Removes all the elements in the container from the scene
  61445. * @param container contains the elements to remove
  61446. * @param dispose if the removed element should be disposed (default: false)
  61447. */
  61448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61449. /**
  61450. * Rebuilds the elements related to this component in case of
  61451. * context lost for instance.
  61452. */
  61453. dispose(): void;
  61454. private _gatherRenderTargets;
  61455. }
  61456. }
  61457. declare module BABYLON {
  61458. /**
  61459. * A point light is a light defined by an unique point in world space.
  61460. * The light is emitted in every direction from this point.
  61461. * A good example of a point light is a standard light bulb.
  61462. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61463. */
  61464. export class PointLight extends ShadowLight {
  61465. private _shadowAngle;
  61466. /**
  61467. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61468. * This specifies what angle the shadow will use to be created.
  61469. *
  61470. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61471. */
  61472. get shadowAngle(): number;
  61473. /**
  61474. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61475. * This specifies what angle the shadow will use to be created.
  61476. *
  61477. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61478. */
  61479. set shadowAngle(value: number);
  61480. /**
  61481. * Gets the direction if it has been set.
  61482. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61483. */
  61484. get direction(): Vector3;
  61485. /**
  61486. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61487. */
  61488. set direction(value: Vector3);
  61489. /**
  61490. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61491. * A PointLight emits the light in every direction.
  61492. * It can cast shadows.
  61493. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61494. * ```javascript
  61495. * var pointLight = new PointLight("pl", camera.position, scene);
  61496. * ```
  61497. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61498. * @param name The light friendly name
  61499. * @param position The position of the point light in the scene
  61500. * @param scene The scene the lights belongs to
  61501. */
  61502. constructor(name: string, position: Vector3, scene: Scene);
  61503. /**
  61504. * Returns the string "PointLight"
  61505. * @returns the class name
  61506. */
  61507. getClassName(): string;
  61508. /**
  61509. * Returns the integer 0.
  61510. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61511. */
  61512. getTypeID(): number;
  61513. /**
  61514. * Specifies wether or not the shadowmap should be a cube texture.
  61515. * @returns true if the shadowmap needs to be a cube texture.
  61516. */
  61517. needCube(): boolean;
  61518. /**
  61519. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61520. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61521. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61522. */
  61523. getShadowDirection(faceIndex?: number): Vector3;
  61524. /**
  61525. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61526. * - fov = PI / 2
  61527. * - aspect ratio : 1.0
  61528. * - z-near and far equal to the active camera minZ and maxZ.
  61529. * Returns the PointLight.
  61530. */
  61531. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61532. protected _buildUniformLayout(): void;
  61533. /**
  61534. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61535. * @param effect The effect to update
  61536. * @param lightIndex The index of the light in the effect to update
  61537. * @returns The point light
  61538. */
  61539. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61540. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61541. /**
  61542. * Prepares the list of defines specific to the light type.
  61543. * @param defines the list of defines
  61544. * @param lightIndex defines the index of the light for the effect
  61545. */
  61546. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61547. }
  61548. }
  61549. declare module BABYLON {
  61550. /**
  61551. * Header information of HDR texture files.
  61552. */
  61553. export interface HDRInfo {
  61554. /**
  61555. * The height of the texture in pixels.
  61556. */
  61557. height: number;
  61558. /**
  61559. * The width of the texture in pixels.
  61560. */
  61561. width: number;
  61562. /**
  61563. * The index of the beginning of the data in the binary file.
  61564. */
  61565. dataPosition: number;
  61566. }
  61567. /**
  61568. * This groups tools to convert HDR texture to native colors array.
  61569. */
  61570. export class HDRTools {
  61571. private static Ldexp;
  61572. private static Rgbe2float;
  61573. private static readStringLine;
  61574. /**
  61575. * Reads header information from an RGBE texture stored in a native array.
  61576. * More information on this format are available here:
  61577. * https://en.wikipedia.org/wiki/RGBE_image_format
  61578. *
  61579. * @param uint8array The binary file stored in native array.
  61580. * @return The header information.
  61581. */
  61582. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61583. /**
  61584. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61585. * This RGBE texture needs to store the information as a panorama.
  61586. *
  61587. * More information on this format are available here:
  61588. * https://en.wikipedia.org/wiki/RGBE_image_format
  61589. *
  61590. * @param buffer The binary file stored in an array buffer.
  61591. * @param size The expected size of the extracted cubemap.
  61592. * @return The Cube Map information.
  61593. */
  61594. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61595. /**
  61596. * Returns the pixels data extracted from an RGBE texture.
  61597. * This pixels will be stored left to right up to down in the R G B order in one array.
  61598. *
  61599. * More information on this format are available here:
  61600. * https://en.wikipedia.org/wiki/RGBE_image_format
  61601. *
  61602. * @param uint8array The binary file stored in an array buffer.
  61603. * @param hdrInfo The header information of the file.
  61604. * @return The pixels data in RGB right to left up to down order.
  61605. */
  61606. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61607. private static RGBE_ReadPixels_RLE;
  61608. private static RGBE_ReadPixels_NOT_RLE;
  61609. }
  61610. }
  61611. declare module BABYLON {
  61612. /**
  61613. * Effect Render Options
  61614. */
  61615. export interface IEffectRendererOptions {
  61616. /**
  61617. * Defines the vertices positions.
  61618. */
  61619. positions?: number[];
  61620. /**
  61621. * Defines the indices.
  61622. */
  61623. indices?: number[];
  61624. }
  61625. /**
  61626. * Helper class to render one or more effects.
  61627. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61628. */
  61629. export class EffectRenderer {
  61630. private engine;
  61631. private static _DefaultOptions;
  61632. private _vertexBuffers;
  61633. private _indexBuffer;
  61634. private _fullscreenViewport;
  61635. /**
  61636. * Creates an effect renderer
  61637. * @param engine the engine to use for rendering
  61638. * @param options defines the options of the effect renderer
  61639. */
  61640. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61641. /**
  61642. * Sets the current viewport in normalized coordinates 0-1
  61643. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61644. */
  61645. setViewport(viewport?: Viewport): void;
  61646. /**
  61647. * Binds the embedded attributes buffer to the effect.
  61648. * @param effect Defines the effect to bind the attributes for
  61649. */
  61650. bindBuffers(effect: Effect): void;
  61651. /**
  61652. * Sets the current effect wrapper to use during draw.
  61653. * The effect needs to be ready before calling this api.
  61654. * This also sets the default full screen position attribute.
  61655. * @param effectWrapper Defines the effect to draw with
  61656. */
  61657. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61658. /**
  61659. * Restores engine states
  61660. */
  61661. restoreStates(): void;
  61662. /**
  61663. * Draws a full screen quad.
  61664. */
  61665. draw(): void;
  61666. private isRenderTargetTexture;
  61667. /**
  61668. * renders one or more effects to a specified texture
  61669. * @param effectWrapper the effect to renderer
  61670. * @param outputTexture texture to draw to, if null it will render to the screen.
  61671. */
  61672. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61673. /**
  61674. * Disposes of the effect renderer
  61675. */
  61676. dispose(): void;
  61677. }
  61678. /**
  61679. * Options to create an EffectWrapper
  61680. */
  61681. interface EffectWrapperCreationOptions {
  61682. /**
  61683. * Engine to use to create the effect
  61684. */
  61685. engine: ThinEngine;
  61686. /**
  61687. * Fragment shader for the effect
  61688. */
  61689. fragmentShader: string;
  61690. /**
  61691. * Use the shader store instead of direct source code
  61692. */
  61693. useShaderStore?: boolean;
  61694. /**
  61695. * Vertex shader for the effect
  61696. */
  61697. vertexShader?: string;
  61698. /**
  61699. * Attributes to use in the shader
  61700. */
  61701. attributeNames?: Array<string>;
  61702. /**
  61703. * Uniforms to use in the shader
  61704. */
  61705. uniformNames?: Array<string>;
  61706. /**
  61707. * Texture sampler names to use in the shader
  61708. */
  61709. samplerNames?: Array<string>;
  61710. /**
  61711. * Defines to use in the shader
  61712. */
  61713. defines?: Array<string>;
  61714. /**
  61715. * Callback when effect is compiled
  61716. */
  61717. onCompiled?: Nullable<(effect: Effect) => void>;
  61718. /**
  61719. * The friendly name of the effect displayed in Spector.
  61720. */
  61721. name?: string;
  61722. }
  61723. /**
  61724. * Wraps an effect to be used for rendering
  61725. */
  61726. export class EffectWrapper {
  61727. /**
  61728. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61729. */
  61730. onApplyObservable: Observable<{}>;
  61731. /**
  61732. * The underlying effect
  61733. */
  61734. effect: Effect;
  61735. /**
  61736. * Creates an effect to be renderer
  61737. * @param creationOptions options to create the effect
  61738. */
  61739. constructor(creationOptions: EffectWrapperCreationOptions);
  61740. /**
  61741. * Disposes of the effect wrapper
  61742. */
  61743. dispose(): void;
  61744. }
  61745. }
  61746. declare module BABYLON {
  61747. /** @hidden */
  61748. export var hdrFilteringVertexShader: {
  61749. name: string;
  61750. shader: string;
  61751. };
  61752. }
  61753. declare module BABYLON {
  61754. /** @hidden */
  61755. export var hdrFilteringPixelShader: {
  61756. name: string;
  61757. shader: string;
  61758. };
  61759. }
  61760. declare module BABYLON {
  61761. /**
  61762. * Options for texture filtering
  61763. */
  61764. interface IHDRFilteringOptions {
  61765. /**
  61766. * Scales pixel intensity for the input HDR map.
  61767. */
  61768. hdrScale?: number;
  61769. /**
  61770. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61771. */
  61772. quality?: number;
  61773. }
  61774. /**
  61775. * Filters HDR maps to get correct renderings of PBR reflections
  61776. */
  61777. export class HDRFiltering {
  61778. private _engine;
  61779. private _effectRenderer;
  61780. private _effectWrapper;
  61781. private _lodGenerationOffset;
  61782. private _lodGenerationScale;
  61783. /**
  61784. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61785. * you care about baking speed.
  61786. */
  61787. quality: number;
  61788. /**
  61789. * Scales pixel intensity for the input HDR map.
  61790. */
  61791. hdrScale: number;
  61792. /**
  61793. * Instantiates HDR filter for reflection maps
  61794. *
  61795. * @param engine Thin engine
  61796. * @param options Options
  61797. */
  61798. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61799. private _createRenderTarget;
  61800. private _prefilterInternal;
  61801. private _createEffect;
  61802. /**
  61803. * Get a value indicating if the filter is ready to be used
  61804. * @param texture Texture to filter
  61805. * @returns true if the filter is ready
  61806. */
  61807. isReady(texture: BaseTexture): boolean;
  61808. /**
  61809. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61810. * Prefiltering will be invoked at the end of next rendering pass.
  61811. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61812. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61813. * @param texture Texture to filter
  61814. * @param onFinished Callback when filtering is done
  61815. * @return Promise called when prefiltering is done
  61816. */
  61817. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61818. }
  61819. }
  61820. declare module BABYLON {
  61821. /**
  61822. * This represents a texture coming from an HDR input.
  61823. *
  61824. * The only supported format is currently panorama picture stored in RGBE format.
  61825. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61826. */
  61827. export class HDRCubeTexture extends BaseTexture {
  61828. private static _facesMapping;
  61829. private _generateHarmonics;
  61830. private _noMipmap;
  61831. private _prefilterOnLoad;
  61832. private _textureMatrix;
  61833. private _size;
  61834. private _onLoad;
  61835. private _onError;
  61836. /**
  61837. * The texture URL.
  61838. */
  61839. url: string;
  61840. protected _isBlocking: boolean;
  61841. /**
  61842. * Sets wether or not the texture is blocking during loading.
  61843. */
  61844. set isBlocking(value: boolean);
  61845. /**
  61846. * Gets wether or not the texture is blocking during loading.
  61847. */
  61848. get isBlocking(): boolean;
  61849. protected _rotationY: number;
  61850. /**
  61851. * Sets texture matrix rotation angle around Y axis in radians.
  61852. */
  61853. set rotationY(value: number);
  61854. /**
  61855. * Gets texture matrix rotation angle around Y axis radians.
  61856. */
  61857. get rotationY(): number;
  61858. /**
  61859. * Gets or sets the center of the bounding box associated with the cube texture
  61860. * It must define where the camera used to render the texture was set
  61861. */
  61862. boundingBoxPosition: Vector3;
  61863. private _boundingBoxSize;
  61864. /**
  61865. * Gets or sets the size of the bounding box associated with the cube texture
  61866. * When defined, the cubemap will switch to local mode
  61867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61868. * @example https://www.babylonjs-playground.com/#RNASML
  61869. */
  61870. set boundingBoxSize(value: Vector3);
  61871. get boundingBoxSize(): Vector3;
  61872. /**
  61873. * Instantiates an HDRTexture from the following parameters.
  61874. *
  61875. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61876. * @param sceneOrEngine The scene or engine the texture will be used in
  61877. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61878. * @param noMipmap Forces to not generate the mipmap if true
  61879. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61880. * @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)
  61881. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61882. */
  61883. 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>);
  61884. /**
  61885. * Get the current class name of the texture useful for serialization or dynamic coding.
  61886. * @returns "HDRCubeTexture"
  61887. */
  61888. getClassName(): string;
  61889. /**
  61890. * Occurs when the file is raw .hdr file.
  61891. */
  61892. private loadTexture;
  61893. clone(): HDRCubeTexture;
  61894. delayLoad(): void;
  61895. /**
  61896. * Get the texture reflection matrix used to rotate/transform the reflection.
  61897. * @returns the reflection matrix
  61898. */
  61899. getReflectionTextureMatrix(): Matrix;
  61900. /**
  61901. * Set the texture reflection matrix used to rotate/transform the reflection.
  61902. * @param value Define the reflection matrix to set
  61903. */
  61904. setReflectionTextureMatrix(value: Matrix): void;
  61905. /**
  61906. * Parses a JSON representation of an HDR Texture in order to create the texture
  61907. * @param parsedTexture Define the JSON representation
  61908. * @param scene Define the scene the texture should be created in
  61909. * @param rootUrl Define the root url in case we need to load relative dependencies
  61910. * @returns the newly created texture after parsing
  61911. */
  61912. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61913. serialize(): any;
  61914. }
  61915. }
  61916. declare module BABYLON {
  61917. /**
  61918. * Class used to control physics engine
  61919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61920. */
  61921. export class PhysicsEngine implements IPhysicsEngine {
  61922. private _physicsPlugin;
  61923. /**
  61924. * Global value used to control the smallest number supported by the simulation
  61925. */
  61926. static Epsilon: number;
  61927. private _impostors;
  61928. private _joints;
  61929. private _subTimeStep;
  61930. /**
  61931. * Gets the gravity vector used by the simulation
  61932. */
  61933. gravity: Vector3;
  61934. /**
  61935. * Factory used to create the default physics plugin.
  61936. * @returns The default physics plugin
  61937. */
  61938. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61939. /**
  61940. * Creates a new Physics Engine
  61941. * @param gravity defines the gravity vector used by the simulation
  61942. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61943. */
  61944. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61945. /**
  61946. * Sets the gravity vector used by the simulation
  61947. * @param gravity defines the gravity vector to use
  61948. */
  61949. setGravity(gravity: Vector3): void;
  61950. /**
  61951. * Set the time step of the physics engine.
  61952. * Default is 1/60.
  61953. * To slow it down, enter 1/600 for example.
  61954. * To speed it up, 1/30
  61955. * @param newTimeStep defines the new timestep to apply to this world.
  61956. */
  61957. setTimeStep(newTimeStep?: number): void;
  61958. /**
  61959. * Get the time step of the physics engine.
  61960. * @returns the current time step
  61961. */
  61962. getTimeStep(): number;
  61963. /**
  61964. * Set the sub time step of the physics engine.
  61965. * Default is 0 meaning there is no sub steps
  61966. * To increase physics resolution precision, set a small value (like 1 ms)
  61967. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61968. */
  61969. setSubTimeStep(subTimeStep?: number): void;
  61970. /**
  61971. * Get the sub time step of the physics engine.
  61972. * @returns the current sub time step
  61973. */
  61974. getSubTimeStep(): number;
  61975. /**
  61976. * Release all resources
  61977. */
  61978. dispose(): void;
  61979. /**
  61980. * Gets the name of the current physics plugin
  61981. * @returns the name of the plugin
  61982. */
  61983. getPhysicsPluginName(): string;
  61984. /**
  61985. * Adding a new impostor for the impostor tracking.
  61986. * This will be done by the impostor itself.
  61987. * @param impostor the impostor to add
  61988. */
  61989. addImpostor(impostor: PhysicsImpostor): void;
  61990. /**
  61991. * Remove an impostor from the engine.
  61992. * This impostor and its mesh will not longer be updated by the physics engine.
  61993. * @param impostor the impostor to remove
  61994. */
  61995. removeImpostor(impostor: PhysicsImpostor): void;
  61996. /**
  61997. * Add a joint to the physics engine
  61998. * @param mainImpostor defines the main impostor to which the joint is added.
  61999. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62000. * @param joint defines the joint that will connect both impostors.
  62001. */
  62002. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62003. /**
  62004. * Removes a joint from the simulation
  62005. * @param mainImpostor defines the impostor used with the joint
  62006. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62007. * @param joint defines the joint to remove
  62008. */
  62009. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62010. /**
  62011. * Called by the scene. No need to call it.
  62012. * @param delta defines the timespam between frames
  62013. */
  62014. _step(delta: number): void;
  62015. /**
  62016. * Gets the current plugin used to run the simulation
  62017. * @returns current plugin
  62018. */
  62019. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62020. /**
  62021. * Gets the list of physic impostors
  62022. * @returns an array of PhysicsImpostor
  62023. */
  62024. getImpostors(): Array<PhysicsImpostor>;
  62025. /**
  62026. * Gets the impostor for a physics enabled object
  62027. * @param object defines the object impersonated by the impostor
  62028. * @returns the PhysicsImpostor or null if not found
  62029. */
  62030. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62031. /**
  62032. * Gets the impostor for a physics body object
  62033. * @param body defines physics body used by the impostor
  62034. * @returns the PhysicsImpostor or null if not found
  62035. */
  62036. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62037. /**
  62038. * Does a raycast in the physics world
  62039. * @param from when should the ray start?
  62040. * @param to when should the ray end?
  62041. * @returns PhysicsRaycastResult
  62042. */
  62043. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62044. }
  62045. }
  62046. declare module BABYLON {
  62047. /** @hidden */
  62048. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62049. private _useDeltaForWorldStep;
  62050. world: any;
  62051. name: string;
  62052. private _physicsMaterials;
  62053. private _fixedTimeStep;
  62054. private _cannonRaycastResult;
  62055. private _raycastResult;
  62056. private _physicsBodysToRemoveAfterStep;
  62057. private _firstFrame;
  62058. BJSCANNON: any;
  62059. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62060. setGravity(gravity: Vector3): void;
  62061. setTimeStep(timeStep: number): void;
  62062. getTimeStep(): number;
  62063. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62064. private _removeMarkedPhysicsBodiesFromWorld;
  62065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62066. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62067. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62068. private _processChildMeshes;
  62069. removePhysicsBody(impostor: PhysicsImpostor): void;
  62070. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62071. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62072. private _addMaterial;
  62073. private _checkWithEpsilon;
  62074. private _createShape;
  62075. private _createHeightmap;
  62076. private _minus90X;
  62077. private _plus90X;
  62078. private _tmpPosition;
  62079. private _tmpDeltaPosition;
  62080. private _tmpUnityRotation;
  62081. private _updatePhysicsBodyTransformation;
  62082. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62083. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62084. isSupported(): boolean;
  62085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62090. getBodyMass(impostor: PhysicsImpostor): number;
  62091. getBodyFriction(impostor: PhysicsImpostor): number;
  62092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62093. getBodyRestitution(impostor: PhysicsImpostor): number;
  62094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62095. sleepBody(impostor: PhysicsImpostor): void;
  62096. wakeUpBody(impostor: PhysicsImpostor): void;
  62097. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62098. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62100. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62101. getRadius(impostor: PhysicsImpostor): number;
  62102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62103. dispose(): void;
  62104. private _extendNamespace;
  62105. /**
  62106. * Does a raycast in the physics world
  62107. * @param from when should the ray start?
  62108. * @param to when should the ray end?
  62109. * @returns PhysicsRaycastResult
  62110. */
  62111. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62112. }
  62113. }
  62114. declare module BABYLON {
  62115. /** @hidden */
  62116. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62117. private _useDeltaForWorldStep;
  62118. world: any;
  62119. name: string;
  62120. BJSOIMO: any;
  62121. private _raycastResult;
  62122. private _fixedTimeStep;
  62123. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62124. setGravity(gravity: Vector3): void;
  62125. setTimeStep(timeStep: number): void;
  62126. getTimeStep(): number;
  62127. private _tmpImpostorsArray;
  62128. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62129. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62130. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62132. private _tmpPositionVector;
  62133. removePhysicsBody(impostor: PhysicsImpostor): void;
  62134. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62135. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62136. isSupported(): boolean;
  62137. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62138. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62139. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62140. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62141. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62142. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62143. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62144. getBodyMass(impostor: PhysicsImpostor): number;
  62145. getBodyFriction(impostor: PhysicsImpostor): number;
  62146. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62147. getBodyRestitution(impostor: PhysicsImpostor): number;
  62148. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62149. sleepBody(impostor: PhysicsImpostor): void;
  62150. wakeUpBody(impostor: PhysicsImpostor): void;
  62151. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62152. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62153. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62154. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62155. getRadius(impostor: PhysicsImpostor): number;
  62156. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62157. dispose(): void;
  62158. /**
  62159. * Does a raycast in the physics world
  62160. * @param from when should the ray start?
  62161. * @param to when should the ray end?
  62162. * @returns PhysicsRaycastResult
  62163. */
  62164. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62165. }
  62166. }
  62167. declare module BABYLON {
  62168. /**
  62169. * AmmoJS Physics plugin
  62170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62171. * @see https://github.com/kripken/ammo.js/
  62172. */
  62173. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62174. private _useDeltaForWorldStep;
  62175. /**
  62176. * Reference to the Ammo library
  62177. */
  62178. bjsAMMO: any;
  62179. /**
  62180. * Created ammoJS world which physics bodies are added to
  62181. */
  62182. world: any;
  62183. /**
  62184. * Name of the plugin
  62185. */
  62186. name: string;
  62187. private _timeStep;
  62188. private _fixedTimeStep;
  62189. private _maxSteps;
  62190. private _tmpQuaternion;
  62191. private _tmpAmmoTransform;
  62192. private _tmpAmmoQuaternion;
  62193. private _tmpAmmoConcreteContactResultCallback;
  62194. private _collisionConfiguration;
  62195. private _dispatcher;
  62196. private _overlappingPairCache;
  62197. private _solver;
  62198. private _softBodySolver;
  62199. private _tmpAmmoVectorA;
  62200. private _tmpAmmoVectorB;
  62201. private _tmpAmmoVectorC;
  62202. private _tmpAmmoVectorD;
  62203. private _tmpContactCallbackResult;
  62204. private _tmpAmmoVectorRCA;
  62205. private _tmpAmmoVectorRCB;
  62206. private _raycastResult;
  62207. private _tmpContactPoint;
  62208. private static readonly DISABLE_COLLISION_FLAG;
  62209. private static readonly KINEMATIC_FLAG;
  62210. private static readonly DISABLE_DEACTIVATION_FLAG;
  62211. /**
  62212. * Initializes the ammoJS plugin
  62213. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62214. * @param ammoInjection can be used to inject your own ammo reference
  62215. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62216. */
  62217. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62218. /**
  62219. * Sets the gravity of the physics world (m/(s^2))
  62220. * @param gravity Gravity to set
  62221. */
  62222. setGravity(gravity: Vector3): void;
  62223. /**
  62224. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62225. * @param timeStep timestep to use in seconds
  62226. */
  62227. setTimeStep(timeStep: number): void;
  62228. /**
  62229. * 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)
  62230. * @param fixedTimeStep fixedTimeStep to use in seconds
  62231. */
  62232. setFixedTimeStep(fixedTimeStep: number): void;
  62233. /**
  62234. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62235. * @param maxSteps the maximum number of steps by the physics engine per frame
  62236. */
  62237. setMaxSteps(maxSteps: number): void;
  62238. /**
  62239. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62240. * @returns the current timestep in seconds
  62241. */
  62242. getTimeStep(): number;
  62243. /**
  62244. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62245. */
  62246. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62247. private _isImpostorInContact;
  62248. private _isImpostorPairInContact;
  62249. private _stepSimulation;
  62250. /**
  62251. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62252. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62253. * After the step the babylon meshes are set to the position of the physics imposters
  62254. * @param delta amount of time to step forward
  62255. * @param impostors array of imposters to update before/after the step
  62256. */
  62257. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62258. /**
  62259. * Update babylon mesh to match physics world object
  62260. * @param impostor imposter to match
  62261. */
  62262. private _afterSoftStep;
  62263. /**
  62264. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62265. * @param impostor imposter to match
  62266. */
  62267. private _ropeStep;
  62268. /**
  62269. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62270. * @param impostor imposter to match
  62271. */
  62272. private _softbodyOrClothStep;
  62273. private _tmpMatrix;
  62274. /**
  62275. * Applies an impulse on the imposter
  62276. * @param impostor imposter to apply impulse to
  62277. * @param force amount of force to be applied to the imposter
  62278. * @param contactPoint the location to apply the impulse on the imposter
  62279. */
  62280. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62281. /**
  62282. * Applies a force on the imposter
  62283. * @param impostor imposter to apply force
  62284. * @param force amount of force to be applied to the imposter
  62285. * @param contactPoint the location to apply the force on the imposter
  62286. */
  62287. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62288. /**
  62289. * Creates a physics body using the plugin
  62290. * @param impostor the imposter to create the physics body on
  62291. */
  62292. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62293. /**
  62294. * Removes the physics body from the imposter and disposes of the body's memory
  62295. * @param impostor imposter to remove the physics body from
  62296. */
  62297. removePhysicsBody(impostor: PhysicsImpostor): void;
  62298. /**
  62299. * Generates a joint
  62300. * @param impostorJoint the imposter joint to create the joint with
  62301. */
  62302. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62303. /**
  62304. * Removes a joint
  62305. * @param impostorJoint the imposter joint to remove the joint from
  62306. */
  62307. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62308. private _addMeshVerts;
  62309. /**
  62310. * Initialise the soft body vertices to match its object's (mesh) vertices
  62311. * Softbody vertices (nodes) are in world space and to match this
  62312. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62313. * @param impostor to create the softbody for
  62314. */
  62315. private _softVertexData;
  62316. /**
  62317. * Create an impostor's soft body
  62318. * @param impostor to create the softbody for
  62319. */
  62320. private _createSoftbody;
  62321. /**
  62322. * Create cloth for an impostor
  62323. * @param impostor to create the softbody for
  62324. */
  62325. private _createCloth;
  62326. /**
  62327. * Create rope for an impostor
  62328. * @param impostor to create the softbody for
  62329. */
  62330. private _createRope;
  62331. /**
  62332. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62333. * @param impostor to create the custom physics shape for
  62334. */
  62335. private _createCustom;
  62336. private _addHullVerts;
  62337. private _createShape;
  62338. /**
  62339. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62340. * @param impostor imposter containing the physics body and babylon object
  62341. */
  62342. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62343. /**
  62344. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62345. * @param impostor imposter containing the physics body and babylon object
  62346. * @param newPosition new position
  62347. * @param newRotation new rotation
  62348. */
  62349. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62350. /**
  62351. * If this plugin is supported
  62352. * @returns true if its supported
  62353. */
  62354. isSupported(): boolean;
  62355. /**
  62356. * Sets the linear velocity of the physics body
  62357. * @param impostor imposter to set the velocity on
  62358. * @param velocity velocity to set
  62359. */
  62360. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62361. /**
  62362. * Sets the angular velocity of the physics body
  62363. * @param impostor imposter to set the velocity on
  62364. * @param velocity velocity to set
  62365. */
  62366. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62367. /**
  62368. * gets the linear velocity
  62369. * @param impostor imposter to get linear velocity from
  62370. * @returns linear velocity
  62371. */
  62372. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62373. /**
  62374. * gets the angular velocity
  62375. * @param impostor imposter to get angular velocity from
  62376. * @returns angular velocity
  62377. */
  62378. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62379. /**
  62380. * Sets the mass of physics body
  62381. * @param impostor imposter to set the mass on
  62382. * @param mass mass to set
  62383. */
  62384. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62385. /**
  62386. * Gets the mass of the physics body
  62387. * @param impostor imposter to get the mass from
  62388. * @returns mass
  62389. */
  62390. getBodyMass(impostor: PhysicsImpostor): number;
  62391. /**
  62392. * Gets friction of the impostor
  62393. * @param impostor impostor to get friction from
  62394. * @returns friction value
  62395. */
  62396. getBodyFriction(impostor: PhysicsImpostor): number;
  62397. /**
  62398. * Sets friction of the impostor
  62399. * @param impostor impostor to set friction on
  62400. * @param friction friction value
  62401. */
  62402. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62403. /**
  62404. * Gets restitution of the impostor
  62405. * @param impostor impostor to get restitution from
  62406. * @returns restitution value
  62407. */
  62408. getBodyRestitution(impostor: PhysicsImpostor): number;
  62409. /**
  62410. * Sets resitution of the impostor
  62411. * @param impostor impostor to set resitution on
  62412. * @param restitution resitution value
  62413. */
  62414. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62415. /**
  62416. * Gets pressure inside the impostor
  62417. * @param impostor impostor to get pressure from
  62418. * @returns pressure value
  62419. */
  62420. getBodyPressure(impostor: PhysicsImpostor): number;
  62421. /**
  62422. * Sets pressure inside a soft body impostor
  62423. * Cloth and rope must remain 0 pressure
  62424. * @param impostor impostor to set pressure on
  62425. * @param pressure pressure value
  62426. */
  62427. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62428. /**
  62429. * Gets stiffness of the impostor
  62430. * @param impostor impostor to get stiffness from
  62431. * @returns pressure value
  62432. */
  62433. getBodyStiffness(impostor: PhysicsImpostor): number;
  62434. /**
  62435. * Sets stiffness of the impostor
  62436. * @param impostor impostor to set stiffness on
  62437. * @param stiffness stiffness value from 0 to 1
  62438. */
  62439. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62440. /**
  62441. * Gets velocityIterations of the impostor
  62442. * @param impostor impostor to get velocity iterations from
  62443. * @returns velocityIterations value
  62444. */
  62445. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62446. /**
  62447. * Sets velocityIterations of the impostor
  62448. * @param impostor impostor to set velocity iterations on
  62449. * @param velocityIterations velocityIterations value
  62450. */
  62451. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62452. /**
  62453. * Gets positionIterations of the impostor
  62454. * @param impostor impostor to get position iterations from
  62455. * @returns positionIterations value
  62456. */
  62457. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62458. /**
  62459. * Sets positionIterations of the impostor
  62460. * @param impostor impostor to set position on
  62461. * @param positionIterations positionIterations value
  62462. */
  62463. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62464. /**
  62465. * Append an anchor to a cloth object
  62466. * @param impostor is the cloth impostor to add anchor to
  62467. * @param otherImpostor is the rigid impostor to anchor to
  62468. * @param width ratio across width from 0 to 1
  62469. * @param height ratio up height from 0 to 1
  62470. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62471. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62472. */
  62473. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62474. /**
  62475. * Append an hook to a rope object
  62476. * @param impostor is the rope impostor to add hook to
  62477. * @param otherImpostor is the rigid impostor to hook to
  62478. * @param length ratio along the rope from 0 to 1
  62479. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62480. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62481. */
  62482. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62483. /**
  62484. * Sleeps the physics body and stops it from being active
  62485. * @param impostor impostor to sleep
  62486. */
  62487. sleepBody(impostor: PhysicsImpostor): void;
  62488. /**
  62489. * Activates the physics body
  62490. * @param impostor impostor to activate
  62491. */
  62492. wakeUpBody(impostor: PhysicsImpostor): void;
  62493. /**
  62494. * Updates the distance parameters of the joint
  62495. * @param joint joint to update
  62496. * @param maxDistance maximum distance of the joint
  62497. * @param minDistance minimum distance of the joint
  62498. */
  62499. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62500. /**
  62501. * Sets a motor on the joint
  62502. * @param joint joint to set motor on
  62503. * @param speed speed of the motor
  62504. * @param maxForce maximum force of the motor
  62505. * @param motorIndex index of the motor
  62506. */
  62507. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62508. /**
  62509. * Sets the motors limit
  62510. * @param joint joint to set limit on
  62511. * @param upperLimit upper limit
  62512. * @param lowerLimit lower limit
  62513. */
  62514. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62515. /**
  62516. * Syncs the position and rotation of a mesh with the impostor
  62517. * @param mesh mesh to sync
  62518. * @param impostor impostor to update the mesh with
  62519. */
  62520. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62521. /**
  62522. * Gets the radius of the impostor
  62523. * @param impostor impostor to get radius from
  62524. * @returns the radius
  62525. */
  62526. getRadius(impostor: PhysicsImpostor): number;
  62527. /**
  62528. * Gets the box size of the impostor
  62529. * @param impostor impostor to get box size from
  62530. * @param result the resulting box size
  62531. */
  62532. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62533. /**
  62534. * Disposes of the impostor
  62535. */
  62536. dispose(): void;
  62537. /**
  62538. * Does a raycast in the physics world
  62539. * @param from when should the ray start?
  62540. * @param to when should the ray end?
  62541. * @returns PhysicsRaycastResult
  62542. */
  62543. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62544. }
  62545. }
  62546. declare module BABYLON {
  62547. interface AbstractScene {
  62548. /**
  62549. * The list of reflection probes added to the scene
  62550. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62551. */
  62552. reflectionProbes: Array<ReflectionProbe>;
  62553. /**
  62554. * Removes the given reflection probe from this scene.
  62555. * @param toRemove The reflection probe to remove
  62556. * @returns The index of the removed reflection probe
  62557. */
  62558. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62559. /**
  62560. * Adds the given reflection probe to this scene.
  62561. * @param newReflectionProbe The reflection probe to add
  62562. */
  62563. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62564. }
  62565. /**
  62566. * Class used to generate realtime reflection / refraction cube textures
  62567. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62568. */
  62569. export class ReflectionProbe {
  62570. /** defines the name of the probe */
  62571. name: string;
  62572. private _scene;
  62573. private _renderTargetTexture;
  62574. private _projectionMatrix;
  62575. private _viewMatrix;
  62576. private _target;
  62577. private _add;
  62578. private _attachedMesh;
  62579. private _invertYAxis;
  62580. /** Gets or sets probe position (center of the cube map) */
  62581. position: Vector3;
  62582. /**
  62583. * Creates a new reflection probe
  62584. * @param name defines the name of the probe
  62585. * @param size defines the texture resolution (for each face)
  62586. * @param scene defines the hosting scene
  62587. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62588. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62589. */
  62590. constructor(
  62591. /** defines the name of the probe */
  62592. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62593. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62594. get samples(): number;
  62595. set samples(value: number);
  62596. /** Gets or sets the refresh rate to use (on every frame by default) */
  62597. get refreshRate(): number;
  62598. set refreshRate(value: number);
  62599. /**
  62600. * Gets the hosting scene
  62601. * @returns a Scene
  62602. */
  62603. getScene(): Scene;
  62604. /** Gets the internal CubeTexture used to render to */
  62605. get cubeTexture(): RenderTargetTexture;
  62606. /** Gets the list of meshes to render */
  62607. get renderList(): Nullable<AbstractMesh[]>;
  62608. /**
  62609. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62610. * @param mesh defines the mesh to attach to
  62611. */
  62612. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62613. /**
  62614. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62615. * @param renderingGroupId The rendering group id corresponding to its index
  62616. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62617. */
  62618. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62619. /**
  62620. * Clean all associated resources
  62621. */
  62622. dispose(): void;
  62623. /**
  62624. * Converts the reflection probe information to a readable string for debug purpose.
  62625. * @param fullDetails Supports for multiple levels of logging within scene loading
  62626. * @returns the human readable reflection probe info
  62627. */
  62628. toString(fullDetails?: boolean): string;
  62629. /**
  62630. * Get the class name of the relfection probe.
  62631. * @returns "ReflectionProbe"
  62632. */
  62633. getClassName(): string;
  62634. /**
  62635. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62636. * @returns The JSON representation of the texture
  62637. */
  62638. serialize(): any;
  62639. /**
  62640. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62641. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62642. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62643. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62644. * @returns The parsed reflection probe if successful
  62645. */
  62646. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62647. }
  62648. }
  62649. declare module BABYLON {
  62650. /** @hidden */
  62651. export var _BabylonLoaderRegistered: boolean;
  62652. /**
  62653. * Helps setting up some configuration for the babylon file loader.
  62654. */
  62655. export class BabylonFileLoaderConfiguration {
  62656. /**
  62657. * The loader does not allow injecting custom physix engine into the plugins.
  62658. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62659. * So you could set this variable to your engine import to make it work.
  62660. */
  62661. static LoaderInjectedPhysicsEngine: any;
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * The Physically based simple base material of BJS.
  62667. *
  62668. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62669. * It is used as the base class for both the specGloss and metalRough conventions.
  62670. */
  62671. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62672. /**
  62673. * Number of Simultaneous lights allowed on the material.
  62674. */
  62675. maxSimultaneousLights: number;
  62676. /**
  62677. * If sets to true, disables all the lights affecting the material.
  62678. */
  62679. disableLighting: boolean;
  62680. /**
  62681. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62682. */
  62683. environmentTexture: BaseTexture;
  62684. /**
  62685. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62686. */
  62687. invertNormalMapX: boolean;
  62688. /**
  62689. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62690. */
  62691. invertNormalMapY: boolean;
  62692. /**
  62693. * Normal map used in the model.
  62694. */
  62695. normalTexture: BaseTexture;
  62696. /**
  62697. * Emissivie color used to self-illuminate the model.
  62698. */
  62699. emissiveColor: Color3;
  62700. /**
  62701. * Emissivie texture used to self-illuminate the model.
  62702. */
  62703. emissiveTexture: BaseTexture;
  62704. /**
  62705. * Occlusion Channel Strenght.
  62706. */
  62707. occlusionStrength: number;
  62708. /**
  62709. * Occlusion Texture of the material (adding extra occlusion effects).
  62710. */
  62711. occlusionTexture: BaseTexture;
  62712. /**
  62713. * Defines the alpha limits in alpha test mode.
  62714. */
  62715. alphaCutOff: number;
  62716. /**
  62717. * Gets the current double sided mode.
  62718. */
  62719. get doubleSided(): boolean;
  62720. /**
  62721. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62722. */
  62723. set doubleSided(value: boolean);
  62724. /**
  62725. * Stores the pre-calculated light information of a mesh in a texture.
  62726. */
  62727. lightmapTexture: BaseTexture;
  62728. /**
  62729. * If true, the light map contains occlusion information instead of lighting info.
  62730. */
  62731. useLightmapAsShadowmap: boolean;
  62732. /**
  62733. * Instantiates a new PBRMaterial instance.
  62734. *
  62735. * @param name The material name
  62736. * @param scene The scene the material will be use in.
  62737. */
  62738. constructor(name: string, scene: Scene);
  62739. getClassName(): string;
  62740. }
  62741. }
  62742. declare module BABYLON {
  62743. /**
  62744. * The PBR material of BJS following the metal roughness convention.
  62745. *
  62746. * This fits to the PBR convention in the GLTF definition:
  62747. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62748. */
  62749. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62750. /**
  62751. * The base color has two different interpretations depending on the value of metalness.
  62752. * When the material is a metal, the base color is the specific measured reflectance value
  62753. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62754. * of the material.
  62755. */
  62756. baseColor: Color3;
  62757. /**
  62758. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62759. * well as opacity information in the alpha channel.
  62760. */
  62761. baseTexture: BaseTexture;
  62762. /**
  62763. * Specifies the metallic scalar value of the material.
  62764. * Can also be used to scale the metalness values of the metallic texture.
  62765. */
  62766. metallic: number;
  62767. /**
  62768. * Specifies the roughness scalar value of the material.
  62769. * Can also be used to scale the roughness values of the metallic texture.
  62770. */
  62771. roughness: number;
  62772. /**
  62773. * Texture containing both the metallic value in the B channel and the
  62774. * roughness value in the G channel to keep better precision.
  62775. */
  62776. metallicRoughnessTexture: BaseTexture;
  62777. /**
  62778. * Instantiates a new PBRMetalRoughnessMaterial 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. /**
  62785. * Return the currrent class name of the material.
  62786. */
  62787. getClassName(): string;
  62788. /**
  62789. * Makes a duplicate of the current material.
  62790. * @param name - name to use for the new material.
  62791. */
  62792. clone(name: string): PBRMetallicRoughnessMaterial;
  62793. /**
  62794. * Serialize the material to a parsable JSON object.
  62795. */
  62796. serialize(): any;
  62797. /**
  62798. * Parses a JSON object correponding to the serialize function.
  62799. */
  62800. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62801. }
  62802. }
  62803. declare module BABYLON {
  62804. /**
  62805. * The PBR material of BJS following the specular glossiness convention.
  62806. *
  62807. * This fits to the PBR convention in the GLTF definition:
  62808. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62809. */
  62810. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62811. /**
  62812. * Specifies the diffuse color of the material.
  62813. */
  62814. diffuseColor: Color3;
  62815. /**
  62816. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62817. * channel.
  62818. */
  62819. diffuseTexture: BaseTexture;
  62820. /**
  62821. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62822. */
  62823. specularColor: Color3;
  62824. /**
  62825. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62826. */
  62827. glossiness: number;
  62828. /**
  62829. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62830. */
  62831. specularGlossinessTexture: BaseTexture;
  62832. /**
  62833. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62834. *
  62835. * @param name The material name
  62836. * @param scene The scene the material will be use in.
  62837. */
  62838. constructor(name: string, scene: Scene);
  62839. /**
  62840. * Return the currrent class name of the material.
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Makes a duplicate of the current material.
  62845. * @param name - name to use for the new material.
  62846. */
  62847. clone(name: string): PBRSpecularGlossinessMaterial;
  62848. /**
  62849. * Serialize the material to a parsable JSON object.
  62850. */
  62851. serialize(): any;
  62852. /**
  62853. * Parses a JSON object correponding to the serialize function.
  62854. */
  62855. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62861. * It can help converting any input color in a desired output one. This can then be used to create effects
  62862. * from sepia, black and white to sixties or futuristic rendering...
  62863. *
  62864. * The only supported format is currently 3dl.
  62865. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62866. */
  62867. export class ColorGradingTexture extends BaseTexture {
  62868. /**
  62869. * The texture URL.
  62870. */
  62871. url: string;
  62872. /**
  62873. * Empty line regex stored for GC.
  62874. */
  62875. private static _noneEmptyLineRegex;
  62876. private _textureMatrix;
  62877. private _onLoad;
  62878. /**
  62879. * Instantiates a ColorGradingTexture from the following parameters.
  62880. *
  62881. * @param url The location of the color gradind data (currently only supporting 3dl)
  62882. * @param sceneOrEngine The scene or engine the texture will be used in
  62883. * @param onLoad defines a callback triggered when the texture has been loaded
  62884. */
  62885. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62886. /**
  62887. * Fires the onload event from the constructor if requested.
  62888. */
  62889. private _triggerOnLoad;
  62890. /**
  62891. * Returns the texture matrix used in most of the material.
  62892. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62893. */
  62894. getTextureMatrix(): Matrix;
  62895. /**
  62896. * Occurs when the file being loaded is a .3dl LUT file.
  62897. */
  62898. private load3dlTexture;
  62899. /**
  62900. * Starts the loading process of the texture.
  62901. */
  62902. private loadTexture;
  62903. /**
  62904. * Clones the color gradind texture.
  62905. */
  62906. clone(): ColorGradingTexture;
  62907. /**
  62908. * Called during delayed load for textures.
  62909. */
  62910. delayLoad(): void;
  62911. /**
  62912. * Parses a color grading texture serialized by Babylon.
  62913. * @param parsedTexture The texture information being parsedTexture
  62914. * @param scene The scene to load the texture in
  62915. * @param rootUrl The root url of the data assets to load
  62916. * @return A color gradind texture
  62917. */
  62918. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62919. /**
  62920. * Serializes the LUT texture to json format.
  62921. */
  62922. serialize(): any;
  62923. }
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62928. */
  62929. export class EquiRectangularCubeTexture extends BaseTexture {
  62930. /** The six faces of the cube. */
  62931. private static _FacesMapping;
  62932. private _noMipmap;
  62933. private _onLoad;
  62934. private _onError;
  62935. /** The size of the cubemap. */
  62936. private _size;
  62937. /** The buffer of the image. */
  62938. private _buffer;
  62939. /** The width of the input image. */
  62940. private _width;
  62941. /** The height of the input image. */
  62942. private _height;
  62943. /** The URL to the image. */
  62944. url: string;
  62945. /**
  62946. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62947. * @param url The location of the image
  62948. * @param scene The scene the texture will be used in
  62949. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62950. * @param noMipmap Forces to not generate the mipmap if true
  62951. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62952. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62953. * @param onLoad — defines a callback called when texture is loaded
  62954. * @param onError — defines a callback called if there is an error
  62955. */
  62956. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62957. /**
  62958. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62959. */
  62960. private loadImage;
  62961. /**
  62962. * Convert the image buffer into a cubemap and create a CubeTexture.
  62963. */
  62964. private loadTexture;
  62965. /**
  62966. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62967. * @param buffer The ArrayBuffer that should be converted.
  62968. * @returns The buffer as Float32Array.
  62969. */
  62970. private getFloat32ArrayFromArrayBuffer;
  62971. /**
  62972. * Get the current class name of the texture useful for serialization or dynamic coding.
  62973. * @returns "EquiRectangularCubeTexture"
  62974. */
  62975. getClassName(): string;
  62976. /**
  62977. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62978. * @returns A clone of the current EquiRectangularCubeTexture.
  62979. */
  62980. clone(): EquiRectangularCubeTexture;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * Defines the options related to the creation of an HtmlElementTexture
  62986. */
  62987. export interface IHtmlElementTextureOptions {
  62988. /**
  62989. * Defines wether mip maps should be created or not.
  62990. */
  62991. generateMipMaps?: boolean;
  62992. /**
  62993. * Defines the sampling mode of the texture.
  62994. */
  62995. samplingMode?: number;
  62996. /**
  62997. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62998. */
  62999. engine: Nullable<ThinEngine>;
  63000. /**
  63001. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63002. */
  63003. scene: Nullable<Scene>;
  63004. }
  63005. /**
  63006. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63007. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63008. * is automatically managed.
  63009. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63010. * in your application.
  63011. *
  63012. * As the update is not automatic, you need to call them manually.
  63013. */
  63014. export class HtmlElementTexture extends BaseTexture {
  63015. /**
  63016. * The texture URL.
  63017. */
  63018. element: HTMLVideoElement | HTMLCanvasElement;
  63019. private static readonly DefaultOptions;
  63020. private _textureMatrix;
  63021. private _isVideo;
  63022. private _generateMipMaps;
  63023. private _samplingMode;
  63024. /**
  63025. * Instantiates a HtmlElementTexture from the following parameters.
  63026. *
  63027. * @param name Defines the name of the texture
  63028. * @param element Defines the video or canvas the texture is filled with
  63029. * @param options Defines the other none mandatory texture creation options
  63030. */
  63031. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63032. private _createInternalTexture;
  63033. /**
  63034. * Returns the texture matrix used in most of the material.
  63035. */
  63036. getTextureMatrix(): Matrix;
  63037. /**
  63038. * Updates the content of the texture.
  63039. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63040. */
  63041. update(invertY?: Nullable<boolean>): void;
  63042. }
  63043. }
  63044. declare module BABYLON {
  63045. /**
  63046. * Based on jsTGALoader - Javascript loader for TGA file
  63047. * By Vincent Thibault
  63048. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63049. */
  63050. export class TGATools {
  63051. private static _TYPE_INDEXED;
  63052. private static _TYPE_RGB;
  63053. private static _TYPE_GREY;
  63054. private static _TYPE_RLE_INDEXED;
  63055. private static _TYPE_RLE_RGB;
  63056. private static _TYPE_RLE_GREY;
  63057. private static _ORIGIN_MASK;
  63058. private static _ORIGIN_SHIFT;
  63059. private static _ORIGIN_BL;
  63060. private static _ORIGIN_BR;
  63061. private static _ORIGIN_UL;
  63062. private static _ORIGIN_UR;
  63063. /**
  63064. * Gets the header of a TGA file
  63065. * @param data defines the TGA data
  63066. * @returns the header
  63067. */
  63068. static GetTGAHeader(data: Uint8Array): any;
  63069. /**
  63070. * Uploads TGA content to a Babylon Texture
  63071. * @hidden
  63072. */
  63073. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63074. /** @hidden */
  63075. 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;
  63076. /** @hidden */
  63077. 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;
  63078. /** @hidden */
  63079. 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;
  63080. /** @hidden */
  63081. 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;
  63082. /** @hidden */
  63083. 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;
  63084. /** @hidden */
  63085. 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;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Implementation of the TGA Texture Loader.
  63091. * @hidden
  63092. */
  63093. export class _TGATextureLoader implements IInternalTextureLoader {
  63094. /**
  63095. * Defines wether the loader supports cascade loading the different faces.
  63096. */
  63097. readonly supportCascades: boolean;
  63098. /**
  63099. * This returns if the loader support the current file information.
  63100. * @param extension defines the file extension of the file being loaded
  63101. * @returns true if the loader can load the specified file
  63102. */
  63103. canLoad(extension: string): boolean;
  63104. /**
  63105. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63106. * @param data contains the texture data
  63107. * @param texture defines the BabylonJS internal texture
  63108. * @param createPolynomials will be true if polynomials have been requested
  63109. * @param onLoad defines the callback to trigger once the texture is ready
  63110. * @param onError defines the callback to trigger in case of error
  63111. */
  63112. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63113. /**
  63114. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63115. * @param data contains the texture data
  63116. * @param texture defines the BabylonJS internal texture
  63117. * @param callback defines the method to call once ready to upload
  63118. */
  63119. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63120. }
  63121. }
  63122. declare module BABYLON {
  63123. /**
  63124. * Info about the .basis files
  63125. */
  63126. class BasisFileInfo {
  63127. /**
  63128. * If the file has alpha
  63129. */
  63130. hasAlpha: boolean;
  63131. /**
  63132. * Info about each image of the basis file
  63133. */
  63134. images: Array<{
  63135. levels: Array<{
  63136. width: number;
  63137. height: number;
  63138. transcodedPixels: ArrayBufferView;
  63139. }>;
  63140. }>;
  63141. }
  63142. /**
  63143. * Result of transcoding a basis file
  63144. */
  63145. class TranscodeResult {
  63146. /**
  63147. * Info about the .basis file
  63148. */
  63149. fileInfo: BasisFileInfo;
  63150. /**
  63151. * Format to use when loading the file
  63152. */
  63153. format: number;
  63154. }
  63155. /**
  63156. * Configuration options for the Basis transcoder
  63157. */
  63158. export class BasisTranscodeConfiguration {
  63159. /**
  63160. * Supported compression formats used to determine the supported output format of the transcoder
  63161. */
  63162. supportedCompressionFormats?: {
  63163. /**
  63164. * etc1 compression format
  63165. */
  63166. etc1?: boolean;
  63167. /**
  63168. * s3tc compression format
  63169. */
  63170. s3tc?: boolean;
  63171. /**
  63172. * pvrtc compression format
  63173. */
  63174. pvrtc?: boolean;
  63175. /**
  63176. * etc2 compression format
  63177. */
  63178. etc2?: boolean;
  63179. };
  63180. /**
  63181. * If mipmap levels should be loaded for transcoded images (Default: true)
  63182. */
  63183. loadMipmapLevels?: boolean;
  63184. /**
  63185. * Index of a single image to load (Default: all images)
  63186. */
  63187. loadSingleImage?: number;
  63188. }
  63189. /**
  63190. * Used to load .Basis files
  63191. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63192. */
  63193. export class BasisTools {
  63194. private static _IgnoreSupportedFormats;
  63195. /**
  63196. * URL to use when loading the basis transcoder
  63197. */
  63198. static JSModuleURL: string;
  63199. /**
  63200. * URL to use when loading the wasm module for the transcoder
  63201. */
  63202. static WasmModuleURL: string;
  63203. /**
  63204. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63205. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63206. * @returns internal format corresponding to the Basis format
  63207. */
  63208. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63209. private static _WorkerPromise;
  63210. private static _Worker;
  63211. private static _actionId;
  63212. private static _CreateWorkerAsync;
  63213. /**
  63214. * Transcodes a loaded image file to compressed pixel data
  63215. * @param data image data to transcode
  63216. * @param config configuration options for the transcoding
  63217. * @returns a promise resulting in the transcoded image
  63218. */
  63219. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63220. /**
  63221. * Loads a texture from the transcode result
  63222. * @param texture texture load to
  63223. * @param transcodeResult the result of transcoding the basis file to load from
  63224. */
  63225. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63226. }
  63227. }
  63228. declare module BABYLON {
  63229. /**
  63230. * Loader for .basis file format
  63231. */
  63232. export class _BasisTextureLoader implements IInternalTextureLoader {
  63233. /**
  63234. * Defines whether the loader supports cascade loading the different faces.
  63235. */
  63236. readonly supportCascades: boolean;
  63237. /**
  63238. * This returns if the loader support the current file information.
  63239. * @param extension defines the file extension of the file being loaded
  63240. * @returns true if the loader can load the specified file
  63241. */
  63242. canLoad(extension: string): boolean;
  63243. /**
  63244. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63245. * @param data contains the texture data
  63246. * @param texture defines the BabylonJS internal texture
  63247. * @param createPolynomials will be true if polynomials have been requested
  63248. * @param onLoad defines the callback to trigger once the texture is ready
  63249. * @param onError defines the callback to trigger in case of error
  63250. */
  63251. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63252. /**
  63253. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63254. * @param data contains the texture data
  63255. * @param texture defines the BabylonJS internal texture
  63256. * @param callback defines the method to call once ready to upload
  63257. */
  63258. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63259. }
  63260. }
  63261. declare module BABYLON {
  63262. /**
  63263. * Defines the basic options interface of a TexturePacker Frame
  63264. */
  63265. export interface ITexturePackerFrame {
  63266. /**
  63267. * The frame ID
  63268. */
  63269. id: number;
  63270. /**
  63271. * The frames Scale
  63272. */
  63273. scale: Vector2;
  63274. /**
  63275. * The Frames offset
  63276. */
  63277. offset: Vector2;
  63278. }
  63279. /**
  63280. * This is a support class for frame Data on texture packer sets.
  63281. */
  63282. export class TexturePackerFrame implements ITexturePackerFrame {
  63283. /**
  63284. * The frame ID
  63285. */
  63286. id: number;
  63287. /**
  63288. * The frames Scale
  63289. */
  63290. scale: Vector2;
  63291. /**
  63292. * The Frames offset
  63293. */
  63294. offset: Vector2;
  63295. /**
  63296. * Initializes a texture package frame.
  63297. * @param id The numerical frame identifier
  63298. * @param scale Scalar Vector2 for UV frame
  63299. * @param offset Vector2 for the frame position in UV units.
  63300. * @returns TexturePackerFrame
  63301. */
  63302. constructor(id: number, scale: Vector2, offset: Vector2);
  63303. }
  63304. }
  63305. declare module BABYLON {
  63306. /**
  63307. * Defines the basic options interface of a TexturePacker
  63308. */
  63309. export interface ITexturePackerOptions {
  63310. /**
  63311. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63312. */
  63313. map?: string[];
  63314. /**
  63315. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63316. */
  63317. uvsIn?: string;
  63318. /**
  63319. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63320. */
  63321. uvsOut?: string;
  63322. /**
  63323. * number representing the layout style. Defaults to LAYOUT_STRIP
  63324. */
  63325. layout?: number;
  63326. /**
  63327. * number of columns if using custom column count layout(2). This defaults to 4.
  63328. */
  63329. colnum?: number;
  63330. /**
  63331. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63332. */
  63333. updateInputMeshes?: boolean;
  63334. /**
  63335. * boolean flag to dispose all the source textures. Defaults to true.
  63336. */
  63337. disposeSources?: boolean;
  63338. /**
  63339. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63340. */
  63341. fillBlanks?: boolean;
  63342. /**
  63343. * string value representing the context fill style color. Defaults to 'black'.
  63344. */
  63345. customFillColor?: string;
  63346. /**
  63347. * Width and Height Value of each Frame in the TexturePacker Sets
  63348. */
  63349. frameSize?: number;
  63350. /**
  63351. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63352. */
  63353. paddingRatio?: number;
  63354. /**
  63355. * Number that declares the fill method for the padding gutter.
  63356. */
  63357. paddingMode?: number;
  63358. /**
  63359. * If in SUBUV_COLOR padding mode what color to use.
  63360. */
  63361. paddingColor?: Color3 | Color4;
  63362. }
  63363. /**
  63364. * Defines the basic interface of a TexturePacker JSON File
  63365. */
  63366. export interface ITexturePackerJSON {
  63367. /**
  63368. * The frame ID
  63369. */
  63370. name: string;
  63371. /**
  63372. * The base64 channel data
  63373. */
  63374. sets: any;
  63375. /**
  63376. * The options of the Packer
  63377. */
  63378. options: ITexturePackerOptions;
  63379. /**
  63380. * The frame data of the Packer
  63381. */
  63382. frames: Array<number>;
  63383. }
  63384. /**
  63385. * This is a support class that generates a series of packed texture sets.
  63386. * @see https://doc.babylonjs.com/babylon101/materials
  63387. */
  63388. export class TexturePacker {
  63389. /** Packer Layout Constant 0 */
  63390. static readonly LAYOUT_STRIP: number;
  63391. /** Packer Layout Constant 1 */
  63392. static readonly LAYOUT_POWER2: number;
  63393. /** Packer Layout Constant 2 */
  63394. static readonly LAYOUT_COLNUM: number;
  63395. /** Packer Layout Constant 0 */
  63396. static readonly SUBUV_WRAP: number;
  63397. /** Packer Layout Constant 1 */
  63398. static readonly SUBUV_EXTEND: number;
  63399. /** Packer Layout Constant 2 */
  63400. static readonly SUBUV_COLOR: number;
  63401. /** The Name of the Texture Package */
  63402. name: string;
  63403. /** The scene scope of the TexturePacker */
  63404. scene: Scene;
  63405. /** The Meshes to target */
  63406. meshes: AbstractMesh[];
  63407. /** Arguments passed with the Constructor */
  63408. options: ITexturePackerOptions;
  63409. /** The promise that is started upon initialization */
  63410. promise: Nullable<Promise<TexturePacker | string>>;
  63411. /** The Container object for the channel sets that are generated */
  63412. sets: object;
  63413. /** The Container array for the frames that are generated */
  63414. frames: TexturePackerFrame[];
  63415. /** The expected number of textures the system is parsing. */
  63416. private _expecting;
  63417. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63418. private _paddingValue;
  63419. /**
  63420. * Initializes a texture package series from an array of meshes or a single mesh.
  63421. * @param name The name of the package
  63422. * @param meshes The target meshes to compose the package from
  63423. * @param options The arguments that texture packer should follow while building.
  63424. * @param scene The scene which the textures are scoped to.
  63425. * @returns TexturePacker
  63426. */
  63427. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63428. /**
  63429. * Starts the package process
  63430. * @param resolve The promises resolution function
  63431. * @returns TexturePacker
  63432. */
  63433. private _createFrames;
  63434. /**
  63435. * Calculates the Size of the Channel Sets
  63436. * @returns Vector2
  63437. */
  63438. private _calculateSize;
  63439. /**
  63440. * Calculates the UV data for the frames.
  63441. * @param baseSize the base frameSize
  63442. * @param padding the base frame padding
  63443. * @param dtSize size of the Dynamic Texture for that channel
  63444. * @param dtUnits is 1/dtSize
  63445. * @param update flag to update the input meshes
  63446. */
  63447. private _calculateMeshUVFrames;
  63448. /**
  63449. * Calculates the frames Offset.
  63450. * @param index of the frame
  63451. * @returns Vector2
  63452. */
  63453. private _getFrameOffset;
  63454. /**
  63455. * Updates a Mesh to the frame data
  63456. * @param mesh that is the target
  63457. * @param frameID or the frame index
  63458. */
  63459. private _updateMeshUV;
  63460. /**
  63461. * Updates a Meshes materials to use the texture packer channels
  63462. * @param m is the mesh to target
  63463. * @param force all channels on the packer to be set.
  63464. */
  63465. private _updateTextureReferences;
  63466. /**
  63467. * Public method to set a Mesh to a frame
  63468. * @param m that is the target
  63469. * @param frameID or the frame index
  63470. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63471. */
  63472. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63473. /**
  63474. * Starts the async promise to compile the texture packer.
  63475. * @returns Promise<void>
  63476. */
  63477. processAsync(): Promise<void>;
  63478. /**
  63479. * Disposes all textures associated with this packer
  63480. */
  63481. dispose(): void;
  63482. /**
  63483. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63484. * @param imageType is the image type to use.
  63485. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63486. */
  63487. download(imageType?: string, quality?: number): void;
  63488. /**
  63489. * Public method to load a texturePacker JSON file.
  63490. * @param data of the JSON file in string format.
  63491. */
  63492. updateFromJSON(data: string): void;
  63493. }
  63494. }
  63495. declare module BABYLON {
  63496. /**
  63497. * 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.
  63498. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63499. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63500. */
  63501. export class CustomProceduralTexture extends ProceduralTexture {
  63502. private _animate;
  63503. private _time;
  63504. private _config;
  63505. private _texturePath;
  63506. /**
  63507. * Instantiates a new Custom Procedural Texture.
  63508. * 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.
  63509. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63510. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63511. * @param name Define the name of the texture
  63512. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63513. * @param size Define the size of the texture to create
  63514. * @param scene Define the scene the texture belongs to
  63515. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63516. * @param generateMipMaps Define if the texture should creates mip maps or not
  63517. */
  63518. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63519. private _loadJson;
  63520. /**
  63521. * Is the texture ready to be used ? (rendered at least once)
  63522. * @returns true if ready, otherwise, false.
  63523. */
  63524. isReady(): boolean;
  63525. /**
  63526. * Render the texture to its associated render target.
  63527. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63528. */
  63529. render(useCameraPostProcess?: boolean): void;
  63530. /**
  63531. * Update the list of dependant textures samplers in the shader.
  63532. */
  63533. updateTextures(): void;
  63534. /**
  63535. * Update the uniform values of the procedural texture in the shader.
  63536. */
  63537. updateShaderUniforms(): void;
  63538. /**
  63539. * Define if the texture animates or not.
  63540. */
  63541. get animate(): boolean;
  63542. set animate(value: boolean);
  63543. }
  63544. }
  63545. declare module BABYLON {
  63546. /** @hidden */
  63547. export var noisePixelShader: {
  63548. name: string;
  63549. shader: string;
  63550. };
  63551. }
  63552. declare module BABYLON {
  63553. /**
  63554. * Class used to generate noise procedural textures
  63555. */
  63556. export class NoiseProceduralTexture extends ProceduralTexture {
  63557. /** Gets or sets the start time (default is 0) */
  63558. time: number;
  63559. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63560. brightness: number;
  63561. /** Defines the number of octaves to process */
  63562. octaves: number;
  63563. /** Defines the level of persistence (0.8 by default) */
  63564. persistence: number;
  63565. /** Gets or sets animation speed factor (default is 1) */
  63566. animationSpeedFactor: number;
  63567. /**
  63568. * Creates a new NoiseProceduralTexture
  63569. * @param name defines the name fo the texture
  63570. * @param size defines the size of the texture (default is 256)
  63571. * @param scene defines the hosting scene
  63572. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63573. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63574. */
  63575. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63576. private _updateShaderUniforms;
  63577. protected _getDefines(): string;
  63578. /** Generate the current state of the procedural texture */
  63579. render(useCameraPostProcess?: boolean): void;
  63580. /**
  63581. * Serializes this noise procedural texture
  63582. * @returns a serialized noise procedural texture object
  63583. */
  63584. serialize(): any;
  63585. /**
  63586. * Clone the texture.
  63587. * @returns the cloned texture
  63588. */
  63589. clone(): NoiseProceduralTexture;
  63590. /**
  63591. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63592. * @param parsedTexture defines parsed texture data
  63593. * @param scene defines the current scene
  63594. * @param rootUrl defines the root URL containing noise procedural texture information
  63595. * @returns a parsed NoiseProceduralTexture
  63596. */
  63597. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63598. }
  63599. }
  63600. declare module BABYLON {
  63601. /**
  63602. * Raw cube texture where the raw buffers are passed in
  63603. */
  63604. export class RawCubeTexture extends CubeTexture {
  63605. /**
  63606. * Creates a cube texture where the raw buffers are passed in.
  63607. * @param scene defines the scene the texture is attached to
  63608. * @param data defines the array of data to use to create each face
  63609. * @param size defines the size of the textures
  63610. * @param format defines the format of the data
  63611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63612. * @param generateMipMaps defines if the engine should generate the mip levels
  63613. * @param invertY defines if data must be stored with Y axis inverted
  63614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63615. * @param compression defines the compression used (null by default)
  63616. */
  63617. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63618. /**
  63619. * Updates the raw cube texture.
  63620. * @param data defines the data to store
  63621. * @param format defines the data format
  63622. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63623. * @param invertY defines if data must be stored with Y axis inverted
  63624. * @param compression defines the compression used (null by default)
  63625. * @param level defines which level of the texture to update
  63626. */
  63627. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63628. /**
  63629. * Updates a raw cube texture with RGBD encoded data.
  63630. * @param data defines the array of data [mipmap][face] to use to create each face
  63631. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63632. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63633. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63634. * @returns a promsie that resolves when the operation is complete
  63635. */
  63636. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63637. /**
  63638. * Clones the raw cube texture.
  63639. * @return a new cube texture
  63640. */
  63641. clone(): CubeTexture;
  63642. /** @hidden */
  63643. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63644. }
  63645. }
  63646. declare module BABYLON {
  63647. /**
  63648. * Class used to store 2D array textures containing user data
  63649. */
  63650. export class RawTexture2DArray extends Texture {
  63651. /** Gets or sets the texture format to use */
  63652. format: number;
  63653. /**
  63654. * Create a new RawTexture2DArray
  63655. * @param data defines the data of the texture
  63656. * @param width defines the width of the texture
  63657. * @param height defines the height of the texture
  63658. * @param depth defines the number of layers of the texture
  63659. * @param format defines the texture format to use
  63660. * @param scene defines the hosting scene
  63661. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63662. * @param invertY defines if texture must be stored with Y axis inverted
  63663. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63664. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63665. */
  63666. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63667. /** Gets or sets the texture format to use */
  63668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63669. /**
  63670. * Update the texture with new data
  63671. * @param data defines the data to store in the texture
  63672. */
  63673. update(data: ArrayBufferView): void;
  63674. }
  63675. }
  63676. declare module BABYLON {
  63677. /**
  63678. * Class used to store 3D textures containing user data
  63679. */
  63680. export class RawTexture3D extends Texture {
  63681. /** Gets or sets the texture format to use */
  63682. format: number;
  63683. /**
  63684. * Create a new RawTexture3D
  63685. * @param data defines the data of the texture
  63686. * @param width defines the width of the texture
  63687. * @param height defines the height of the texture
  63688. * @param depth defines the depth of the texture
  63689. * @param format defines the texture format to use
  63690. * @param scene defines the hosting scene
  63691. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63692. * @param invertY defines if texture must be stored with Y axis inverted
  63693. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63694. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63695. */
  63696. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63697. /** Gets or sets the texture format to use */
  63698. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63699. /**
  63700. * Update the texture with new data
  63701. * @param data defines the data to store in the texture
  63702. */
  63703. update(data: ArrayBufferView): void;
  63704. }
  63705. }
  63706. declare module BABYLON {
  63707. /**
  63708. * Creates a refraction texture used by refraction channel of the standard material.
  63709. * It is like a mirror but to see through a material.
  63710. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63711. */
  63712. export class RefractionTexture extends RenderTargetTexture {
  63713. /**
  63714. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63715. * 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.
  63716. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63717. */
  63718. refractionPlane: Plane;
  63719. /**
  63720. * Define how deep under the surface we should see.
  63721. */
  63722. depth: number;
  63723. /**
  63724. * Creates a refraction texture used by refraction channel of the standard material.
  63725. * It is like a mirror but to see through a material.
  63726. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63727. * @param name Define the texture name
  63728. * @param size Define the size of the underlying texture
  63729. * @param scene Define the scene the refraction belongs to
  63730. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63731. */
  63732. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63733. /**
  63734. * Clone the refraction texture.
  63735. * @returns the cloned texture
  63736. */
  63737. clone(): RefractionTexture;
  63738. /**
  63739. * Serialize the texture to a JSON representation you could use in Parse later on
  63740. * @returns the serialized JSON representation
  63741. */
  63742. serialize(): any;
  63743. }
  63744. }
  63745. declare module BABYLON {
  63746. /**
  63747. * Block used to add support for vertex skinning (bones)
  63748. */
  63749. export class BonesBlock extends NodeMaterialBlock {
  63750. /**
  63751. * Creates a new BonesBlock
  63752. * @param name defines the block name
  63753. */
  63754. constructor(name: string);
  63755. /**
  63756. * Initialize the block and prepare the context for build
  63757. * @param state defines the state that will be used for the build
  63758. */
  63759. initialize(state: NodeMaterialBuildState): void;
  63760. /**
  63761. * Gets the current class name
  63762. * @returns the class name
  63763. */
  63764. getClassName(): string;
  63765. /**
  63766. * Gets the matrix indices input component
  63767. */
  63768. get matricesIndices(): NodeMaterialConnectionPoint;
  63769. /**
  63770. * Gets the matrix weights input component
  63771. */
  63772. get matricesWeights(): NodeMaterialConnectionPoint;
  63773. /**
  63774. * Gets the extra matrix indices input component
  63775. */
  63776. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the extra matrix weights input component
  63779. */
  63780. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63781. /**
  63782. * Gets the world input component
  63783. */
  63784. get world(): NodeMaterialConnectionPoint;
  63785. /**
  63786. * Gets the output component
  63787. */
  63788. get output(): NodeMaterialConnectionPoint;
  63789. autoConfigure(material: NodeMaterial): void;
  63790. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63791. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63792. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63793. protected _buildBlock(state: NodeMaterialBuildState): this;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /**
  63798. * Block used to add support for instances
  63799. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63800. */
  63801. export class InstancesBlock extends NodeMaterialBlock {
  63802. /**
  63803. * Creates a new InstancesBlock
  63804. * @param name defines the block name
  63805. */
  63806. constructor(name: string);
  63807. /**
  63808. * Gets the current class name
  63809. * @returns the class name
  63810. */
  63811. getClassName(): string;
  63812. /**
  63813. * Gets the first world row input component
  63814. */
  63815. get world0(): NodeMaterialConnectionPoint;
  63816. /**
  63817. * Gets the second world row input component
  63818. */
  63819. get world1(): NodeMaterialConnectionPoint;
  63820. /**
  63821. * Gets the third world row input component
  63822. */
  63823. get world2(): NodeMaterialConnectionPoint;
  63824. /**
  63825. * Gets the forth world row input component
  63826. */
  63827. get world3(): NodeMaterialConnectionPoint;
  63828. /**
  63829. * Gets the world input component
  63830. */
  63831. get world(): NodeMaterialConnectionPoint;
  63832. /**
  63833. * Gets the output component
  63834. */
  63835. get output(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the isntanceID component
  63838. */
  63839. get instanceID(): NodeMaterialConnectionPoint;
  63840. autoConfigure(material: NodeMaterial): void;
  63841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63842. protected _buildBlock(state: NodeMaterialBuildState): this;
  63843. }
  63844. }
  63845. declare module BABYLON {
  63846. /**
  63847. * Block used to add morph targets support to vertex shader
  63848. */
  63849. export class MorphTargetsBlock extends NodeMaterialBlock {
  63850. private _repeatableContentAnchor;
  63851. /**
  63852. * Create a new MorphTargetsBlock
  63853. * @param name defines the block name
  63854. */
  63855. constructor(name: string);
  63856. /**
  63857. * Gets the current class name
  63858. * @returns the class name
  63859. */
  63860. getClassName(): string;
  63861. /**
  63862. * Gets the position input component
  63863. */
  63864. get position(): NodeMaterialConnectionPoint;
  63865. /**
  63866. * Gets the normal input component
  63867. */
  63868. get normal(): NodeMaterialConnectionPoint;
  63869. /**
  63870. * Gets the tangent input component
  63871. */
  63872. get tangent(): NodeMaterialConnectionPoint;
  63873. /**
  63874. * Gets the tangent input component
  63875. */
  63876. get uv(): NodeMaterialConnectionPoint;
  63877. /**
  63878. * Gets the position output component
  63879. */
  63880. get positionOutput(): NodeMaterialConnectionPoint;
  63881. /**
  63882. * Gets the normal output component
  63883. */
  63884. get normalOutput(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the tangent output component
  63887. */
  63888. get tangentOutput(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the tangent output component
  63891. */
  63892. get uvOutput(): NodeMaterialConnectionPoint;
  63893. initialize(state: NodeMaterialBuildState): void;
  63894. autoConfigure(material: NodeMaterial): void;
  63895. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63896. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63897. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63898. protected _buildBlock(state: NodeMaterialBuildState): this;
  63899. }
  63900. }
  63901. declare module BABYLON {
  63902. /**
  63903. * Block used to get data information from a light
  63904. */
  63905. export class LightInformationBlock extends NodeMaterialBlock {
  63906. private _lightDataUniformName;
  63907. private _lightColorUniformName;
  63908. private _lightTypeDefineName;
  63909. /**
  63910. * Gets or sets the light associated with this block
  63911. */
  63912. light: Nullable<Light>;
  63913. /**
  63914. * Creates a new LightInformationBlock
  63915. * @param name defines the block name
  63916. */
  63917. constructor(name: string);
  63918. /**
  63919. * Gets the current class name
  63920. * @returns the class name
  63921. */
  63922. getClassName(): string;
  63923. /**
  63924. * Gets the world position input component
  63925. */
  63926. get worldPosition(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the direction output component
  63929. */
  63930. get direction(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the direction output component
  63933. */
  63934. get color(): NodeMaterialConnectionPoint;
  63935. /**
  63936. * Gets the direction output component
  63937. */
  63938. get intensity(): NodeMaterialConnectionPoint;
  63939. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63941. protected _buildBlock(state: NodeMaterialBuildState): this;
  63942. serialize(): any;
  63943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /**
  63948. * Block used to add image processing support to fragment shader
  63949. */
  63950. export class ImageProcessingBlock extends NodeMaterialBlock {
  63951. /**
  63952. * Create a new ImageProcessingBlock
  63953. * @param name defines the block name
  63954. */
  63955. constructor(name: string);
  63956. /**
  63957. * Gets the current class name
  63958. * @returns the class name
  63959. */
  63960. getClassName(): string;
  63961. /**
  63962. * Gets the color input component
  63963. */
  63964. get color(): NodeMaterialConnectionPoint;
  63965. /**
  63966. * Gets the output component
  63967. */
  63968. get output(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Initialize the block and prepare the context for build
  63971. * @param state defines the state that will be used for the build
  63972. */
  63973. initialize(state: NodeMaterialBuildState): void;
  63974. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63977. protected _buildBlock(state: NodeMaterialBuildState): this;
  63978. }
  63979. }
  63980. declare module BABYLON {
  63981. /**
  63982. * Block used to pertub normals based on a normal map
  63983. */
  63984. export class PerturbNormalBlock extends NodeMaterialBlock {
  63985. private _tangentSpaceParameterName;
  63986. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63987. invertX: boolean;
  63988. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63989. invertY: boolean;
  63990. /**
  63991. * Create a new PerturbNormalBlock
  63992. * @param name defines the block name
  63993. */
  63994. constructor(name: string);
  63995. /**
  63996. * Gets the current class name
  63997. * @returns the class name
  63998. */
  63999. getClassName(): string;
  64000. /**
  64001. * Gets the world position input component
  64002. */
  64003. get worldPosition(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the world normal input component
  64006. */
  64007. get worldNormal(): NodeMaterialConnectionPoint;
  64008. /**
  64009. * Gets the world tangent input component
  64010. */
  64011. get worldTangent(): NodeMaterialConnectionPoint;
  64012. /**
  64013. * Gets the uv input component
  64014. */
  64015. get uv(): NodeMaterialConnectionPoint;
  64016. /**
  64017. * Gets the normal map color input component
  64018. */
  64019. get normalMapColor(): NodeMaterialConnectionPoint;
  64020. /**
  64021. * Gets the strength input component
  64022. */
  64023. get strength(): NodeMaterialConnectionPoint;
  64024. /**
  64025. * Gets the output component
  64026. */
  64027. get output(): NodeMaterialConnectionPoint;
  64028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64030. autoConfigure(material: NodeMaterial): void;
  64031. protected _buildBlock(state: NodeMaterialBuildState): this;
  64032. protected _dumpPropertiesCode(): string;
  64033. serialize(): any;
  64034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64035. }
  64036. }
  64037. declare module BABYLON {
  64038. /**
  64039. * Block used to discard a pixel if a value is smaller than a cutoff
  64040. */
  64041. export class DiscardBlock extends NodeMaterialBlock {
  64042. /**
  64043. * Create a new DiscardBlock
  64044. * @param name defines the block name
  64045. */
  64046. constructor(name: string);
  64047. /**
  64048. * Gets the current class name
  64049. * @returns the class name
  64050. */
  64051. getClassName(): string;
  64052. /**
  64053. * Gets the color input component
  64054. */
  64055. get value(): NodeMaterialConnectionPoint;
  64056. /**
  64057. * Gets the cutoff input component
  64058. */
  64059. get cutoff(): NodeMaterialConnectionPoint;
  64060. protected _buildBlock(state: NodeMaterialBuildState): this;
  64061. }
  64062. }
  64063. declare module BABYLON {
  64064. /**
  64065. * Block used to test if the fragment shader is front facing
  64066. */
  64067. export class FrontFacingBlock extends NodeMaterialBlock {
  64068. /**
  64069. * Creates a new FrontFacingBlock
  64070. * @param name defines the block name
  64071. */
  64072. constructor(name: string);
  64073. /**
  64074. * Gets the current class name
  64075. * @returns the class name
  64076. */
  64077. getClassName(): string;
  64078. /**
  64079. * Gets the output component
  64080. */
  64081. get output(): NodeMaterialConnectionPoint;
  64082. protected _buildBlock(state: NodeMaterialBuildState): this;
  64083. }
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * Block used to get the derivative value on x and y of a given input
  64088. */
  64089. export class DerivativeBlock extends NodeMaterialBlock {
  64090. /**
  64091. * Create a new DerivativeBlock
  64092. * @param name defines the block name
  64093. */
  64094. constructor(name: string);
  64095. /**
  64096. * Gets the current class name
  64097. * @returns the class name
  64098. */
  64099. getClassName(): string;
  64100. /**
  64101. * Gets the input component
  64102. */
  64103. get input(): NodeMaterialConnectionPoint;
  64104. /**
  64105. * Gets the derivative output on x
  64106. */
  64107. get dx(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the derivative output on y
  64110. */
  64111. get dy(): NodeMaterialConnectionPoint;
  64112. protected _buildBlock(state: NodeMaterialBuildState): this;
  64113. }
  64114. }
  64115. declare module BABYLON {
  64116. /**
  64117. * Block used to make gl_FragCoord available
  64118. */
  64119. export class FragCoordBlock extends NodeMaterialBlock {
  64120. /**
  64121. * Creates a new FragCoordBlock
  64122. * @param name defines the block name
  64123. */
  64124. constructor(name: string);
  64125. /**
  64126. * Gets the current class name
  64127. * @returns the class name
  64128. */
  64129. getClassName(): string;
  64130. /**
  64131. * Gets the xy component
  64132. */
  64133. get xy(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the xyz component
  64136. */
  64137. get xyz(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the xyzw component
  64140. */
  64141. get xyzw(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the x component
  64144. */
  64145. get x(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the y component
  64148. */
  64149. get y(): NodeMaterialConnectionPoint;
  64150. /**
  64151. * Gets the z component
  64152. */
  64153. get z(): NodeMaterialConnectionPoint;
  64154. /**
  64155. * Gets the w component
  64156. */
  64157. get output(): NodeMaterialConnectionPoint;
  64158. protected writeOutputs(state: NodeMaterialBuildState): string;
  64159. protected _buildBlock(state: NodeMaterialBuildState): this;
  64160. }
  64161. }
  64162. declare module BABYLON {
  64163. /**
  64164. * Block used to get the screen sizes
  64165. */
  64166. export class ScreenSizeBlock extends NodeMaterialBlock {
  64167. private _varName;
  64168. private _scene;
  64169. /**
  64170. * Creates a new ScreenSizeBlock
  64171. * @param name defines the block name
  64172. */
  64173. constructor(name: string);
  64174. /**
  64175. * Gets the current class name
  64176. * @returns the class name
  64177. */
  64178. getClassName(): string;
  64179. /**
  64180. * Gets the xy component
  64181. */
  64182. get xy(): NodeMaterialConnectionPoint;
  64183. /**
  64184. * Gets the x component
  64185. */
  64186. get x(): NodeMaterialConnectionPoint;
  64187. /**
  64188. * Gets the y component
  64189. */
  64190. get y(): NodeMaterialConnectionPoint;
  64191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64192. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64193. protected _buildBlock(state: NodeMaterialBuildState): this;
  64194. }
  64195. }
  64196. declare module BABYLON {
  64197. /**
  64198. * Block used to add support for scene fog
  64199. */
  64200. export class FogBlock extends NodeMaterialBlock {
  64201. private _fogDistanceName;
  64202. private _fogParameters;
  64203. /**
  64204. * Create a new FogBlock
  64205. * @param name defines the block name
  64206. */
  64207. constructor(name: string);
  64208. /**
  64209. * Gets the current class name
  64210. * @returns the class name
  64211. */
  64212. getClassName(): string;
  64213. /**
  64214. * Gets the world position input component
  64215. */
  64216. get worldPosition(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Gets the view input component
  64219. */
  64220. get view(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Gets the color input component
  64223. */
  64224. get input(): NodeMaterialConnectionPoint;
  64225. /**
  64226. * Gets the fog color input component
  64227. */
  64228. get fogColor(): NodeMaterialConnectionPoint;
  64229. /**
  64230. * Gets the output component
  64231. */
  64232. get output(): NodeMaterialConnectionPoint;
  64233. autoConfigure(material: NodeMaterial): void;
  64234. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64235. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64236. protected _buildBlock(state: NodeMaterialBuildState): this;
  64237. }
  64238. }
  64239. declare module BABYLON {
  64240. /**
  64241. * Block used to add light in the fragment shader
  64242. */
  64243. export class LightBlock extends NodeMaterialBlock {
  64244. private _lightId;
  64245. /**
  64246. * Gets or sets the light associated with this block
  64247. */
  64248. light: Nullable<Light>;
  64249. /**
  64250. * Create a new LightBlock
  64251. * @param name defines the block name
  64252. */
  64253. constructor(name: string);
  64254. /**
  64255. * Gets the current class name
  64256. * @returns the class name
  64257. */
  64258. getClassName(): string;
  64259. /**
  64260. * Gets the world position input component
  64261. */
  64262. get worldPosition(): NodeMaterialConnectionPoint;
  64263. /**
  64264. * Gets the world normal input component
  64265. */
  64266. get worldNormal(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the camera (or eye) position component
  64269. */
  64270. get cameraPosition(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the glossiness component
  64273. */
  64274. get glossiness(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the glossinness power component
  64277. */
  64278. get glossPower(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the diffuse color component
  64281. */
  64282. get diffuseColor(): NodeMaterialConnectionPoint;
  64283. /**
  64284. * Gets the specular color component
  64285. */
  64286. get specularColor(): NodeMaterialConnectionPoint;
  64287. /**
  64288. * Gets the view matrix component
  64289. */
  64290. get view(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the diffuse output component
  64293. */
  64294. get diffuseOutput(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the specular output component
  64297. */
  64298. get specularOutput(): NodeMaterialConnectionPoint;
  64299. /**
  64300. * Gets the shadow output component
  64301. */
  64302. get shadow(): NodeMaterialConnectionPoint;
  64303. autoConfigure(material: NodeMaterial): void;
  64304. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64305. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64306. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64307. private _injectVertexCode;
  64308. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64309. serialize(): any;
  64310. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64311. }
  64312. }
  64313. declare module BABYLON {
  64314. /**
  64315. * Block used to read a reflection texture from a sampler
  64316. */
  64317. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64318. /**
  64319. * Create a new ReflectionTextureBlock
  64320. * @param name defines the block name
  64321. */
  64322. constructor(name: string);
  64323. /**
  64324. * Gets the current class name
  64325. * @returns the class name
  64326. */
  64327. getClassName(): string;
  64328. /**
  64329. * Gets the world position input component
  64330. */
  64331. get position(): NodeMaterialConnectionPoint;
  64332. /**
  64333. * Gets the world position input component
  64334. */
  64335. get worldPosition(): NodeMaterialConnectionPoint;
  64336. /**
  64337. * Gets the world normal input component
  64338. */
  64339. get worldNormal(): NodeMaterialConnectionPoint;
  64340. /**
  64341. * Gets the world input component
  64342. */
  64343. get world(): NodeMaterialConnectionPoint;
  64344. /**
  64345. * Gets the camera (or eye) position component
  64346. */
  64347. get cameraPosition(): NodeMaterialConnectionPoint;
  64348. /**
  64349. * Gets the view input component
  64350. */
  64351. get view(): NodeMaterialConnectionPoint;
  64352. /**
  64353. * Gets the rgb output component
  64354. */
  64355. get rgb(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the rgba output component
  64358. */
  64359. get rgba(): NodeMaterialConnectionPoint;
  64360. /**
  64361. * Gets the r output component
  64362. */
  64363. get r(): NodeMaterialConnectionPoint;
  64364. /**
  64365. * Gets the g output component
  64366. */
  64367. get g(): NodeMaterialConnectionPoint;
  64368. /**
  64369. * Gets the b output component
  64370. */
  64371. get b(): NodeMaterialConnectionPoint;
  64372. /**
  64373. * Gets the a output component
  64374. */
  64375. get a(): NodeMaterialConnectionPoint;
  64376. autoConfigure(material: NodeMaterial): void;
  64377. protected _buildBlock(state: NodeMaterialBuildState): this;
  64378. }
  64379. }
  64380. declare module BABYLON {
  64381. /**
  64382. * Block used to add 2 vectors
  64383. */
  64384. export class AddBlock extends NodeMaterialBlock {
  64385. /**
  64386. * Creates a new AddBlock
  64387. * @param name defines the block name
  64388. */
  64389. constructor(name: string);
  64390. /**
  64391. * Gets the current class name
  64392. * @returns the class name
  64393. */
  64394. getClassName(): string;
  64395. /**
  64396. * Gets the left operand input component
  64397. */
  64398. get left(): NodeMaterialConnectionPoint;
  64399. /**
  64400. * Gets the right operand input component
  64401. */
  64402. get right(): NodeMaterialConnectionPoint;
  64403. /**
  64404. * Gets the output component
  64405. */
  64406. get output(): NodeMaterialConnectionPoint;
  64407. protected _buildBlock(state: NodeMaterialBuildState): this;
  64408. }
  64409. }
  64410. declare module BABYLON {
  64411. /**
  64412. * Block used to scale a vector by a float
  64413. */
  64414. export class ScaleBlock extends NodeMaterialBlock {
  64415. /**
  64416. * Creates a new ScaleBlock
  64417. * @param name defines the block name
  64418. */
  64419. constructor(name: string);
  64420. /**
  64421. * Gets the current class name
  64422. * @returns the class name
  64423. */
  64424. getClassName(): string;
  64425. /**
  64426. * Gets the input component
  64427. */
  64428. get input(): NodeMaterialConnectionPoint;
  64429. /**
  64430. * Gets the factor input component
  64431. */
  64432. get factor(): NodeMaterialConnectionPoint;
  64433. /**
  64434. * Gets the output component
  64435. */
  64436. get output(): NodeMaterialConnectionPoint;
  64437. protected _buildBlock(state: NodeMaterialBuildState): this;
  64438. }
  64439. }
  64440. declare module BABYLON {
  64441. /**
  64442. * Block used to clamp a float
  64443. */
  64444. export class ClampBlock extends NodeMaterialBlock {
  64445. /** Gets or sets the minimum range */
  64446. minimum: number;
  64447. /** Gets or sets the maximum range */
  64448. maximum: number;
  64449. /**
  64450. * Creates a new ClampBlock
  64451. * @param name defines the block name
  64452. */
  64453. constructor(name: string);
  64454. /**
  64455. * Gets the current class name
  64456. * @returns the class name
  64457. */
  64458. getClassName(): string;
  64459. /**
  64460. * Gets the value input component
  64461. */
  64462. get value(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the output component
  64465. */
  64466. get output(): NodeMaterialConnectionPoint;
  64467. protected _buildBlock(state: NodeMaterialBuildState): this;
  64468. protected _dumpPropertiesCode(): string;
  64469. serialize(): any;
  64470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64471. }
  64472. }
  64473. declare module BABYLON {
  64474. /**
  64475. * Block used to apply a cross product between 2 vectors
  64476. */
  64477. export class CrossBlock extends NodeMaterialBlock {
  64478. /**
  64479. * Creates a new CrossBlock
  64480. * @param name defines the block name
  64481. */
  64482. constructor(name: string);
  64483. /**
  64484. * Gets the current class name
  64485. * @returns the class name
  64486. */
  64487. getClassName(): string;
  64488. /**
  64489. * Gets the left operand input component
  64490. */
  64491. get left(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the right operand input component
  64494. */
  64495. get right(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the output component
  64498. */
  64499. get output(): NodeMaterialConnectionPoint;
  64500. protected _buildBlock(state: NodeMaterialBuildState): this;
  64501. }
  64502. }
  64503. declare module BABYLON {
  64504. /**
  64505. * Block used to apply a dot product between 2 vectors
  64506. */
  64507. export class DotBlock extends NodeMaterialBlock {
  64508. /**
  64509. * Creates a new DotBlock
  64510. * @param name defines the block name
  64511. */
  64512. constructor(name: string);
  64513. /**
  64514. * Gets the current class name
  64515. * @returns the class name
  64516. */
  64517. getClassName(): string;
  64518. /**
  64519. * Gets the left operand input component
  64520. */
  64521. get left(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the right operand input component
  64524. */
  64525. get right(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the output component
  64528. */
  64529. get output(): NodeMaterialConnectionPoint;
  64530. protected _buildBlock(state: NodeMaterialBuildState): this;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /**
  64535. * Block used to normalize a vector
  64536. */
  64537. export class NormalizeBlock extends NodeMaterialBlock {
  64538. /**
  64539. * Creates a new NormalizeBlock
  64540. * @param name defines the block name
  64541. */
  64542. constructor(name: string);
  64543. /**
  64544. * Gets the current class name
  64545. * @returns the class name
  64546. */
  64547. getClassName(): string;
  64548. /**
  64549. * Gets the input component
  64550. */
  64551. get input(): NodeMaterialConnectionPoint;
  64552. /**
  64553. * Gets the output component
  64554. */
  64555. get output(): NodeMaterialConnectionPoint;
  64556. protected _buildBlock(state: NodeMaterialBuildState): this;
  64557. }
  64558. }
  64559. declare module BABYLON {
  64560. /**
  64561. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64562. */
  64563. export class ColorMergerBlock extends NodeMaterialBlock {
  64564. /**
  64565. * Create a new ColorMergerBlock
  64566. * @param name defines the block name
  64567. */
  64568. constructor(name: string);
  64569. /**
  64570. * Gets the current class name
  64571. * @returns the class name
  64572. */
  64573. getClassName(): string;
  64574. /**
  64575. * Gets the rgb component (input)
  64576. */
  64577. get rgbIn(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the r component (input)
  64580. */
  64581. get r(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the g component (input)
  64584. */
  64585. get g(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the b component (input)
  64588. */
  64589. get b(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the a component (input)
  64592. */
  64593. get a(): NodeMaterialConnectionPoint;
  64594. /**
  64595. * Gets the rgba component (output)
  64596. */
  64597. get rgba(): NodeMaterialConnectionPoint;
  64598. /**
  64599. * Gets the rgb component (output)
  64600. */
  64601. get rgbOut(): NodeMaterialConnectionPoint;
  64602. /**
  64603. * Gets the rgb component (output)
  64604. * @deprecated Please use rgbOut instead.
  64605. */
  64606. get rgb(): NodeMaterialConnectionPoint;
  64607. protected _buildBlock(state: NodeMaterialBuildState): this;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /**
  64612. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64613. */
  64614. export class VectorSplitterBlock extends NodeMaterialBlock {
  64615. /**
  64616. * Create a new VectorSplitterBlock
  64617. * @param name defines the block name
  64618. */
  64619. constructor(name: string);
  64620. /**
  64621. * Gets the current class name
  64622. * @returns the class name
  64623. */
  64624. getClassName(): string;
  64625. /**
  64626. * Gets the xyzw component (input)
  64627. */
  64628. get xyzw(): NodeMaterialConnectionPoint;
  64629. /**
  64630. * Gets the xyz component (input)
  64631. */
  64632. get xyzIn(): NodeMaterialConnectionPoint;
  64633. /**
  64634. * Gets the xy component (input)
  64635. */
  64636. get xyIn(): NodeMaterialConnectionPoint;
  64637. /**
  64638. * Gets the xyz component (output)
  64639. */
  64640. get xyzOut(): NodeMaterialConnectionPoint;
  64641. /**
  64642. * Gets the xy component (output)
  64643. */
  64644. get xyOut(): NodeMaterialConnectionPoint;
  64645. /**
  64646. * Gets the x component (output)
  64647. */
  64648. get x(): NodeMaterialConnectionPoint;
  64649. /**
  64650. * Gets the y component (output)
  64651. */
  64652. get y(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the z component (output)
  64655. */
  64656. get z(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the w component (output)
  64659. */
  64660. get w(): NodeMaterialConnectionPoint;
  64661. protected _inputRename(name: string): string;
  64662. protected _outputRename(name: string): string;
  64663. protected _buildBlock(state: NodeMaterialBuildState): this;
  64664. }
  64665. }
  64666. declare module BABYLON {
  64667. /**
  64668. * Block used to lerp between 2 values
  64669. */
  64670. export class LerpBlock extends NodeMaterialBlock {
  64671. /**
  64672. * Creates a new LerpBlock
  64673. * @param name defines the block name
  64674. */
  64675. constructor(name: string);
  64676. /**
  64677. * Gets the current class name
  64678. * @returns the class name
  64679. */
  64680. getClassName(): string;
  64681. /**
  64682. * Gets the left operand input component
  64683. */
  64684. get left(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the right operand input component
  64687. */
  64688. get right(): NodeMaterialConnectionPoint;
  64689. /**
  64690. * Gets the gradient operand input component
  64691. */
  64692. get gradient(): NodeMaterialConnectionPoint;
  64693. /**
  64694. * Gets the output component
  64695. */
  64696. get output(): NodeMaterialConnectionPoint;
  64697. protected _buildBlock(state: NodeMaterialBuildState): this;
  64698. }
  64699. }
  64700. declare module BABYLON {
  64701. /**
  64702. * Block used to divide 2 vectors
  64703. */
  64704. export class DivideBlock extends NodeMaterialBlock {
  64705. /**
  64706. * Creates a new DivideBlock
  64707. * @param name defines the block name
  64708. */
  64709. constructor(name: string);
  64710. /**
  64711. * Gets the current class name
  64712. * @returns the class name
  64713. */
  64714. getClassName(): string;
  64715. /**
  64716. * Gets the left operand input component
  64717. */
  64718. get left(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the right operand input component
  64721. */
  64722. get right(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the output component
  64725. */
  64726. get output(): NodeMaterialConnectionPoint;
  64727. protected _buildBlock(state: NodeMaterialBuildState): this;
  64728. }
  64729. }
  64730. declare module BABYLON {
  64731. /**
  64732. * Block used to subtract 2 vectors
  64733. */
  64734. export class SubtractBlock extends NodeMaterialBlock {
  64735. /**
  64736. * Creates a new SubtractBlock
  64737. * @param name defines the block name
  64738. */
  64739. constructor(name: string);
  64740. /**
  64741. * Gets the current class name
  64742. * @returns the class name
  64743. */
  64744. getClassName(): string;
  64745. /**
  64746. * Gets the left operand input component
  64747. */
  64748. get left(): NodeMaterialConnectionPoint;
  64749. /**
  64750. * Gets the right operand input component
  64751. */
  64752. get right(): NodeMaterialConnectionPoint;
  64753. /**
  64754. * Gets the output component
  64755. */
  64756. get output(): NodeMaterialConnectionPoint;
  64757. protected _buildBlock(state: NodeMaterialBuildState): this;
  64758. }
  64759. }
  64760. declare module BABYLON {
  64761. /**
  64762. * Block used to step a value
  64763. */
  64764. export class StepBlock extends NodeMaterialBlock {
  64765. /**
  64766. * Creates a new StepBlock
  64767. * @param name defines the block name
  64768. */
  64769. constructor(name: string);
  64770. /**
  64771. * Gets the current class name
  64772. * @returns the class name
  64773. */
  64774. getClassName(): string;
  64775. /**
  64776. * Gets the value operand input component
  64777. */
  64778. get value(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the edge operand input component
  64781. */
  64782. get edge(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the output component
  64785. */
  64786. get output(): NodeMaterialConnectionPoint;
  64787. protected _buildBlock(state: NodeMaterialBuildState): this;
  64788. }
  64789. }
  64790. declare module BABYLON {
  64791. /**
  64792. * Block used to get the opposite (1 - x) of a value
  64793. */
  64794. export class OneMinusBlock extends NodeMaterialBlock {
  64795. /**
  64796. * Creates a new OneMinusBlock
  64797. * @param name defines the block name
  64798. */
  64799. constructor(name: string);
  64800. /**
  64801. * Gets the current class name
  64802. * @returns the class name
  64803. */
  64804. getClassName(): string;
  64805. /**
  64806. * Gets the input component
  64807. */
  64808. get input(): NodeMaterialConnectionPoint;
  64809. /**
  64810. * Gets the output component
  64811. */
  64812. get output(): NodeMaterialConnectionPoint;
  64813. protected _buildBlock(state: NodeMaterialBuildState): this;
  64814. }
  64815. }
  64816. declare module BABYLON {
  64817. /**
  64818. * Block used to get the view direction
  64819. */
  64820. export class ViewDirectionBlock extends NodeMaterialBlock {
  64821. /**
  64822. * Creates a new ViewDirectionBlock
  64823. * @param name defines the block name
  64824. */
  64825. constructor(name: string);
  64826. /**
  64827. * Gets the current class name
  64828. * @returns the class name
  64829. */
  64830. getClassName(): string;
  64831. /**
  64832. * Gets the world position component
  64833. */
  64834. get worldPosition(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the camera position component
  64837. */
  64838. get cameraPosition(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the output component
  64841. */
  64842. get output(): NodeMaterialConnectionPoint;
  64843. autoConfigure(material: NodeMaterial): void;
  64844. protected _buildBlock(state: NodeMaterialBuildState): this;
  64845. }
  64846. }
  64847. declare module BABYLON {
  64848. /**
  64849. * Block used to compute fresnel value
  64850. */
  64851. export class FresnelBlock extends NodeMaterialBlock {
  64852. /**
  64853. * Create a new FresnelBlock
  64854. * @param name defines the block name
  64855. */
  64856. constructor(name: string);
  64857. /**
  64858. * Gets the current class name
  64859. * @returns the class name
  64860. */
  64861. getClassName(): string;
  64862. /**
  64863. * Gets the world normal input component
  64864. */
  64865. get worldNormal(): NodeMaterialConnectionPoint;
  64866. /**
  64867. * Gets the view direction input component
  64868. */
  64869. get viewDirection(): NodeMaterialConnectionPoint;
  64870. /**
  64871. * Gets the bias input component
  64872. */
  64873. get bias(): NodeMaterialConnectionPoint;
  64874. /**
  64875. * Gets the camera (or eye) position component
  64876. */
  64877. get power(): NodeMaterialConnectionPoint;
  64878. /**
  64879. * Gets the fresnel output component
  64880. */
  64881. get fresnel(): NodeMaterialConnectionPoint;
  64882. autoConfigure(material: NodeMaterial): void;
  64883. protected _buildBlock(state: NodeMaterialBuildState): this;
  64884. }
  64885. }
  64886. declare module BABYLON {
  64887. /**
  64888. * Block used to get the max of 2 values
  64889. */
  64890. export class MaxBlock extends NodeMaterialBlock {
  64891. /**
  64892. * Creates a new MaxBlock
  64893. * @param name defines the block name
  64894. */
  64895. constructor(name: string);
  64896. /**
  64897. * Gets the current class name
  64898. * @returns the class name
  64899. */
  64900. getClassName(): string;
  64901. /**
  64902. * Gets the left operand input component
  64903. */
  64904. get left(): NodeMaterialConnectionPoint;
  64905. /**
  64906. * Gets the right operand input component
  64907. */
  64908. get right(): NodeMaterialConnectionPoint;
  64909. /**
  64910. * Gets the output component
  64911. */
  64912. get output(): NodeMaterialConnectionPoint;
  64913. protected _buildBlock(state: NodeMaterialBuildState): this;
  64914. }
  64915. }
  64916. declare module BABYLON {
  64917. /**
  64918. * Block used to get the min of 2 values
  64919. */
  64920. export class MinBlock extends NodeMaterialBlock {
  64921. /**
  64922. * Creates a new MinBlock
  64923. * @param name defines the block name
  64924. */
  64925. constructor(name: string);
  64926. /**
  64927. * Gets the current class name
  64928. * @returns the class name
  64929. */
  64930. getClassName(): string;
  64931. /**
  64932. * Gets the left operand input component
  64933. */
  64934. get left(): NodeMaterialConnectionPoint;
  64935. /**
  64936. * Gets the right operand input component
  64937. */
  64938. get right(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the output component
  64941. */
  64942. get output(): NodeMaterialConnectionPoint;
  64943. protected _buildBlock(state: NodeMaterialBuildState): this;
  64944. }
  64945. }
  64946. declare module BABYLON {
  64947. /**
  64948. * Block used to get the distance between 2 values
  64949. */
  64950. export class DistanceBlock extends NodeMaterialBlock {
  64951. /**
  64952. * Creates a new DistanceBlock
  64953. * @param name defines the block name
  64954. */
  64955. constructor(name: string);
  64956. /**
  64957. * Gets the current class name
  64958. * @returns the class name
  64959. */
  64960. getClassName(): string;
  64961. /**
  64962. * Gets the left operand input component
  64963. */
  64964. get left(): NodeMaterialConnectionPoint;
  64965. /**
  64966. * Gets the right operand input component
  64967. */
  64968. get right(): NodeMaterialConnectionPoint;
  64969. /**
  64970. * Gets the output component
  64971. */
  64972. get output(): NodeMaterialConnectionPoint;
  64973. protected _buildBlock(state: NodeMaterialBuildState): this;
  64974. }
  64975. }
  64976. declare module BABYLON {
  64977. /**
  64978. * Block used to get the length of a vector
  64979. */
  64980. export class LengthBlock extends NodeMaterialBlock {
  64981. /**
  64982. * Creates a new LengthBlock
  64983. * @param name defines the block name
  64984. */
  64985. constructor(name: string);
  64986. /**
  64987. * Gets the current class name
  64988. * @returns the class name
  64989. */
  64990. getClassName(): string;
  64991. /**
  64992. * Gets the value input component
  64993. */
  64994. get value(): NodeMaterialConnectionPoint;
  64995. /**
  64996. * Gets the output component
  64997. */
  64998. get output(): NodeMaterialConnectionPoint;
  64999. protected _buildBlock(state: NodeMaterialBuildState): this;
  65000. }
  65001. }
  65002. declare module BABYLON {
  65003. /**
  65004. * Block used to get negative version of a value (i.e. x * -1)
  65005. */
  65006. export class NegateBlock extends NodeMaterialBlock {
  65007. /**
  65008. * Creates a new NegateBlock
  65009. * @param name defines the block name
  65010. */
  65011. constructor(name: string);
  65012. /**
  65013. * Gets the current class name
  65014. * @returns the class name
  65015. */
  65016. getClassName(): string;
  65017. /**
  65018. * Gets the value input component
  65019. */
  65020. get value(): NodeMaterialConnectionPoint;
  65021. /**
  65022. * Gets the output component
  65023. */
  65024. get output(): NodeMaterialConnectionPoint;
  65025. protected _buildBlock(state: NodeMaterialBuildState): this;
  65026. }
  65027. }
  65028. declare module BABYLON {
  65029. /**
  65030. * Block used to get the value of the first parameter raised to the power of the second
  65031. */
  65032. export class PowBlock extends NodeMaterialBlock {
  65033. /**
  65034. * Creates a new PowBlock
  65035. * @param name defines the block name
  65036. */
  65037. constructor(name: string);
  65038. /**
  65039. * Gets the current class name
  65040. * @returns the class name
  65041. */
  65042. getClassName(): string;
  65043. /**
  65044. * Gets the value operand input component
  65045. */
  65046. get value(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the power operand input component
  65049. */
  65050. get power(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the output component
  65053. */
  65054. get output(): NodeMaterialConnectionPoint;
  65055. protected _buildBlock(state: NodeMaterialBuildState): this;
  65056. }
  65057. }
  65058. declare module BABYLON {
  65059. /**
  65060. * Block used to get a random number
  65061. */
  65062. export class RandomNumberBlock extends NodeMaterialBlock {
  65063. /**
  65064. * Creates a new RandomNumberBlock
  65065. * @param name defines the block name
  65066. */
  65067. constructor(name: string);
  65068. /**
  65069. * Gets the current class name
  65070. * @returns the class name
  65071. */
  65072. getClassName(): string;
  65073. /**
  65074. * Gets the seed input component
  65075. */
  65076. get seed(): NodeMaterialConnectionPoint;
  65077. /**
  65078. * Gets the output component
  65079. */
  65080. get output(): NodeMaterialConnectionPoint;
  65081. protected _buildBlock(state: NodeMaterialBuildState): this;
  65082. }
  65083. }
  65084. declare module BABYLON {
  65085. /**
  65086. * Block used to compute arc tangent of 2 values
  65087. */
  65088. export class ArcTan2Block extends NodeMaterialBlock {
  65089. /**
  65090. * Creates a new ArcTan2Block
  65091. * @param name defines the block name
  65092. */
  65093. constructor(name: string);
  65094. /**
  65095. * Gets the current class name
  65096. * @returns the class name
  65097. */
  65098. getClassName(): string;
  65099. /**
  65100. * Gets the x operand input component
  65101. */
  65102. get x(): NodeMaterialConnectionPoint;
  65103. /**
  65104. * Gets the y operand input component
  65105. */
  65106. get y(): NodeMaterialConnectionPoint;
  65107. /**
  65108. * Gets the output component
  65109. */
  65110. get output(): NodeMaterialConnectionPoint;
  65111. protected _buildBlock(state: NodeMaterialBuildState): this;
  65112. }
  65113. }
  65114. declare module BABYLON {
  65115. /**
  65116. * Block used to smooth step a value
  65117. */
  65118. export class SmoothStepBlock extends NodeMaterialBlock {
  65119. /**
  65120. * Creates a new SmoothStepBlock
  65121. * @param name defines the block name
  65122. */
  65123. constructor(name: string);
  65124. /**
  65125. * Gets the current class name
  65126. * @returns the class name
  65127. */
  65128. getClassName(): string;
  65129. /**
  65130. * Gets the value operand input component
  65131. */
  65132. get value(): NodeMaterialConnectionPoint;
  65133. /**
  65134. * Gets the first edge operand input component
  65135. */
  65136. get edge0(): NodeMaterialConnectionPoint;
  65137. /**
  65138. * Gets the second edge operand input component
  65139. */
  65140. get edge1(): NodeMaterialConnectionPoint;
  65141. /**
  65142. * Gets the output component
  65143. */
  65144. get output(): NodeMaterialConnectionPoint;
  65145. protected _buildBlock(state: NodeMaterialBuildState): this;
  65146. }
  65147. }
  65148. declare module BABYLON {
  65149. /**
  65150. * Block used to get the reciprocal (1 / x) of a value
  65151. */
  65152. export class ReciprocalBlock extends NodeMaterialBlock {
  65153. /**
  65154. * Creates a new ReciprocalBlock
  65155. * @param name defines the block name
  65156. */
  65157. constructor(name: string);
  65158. /**
  65159. * Gets the current class name
  65160. * @returns the class name
  65161. */
  65162. getClassName(): string;
  65163. /**
  65164. * Gets the input component
  65165. */
  65166. get input(): NodeMaterialConnectionPoint;
  65167. /**
  65168. * Gets the output component
  65169. */
  65170. get output(): NodeMaterialConnectionPoint;
  65171. protected _buildBlock(state: NodeMaterialBuildState): this;
  65172. }
  65173. }
  65174. declare module BABYLON {
  65175. /**
  65176. * Block used to replace a color by another one
  65177. */
  65178. export class ReplaceColorBlock extends NodeMaterialBlock {
  65179. /**
  65180. * Creates a new ReplaceColorBlock
  65181. * @param name defines the block name
  65182. */
  65183. constructor(name: string);
  65184. /**
  65185. * Gets the current class name
  65186. * @returns the class name
  65187. */
  65188. getClassName(): string;
  65189. /**
  65190. * Gets the value input component
  65191. */
  65192. get value(): NodeMaterialConnectionPoint;
  65193. /**
  65194. * Gets the reference input component
  65195. */
  65196. get reference(): NodeMaterialConnectionPoint;
  65197. /**
  65198. * Gets the distance input component
  65199. */
  65200. get distance(): NodeMaterialConnectionPoint;
  65201. /**
  65202. * Gets the replacement input component
  65203. */
  65204. get replacement(): NodeMaterialConnectionPoint;
  65205. /**
  65206. * Gets the output component
  65207. */
  65208. get output(): NodeMaterialConnectionPoint;
  65209. protected _buildBlock(state: NodeMaterialBuildState): this;
  65210. }
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Block used to posterize a value
  65215. * @see https://en.wikipedia.org/wiki/Posterization
  65216. */
  65217. export class PosterizeBlock extends NodeMaterialBlock {
  65218. /**
  65219. * Creates a new PosterizeBlock
  65220. * @param name defines the block name
  65221. */
  65222. constructor(name: string);
  65223. /**
  65224. * Gets the current class name
  65225. * @returns the class name
  65226. */
  65227. getClassName(): string;
  65228. /**
  65229. * Gets the value input component
  65230. */
  65231. get value(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the steps input component
  65234. */
  65235. get steps(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the output component
  65238. */
  65239. get output(): NodeMaterialConnectionPoint;
  65240. protected _buildBlock(state: NodeMaterialBuildState): this;
  65241. }
  65242. }
  65243. declare module BABYLON {
  65244. /**
  65245. * Operations supported by the Wave block
  65246. */
  65247. export enum WaveBlockKind {
  65248. /** SawTooth */
  65249. SawTooth = 0,
  65250. /** Square */
  65251. Square = 1,
  65252. /** Triangle */
  65253. Triangle = 2
  65254. }
  65255. /**
  65256. * Block used to apply wave operation to floats
  65257. */
  65258. export class WaveBlock extends NodeMaterialBlock {
  65259. /**
  65260. * Gets or sets the kibnd of wave to be applied by the block
  65261. */
  65262. kind: WaveBlockKind;
  65263. /**
  65264. * Creates a new WaveBlock
  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 input component
  65275. */
  65276. get input(): NodeMaterialConnectionPoint;
  65277. /**
  65278. * Gets the output component
  65279. */
  65280. get output(): NodeMaterialConnectionPoint;
  65281. protected _buildBlock(state: NodeMaterialBuildState): this;
  65282. serialize(): any;
  65283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65284. }
  65285. }
  65286. declare module BABYLON {
  65287. /**
  65288. * Class used to store a color step for the GradientBlock
  65289. */
  65290. export class GradientBlockColorStep {
  65291. private _step;
  65292. /**
  65293. * Gets value indicating which step this color is associated with (between 0 and 1)
  65294. */
  65295. get step(): number;
  65296. /**
  65297. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65298. */
  65299. set step(val: number);
  65300. private _color;
  65301. /**
  65302. * Gets the color associated with this step
  65303. */
  65304. get color(): Color3;
  65305. /**
  65306. * Sets the color associated with this step
  65307. */
  65308. set color(val: Color3);
  65309. /**
  65310. * Creates a new GradientBlockColorStep
  65311. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65312. * @param color defines the color associated with this step
  65313. */
  65314. constructor(step: number, color: Color3);
  65315. }
  65316. /**
  65317. * Block used to return a color from a gradient based on an input value between 0 and 1
  65318. */
  65319. export class GradientBlock extends NodeMaterialBlock {
  65320. /**
  65321. * Gets or sets the list of color steps
  65322. */
  65323. colorSteps: GradientBlockColorStep[];
  65324. /** Gets an observable raised when the value is changed */
  65325. onValueChangedObservable: Observable<GradientBlock>;
  65326. /** calls observable when the value is changed*/
  65327. colorStepsUpdated(): void;
  65328. /**
  65329. * Creates a new GradientBlock
  65330. * @param name defines the block name
  65331. */
  65332. constructor(name: string);
  65333. /**
  65334. * Gets the current class name
  65335. * @returns the class name
  65336. */
  65337. getClassName(): string;
  65338. /**
  65339. * Gets the gradient input component
  65340. */
  65341. get gradient(): NodeMaterialConnectionPoint;
  65342. /**
  65343. * Gets the output component
  65344. */
  65345. get output(): NodeMaterialConnectionPoint;
  65346. private _writeColorConstant;
  65347. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65348. serialize(): any;
  65349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65350. protected _dumpPropertiesCode(): string;
  65351. }
  65352. }
  65353. declare module BABYLON {
  65354. /**
  65355. * Block used to normalize lerp between 2 values
  65356. */
  65357. export class NLerpBlock extends NodeMaterialBlock {
  65358. /**
  65359. * Creates a new NLerpBlock
  65360. * @param name defines the block name
  65361. */
  65362. constructor(name: string);
  65363. /**
  65364. * Gets the current class name
  65365. * @returns the class name
  65366. */
  65367. getClassName(): string;
  65368. /**
  65369. * Gets the left operand input component
  65370. */
  65371. get left(): NodeMaterialConnectionPoint;
  65372. /**
  65373. * Gets the right operand input component
  65374. */
  65375. get right(): NodeMaterialConnectionPoint;
  65376. /**
  65377. * Gets the gradient operand input component
  65378. */
  65379. get gradient(): NodeMaterialConnectionPoint;
  65380. /**
  65381. * Gets the output component
  65382. */
  65383. get output(): NodeMaterialConnectionPoint;
  65384. protected _buildBlock(state: NodeMaterialBuildState): this;
  65385. }
  65386. }
  65387. declare module BABYLON {
  65388. /**
  65389. * block used to Generate a Worley Noise 3D Noise Pattern
  65390. */
  65391. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65392. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65393. manhattanDistance: boolean;
  65394. /**
  65395. * Creates a new WorleyNoise3DBlock
  65396. * @param name defines the block name
  65397. */
  65398. constructor(name: string);
  65399. /**
  65400. * Gets the current class name
  65401. * @returns the class name
  65402. */
  65403. getClassName(): string;
  65404. /**
  65405. * Gets the seed input component
  65406. */
  65407. get seed(): NodeMaterialConnectionPoint;
  65408. /**
  65409. * Gets the jitter input component
  65410. */
  65411. get jitter(): NodeMaterialConnectionPoint;
  65412. /**
  65413. * Gets the output component
  65414. */
  65415. get output(): NodeMaterialConnectionPoint;
  65416. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65417. /**
  65418. * Exposes the properties to the UI?
  65419. */
  65420. protected _dumpPropertiesCode(): string;
  65421. /**
  65422. * Exposes the properties to the Seralize?
  65423. */
  65424. serialize(): any;
  65425. /**
  65426. * Exposes the properties to the deseralize?
  65427. */
  65428. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65429. }
  65430. }
  65431. declare module BABYLON {
  65432. /**
  65433. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65434. */
  65435. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65436. /**
  65437. * Creates a new SimplexPerlin3DBlock
  65438. * @param name defines the block name
  65439. */
  65440. constructor(name: string);
  65441. /**
  65442. * Gets the current class name
  65443. * @returns the class name
  65444. */
  65445. getClassName(): string;
  65446. /**
  65447. * Gets the seed operand input component
  65448. */
  65449. get seed(): NodeMaterialConnectionPoint;
  65450. /**
  65451. * Gets the output component
  65452. */
  65453. get output(): NodeMaterialConnectionPoint;
  65454. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65455. }
  65456. }
  65457. declare module BABYLON {
  65458. /**
  65459. * Block used to blend normals
  65460. */
  65461. export class NormalBlendBlock extends NodeMaterialBlock {
  65462. /**
  65463. * Creates a new NormalBlendBlock
  65464. * @param name defines the block name
  65465. */
  65466. constructor(name: string);
  65467. /**
  65468. * Gets the current class name
  65469. * @returns the class name
  65470. */
  65471. getClassName(): string;
  65472. /**
  65473. * Gets the first input component
  65474. */
  65475. get normalMap0(): NodeMaterialConnectionPoint;
  65476. /**
  65477. * Gets the second input component
  65478. */
  65479. get normalMap1(): NodeMaterialConnectionPoint;
  65480. /**
  65481. * Gets the output component
  65482. */
  65483. get output(): NodeMaterialConnectionPoint;
  65484. protected _buildBlock(state: NodeMaterialBuildState): this;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. /**
  65489. * Block used to rotate a 2d vector by a given angle
  65490. */
  65491. export class Rotate2dBlock extends NodeMaterialBlock {
  65492. /**
  65493. * Creates a new Rotate2dBlock
  65494. * @param name defines the block name
  65495. */
  65496. constructor(name: string);
  65497. /**
  65498. * Gets the current class name
  65499. * @returns the class name
  65500. */
  65501. getClassName(): string;
  65502. /**
  65503. * Gets the input vector
  65504. */
  65505. get input(): NodeMaterialConnectionPoint;
  65506. /**
  65507. * Gets the input angle
  65508. */
  65509. get angle(): NodeMaterialConnectionPoint;
  65510. /**
  65511. * Gets the output component
  65512. */
  65513. get output(): NodeMaterialConnectionPoint;
  65514. autoConfigure(material: NodeMaterial): void;
  65515. protected _buildBlock(state: NodeMaterialBuildState): this;
  65516. }
  65517. }
  65518. declare module BABYLON {
  65519. /**
  65520. * Block used to get the reflected vector from a direction and a normal
  65521. */
  65522. export class ReflectBlock extends NodeMaterialBlock {
  65523. /**
  65524. * Creates a new ReflectBlock
  65525. * @param name defines the block name
  65526. */
  65527. constructor(name: string);
  65528. /**
  65529. * Gets the current class name
  65530. * @returns the class name
  65531. */
  65532. getClassName(): string;
  65533. /**
  65534. * Gets the incident component
  65535. */
  65536. get incident(): NodeMaterialConnectionPoint;
  65537. /**
  65538. * Gets the normal component
  65539. */
  65540. get normal(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the output component
  65543. */
  65544. get output(): NodeMaterialConnectionPoint;
  65545. protected _buildBlock(state: NodeMaterialBuildState): this;
  65546. }
  65547. }
  65548. declare module BABYLON {
  65549. /**
  65550. * Block used to get the refracted vector from a direction and a normal
  65551. */
  65552. export class RefractBlock extends NodeMaterialBlock {
  65553. /**
  65554. * Creates a new RefractBlock
  65555. * @param name defines the block name
  65556. */
  65557. constructor(name: string);
  65558. /**
  65559. * Gets the current class name
  65560. * @returns the class name
  65561. */
  65562. getClassName(): string;
  65563. /**
  65564. * Gets the incident component
  65565. */
  65566. get incident(): NodeMaterialConnectionPoint;
  65567. /**
  65568. * Gets the normal component
  65569. */
  65570. get normal(): NodeMaterialConnectionPoint;
  65571. /**
  65572. * Gets the index of refraction component
  65573. */
  65574. get ior(): NodeMaterialConnectionPoint;
  65575. /**
  65576. * Gets the output component
  65577. */
  65578. get output(): NodeMaterialConnectionPoint;
  65579. protected _buildBlock(state: NodeMaterialBuildState): this;
  65580. }
  65581. }
  65582. declare module BABYLON {
  65583. /**
  65584. * Block used to desaturate a color
  65585. */
  65586. export class DesaturateBlock extends NodeMaterialBlock {
  65587. /**
  65588. * Creates a new DesaturateBlock
  65589. * @param name defines the block name
  65590. */
  65591. constructor(name: string);
  65592. /**
  65593. * Gets the current class name
  65594. * @returns the class name
  65595. */
  65596. getClassName(): string;
  65597. /**
  65598. * Gets the color operand input component
  65599. */
  65600. get color(): NodeMaterialConnectionPoint;
  65601. /**
  65602. * Gets the level operand input component
  65603. */
  65604. get level(): NodeMaterialConnectionPoint;
  65605. /**
  65606. * Gets the output component
  65607. */
  65608. get output(): NodeMaterialConnectionPoint;
  65609. protected _buildBlock(state: NodeMaterialBuildState): this;
  65610. }
  65611. }
  65612. declare module BABYLON {
  65613. /**
  65614. * Block used to implement the reflection module of the PBR material
  65615. */
  65616. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65617. /** @hidden */
  65618. _defineLODReflectionAlpha: string;
  65619. /** @hidden */
  65620. _defineLinearSpecularReflection: string;
  65621. private _vEnvironmentIrradianceName;
  65622. /** @hidden */
  65623. _vReflectionMicrosurfaceInfosName: string;
  65624. /** @hidden */
  65625. _vReflectionInfosName: string;
  65626. /** @hidden */
  65627. _vReflectionFilteringInfoName: string;
  65628. private _scene;
  65629. /**
  65630. * The properties below are set by the main PBR block prior to calling methods of this class.
  65631. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65632. * It's less burden on the user side in the editor part.
  65633. */
  65634. /** @hidden */
  65635. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65636. /** @hidden */
  65637. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65638. /** @hidden */
  65639. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65640. /** @hidden */
  65641. viewConnectionPoint: NodeMaterialConnectionPoint;
  65642. /**
  65643. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65644. * diffuse part of the IBL.
  65645. */
  65646. useSphericalHarmonics: boolean;
  65647. /**
  65648. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65649. */
  65650. forceIrradianceInFragment: boolean;
  65651. /**
  65652. * Create a new ReflectionBlock
  65653. * @param name defines the block name
  65654. */
  65655. constructor(name: string);
  65656. /**
  65657. * Gets the current class name
  65658. * @returns the class name
  65659. */
  65660. getClassName(): string;
  65661. /**
  65662. * Gets the position input component
  65663. */
  65664. get position(): NodeMaterialConnectionPoint;
  65665. /**
  65666. * Gets the world position input component
  65667. */
  65668. get worldPosition(): NodeMaterialConnectionPoint;
  65669. /**
  65670. * Gets the world normal input component
  65671. */
  65672. get worldNormal(): NodeMaterialConnectionPoint;
  65673. /**
  65674. * Gets the world input component
  65675. */
  65676. get world(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the camera (or eye) position component
  65679. */
  65680. get cameraPosition(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the view input component
  65683. */
  65684. get view(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the color input component
  65687. */
  65688. get color(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the reflection object output component
  65691. */
  65692. get reflection(): NodeMaterialConnectionPoint;
  65693. /**
  65694. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65695. */
  65696. get hasTexture(): boolean;
  65697. /**
  65698. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65699. */
  65700. get reflectionColor(): string;
  65701. protected _getTexture(): Nullable<BaseTexture>;
  65702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65704. /**
  65705. * Gets the code to inject in the vertex shader
  65706. * @param state current state of the node material building
  65707. * @returns the shader code
  65708. */
  65709. handleVertexSide(state: NodeMaterialBuildState): string;
  65710. /**
  65711. * Gets the main code of the block (fragment side)
  65712. * @param state current state of the node material building
  65713. * @param normalVarName name of the existing variable corresponding to the normal
  65714. * @returns the shader code
  65715. */
  65716. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65717. protected _buildBlock(state: NodeMaterialBuildState): this;
  65718. protected _dumpPropertiesCode(): string;
  65719. serialize(): any;
  65720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65721. }
  65722. }
  65723. declare module BABYLON {
  65724. /**
  65725. * Block used to implement the sheen module of the PBR material
  65726. */
  65727. export class SheenBlock extends NodeMaterialBlock {
  65728. /**
  65729. * Create a new SheenBlock
  65730. * @param name defines the block name
  65731. */
  65732. constructor(name: string);
  65733. /**
  65734. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65735. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65736. * making it easier to setup and tweak the effect
  65737. */
  65738. albedoScaling: boolean;
  65739. /**
  65740. * Defines if the sheen is linked to the sheen color.
  65741. */
  65742. linkSheenWithAlbedo: boolean;
  65743. /**
  65744. * Initialize the block and prepare the context for build
  65745. * @param state defines the state that will be used for the build
  65746. */
  65747. initialize(state: NodeMaterialBuildState): void;
  65748. /**
  65749. * Gets the current class name
  65750. * @returns the class name
  65751. */
  65752. getClassName(): string;
  65753. /**
  65754. * Gets the intensity input component
  65755. */
  65756. get intensity(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the color input component
  65759. */
  65760. get color(): NodeMaterialConnectionPoint;
  65761. /**
  65762. * Gets the roughness input component
  65763. */
  65764. get roughness(): NodeMaterialConnectionPoint;
  65765. /**
  65766. * Gets the sheen object output component
  65767. */
  65768. get sheen(): NodeMaterialConnectionPoint;
  65769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65770. /**
  65771. * Gets the main code of the block (fragment side)
  65772. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65773. * @returns the shader code
  65774. */
  65775. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65776. protected _buildBlock(state: NodeMaterialBuildState): this;
  65777. protected _dumpPropertiesCode(): string;
  65778. serialize(): any;
  65779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65780. }
  65781. }
  65782. declare module BABYLON {
  65783. /**
  65784. * Block used to implement the anisotropy module of the PBR material
  65785. */
  65786. export class AnisotropyBlock extends NodeMaterialBlock {
  65787. /**
  65788. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65789. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65790. * It's less burden on the user side in the editor part.
  65791. */
  65792. /** @hidden */
  65793. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65794. /** @hidden */
  65795. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65796. /**
  65797. * Create a new AnisotropyBlock
  65798. * @param name defines the block name
  65799. */
  65800. constructor(name: string);
  65801. /**
  65802. * Initialize the block and prepare the context for build
  65803. * @param state defines the state that will be used for the build
  65804. */
  65805. initialize(state: NodeMaterialBuildState): void;
  65806. /**
  65807. * Gets the current class name
  65808. * @returns the class name
  65809. */
  65810. getClassName(): string;
  65811. /**
  65812. * Gets the intensity input component
  65813. */
  65814. get intensity(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the direction input component
  65817. */
  65818. get direction(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the uv input component
  65821. */
  65822. get uv(): NodeMaterialConnectionPoint;
  65823. /**
  65824. * Gets the worldTangent input component
  65825. */
  65826. get worldTangent(): NodeMaterialConnectionPoint;
  65827. /**
  65828. * Gets the anisotropy object output component
  65829. */
  65830. get anisotropy(): NodeMaterialConnectionPoint;
  65831. private _generateTBNSpace;
  65832. /**
  65833. * Gets the main code of the block (fragment side)
  65834. * @param state current state of the node material building
  65835. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65836. * @returns the shader code
  65837. */
  65838. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65839. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65840. protected _buildBlock(state: NodeMaterialBuildState): this;
  65841. }
  65842. }
  65843. declare module BABYLON {
  65844. /**
  65845. * Block used to implement the clear coat module of the PBR material
  65846. */
  65847. export class ClearCoatBlock extends NodeMaterialBlock {
  65848. private _scene;
  65849. /**
  65850. * Create a new ClearCoatBlock
  65851. * @param name defines the block name
  65852. */
  65853. constructor(name: string);
  65854. /**
  65855. * Defines if the F0 value should be remapped to account for the interface change in the material.
  65856. */
  65857. remapF0OnInterfaceChange: boolean;
  65858. /**
  65859. * Initialize the block and prepare the context for build
  65860. * @param state defines the state that will be used for the build
  65861. */
  65862. initialize(state: NodeMaterialBuildState): void;
  65863. /**
  65864. * Gets the current class name
  65865. * @returns the class name
  65866. */
  65867. getClassName(): string;
  65868. /**
  65869. * Gets the intensity input component
  65870. */
  65871. get intensity(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the roughness input component
  65874. */
  65875. get roughness(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the ior input component
  65878. */
  65879. get indexOfRefraction(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the bump texture input component
  65882. */
  65883. get normalMapColor(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the uv input component
  65886. */
  65887. get uv(): NodeMaterialConnectionPoint;
  65888. /**
  65889. * Gets the tint color input component
  65890. */
  65891. get tintColor(): NodeMaterialConnectionPoint;
  65892. /**
  65893. * Gets the tint "at distance" input component
  65894. */
  65895. get tintAtDistance(): NodeMaterialConnectionPoint;
  65896. /**
  65897. * Gets the tint thickness input component
  65898. */
  65899. get tintThickness(): NodeMaterialConnectionPoint;
  65900. /**
  65901. * Gets the world tangent input component
  65902. */
  65903. get worldTangent(): NodeMaterialConnectionPoint;
  65904. /**
  65905. * Gets the clear coat object output component
  65906. */
  65907. get clearcoat(): NodeMaterialConnectionPoint;
  65908. autoConfigure(material: NodeMaterial): void;
  65909. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65911. private _generateTBNSpace;
  65912. /**
  65913. * Gets the main code of the block (fragment side)
  65914. * @param state current state of the node material building
  65915. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65916. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65917. * @param worldPosVarName name of the variable holding the world position
  65918. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65919. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65920. * @param worldNormalVarName name of the variable holding the world normal
  65921. * @returns the shader code
  65922. */
  65923. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65924. protected _buildBlock(state: NodeMaterialBuildState): this;
  65925. protected _dumpPropertiesCode(): string;
  65926. serialize(): any;
  65927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65928. }
  65929. }
  65930. declare module BABYLON {
  65931. /**
  65932. * Block used to implement the sub surface module of the PBR material
  65933. */
  65934. export class SubSurfaceBlock extends NodeMaterialBlock {
  65935. /**
  65936. * Create a new SubSurfaceBlock
  65937. * @param name defines the block name
  65938. */
  65939. constructor(name: string);
  65940. /**
  65941. * Initialize the block and prepare the context for build
  65942. * @param state defines the state that will be used for the build
  65943. */
  65944. initialize(state: NodeMaterialBuildState): void;
  65945. /**
  65946. * Gets the current class name
  65947. * @returns the class name
  65948. */
  65949. getClassName(): string;
  65950. /**
  65951. * Gets the thickness component
  65952. */
  65953. get thickness(): NodeMaterialConnectionPoint;
  65954. /**
  65955. * Gets the tint color input component
  65956. */
  65957. get tintColor(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the translucency intensity input component
  65960. */
  65961. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the translucency diffusion distance input component
  65964. */
  65965. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the refraction object parameters
  65968. */
  65969. get refraction(): NodeMaterialConnectionPoint;
  65970. /**
  65971. * Gets the sub surface object output component
  65972. */
  65973. get subsurface(): NodeMaterialConnectionPoint;
  65974. autoConfigure(material: NodeMaterial): void;
  65975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65976. /**
  65977. * Gets the main code of the block (fragment side)
  65978. * @param state current state of the node material building
  65979. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65980. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65981. * @param worldPosVarName name of the variable holding the world position
  65982. * @returns the shader code
  65983. */
  65984. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65985. protected _buildBlock(state: NodeMaterialBuildState): this;
  65986. }
  65987. }
  65988. declare module BABYLON {
  65989. /**
  65990. * Block used to implement the PBR metallic/roughness model
  65991. */
  65992. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65993. /**
  65994. * Gets or sets the light associated with this block
  65995. */
  65996. light: Nullable<Light>;
  65997. private _lightId;
  65998. private _scene;
  65999. private _environmentBRDFTexture;
  66000. private _environmentBrdfSamplerName;
  66001. private _vNormalWName;
  66002. private _invertNormalName;
  66003. private _metallicReflectanceColor;
  66004. private _metallicF0Factor;
  66005. private _vMetallicReflectanceFactorsName;
  66006. /**
  66007. * Create a new ReflectionBlock
  66008. * @param name defines the block name
  66009. */
  66010. constructor(name: string);
  66011. /**
  66012. * Intensity of the direct lights e.g. the four lights available in your scene.
  66013. * This impacts both the direct diffuse and specular highlights.
  66014. */
  66015. directIntensity: number;
  66016. /**
  66017. * Intensity of the environment e.g. how much the environment will light the object
  66018. * either through harmonics for rough material or through the refelction for shiny ones.
  66019. */
  66020. environmentIntensity: number;
  66021. /**
  66022. * This is a special control allowing the reduction of the specular highlights coming from the
  66023. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66024. */
  66025. specularIntensity: number;
  66026. /**
  66027. * Defines the falloff type used in this material.
  66028. * It by default is Physical.
  66029. */
  66030. lightFalloff: number;
  66031. /**
  66032. * Specifies that alpha test should be used
  66033. */
  66034. useAlphaTest: boolean;
  66035. /**
  66036. * Defines the alpha limits in alpha test mode.
  66037. */
  66038. alphaTestCutoff: number;
  66039. /**
  66040. * Specifies that alpha blending should be used
  66041. */
  66042. useAlphaBlending: boolean;
  66043. /**
  66044. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66045. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66046. */
  66047. useRadianceOverAlpha: boolean;
  66048. /**
  66049. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66050. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66051. */
  66052. useSpecularOverAlpha: boolean;
  66053. /**
  66054. * Enables specular anti aliasing in the PBR shader.
  66055. * It will both interacts on the Geometry for analytical and IBL lighting.
  66056. * It also prefilter the roughness map based on the bump values.
  66057. */
  66058. enableSpecularAntiAliasing: boolean;
  66059. /**
  66060. * Enables realtime filtering on the texture.
  66061. */
  66062. realTimeFiltering: boolean;
  66063. /**
  66064. * Quality switch for realtime filtering
  66065. */
  66066. realTimeFilteringQuality: number;
  66067. /**
  66068. * Defines if the material uses energy conservation.
  66069. */
  66070. useEnergyConservation: boolean;
  66071. /**
  66072. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66073. * too much the area relying on ambient texture to define their ambient occlusion.
  66074. */
  66075. useRadianceOcclusion: boolean;
  66076. /**
  66077. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66078. * makes the reflect vector face the model (under horizon).
  66079. */
  66080. useHorizonOcclusion: boolean;
  66081. /**
  66082. * If set to true, no lighting calculations will be applied.
  66083. */
  66084. unlit: boolean;
  66085. /**
  66086. * Force normal to face away from face.
  66087. */
  66088. forceNormalForward: boolean;
  66089. /**
  66090. * Defines the material debug mode.
  66091. * It helps seeing only some components of the material while troubleshooting.
  66092. */
  66093. debugMode: number;
  66094. /**
  66095. * Specify from where on screen the debug mode should start.
  66096. * The value goes from -1 (full screen) to 1 (not visible)
  66097. * It helps with side by side comparison against the final render
  66098. * This defaults to 0
  66099. */
  66100. debugLimit: number;
  66101. /**
  66102. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66103. * You can use the factor to better multiply the final value.
  66104. */
  66105. debugFactor: number;
  66106. /**
  66107. * Initialize the block and prepare the context for build
  66108. * @param state defines the state that will be used for the build
  66109. */
  66110. initialize(state: NodeMaterialBuildState): void;
  66111. /**
  66112. * Gets the current class name
  66113. * @returns the class name
  66114. */
  66115. getClassName(): string;
  66116. /**
  66117. * Gets the world position input component
  66118. */
  66119. get worldPosition(): NodeMaterialConnectionPoint;
  66120. /**
  66121. * Gets the world normal input component
  66122. */
  66123. get worldNormal(): NodeMaterialConnectionPoint;
  66124. /**
  66125. * Gets the view matrix parameter
  66126. */
  66127. get view(): NodeMaterialConnectionPoint;
  66128. /**
  66129. * Gets the camera position input component
  66130. */
  66131. get cameraPosition(): NodeMaterialConnectionPoint;
  66132. /**
  66133. * Gets the perturbed normal input component
  66134. */
  66135. get perturbedNormal(): NodeMaterialConnectionPoint;
  66136. /**
  66137. * Gets the base color input component
  66138. */
  66139. get baseColor(): NodeMaterialConnectionPoint;
  66140. /**
  66141. * Gets the metallic input component
  66142. */
  66143. get metallic(): NodeMaterialConnectionPoint;
  66144. /**
  66145. * Gets the roughness input component
  66146. */
  66147. get roughness(): NodeMaterialConnectionPoint;
  66148. /**
  66149. * Gets the ambient occlusion input component
  66150. */
  66151. get ambientOcc(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the opacity input component
  66154. */
  66155. get opacity(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the index of refraction input component
  66158. */
  66159. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66160. /**
  66161. * Gets the ambient color input component
  66162. */
  66163. get ambientColor(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the reflection object parameters
  66166. */
  66167. get reflection(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the clear coat object parameters
  66170. */
  66171. get clearcoat(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the sheen object parameters
  66174. */
  66175. get sheen(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the sub surface object parameters
  66178. */
  66179. get subsurface(): NodeMaterialConnectionPoint;
  66180. /**
  66181. * Gets the anisotropy object parameters
  66182. */
  66183. get anisotropy(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the ambient output component
  66186. */
  66187. get ambientClr(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the diffuse output component
  66190. */
  66191. get diffuseDir(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the specular output component
  66194. */
  66195. get specularDir(): NodeMaterialConnectionPoint;
  66196. /**
  66197. * Gets the clear coat output component
  66198. */
  66199. get clearcoatDir(): NodeMaterialConnectionPoint;
  66200. /**
  66201. * Gets the sheen output component
  66202. */
  66203. get sheenDir(): NodeMaterialConnectionPoint;
  66204. /**
  66205. * Gets the indirect diffuse output component
  66206. */
  66207. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66208. /**
  66209. * Gets the indirect specular output component
  66210. */
  66211. get specularIndirect(): NodeMaterialConnectionPoint;
  66212. /**
  66213. * Gets the indirect clear coat output component
  66214. */
  66215. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66216. /**
  66217. * Gets the indirect sheen output component
  66218. */
  66219. get sheenIndirect(): NodeMaterialConnectionPoint;
  66220. /**
  66221. * Gets the refraction output component
  66222. */
  66223. get refraction(): NodeMaterialConnectionPoint;
  66224. /**
  66225. * Gets the global lighting output component
  66226. */
  66227. get lighting(): NodeMaterialConnectionPoint;
  66228. /**
  66229. * Gets the shadow output component
  66230. */
  66231. get shadow(): NodeMaterialConnectionPoint;
  66232. /**
  66233. * Gets the alpha output component
  66234. */
  66235. get alpha(): NodeMaterialConnectionPoint;
  66236. autoConfigure(material: NodeMaterial): void;
  66237. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66238. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66240. private _injectVertexCode;
  66241. private _getAlbedoOpacityCode;
  66242. private _getAmbientOcclusionCode;
  66243. private _getReflectivityCode;
  66244. protected _buildBlock(state: NodeMaterialBuildState): this;
  66245. protected _dumpPropertiesCode(): string;
  66246. serialize(): any;
  66247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66248. }
  66249. }
  66250. declare module BABYLON {
  66251. /**
  66252. * Block used to compute value of one parameter modulo another
  66253. */
  66254. export class ModBlock extends NodeMaterialBlock {
  66255. /**
  66256. * Creates a new ModBlock
  66257. * @param name defines the block name
  66258. */
  66259. constructor(name: string);
  66260. /**
  66261. * Gets the current class name
  66262. * @returns the class name
  66263. */
  66264. getClassName(): string;
  66265. /**
  66266. * Gets the left operand input component
  66267. */
  66268. get left(): NodeMaterialConnectionPoint;
  66269. /**
  66270. * Gets the right operand input component
  66271. */
  66272. get right(): NodeMaterialConnectionPoint;
  66273. /**
  66274. * Gets the output component
  66275. */
  66276. get output(): NodeMaterialConnectionPoint;
  66277. protected _buildBlock(state: NodeMaterialBuildState): this;
  66278. }
  66279. }
  66280. declare module BABYLON {
  66281. /**
  66282. * Configuration for Draco compression
  66283. */
  66284. export interface IDracoCompressionConfiguration {
  66285. /**
  66286. * Configuration for the decoder.
  66287. */
  66288. decoder: {
  66289. /**
  66290. * The url to the WebAssembly module.
  66291. */
  66292. wasmUrl?: string;
  66293. /**
  66294. * The url to the WebAssembly binary.
  66295. */
  66296. wasmBinaryUrl?: string;
  66297. /**
  66298. * The url to the fallback JavaScript module.
  66299. */
  66300. fallbackUrl?: string;
  66301. };
  66302. }
  66303. /**
  66304. * Draco compression (https://google.github.io/draco/)
  66305. *
  66306. * This class wraps the Draco module.
  66307. *
  66308. * **Encoder**
  66309. *
  66310. * The encoder is not currently implemented.
  66311. *
  66312. * **Decoder**
  66313. *
  66314. * 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.
  66315. *
  66316. * To update the configuration, use the following code:
  66317. * ```javascript
  66318. * DracoCompression.Configuration = {
  66319. * decoder: {
  66320. * wasmUrl: "<url to the WebAssembly library>",
  66321. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66322. * fallbackUrl: "<url to the fallback JavaScript library>",
  66323. * }
  66324. * };
  66325. * ```
  66326. *
  66327. * 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.
  66328. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66329. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66330. *
  66331. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66332. * ```javascript
  66333. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66334. * ```
  66335. *
  66336. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66337. */
  66338. export class DracoCompression implements IDisposable {
  66339. private _workerPoolPromise?;
  66340. private _decoderModulePromise?;
  66341. /**
  66342. * The configuration. Defaults to the following urls:
  66343. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66344. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66345. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66346. */
  66347. static Configuration: IDracoCompressionConfiguration;
  66348. /**
  66349. * Returns true if the decoder configuration is available.
  66350. */
  66351. static get DecoderAvailable(): boolean;
  66352. /**
  66353. * Default number of workers to create when creating the draco compression object.
  66354. */
  66355. static DefaultNumWorkers: number;
  66356. private static GetDefaultNumWorkers;
  66357. private static _Default;
  66358. /**
  66359. * Default instance for the draco compression object.
  66360. */
  66361. static get Default(): DracoCompression;
  66362. /**
  66363. * Constructor
  66364. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66365. */
  66366. constructor(numWorkers?: number);
  66367. /**
  66368. * Stop all async operations and release resources.
  66369. */
  66370. dispose(): void;
  66371. /**
  66372. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66373. * @returns a promise that resolves when ready
  66374. */
  66375. whenReadyAsync(): Promise<void>;
  66376. /**
  66377. * Decode Draco compressed mesh data to vertex data.
  66378. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66379. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66380. * @returns A promise that resolves with the decoded vertex data
  66381. */
  66382. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66383. [kind: string]: number;
  66384. }): Promise<VertexData>;
  66385. }
  66386. }
  66387. declare module BABYLON {
  66388. /**
  66389. * Class for building Constructive Solid Geometry
  66390. */
  66391. export class CSG {
  66392. private polygons;
  66393. /**
  66394. * The world matrix
  66395. */
  66396. matrix: Matrix;
  66397. /**
  66398. * Stores the position
  66399. */
  66400. position: Vector3;
  66401. /**
  66402. * Stores the rotation
  66403. */
  66404. rotation: Vector3;
  66405. /**
  66406. * Stores the rotation quaternion
  66407. */
  66408. rotationQuaternion: Nullable<Quaternion>;
  66409. /**
  66410. * Stores the scaling vector
  66411. */
  66412. scaling: Vector3;
  66413. /**
  66414. * Convert the Mesh to CSG
  66415. * @param mesh The Mesh to convert to CSG
  66416. * @returns A new CSG from the Mesh
  66417. */
  66418. static FromMesh(mesh: Mesh): CSG;
  66419. /**
  66420. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66421. * @param polygons Polygons used to construct a CSG solid
  66422. */
  66423. private static FromPolygons;
  66424. /**
  66425. * Clones, or makes a deep copy, of the CSG
  66426. * @returns A new CSG
  66427. */
  66428. clone(): CSG;
  66429. /**
  66430. * Unions this CSG with another CSG
  66431. * @param csg The CSG to union against this CSG
  66432. * @returns The unioned CSG
  66433. */
  66434. union(csg: CSG): CSG;
  66435. /**
  66436. * Unions this CSG with another CSG in place
  66437. * @param csg The CSG to union against this CSG
  66438. */
  66439. unionInPlace(csg: CSG): void;
  66440. /**
  66441. * Subtracts this CSG with another CSG
  66442. * @param csg The CSG to subtract against this CSG
  66443. * @returns A new CSG
  66444. */
  66445. subtract(csg: CSG): CSG;
  66446. /**
  66447. * Subtracts this CSG with another CSG in place
  66448. * @param csg The CSG to subtact against this CSG
  66449. */
  66450. subtractInPlace(csg: CSG): void;
  66451. /**
  66452. * Intersect this CSG with another CSG
  66453. * @param csg The CSG to intersect against this CSG
  66454. * @returns A new CSG
  66455. */
  66456. intersect(csg: CSG): CSG;
  66457. /**
  66458. * Intersects this CSG with another CSG in place
  66459. * @param csg The CSG to intersect against this CSG
  66460. */
  66461. intersectInPlace(csg: CSG): void;
  66462. /**
  66463. * Return a new CSG solid with solid and empty space switched. This solid is
  66464. * not modified.
  66465. * @returns A new CSG solid with solid and empty space switched
  66466. */
  66467. inverse(): CSG;
  66468. /**
  66469. * Inverses the CSG in place
  66470. */
  66471. inverseInPlace(): void;
  66472. /**
  66473. * This is used to keep meshes transformations so they can be restored
  66474. * when we build back a Babylon Mesh
  66475. * NB : All CSG operations are performed in world coordinates
  66476. * @param csg The CSG to copy the transform attributes from
  66477. * @returns This CSG
  66478. */
  66479. copyTransformAttributes(csg: CSG): CSG;
  66480. /**
  66481. * Build Raw mesh from CSG
  66482. * Coordinates here are in world space
  66483. * @param name The name of the mesh geometry
  66484. * @param scene The Scene
  66485. * @param keepSubMeshes Specifies if the submeshes should be kept
  66486. * @returns A new Mesh
  66487. */
  66488. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66489. /**
  66490. * Build Mesh from CSG taking material and transforms into account
  66491. * @param name The name of the Mesh
  66492. * @param material The material of the Mesh
  66493. * @param scene The Scene
  66494. * @param keepSubMeshes Specifies if submeshes should be kept
  66495. * @returns The new Mesh
  66496. */
  66497. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66498. }
  66499. }
  66500. declare module BABYLON {
  66501. /**
  66502. * Class used to create a trail following a mesh
  66503. */
  66504. export class TrailMesh extends Mesh {
  66505. private _generator;
  66506. private _autoStart;
  66507. private _running;
  66508. private _diameter;
  66509. private _length;
  66510. private _sectionPolygonPointsCount;
  66511. private _sectionVectors;
  66512. private _sectionNormalVectors;
  66513. private _beforeRenderObserver;
  66514. /**
  66515. * @constructor
  66516. * @param name The value used by scene.getMeshByName() to do a lookup.
  66517. * @param generator The mesh or transform node to generate a trail.
  66518. * @param scene The scene to add this mesh to.
  66519. * @param diameter Diameter of trailing mesh. Default is 1.
  66520. * @param length Length of trailing mesh. Default is 60.
  66521. * @param autoStart Automatically start trailing mesh. Default true.
  66522. */
  66523. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66524. /**
  66525. * "TrailMesh"
  66526. * @returns "TrailMesh"
  66527. */
  66528. getClassName(): string;
  66529. private _createMesh;
  66530. /**
  66531. * Start trailing mesh.
  66532. */
  66533. start(): void;
  66534. /**
  66535. * Stop trailing mesh.
  66536. */
  66537. stop(): void;
  66538. /**
  66539. * Update trailing mesh geometry.
  66540. */
  66541. update(): void;
  66542. /**
  66543. * Returns a new TrailMesh object.
  66544. * @param name is a string, the name given to the new mesh
  66545. * @param newGenerator use new generator object for cloned trail mesh
  66546. * @returns a new mesh
  66547. */
  66548. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66549. /**
  66550. * Serializes this trail mesh
  66551. * @param serializationObject object to write serialization to
  66552. */
  66553. serialize(serializationObject: any): void;
  66554. /**
  66555. * Parses a serialized trail mesh
  66556. * @param parsedMesh the serialized mesh
  66557. * @param scene the scene to create the trail mesh in
  66558. * @returns the created trail mesh
  66559. */
  66560. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66561. }
  66562. }
  66563. declare module BABYLON {
  66564. /**
  66565. * Class containing static functions to help procedurally build meshes
  66566. */
  66567. export class TiledBoxBuilder {
  66568. /**
  66569. * Creates a box mesh
  66570. * 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)
  66571. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66573. * * 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
  66574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66575. * @param name defines the name of the mesh
  66576. * @param options defines the options used to create the mesh
  66577. * @param scene defines the hosting scene
  66578. * @returns the box mesh
  66579. */
  66580. static CreateTiledBox(name: string, options: {
  66581. pattern?: number;
  66582. width?: number;
  66583. height?: number;
  66584. depth?: number;
  66585. tileSize?: number;
  66586. tileWidth?: number;
  66587. tileHeight?: number;
  66588. alignHorizontal?: number;
  66589. alignVertical?: number;
  66590. faceUV?: Vector4[];
  66591. faceColors?: Color4[];
  66592. sideOrientation?: number;
  66593. updatable?: boolean;
  66594. }, scene?: Nullable<Scene>): Mesh;
  66595. }
  66596. }
  66597. declare module BABYLON {
  66598. /**
  66599. * Class containing static functions to help procedurally build meshes
  66600. */
  66601. export class TorusKnotBuilder {
  66602. /**
  66603. * Creates a torus knot mesh
  66604. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66605. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66606. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66607. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66609. * * 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
  66610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66611. * @param name defines the name of the mesh
  66612. * @param options defines the options used to create the mesh
  66613. * @param scene defines the hosting scene
  66614. * @returns the torus knot mesh
  66615. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66616. */
  66617. static CreateTorusKnot(name: string, options: {
  66618. radius?: number;
  66619. tube?: number;
  66620. radialSegments?: number;
  66621. tubularSegments?: number;
  66622. p?: number;
  66623. q?: number;
  66624. updatable?: boolean;
  66625. sideOrientation?: number;
  66626. frontUVs?: Vector4;
  66627. backUVs?: Vector4;
  66628. }, scene: any): Mesh;
  66629. }
  66630. }
  66631. declare module BABYLON {
  66632. /**
  66633. * Polygon
  66634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66635. */
  66636. export class Polygon {
  66637. /**
  66638. * Creates a rectangle
  66639. * @param xmin bottom X coord
  66640. * @param ymin bottom Y coord
  66641. * @param xmax top X coord
  66642. * @param ymax top Y coord
  66643. * @returns points that make the resulting rectation
  66644. */
  66645. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66646. /**
  66647. * Creates a circle
  66648. * @param radius radius of circle
  66649. * @param cx scale in x
  66650. * @param cy scale in y
  66651. * @param numberOfSides number of sides that make up the circle
  66652. * @returns points that make the resulting circle
  66653. */
  66654. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66655. /**
  66656. * Creates a polygon from input string
  66657. * @param input Input polygon data
  66658. * @returns the parsed points
  66659. */
  66660. static Parse(input: string): Vector2[];
  66661. /**
  66662. * Starts building a polygon from x and y coordinates
  66663. * @param x x coordinate
  66664. * @param y y coordinate
  66665. * @returns the started path2
  66666. */
  66667. static StartingAt(x: number, y: number): Path2;
  66668. }
  66669. /**
  66670. * Builds a polygon
  66671. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66672. */
  66673. export class PolygonMeshBuilder {
  66674. private _points;
  66675. private _outlinepoints;
  66676. private _holes;
  66677. private _name;
  66678. private _scene;
  66679. private _epoints;
  66680. private _eholes;
  66681. private _addToepoint;
  66682. /**
  66683. * Babylon reference to the earcut plugin.
  66684. */
  66685. bjsEarcut: any;
  66686. /**
  66687. * Creates a PolygonMeshBuilder
  66688. * @param name name of the builder
  66689. * @param contours Path of the polygon
  66690. * @param scene scene to add to when creating the mesh
  66691. * @param earcutInjection can be used to inject your own earcut reference
  66692. */
  66693. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66694. /**
  66695. * Adds a whole within the polygon
  66696. * @param hole Array of points defining the hole
  66697. * @returns this
  66698. */
  66699. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66700. /**
  66701. * Creates the polygon
  66702. * @param updatable If the mesh should be updatable
  66703. * @param depth The depth of the mesh created
  66704. * @returns the created mesh
  66705. */
  66706. build(updatable?: boolean, depth?: number): Mesh;
  66707. /**
  66708. * Creates the polygon
  66709. * @param depth The depth of the mesh created
  66710. * @returns the created VertexData
  66711. */
  66712. buildVertexData(depth?: number): VertexData;
  66713. /**
  66714. * Adds a side to the polygon
  66715. * @param positions points that make the polygon
  66716. * @param normals normals of the polygon
  66717. * @param uvs uvs of the polygon
  66718. * @param indices indices of the polygon
  66719. * @param bounds bounds of the polygon
  66720. * @param points points of the polygon
  66721. * @param depth depth of the polygon
  66722. * @param flip flip of the polygon
  66723. */
  66724. private addSide;
  66725. }
  66726. }
  66727. declare module BABYLON {
  66728. /**
  66729. * Class containing static functions to help procedurally build meshes
  66730. */
  66731. export class PolygonBuilder {
  66732. /**
  66733. * Creates a polygon mesh
  66734. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66735. * * 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
  66736. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66738. * * 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)
  66739. * * Remember you can only change the shape positions, not their number when updating a polygon
  66740. * @param name defines the name of the mesh
  66741. * @param options defines the options used to create the mesh
  66742. * @param scene defines the hosting scene
  66743. * @param earcutInjection can be used to inject your own earcut reference
  66744. * @returns the polygon mesh
  66745. */
  66746. static CreatePolygon(name: string, options: {
  66747. shape: Vector3[];
  66748. holes?: Vector3[][];
  66749. depth?: number;
  66750. faceUV?: Vector4[];
  66751. faceColors?: Color4[];
  66752. updatable?: boolean;
  66753. sideOrientation?: number;
  66754. frontUVs?: Vector4;
  66755. backUVs?: Vector4;
  66756. wrap?: boolean;
  66757. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66758. /**
  66759. * Creates an extruded polygon mesh, with depth in the Y direction.
  66760. * * 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)
  66761. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66762. * @param name defines the name of the mesh
  66763. * @param options defines the options used to create the mesh
  66764. * @param scene defines the hosting scene
  66765. * @param earcutInjection can be used to inject your own earcut reference
  66766. * @returns the polygon mesh
  66767. */
  66768. static ExtrudePolygon(name: string, options: {
  66769. shape: Vector3[];
  66770. holes?: Vector3[][];
  66771. depth?: number;
  66772. faceUV?: Vector4[];
  66773. faceColors?: Color4[];
  66774. updatable?: boolean;
  66775. sideOrientation?: number;
  66776. frontUVs?: Vector4;
  66777. backUVs?: Vector4;
  66778. wrap?: boolean;
  66779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66780. }
  66781. }
  66782. declare module BABYLON {
  66783. /**
  66784. * Class containing static functions to help procedurally build meshes
  66785. */
  66786. export class LatheBuilder {
  66787. /**
  66788. * Creates lathe mesh.
  66789. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66790. * * 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
  66791. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66792. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66793. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66794. * * 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
  66795. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66796. * * 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
  66797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66798. * * 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
  66799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66801. * @param name defines the name of the mesh
  66802. * @param options defines the options used to create the mesh
  66803. * @param scene defines the hosting scene
  66804. * @returns the lathe mesh
  66805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66806. */
  66807. static CreateLathe(name: string, options: {
  66808. shape: Vector3[];
  66809. radius?: number;
  66810. tessellation?: number;
  66811. clip?: number;
  66812. arc?: number;
  66813. closed?: boolean;
  66814. updatable?: boolean;
  66815. sideOrientation?: number;
  66816. frontUVs?: Vector4;
  66817. backUVs?: Vector4;
  66818. cap?: number;
  66819. invertUV?: boolean;
  66820. }, scene?: Nullable<Scene>): Mesh;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * Class containing static functions to help procedurally build meshes
  66826. */
  66827. export class TiledPlaneBuilder {
  66828. /**
  66829. * Creates a tiled plane mesh
  66830. * * The parameter `pattern` will, depending on value, do nothing or
  66831. * * * flip (reflect about central vertical) alternate tiles across and up
  66832. * * * flip every tile on alternate rows
  66833. * * * rotate (180 degs) alternate tiles across and up
  66834. * * * rotate every tile on alternate rows
  66835. * * * flip and rotate alternate tiles across and up
  66836. * * * flip and rotate every tile on alternate rows
  66837. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66838. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66839. * * 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
  66840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66841. * * 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)
  66842. * * 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)
  66843. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66844. * @param name defines the name of the mesh
  66845. * @param options defines the options used to create the mesh
  66846. * @param scene defines the hosting scene
  66847. * @returns the box mesh
  66848. */
  66849. static CreateTiledPlane(name: string, options: {
  66850. pattern?: number;
  66851. tileSize?: number;
  66852. tileWidth?: number;
  66853. tileHeight?: number;
  66854. size?: number;
  66855. width?: number;
  66856. height?: number;
  66857. alignHorizontal?: number;
  66858. alignVertical?: number;
  66859. sideOrientation?: number;
  66860. frontUVs?: Vector4;
  66861. backUVs?: Vector4;
  66862. updatable?: boolean;
  66863. }, scene?: Nullable<Scene>): Mesh;
  66864. }
  66865. }
  66866. declare module BABYLON {
  66867. /**
  66868. * Class containing static functions to help procedurally build meshes
  66869. */
  66870. export class TubeBuilder {
  66871. /**
  66872. * Creates a tube mesh.
  66873. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66874. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66875. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66876. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66877. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66878. * * 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)
  66879. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66880. * * 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
  66881. * * 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
  66882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66883. * * 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
  66884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66886. * @param name defines the name of the mesh
  66887. * @param options defines the options used to create the mesh
  66888. * @param scene defines the hosting scene
  66889. * @returns the tube mesh
  66890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66891. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66892. */
  66893. static CreateTube(name: string, options: {
  66894. path: Vector3[];
  66895. radius?: number;
  66896. tessellation?: number;
  66897. radiusFunction?: {
  66898. (i: number, distance: number): number;
  66899. };
  66900. cap?: number;
  66901. arc?: number;
  66902. updatable?: boolean;
  66903. sideOrientation?: number;
  66904. frontUVs?: Vector4;
  66905. backUVs?: Vector4;
  66906. instance?: Mesh;
  66907. invertUV?: 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 IcoSphereBuilder {
  66916. /**
  66917. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66918. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66919. * * 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`)
  66920. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66921. * * 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
  66922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66923. * * 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
  66924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66925. * @param name defines the name of the mesh
  66926. * @param options defines the options used to create the mesh
  66927. * @param scene defines the hosting scene
  66928. * @returns the icosahedron mesh
  66929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66930. */
  66931. static CreateIcoSphere(name: string, options: {
  66932. radius?: number;
  66933. radiusX?: number;
  66934. radiusY?: number;
  66935. radiusZ?: number;
  66936. flat?: boolean;
  66937. subdivisions?: number;
  66938. sideOrientation?: number;
  66939. frontUVs?: Vector4;
  66940. backUVs?: Vector4;
  66941. updatable?: boolean;
  66942. }, scene?: Nullable<Scene>): Mesh;
  66943. }
  66944. }
  66945. declare module BABYLON {
  66946. /**
  66947. * Class containing static functions to help procedurally build meshes
  66948. */
  66949. export class DecalBuilder {
  66950. /**
  66951. * Creates a decal mesh.
  66952. * 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
  66953. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66954. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66955. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66956. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66957. * @param name defines the name of the mesh
  66958. * @param sourceMesh defines the mesh where the decal must be applied
  66959. * @param options defines the options used to create the mesh
  66960. * @param scene defines the hosting scene
  66961. * @returns the decal mesh
  66962. * @see https://doc.babylonjs.com/how_to/decals
  66963. */
  66964. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66965. position?: Vector3;
  66966. normal?: Vector3;
  66967. size?: Vector3;
  66968. angle?: number;
  66969. }): Mesh;
  66970. }
  66971. }
  66972. declare module BABYLON {
  66973. /**
  66974. * Class containing static functions to help procedurally build meshes
  66975. */
  66976. export class MeshBuilder {
  66977. /**
  66978. * Creates a box mesh
  66979. * * The parameter `size` sets the size (float) of each box side (default 1)
  66980. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66981. * * 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)
  66982. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66984. * * 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
  66985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66986. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66987. * @param name defines the name of the mesh
  66988. * @param options defines the options used to create the mesh
  66989. * @param scene defines the hosting scene
  66990. * @returns the box mesh
  66991. */
  66992. static CreateBox(name: string, options: {
  66993. size?: number;
  66994. width?: number;
  66995. height?: number;
  66996. depth?: number;
  66997. faceUV?: Vector4[];
  66998. faceColors?: Color4[];
  66999. sideOrientation?: number;
  67000. frontUVs?: Vector4;
  67001. backUVs?: Vector4;
  67002. wrap?: boolean;
  67003. topBaseAt?: number;
  67004. bottomBaseAt?: number;
  67005. updatable?: boolean;
  67006. }, scene?: Nullable<Scene>): Mesh;
  67007. /**
  67008. * Creates a tiled box mesh
  67009. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67011. * @param name defines the name of the mesh
  67012. * @param options defines the options used to create the mesh
  67013. * @param scene defines the hosting scene
  67014. * @returns the tiled box mesh
  67015. */
  67016. static CreateTiledBox(name: string, options: {
  67017. pattern?: number;
  67018. size?: number;
  67019. width?: number;
  67020. height?: number;
  67021. depth: number;
  67022. tileSize?: number;
  67023. tileWidth?: number;
  67024. tileHeight?: number;
  67025. faceUV?: Vector4[];
  67026. faceColors?: Color4[];
  67027. alignHorizontal?: number;
  67028. alignVertical?: number;
  67029. sideOrientation?: number;
  67030. updatable?: boolean;
  67031. }, scene?: Nullable<Scene>): Mesh;
  67032. /**
  67033. * Creates a sphere mesh
  67034. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67035. * * 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`)
  67036. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67037. * * 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
  67038. * * 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)
  67039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67040. * * 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
  67041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67042. * @param name defines the name of the mesh
  67043. * @param options defines the options used to create the mesh
  67044. * @param scene defines the hosting scene
  67045. * @returns the sphere mesh
  67046. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67047. */
  67048. static CreateSphere(name: string, options: {
  67049. segments?: number;
  67050. diameter?: number;
  67051. diameterX?: number;
  67052. diameterY?: number;
  67053. diameterZ?: number;
  67054. arc?: number;
  67055. slice?: number;
  67056. sideOrientation?: number;
  67057. frontUVs?: Vector4;
  67058. backUVs?: Vector4;
  67059. updatable?: boolean;
  67060. }, scene?: Nullable<Scene>): Mesh;
  67061. /**
  67062. * Creates a plane polygonal mesh. By default, this is a disc
  67063. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67064. * * 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
  67065. * * 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
  67066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67067. * * 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
  67068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67069. * @param name defines the name of the mesh
  67070. * @param options defines the options used to create the mesh
  67071. * @param scene defines the hosting scene
  67072. * @returns the plane polygonal mesh
  67073. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67074. */
  67075. static CreateDisc(name: string, options: {
  67076. radius?: number;
  67077. tessellation?: number;
  67078. arc?: number;
  67079. updatable?: boolean;
  67080. sideOrientation?: number;
  67081. frontUVs?: Vector4;
  67082. backUVs?: Vector4;
  67083. }, scene?: Nullable<Scene>): Mesh;
  67084. /**
  67085. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67086. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67087. * * 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`)
  67088. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67089. * * 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
  67090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67091. * * 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
  67092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67093. * @param name defines the name of the mesh
  67094. * @param options defines the options used to create the mesh
  67095. * @param scene defines the hosting scene
  67096. * @returns the icosahedron mesh
  67097. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67098. */
  67099. static CreateIcoSphere(name: string, options: {
  67100. radius?: number;
  67101. radiusX?: number;
  67102. radiusY?: number;
  67103. radiusZ?: number;
  67104. flat?: boolean;
  67105. subdivisions?: number;
  67106. sideOrientation?: number;
  67107. frontUVs?: Vector4;
  67108. backUVs?: Vector4;
  67109. updatable?: boolean;
  67110. }, scene?: Nullable<Scene>): Mesh;
  67111. /**
  67112. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67113. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67114. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67115. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67116. * * 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
  67117. * * 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
  67118. * * 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
  67119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67120. * * 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
  67121. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67122. * * 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
  67123. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67124. * * 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
  67125. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67127. * @param name defines the name of the mesh
  67128. * @param options defines the options used to create the mesh
  67129. * @param scene defines the hosting scene
  67130. * @returns the ribbon mesh
  67131. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67132. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67133. */
  67134. static CreateRibbon(name: string, options: {
  67135. pathArray: Vector3[][];
  67136. closeArray?: boolean;
  67137. closePath?: boolean;
  67138. offset?: number;
  67139. updatable?: boolean;
  67140. sideOrientation?: number;
  67141. frontUVs?: Vector4;
  67142. backUVs?: Vector4;
  67143. instance?: Mesh;
  67144. invertUV?: boolean;
  67145. uvs?: Vector2[];
  67146. colors?: Color4[];
  67147. }, scene?: Nullable<Scene>): Mesh;
  67148. /**
  67149. * Creates a cylinder or a cone mesh
  67150. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67151. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67152. * * 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.
  67153. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67154. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67155. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67156. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67157. * * 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).
  67158. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67159. * * 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).
  67160. * * 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
  67161. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67162. * * 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
  67163. * * 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.
  67164. * * If `enclose` is false, a ring surface is one element.
  67165. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67166. * * 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
  67167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67168. * * 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
  67169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67170. * @param name defines the name of the mesh
  67171. * @param options defines the options used to create the mesh
  67172. * @param scene defines the hosting scene
  67173. * @returns the cylinder mesh
  67174. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67175. */
  67176. static CreateCylinder(name: string, options: {
  67177. height?: number;
  67178. diameterTop?: number;
  67179. diameterBottom?: number;
  67180. diameter?: number;
  67181. tessellation?: number;
  67182. subdivisions?: number;
  67183. arc?: number;
  67184. faceColors?: Color4[];
  67185. faceUV?: Vector4[];
  67186. updatable?: boolean;
  67187. hasRings?: boolean;
  67188. enclose?: boolean;
  67189. cap?: number;
  67190. sideOrientation?: number;
  67191. frontUVs?: Vector4;
  67192. backUVs?: Vector4;
  67193. }, scene?: Nullable<Scene>): Mesh;
  67194. /**
  67195. * Creates a torus mesh
  67196. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67197. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67198. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67200. * * 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
  67201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67202. * @param name defines the name of the mesh
  67203. * @param options defines the options used to create the mesh
  67204. * @param scene defines the hosting scene
  67205. * @returns the torus mesh
  67206. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67207. */
  67208. static CreateTorus(name: string, options: {
  67209. diameter?: number;
  67210. thickness?: number;
  67211. tessellation?: number;
  67212. updatable?: boolean;
  67213. sideOrientation?: number;
  67214. frontUVs?: Vector4;
  67215. backUVs?: Vector4;
  67216. }, scene?: Nullable<Scene>): Mesh;
  67217. /**
  67218. * Creates a torus knot mesh
  67219. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67220. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67221. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67222. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67224. * * 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
  67225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67226. * @param name defines the name of the mesh
  67227. * @param options defines the options used to create the mesh
  67228. * @param scene defines the hosting scene
  67229. * @returns the torus knot mesh
  67230. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67231. */
  67232. static CreateTorusKnot(name: string, options: {
  67233. radius?: number;
  67234. tube?: number;
  67235. radialSegments?: number;
  67236. tubularSegments?: number;
  67237. p?: number;
  67238. q?: number;
  67239. updatable?: boolean;
  67240. sideOrientation?: number;
  67241. frontUVs?: Vector4;
  67242. backUVs?: Vector4;
  67243. }, scene?: Nullable<Scene>): Mesh;
  67244. /**
  67245. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67246. * * 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
  67247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67248. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67249. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67250. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67251. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67252. * * 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
  67253. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67255. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67256. * @param name defines the name of the new line system
  67257. * @param options defines the options used to create the line system
  67258. * @param scene defines the hosting scene
  67259. * @returns a new line system mesh
  67260. */
  67261. static CreateLineSystem(name: string, options: {
  67262. lines: Vector3[][];
  67263. updatable?: boolean;
  67264. instance?: Nullable<LinesMesh>;
  67265. colors?: Nullable<Color4[][]>;
  67266. useVertexAlpha?: boolean;
  67267. }, scene: Nullable<Scene>): LinesMesh;
  67268. /**
  67269. * Creates a line mesh
  67270. * 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
  67271. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67272. * * The parameter `points` is an array successive Vector3
  67273. * * 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
  67274. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67275. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67276. * * When updating an instance, remember that only point positions can change, not the number of points
  67277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67278. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67279. * @param name defines the name of the new line system
  67280. * @param options defines the options used to create the line system
  67281. * @param scene defines the hosting scene
  67282. * @returns a new line mesh
  67283. */
  67284. static CreateLines(name: string, options: {
  67285. points: Vector3[];
  67286. updatable?: boolean;
  67287. instance?: Nullable<LinesMesh>;
  67288. colors?: Color4[];
  67289. useVertexAlpha?: boolean;
  67290. }, scene?: Nullable<Scene>): LinesMesh;
  67291. /**
  67292. * Creates a dashed line mesh
  67293. * * 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
  67294. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67295. * * The parameter `points` is an array successive Vector3
  67296. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67297. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67298. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67299. * * 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
  67300. * * When updating an instance, remember that only point positions can change, not the number of points
  67301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67302. * @param name defines the name of the mesh
  67303. * @param options defines the options used to create the mesh
  67304. * @param scene defines the hosting scene
  67305. * @returns the dashed line mesh
  67306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67307. */
  67308. static CreateDashedLines(name: string, options: {
  67309. points: Vector3[];
  67310. dashSize?: number;
  67311. gapSize?: number;
  67312. dashNb?: number;
  67313. updatable?: boolean;
  67314. instance?: LinesMesh;
  67315. }, scene?: Nullable<Scene>): LinesMesh;
  67316. /**
  67317. * 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.
  67318. * * 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.
  67319. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67320. * * 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.
  67321. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67322. * * 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
  67323. * * 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
  67324. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67326. * * 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
  67327. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67329. * @param name defines the name of the mesh
  67330. * @param options defines the options used to create the mesh
  67331. * @param scene defines the hosting scene
  67332. * @returns the extruded shape mesh
  67333. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67334. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67335. */
  67336. static ExtrudeShape(name: string, options: {
  67337. shape: Vector3[];
  67338. path: Vector3[];
  67339. scale?: number;
  67340. rotation?: number;
  67341. cap?: number;
  67342. updatable?: boolean;
  67343. sideOrientation?: number;
  67344. frontUVs?: Vector4;
  67345. backUVs?: Vector4;
  67346. instance?: Mesh;
  67347. invertUV?: boolean;
  67348. }, scene?: Nullable<Scene>): Mesh;
  67349. /**
  67350. * Creates an custom extruded shape mesh.
  67351. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67352. * * 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.
  67353. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67354. * * 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
  67355. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67356. * * 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
  67357. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67358. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67359. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67360. * * 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
  67361. * * 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
  67362. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67364. * * 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
  67365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67367. * @param name defines the name of the mesh
  67368. * @param options defines the options used to create the mesh
  67369. * @param scene defines the hosting scene
  67370. * @returns the custom extruded shape mesh
  67371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67374. */
  67375. static ExtrudeShapeCustom(name: string, options: {
  67376. shape: Vector3[];
  67377. path: Vector3[];
  67378. scaleFunction?: any;
  67379. rotationFunction?: any;
  67380. ribbonCloseArray?: boolean;
  67381. ribbonClosePath?: boolean;
  67382. cap?: number;
  67383. updatable?: boolean;
  67384. sideOrientation?: number;
  67385. frontUVs?: Vector4;
  67386. backUVs?: Vector4;
  67387. instance?: Mesh;
  67388. invertUV?: boolean;
  67389. }, scene?: Nullable<Scene>): Mesh;
  67390. /**
  67391. * Creates lathe mesh.
  67392. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67393. * * 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
  67394. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67395. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67396. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67397. * * 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
  67398. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67399. * * 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
  67400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67401. * * 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
  67402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67404. * @param name defines the name of the mesh
  67405. * @param options defines the options used to create the mesh
  67406. * @param scene defines the hosting scene
  67407. * @returns the lathe mesh
  67408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67409. */
  67410. static CreateLathe(name: string, options: {
  67411. shape: Vector3[];
  67412. radius?: number;
  67413. tessellation?: number;
  67414. clip?: number;
  67415. arc?: number;
  67416. closed?: boolean;
  67417. updatable?: boolean;
  67418. sideOrientation?: number;
  67419. frontUVs?: Vector4;
  67420. backUVs?: Vector4;
  67421. cap?: number;
  67422. invertUV?: boolean;
  67423. }, scene?: Nullable<Scene>): Mesh;
  67424. /**
  67425. * Creates a tiled plane mesh
  67426. * * You can set a limited pattern arrangement with the tiles
  67427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67428. * * 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
  67429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67430. * @param name defines the name of the mesh
  67431. * @param options defines the options used to create the mesh
  67432. * @param scene defines the hosting scene
  67433. * @returns the plane mesh
  67434. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67435. */
  67436. static CreateTiledPlane(name: string, options: {
  67437. pattern?: number;
  67438. tileSize?: number;
  67439. tileWidth?: number;
  67440. tileHeight?: number;
  67441. size?: number;
  67442. width?: number;
  67443. height?: number;
  67444. alignHorizontal?: number;
  67445. alignVertical?: number;
  67446. sideOrientation?: number;
  67447. frontUVs?: Vector4;
  67448. backUVs?: Vector4;
  67449. updatable?: boolean;
  67450. }, scene?: Nullable<Scene>): Mesh;
  67451. /**
  67452. * Creates a plane mesh
  67453. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67454. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67455. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67457. * * 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
  67458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67459. * @param name defines the name of the mesh
  67460. * @param options defines the options used to create the mesh
  67461. * @param scene defines the hosting scene
  67462. * @returns the plane mesh
  67463. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67464. */
  67465. static CreatePlane(name: string, options: {
  67466. size?: number;
  67467. width?: number;
  67468. height?: number;
  67469. sideOrientation?: number;
  67470. frontUVs?: Vector4;
  67471. backUVs?: Vector4;
  67472. updatable?: boolean;
  67473. sourcePlane?: Plane;
  67474. }, scene?: Nullable<Scene>): Mesh;
  67475. /**
  67476. * Creates a ground mesh
  67477. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67478. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67480. * @param name defines the name of the mesh
  67481. * @param options defines the options used to create the mesh
  67482. * @param scene defines the hosting scene
  67483. * @returns the ground mesh
  67484. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67485. */
  67486. static CreateGround(name: string, options: {
  67487. width?: number;
  67488. height?: number;
  67489. subdivisions?: number;
  67490. subdivisionsX?: number;
  67491. subdivisionsY?: number;
  67492. updatable?: boolean;
  67493. }, scene?: Nullable<Scene>): Mesh;
  67494. /**
  67495. * Creates a tiled ground mesh
  67496. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67497. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67498. * * 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
  67499. * * 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
  67500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67501. * @param name defines the name of the mesh
  67502. * @param options defines the options used to create the mesh
  67503. * @param scene defines the hosting scene
  67504. * @returns the tiled ground mesh
  67505. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67506. */
  67507. static CreateTiledGround(name: string, options: {
  67508. xmin: number;
  67509. zmin: number;
  67510. xmax: number;
  67511. zmax: number;
  67512. subdivisions?: {
  67513. w: number;
  67514. h: number;
  67515. };
  67516. precision?: {
  67517. w: number;
  67518. h: number;
  67519. };
  67520. updatable?: boolean;
  67521. }, scene?: Nullable<Scene>): Mesh;
  67522. /**
  67523. * Creates a ground mesh from a height map
  67524. * * The parameter `url` sets the URL of the height map image resource.
  67525. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67526. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67527. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67528. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67529. * * 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.
  67530. * * 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).
  67531. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67533. * @param name defines the name of the mesh
  67534. * @param url defines the url to the height map
  67535. * @param options defines the options used to create the mesh
  67536. * @param scene defines the hosting scene
  67537. * @returns the ground mesh
  67538. * @see https://doc.babylonjs.com/babylon101/height_map
  67539. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67540. */
  67541. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67542. width?: number;
  67543. height?: number;
  67544. subdivisions?: number;
  67545. minHeight?: number;
  67546. maxHeight?: number;
  67547. colorFilter?: Color3;
  67548. alphaFilter?: number;
  67549. updatable?: boolean;
  67550. onReady?: (mesh: GroundMesh) => void;
  67551. }, scene?: Nullable<Scene>): GroundMesh;
  67552. /**
  67553. * Creates a polygon mesh
  67554. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67555. * * 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
  67556. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67558. * * 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)
  67559. * * Remember you can only change the shape positions, not their number when updating a polygon
  67560. * @param name defines the name of the mesh
  67561. * @param options defines the options used to create the mesh
  67562. * @param scene defines the hosting scene
  67563. * @param earcutInjection can be used to inject your own earcut reference
  67564. * @returns the polygon mesh
  67565. */
  67566. static CreatePolygon(name: string, options: {
  67567. shape: Vector3[];
  67568. holes?: Vector3[][];
  67569. depth?: number;
  67570. faceUV?: Vector4[];
  67571. faceColors?: Color4[];
  67572. updatable?: boolean;
  67573. sideOrientation?: number;
  67574. frontUVs?: Vector4;
  67575. backUVs?: Vector4;
  67576. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67577. /**
  67578. * Creates an extruded polygon mesh, with depth in the Y direction.
  67579. * * 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)
  67580. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67581. * @param name defines the name of the mesh
  67582. * @param options defines the options used to create the mesh
  67583. * @param scene defines the hosting scene
  67584. * @param earcutInjection can be used to inject your own earcut reference
  67585. * @returns the polygon mesh
  67586. */
  67587. static ExtrudePolygon(name: string, options: {
  67588. shape: Vector3[];
  67589. holes?: Vector3[][];
  67590. depth?: number;
  67591. faceUV?: Vector4[];
  67592. faceColors?: Color4[];
  67593. updatable?: boolean;
  67594. sideOrientation?: number;
  67595. frontUVs?: Vector4;
  67596. backUVs?: Vector4;
  67597. wrap?: boolean;
  67598. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67599. /**
  67600. * Creates a tube mesh.
  67601. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67602. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67603. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67604. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67605. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67606. * * 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)
  67607. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67608. * * 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
  67609. * * 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
  67610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67611. * * 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
  67612. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67614. * @param name defines the name of the mesh
  67615. * @param options defines the options used to create the mesh
  67616. * @param scene defines the hosting scene
  67617. * @returns the tube mesh
  67618. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67619. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67620. */
  67621. static CreateTube(name: string, options: {
  67622. path: Vector3[];
  67623. radius?: number;
  67624. tessellation?: number;
  67625. radiusFunction?: {
  67626. (i: number, distance: number): number;
  67627. };
  67628. cap?: number;
  67629. arc?: number;
  67630. updatable?: boolean;
  67631. sideOrientation?: number;
  67632. frontUVs?: Vector4;
  67633. backUVs?: Vector4;
  67634. instance?: Mesh;
  67635. invertUV?: boolean;
  67636. }, scene?: Nullable<Scene>): Mesh;
  67637. /**
  67638. * Creates a polyhedron mesh
  67639. * * 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
  67640. * * The parameter `size` (positive float, default 1) sets the polygon size
  67641. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67642. * * 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`
  67643. * * 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
  67644. * * 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)`)
  67645. * * 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
  67646. * * 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
  67647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67648. * * 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
  67649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67650. * @param name defines the name of the mesh
  67651. * @param options defines the options used to create the mesh
  67652. * @param scene defines the hosting scene
  67653. * @returns the polyhedron mesh
  67654. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67655. */
  67656. static CreatePolyhedron(name: string, options: {
  67657. type?: number;
  67658. size?: number;
  67659. sizeX?: number;
  67660. sizeY?: number;
  67661. sizeZ?: number;
  67662. custom?: any;
  67663. faceUV?: Vector4[];
  67664. faceColors?: Color4[];
  67665. flat?: boolean;
  67666. updatable?: boolean;
  67667. sideOrientation?: number;
  67668. frontUVs?: Vector4;
  67669. backUVs?: Vector4;
  67670. }, scene?: Nullable<Scene>): Mesh;
  67671. /**
  67672. * Creates a decal mesh.
  67673. * 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
  67674. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67675. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67676. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67677. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67678. * @param name defines the name of the mesh
  67679. * @param sourceMesh defines the mesh where the decal must be applied
  67680. * @param options defines the options used to create the mesh
  67681. * @param scene defines the hosting scene
  67682. * @returns the decal mesh
  67683. * @see https://doc.babylonjs.com/how_to/decals
  67684. */
  67685. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67686. position?: Vector3;
  67687. normal?: Vector3;
  67688. size?: Vector3;
  67689. angle?: number;
  67690. }): Mesh;
  67691. /**
  67692. * Creates a Capsule Mesh
  67693. * @param name defines the name of the mesh.
  67694. * @param options the constructors options used to shape the mesh.
  67695. * @param scene defines the scene the mesh is scoped to.
  67696. * @returns the capsule mesh
  67697. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67698. */
  67699. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /**
  67704. * A simplifier interface for future simplification implementations
  67705. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67706. */
  67707. export interface ISimplifier {
  67708. /**
  67709. * Simplification of a given mesh according to the given settings.
  67710. * Since this requires computation, it is assumed that the function runs async.
  67711. * @param settings The settings of the simplification, including quality and distance
  67712. * @param successCallback A callback that will be called after the mesh was simplified.
  67713. * @param errorCallback in case of an error, this callback will be called. optional.
  67714. */
  67715. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67716. }
  67717. /**
  67718. * Expected simplification settings.
  67719. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67720. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67721. */
  67722. export interface ISimplificationSettings {
  67723. /**
  67724. * Gets or sets the expected quality
  67725. */
  67726. quality: number;
  67727. /**
  67728. * Gets or sets the distance when this optimized version should be used
  67729. */
  67730. distance: number;
  67731. /**
  67732. * Gets an already optimized mesh
  67733. */
  67734. optimizeMesh?: boolean;
  67735. }
  67736. /**
  67737. * Class used to specify simplification options
  67738. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67739. */
  67740. export class SimplificationSettings implements ISimplificationSettings {
  67741. /** expected quality */
  67742. quality: number;
  67743. /** distance when this optimized version should be used */
  67744. distance: number;
  67745. /** already optimized mesh */
  67746. optimizeMesh?: boolean | undefined;
  67747. /**
  67748. * Creates a SimplificationSettings
  67749. * @param quality expected quality
  67750. * @param distance distance when this optimized version should be used
  67751. * @param optimizeMesh already optimized mesh
  67752. */
  67753. constructor(
  67754. /** expected quality */
  67755. quality: number,
  67756. /** distance when this optimized version should be used */
  67757. distance: number,
  67758. /** already optimized mesh */
  67759. optimizeMesh?: boolean | undefined);
  67760. }
  67761. /**
  67762. * Interface used to define a simplification task
  67763. */
  67764. export interface ISimplificationTask {
  67765. /**
  67766. * Array of settings
  67767. */
  67768. settings: Array<ISimplificationSettings>;
  67769. /**
  67770. * Simplification type
  67771. */
  67772. simplificationType: SimplificationType;
  67773. /**
  67774. * Mesh to simplify
  67775. */
  67776. mesh: Mesh;
  67777. /**
  67778. * Callback called on success
  67779. */
  67780. successCallback?: () => void;
  67781. /**
  67782. * Defines if parallel processing can be used
  67783. */
  67784. parallelProcessing: boolean;
  67785. }
  67786. /**
  67787. * Queue used to order the simplification tasks
  67788. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67789. */
  67790. export class SimplificationQueue {
  67791. private _simplificationArray;
  67792. /**
  67793. * Gets a boolean indicating that the process is still running
  67794. */
  67795. running: boolean;
  67796. /**
  67797. * Creates a new queue
  67798. */
  67799. constructor();
  67800. /**
  67801. * Adds a new simplification task
  67802. * @param task defines a task to add
  67803. */
  67804. addTask(task: ISimplificationTask): void;
  67805. /**
  67806. * Execute next task
  67807. */
  67808. executeNext(): void;
  67809. /**
  67810. * Execute a simplification task
  67811. * @param task defines the task to run
  67812. */
  67813. runSimplification(task: ISimplificationTask): void;
  67814. private getSimplifier;
  67815. }
  67816. /**
  67817. * The implemented types of simplification
  67818. * At the moment only Quadratic Error Decimation is implemented
  67819. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67820. */
  67821. export enum SimplificationType {
  67822. /** Quadratic error decimation */
  67823. QUADRATIC = 0
  67824. }
  67825. /**
  67826. * An implementation of the Quadratic Error simplification algorithm.
  67827. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67828. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67829. * @author RaananW
  67830. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67831. */
  67832. export class QuadraticErrorSimplification implements ISimplifier {
  67833. private _mesh;
  67834. private triangles;
  67835. private vertices;
  67836. private references;
  67837. private _reconstructedMesh;
  67838. /** Gets or sets the number pf sync interations */
  67839. syncIterations: number;
  67840. /** Gets or sets the aggressiveness of the simplifier */
  67841. aggressiveness: number;
  67842. /** Gets or sets the number of allowed iterations for decimation */
  67843. decimationIterations: number;
  67844. /** Gets or sets the espilon to use for bounding box computation */
  67845. boundingBoxEpsilon: number;
  67846. /**
  67847. * Creates a new QuadraticErrorSimplification
  67848. * @param _mesh defines the target mesh
  67849. */
  67850. constructor(_mesh: Mesh);
  67851. /**
  67852. * Simplification of a given mesh according to the given settings.
  67853. * Since this requires computation, it is assumed that the function runs async.
  67854. * @param settings The settings of the simplification, including quality and distance
  67855. * @param successCallback A callback that will be called after the mesh was simplified.
  67856. */
  67857. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67858. private runDecimation;
  67859. private initWithMesh;
  67860. private init;
  67861. private reconstructMesh;
  67862. private initDecimatedMesh;
  67863. private isFlipped;
  67864. private updateTriangles;
  67865. private identifyBorder;
  67866. private updateMesh;
  67867. private vertexError;
  67868. private calculateError;
  67869. }
  67870. }
  67871. declare module BABYLON {
  67872. interface Scene {
  67873. /** @hidden (Backing field) */
  67874. _simplificationQueue: SimplificationQueue;
  67875. /**
  67876. * Gets or sets the simplification queue attached to the scene
  67877. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67878. */
  67879. simplificationQueue: SimplificationQueue;
  67880. }
  67881. interface Mesh {
  67882. /**
  67883. * Simplify the mesh according to the given array of settings.
  67884. * Function will return immediately and will simplify async
  67885. * @param settings a collection of simplification settings
  67886. * @param parallelProcessing should all levels calculate parallel or one after the other
  67887. * @param simplificationType the type of simplification to run
  67888. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67889. * @returns the current mesh
  67890. */
  67891. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67892. }
  67893. /**
  67894. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67895. * created in a scene
  67896. */
  67897. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67898. /**
  67899. * The component name helpfull to identify the component in the list of scene components.
  67900. */
  67901. readonly name: string;
  67902. /**
  67903. * The scene the component belongs to.
  67904. */
  67905. scene: Scene;
  67906. /**
  67907. * Creates a new instance of the component for the given scene
  67908. * @param scene Defines the scene to register the component in
  67909. */
  67910. constructor(scene: Scene);
  67911. /**
  67912. * Registers the component in a given scene
  67913. */
  67914. register(): void;
  67915. /**
  67916. * Rebuilds the elements related to this component in case of
  67917. * context lost for instance.
  67918. */
  67919. rebuild(): void;
  67920. /**
  67921. * Disposes the component and the associated ressources
  67922. */
  67923. dispose(): void;
  67924. private _beforeCameraUpdate;
  67925. }
  67926. }
  67927. declare module BABYLON {
  67928. interface Mesh {
  67929. /**
  67930. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67931. */
  67932. thinInstanceEnablePicking: boolean;
  67933. /**
  67934. * Creates a new thin instance
  67935. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67936. * @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
  67937. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67938. */
  67939. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67940. /**
  67941. * Adds the transformation (matrix) of the current mesh as a thin instance
  67942. * @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
  67943. * @returns the thin instance index number
  67944. */
  67945. thinInstanceAddSelf(refresh: boolean): number;
  67946. /**
  67947. * Registers a custom attribute to be used with thin instances
  67948. * @param kind name of the attribute
  67949. * @param stride size in floats of the attribute
  67950. */
  67951. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67952. /**
  67953. * Sets the matrix of a thin instance
  67954. * @param index index of the thin instance
  67955. * @param matrix matrix to set
  67956. * @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
  67957. */
  67958. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67959. /**
  67960. * Sets the value of a custom attribute for a thin instance
  67961. * @param kind name of the attribute
  67962. * @param index index of the thin instance
  67963. * @param value value to set
  67964. * @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
  67965. */
  67966. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67967. /**
  67968. * 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.
  67969. */
  67970. thinInstanceCount: number;
  67971. /**
  67972. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67973. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67974. * @param buffer buffer to set
  67975. * @param stride size in floats of each value of the buffer
  67976. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67977. */
  67978. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67979. /**
  67980. * Gets the list of world matrices
  67981. * @return an array containing all the world matrices from the thin instances
  67982. */
  67983. thinInstanceGetWorldMatrices(): Matrix[];
  67984. /**
  67985. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67986. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67987. */
  67988. thinInstanceBufferUpdated(kind: string): void;
  67989. /**
  67990. * Applies a partial update to a buffer directly on the GPU
  67991. * 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
  67992. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67993. * @param data the data to set in the GPU buffer
  67994. * @param offset the offset in the GPU buffer where to update the data
  67995. */
  67996. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67997. /**
  67998. * Refreshes the bounding info, taking into account all the thin instances defined
  67999. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68000. */
  68001. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68002. /** @hidden */
  68003. _thinInstanceInitializeUserStorage(): void;
  68004. /** @hidden */
  68005. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68006. /** @hidden */
  68007. _userThinInstanceBuffersStorage: {
  68008. data: {
  68009. [key: string]: Float32Array;
  68010. };
  68011. sizes: {
  68012. [key: string]: number;
  68013. };
  68014. vertexBuffers: {
  68015. [key: string]: Nullable<VertexBuffer>;
  68016. };
  68017. strides: {
  68018. [key: string]: number;
  68019. };
  68020. };
  68021. }
  68022. }
  68023. declare module BABYLON {
  68024. /**
  68025. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68026. */
  68027. export interface INavigationEnginePlugin {
  68028. /**
  68029. * plugin name
  68030. */
  68031. name: string;
  68032. /**
  68033. * Creates a navigation mesh
  68034. * @param meshes array of all the geometry used to compute the navigatio mesh
  68035. * @param parameters bunch of parameters used to filter geometry
  68036. */
  68037. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68038. /**
  68039. * Create a navigation mesh debug mesh
  68040. * @param scene is where the mesh will be added
  68041. * @returns debug display mesh
  68042. */
  68043. createDebugNavMesh(scene: Scene): Mesh;
  68044. /**
  68045. * Get a navigation mesh constrained position, closest to the parameter position
  68046. * @param position world position
  68047. * @returns the closest point to position constrained by the navigation mesh
  68048. */
  68049. getClosestPoint(position: Vector3): Vector3;
  68050. /**
  68051. * Get a navigation mesh constrained position, closest to the parameter position
  68052. * @param position world position
  68053. * @param result output the closest point to position constrained by the navigation mesh
  68054. */
  68055. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68056. /**
  68057. * Get a navigation mesh constrained position, within a particular radius
  68058. * @param position world position
  68059. * @param maxRadius the maximum distance to the constrained world position
  68060. * @returns the closest point to position constrained by the navigation mesh
  68061. */
  68062. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68063. /**
  68064. * Get a navigation mesh constrained position, within a particular radius
  68065. * @param position world position
  68066. * @param maxRadius the maximum distance to the constrained world position
  68067. * @param result output the closest point to position constrained by the navigation mesh
  68068. */
  68069. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68070. /**
  68071. * Compute the final position from a segment made of destination-position
  68072. * @param position world position
  68073. * @param destination world position
  68074. * @returns the resulting point along the navmesh
  68075. */
  68076. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68077. /**
  68078. * Compute the final position from a segment made of destination-position
  68079. * @param position world position
  68080. * @param destination world position
  68081. * @param result output the resulting point along the navmesh
  68082. */
  68083. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68084. /**
  68085. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68086. * @param start world position
  68087. * @param end world position
  68088. * @returns array containing world position composing the path
  68089. */
  68090. computePath(start: Vector3, end: Vector3): Vector3[];
  68091. /**
  68092. * If this plugin is supported
  68093. * @returns true if plugin is supported
  68094. */
  68095. isSupported(): boolean;
  68096. /**
  68097. * Create a new Crowd so you can add agents
  68098. * @param maxAgents the maximum agent count in the crowd
  68099. * @param maxAgentRadius the maximum radius an agent can have
  68100. * @param scene to attach the crowd to
  68101. * @returns the crowd you can add agents to
  68102. */
  68103. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68104. /**
  68105. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68106. * The queries will try to find a solution within those bounds
  68107. * default is (1,1,1)
  68108. * @param extent x,y,z value that define the extent around the queries point of reference
  68109. */
  68110. setDefaultQueryExtent(extent: Vector3): void;
  68111. /**
  68112. * Get the Bounding box extent specified by setDefaultQueryExtent
  68113. * @returns the box extent values
  68114. */
  68115. getDefaultQueryExtent(): Vector3;
  68116. /**
  68117. * build the navmesh from a previously saved state using getNavmeshData
  68118. * @param data the Uint8Array returned by getNavmeshData
  68119. */
  68120. buildFromNavmeshData(data: Uint8Array): void;
  68121. /**
  68122. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68123. * @returns data the Uint8Array that can be saved and reused
  68124. */
  68125. getNavmeshData(): Uint8Array;
  68126. /**
  68127. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68128. * @param result output the box extent values
  68129. */
  68130. getDefaultQueryExtentToRef(result: Vector3): void;
  68131. /**
  68132. * Release all resources
  68133. */
  68134. dispose(): void;
  68135. }
  68136. /**
  68137. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68138. */
  68139. export interface ICrowd {
  68140. /**
  68141. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68142. * You can attach anything to that node. The node position is updated in the scene update tick.
  68143. * @param pos world position that will be constrained by the navigation mesh
  68144. * @param parameters agent parameters
  68145. * @param transform hooked to the agent that will be update by the scene
  68146. * @returns agent index
  68147. */
  68148. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68149. /**
  68150. * Returns the agent position in world space
  68151. * @param index agent index returned by addAgent
  68152. * @returns world space position
  68153. */
  68154. getAgentPosition(index: number): Vector3;
  68155. /**
  68156. * Gets the agent position result in world space
  68157. * @param index agent index returned by addAgent
  68158. * @param result output world space position
  68159. */
  68160. getAgentPositionToRef(index: number, result: Vector3): void;
  68161. /**
  68162. * Gets the agent velocity in world space
  68163. * @param index agent index returned by addAgent
  68164. * @returns world space velocity
  68165. */
  68166. getAgentVelocity(index: number): Vector3;
  68167. /**
  68168. * Gets the agent velocity result in world space
  68169. * @param index agent index returned by addAgent
  68170. * @param result output world space velocity
  68171. */
  68172. getAgentVelocityToRef(index: number, result: Vector3): void;
  68173. /**
  68174. * Gets the agent next target point on the path
  68175. * @param index agent index returned by addAgent
  68176. * @returns world space position
  68177. */
  68178. getAgentNextTargetPath(index: number): Vector3;
  68179. /**
  68180. * Gets the agent state
  68181. * @param index agent index returned by addAgent
  68182. * @returns agent state
  68183. */
  68184. getAgentState(index: number): number;
  68185. /**
  68186. * returns true if the agent in over an off mesh link connection
  68187. * @param index agent index returned by addAgent
  68188. * @returns true if over an off mesh link connection
  68189. */
  68190. overOffmeshConnection(index: number): boolean;
  68191. /**
  68192. * Gets the agent next target point on the path
  68193. * @param index agent index returned by addAgent
  68194. * @param result output world space position
  68195. */
  68196. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68197. /**
  68198. * remove a particular agent previously created
  68199. * @param index agent index returned by addAgent
  68200. */
  68201. removeAgent(index: number): void;
  68202. /**
  68203. * get the list of all agents attached to this crowd
  68204. * @returns list of agent indices
  68205. */
  68206. getAgents(): number[];
  68207. /**
  68208. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68209. * @param deltaTime in seconds
  68210. */
  68211. update(deltaTime: number): void;
  68212. /**
  68213. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68214. * @param index agent index returned by addAgent
  68215. * @param destination targeted world position
  68216. */
  68217. agentGoto(index: number, destination: Vector3): void;
  68218. /**
  68219. * Teleport the agent to a new position
  68220. * @param index agent index returned by addAgent
  68221. * @param destination targeted world position
  68222. */
  68223. agentTeleport(index: number, destination: Vector3): void;
  68224. /**
  68225. * Update agent parameters
  68226. * @param index agent index returned by addAgent
  68227. * @param parameters agent parameters
  68228. */
  68229. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68230. /**
  68231. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68232. * The queries will try to find a solution within those bounds
  68233. * default is (1,1,1)
  68234. * @param extent x,y,z value that define the extent around the queries point of reference
  68235. */
  68236. setDefaultQueryExtent(extent: Vector3): void;
  68237. /**
  68238. * Get the Bounding box extent specified by setDefaultQueryExtent
  68239. * @returns the box extent values
  68240. */
  68241. getDefaultQueryExtent(): Vector3;
  68242. /**
  68243. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68244. * @param result output the box extent values
  68245. */
  68246. getDefaultQueryExtentToRef(result: Vector3): void;
  68247. /**
  68248. * Release all resources
  68249. */
  68250. dispose(): void;
  68251. }
  68252. /**
  68253. * Configures an agent
  68254. */
  68255. export interface IAgentParameters {
  68256. /**
  68257. * Agent radius. [Limit: >= 0]
  68258. */
  68259. radius: number;
  68260. /**
  68261. * Agent height. [Limit: > 0]
  68262. */
  68263. height: number;
  68264. /**
  68265. * Maximum allowed acceleration. [Limit: >= 0]
  68266. */
  68267. maxAcceleration: number;
  68268. /**
  68269. * Maximum allowed speed. [Limit: >= 0]
  68270. */
  68271. maxSpeed: number;
  68272. /**
  68273. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68274. */
  68275. collisionQueryRange: number;
  68276. /**
  68277. * The path visibility optimization range. [Limit: > 0]
  68278. */
  68279. pathOptimizationRange: number;
  68280. /**
  68281. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68282. */
  68283. separationWeight: number;
  68284. }
  68285. /**
  68286. * Configures the navigation mesh creation
  68287. */
  68288. export interface INavMeshParameters {
  68289. /**
  68290. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68291. */
  68292. cs: number;
  68293. /**
  68294. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68295. */
  68296. ch: number;
  68297. /**
  68298. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68299. */
  68300. walkableSlopeAngle: number;
  68301. /**
  68302. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68303. * be considered walkable. [Limit: >= 3] [Units: vx]
  68304. */
  68305. walkableHeight: number;
  68306. /**
  68307. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68308. */
  68309. walkableClimb: number;
  68310. /**
  68311. * The distance to erode/shrink the walkable area of the heightfield away from
  68312. * obstructions. [Limit: >=0] [Units: vx]
  68313. */
  68314. walkableRadius: number;
  68315. /**
  68316. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68317. */
  68318. maxEdgeLen: number;
  68319. /**
  68320. * The maximum distance a simplfied contour's border edges should deviate
  68321. * the original raw contour. [Limit: >=0] [Units: vx]
  68322. */
  68323. maxSimplificationError: number;
  68324. /**
  68325. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68326. */
  68327. minRegionArea: number;
  68328. /**
  68329. * Any regions with a span count smaller than this value will, if possible,
  68330. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68331. */
  68332. mergeRegionArea: number;
  68333. /**
  68334. * The maximum number of vertices allowed for polygons generated during the
  68335. * contour to polygon conversion process. [Limit: >= 3]
  68336. */
  68337. maxVertsPerPoly: number;
  68338. /**
  68339. * Sets the sampling distance to use when generating the detail mesh.
  68340. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68341. */
  68342. detailSampleDist: number;
  68343. /**
  68344. * The maximum distance the detail mesh surface should deviate from heightfield
  68345. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68346. */
  68347. detailSampleMaxError: number;
  68348. }
  68349. }
  68350. declare module BABYLON {
  68351. /**
  68352. * RecastJS navigation plugin
  68353. */
  68354. export class RecastJSPlugin implements INavigationEnginePlugin {
  68355. /**
  68356. * Reference to the Recast library
  68357. */
  68358. bjsRECAST: any;
  68359. /**
  68360. * plugin name
  68361. */
  68362. name: string;
  68363. /**
  68364. * the first navmesh created. We might extend this to support multiple navmeshes
  68365. */
  68366. navMesh: any;
  68367. /**
  68368. * Initializes the recastJS plugin
  68369. * @param recastInjection can be used to inject your own recast reference
  68370. */
  68371. constructor(recastInjection?: any);
  68372. /**
  68373. * Creates a navigation mesh
  68374. * @param meshes array of all the geometry used to compute the navigatio mesh
  68375. * @param parameters bunch of parameters used to filter geometry
  68376. */
  68377. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68378. /**
  68379. * Create a navigation mesh debug mesh
  68380. * @param scene is where the mesh will be added
  68381. * @returns debug display mesh
  68382. */
  68383. createDebugNavMesh(scene: Scene): Mesh;
  68384. /**
  68385. * Get a navigation mesh constrained position, closest to the parameter position
  68386. * @param position world position
  68387. * @returns the closest point to position constrained by the navigation mesh
  68388. */
  68389. getClosestPoint(position: Vector3): Vector3;
  68390. /**
  68391. * Get a navigation mesh constrained position, closest to the parameter position
  68392. * @param position world position
  68393. * @param result output the closest point to position constrained by the navigation mesh
  68394. */
  68395. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68396. /**
  68397. * Get a navigation mesh constrained position, within a particular radius
  68398. * @param position world position
  68399. * @param maxRadius the maximum distance to the constrained world position
  68400. * @returns the closest point to position constrained by the navigation mesh
  68401. */
  68402. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68403. /**
  68404. * Get a navigation mesh constrained position, within a particular radius
  68405. * @param position world position
  68406. * @param maxRadius the maximum distance to the constrained world position
  68407. * @param result output the closest point to position constrained by the navigation mesh
  68408. */
  68409. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68410. /**
  68411. * Compute the final position from a segment made of destination-position
  68412. * @param position world position
  68413. * @param destination world position
  68414. * @returns the resulting point along the navmesh
  68415. */
  68416. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68417. /**
  68418. * Compute the final position from a segment made of destination-position
  68419. * @param position world position
  68420. * @param destination world position
  68421. * @param result output the resulting point along the navmesh
  68422. */
  68423. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68424. /**
  68425. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68426. * @param start world position
  68427. * @param end world position
  68428. * @returns array containing world position composing the path
  68429. */
  68430. computePath(start: Vector3, end: Vector3): Vector3[];
  68431. /**
  68432. * Create a new Crowd so you can add agents
  68433. * @param maxAgents the maximum agent count in the crowd
  68434. * @param maxAgentRadius the maximum radius an agent can have
  68435. * @param scene to attach the crowd to
  68436. * @returns the crowd you can add agents to
  68437. */
  68438. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68439. /**
  68440. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68441. * The queries will try to find a solution within those bounds
  68442. * default is (1,1,1)
  68443. * @param extent x,y,z value that define the extent around the queries point of reference
  68444. */
  68445. setDefaultQueryExtent(extent: Vector3): void;
  68446. /**
  68447. * Get the Bounding box extent specified by setDefaultQueryExtent
  68448. * @returns the box extent values
  68449. */
  68450. getDefaultQueryExtent(): Vector3;
  68451. /**
  68452. * build the navmesh from a previously saved state using getNavmeshData
  68453. * @param data the Uint8Array returned by getNavmeshData
  68454. */
  68455. buildFromNavmeshData(data: Uint8Array): void;
  68456. /**
  68457. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68458. * @returns data the Uint8Array that can be saved and reused
  68459. */
  68460. getNavmeshData(): Uint8Array;
  68461. /**
  68462. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68463. * @param result output the box extent values
  68464. */
  68465. getDefaultQueryExtentToRef(result: Vector3): void;
  68466. /**
  68467. * Disposes
  68468. */
  68469. dispose(): void;
  68470. /**
  68471. * If this plugin is supported
  68472. * @returns true if plugin is supported
  68473. */
  68474. isSupported(): boolean;
  68475. }
  68476. /**
  68477. * Recast detour crowd implementation
  68478. */
  68479. export class RecastJSCrowd implements ICrowd {
  68480. /**
  68481. * Recast/detour plugin
  68482. */
  68483. bjsRECASTPlugin: RecastJSPlugin;
  68484. /**
  68485. * Link to the detour crowd
  68486. */
  68487. recastCrowd: any;
  68488. /**
  68489. * One transform per agent
  68490. */
  68491. transforms: TransformNode[];
  68492. /**
  68493. * All agents created
  68494. */
  68495. agents: number[];
  68496. /**
  68497. * Link to the scene is kept to unregister the crowd from the scene
  68498. */
  68499. private _scene;
  68500. /**
  68501. * Observer for crowd updates
  68502. */
  68503. private _onBeforeAnimationsObserver;
  68504. /**
  68505. * Constructor
  68506. * @param plugin recastJS plugin
  68507. * @param maxAgents the maximum agent count in the crowd
  68508. * @param maxAgentRadius the maximum radius an agent can have
  68509. * @param scene to attach the crowd to
  68510. * @returns the crowd you can add agents to
  68511. */
  68512. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68513. /**
  68514. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68515. * You can attach anything to that node. The node position is updated in the scene update tick.
  68516. * @param pos world position that will be constrained by the navigation mesh
  68517. * @param parameters agent parameters
  68518. * @param transform hooked to the agent that will be update by the scene
  68519. * @returns agent index
  68520. */
  68521. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68522. /**
  68523. * Returns the agent position in world space
  68524. * @param index agent index returned by addAgent
  68525. * @returns world space position
  68526. */
  68527. getAgentPosition(index: number): Vector3;
  68528. /**
  68529. * Returns the agent position result in world space
  68530. * @param index agent index returned by addAgent
  68531. * @param result output world space position
  68532. */
  68533. getAgentPositionToRef(index: number, result: Vector3): void;
  68534. /**
  68535. * Returns the agent velocity in world space
  68536. * @param index agent index returned by addAgent
  68537. * @returns world space velocity
  68538. */
  68539. getAgentVelocity(index: number): Vector3;
  68540. /**
  68541. * Returns the agent velocity result in world space
  68542. * @param index agent index returned by addAgent
  68543. * @param result output world space velocity
  68544. */
  68545. getAgentVelocityToRef(index: number, result: Vector3): void;
  68546. /**
  68547. * Returns the agent next target point on the path
  68548. * @param index agent index returned by addAgent
  68549. * @returns world space position
  68550. */
  68551. getAgentNextTargetPath(index: number): Vector3;
  68552. /**
  68553. * Returns the agent next target point on the path
  68554. * @param index agent index returned by addAgent
  68555. * @param result output world space position
  68556. */
  68557. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68558. /**
  68559. * Gets the agent state
  68560. * @param index agent index returned by addAgent
  68561. * @returns agent state
  68562. */
  68563. getAgentState(index: number): number;
  68564. /**
  68565. * returns true if the agent in over an off mesh link connection
  68566. * @param index agent index returned by addAgent
  68567. * @returns true if over an off mesh link connection
  68568. */
  68569. overOffmeshConnection(index: number): boolean;
  68570. /**
  68571. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68572. * @param index agent index returned by addAgent
  68573. * @param destination targeted world position
  68574. */
  68575. agentGoto(index: number, destination: Vector3): void;
  68576. /**
  68577. * Teleport the agent to a new position
  68578. * @param index agent index returned by addAgent
  68579. * @param destination targeted world position
  68580. */
  68581. agentTeleport(index: number, destination: Vector3): void;
  68582. /**
  68583. * Update agent parameters
  68584. * @param index agent index returned by addAgent
  68585. * @param parameters agent parameters
  68586. */
  68587. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68588. /**
  68589. * remove a particular agent previously created
  68590. * @param index agent index returned by addAgent
  68591. */
  68592. removeAgent(index: number): void;
  68593. /**
  68594. * get the list of all agents attached to this crowd
  68595. * @returns list of agent indices
  68596. */
  68597. getAgents(): number[];
  68598. /**
  68599. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68600. * @param deltaTime in seconds
  68601. */
  68602. update(deltaTime: number): void;
  68603. /**
  68604. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68605. * The queries will try to find a solution within those bounds
  68606. * default is (1,1,1)
  68607. * @param extent x,y,z value that define the extent around the queries point of reference
  68608. */
  68609. setDefaultQueryExtent(extent: Vector3): void;
  68610. /**
  68611. * Get the Bounding box extent specified by setDefaultQueryExtent
  68612. * @returns the box extent values
  68613. */
  68614. getDefaultQueryExtent(): Vector3;
  68615. /**
  68616. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68617. * @param result output the box extent values
  68618. */
  68619. getDefaultQueryExtentToRef(result: Vector3): void;
  68620. /**
  68621. * Release all resources
  68622. */
  68623. dispose(): void;
  68624. }
  68625. }
  68626. declare module BABYLON {
  68627. /**
  68628. * Class used to enable access to IndexedDB
  68629. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68630. */
  68631. export class Database implements IOfflineProvider {
  68632. private _callbackManifestChecked;
  68633. private _currentSceneUrl;
  68634. private _db;
  68635. private _enableSceneOffline;
  68636. private _enableTexturesOffline;
  68637. private _manifestVersionFound;
  68638. private _mustUpdateRessources;
  68639. private _hasReachedQuota;
  68640. private _isSupported;
  68641. private _idbFactory;
  68642. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68643. private static IsUASupportingBlobStorage;
  68644. /**
  68645. * Gets a boolean indicating if Database storate is enabled (off by default)
  68646. */
  68647. static IDBStorageEnabled: boolean;
  68648. /**
  68649. * Gets a boolean indicating if scene must be saved in the database
  68650. */
  68651. get enableSceneOffline(): boolean;
  68652. /**
  68653. * Gets a boolean indicating if textures must be saved in the database
  68654. */
  68655. get enableTexturesOffline(): boolean;
  68656. /**
  68657. * Creates a new Database
  68658. * @param urlToScene defines the url to load the scene
  68659. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68660. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68661. */
  68662. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68663. private static _ParseURL;
  68664. private static _ReturnFullUrlLocation;
  68665. private _checkManifestFile;
  68666. /**
  68667. * Open the database and make it available
  68668. * @param successCallback defines the callback to call on success
  68669. * @param errorCallback defines the callback to call on error
  68670. */
  68671. open(successCallback: () => void, errorCallback: () => void): void;
  68672. /**
  68673. * Loads an image from the database
  68674. * @param url defines the url to load from
  68675. * @param image defines the target DOM image
  68676. */
  68677. loadImage(url: string, image: HTMLImageElement): void;
  68678. private _loadImageFromDBAsync;
  68679. private _saveImageIntoDBAsync;
  68680. private _checkVersionFromDB;
  68681. private _loadVersionFromDBAsync;
  68682. private _saveVersionIntoDBAsync;
  68683. /**
  68684. * Loads a file from database
  68685. * @param url defines the URL to load from
  68686. * @param sceneLoaded defines a callback to call on success
  68687. * @param progressCallBack defines a callback to call when progress changed
  68688. * @param errorCallback defines a callback to call on error
  68689. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68690. */
  68691. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68692. private _loadFileAsync;
  68693. private _saveFileAsync;
  68694. /**
  68695. * Validates if xhr data is correct
  68696. * @param xhr defines the request to validate
  68697. * @param dataType defines the expected data type
  68698. * @returns true if data is correct
  68699. */
  68700. private static _ValidateXHRData;
  68701. }
  68702. }
  68703. declare module BABYLON {
  68704. /** @hidden */
  68705. export var gpuUpdateParticlesPixelShader: {
  68706. name: string;
  68707. shader: string;
  68708. };
  68709. }
  68710. declare module BABYLON {
  68711. /** @hidden */
  68712. export var gpuUpdateParticlesVertexShader: {
  68713. name: string;
  68714. shader: string;
  68715. };
  68716. }
  68717. declare module BABYLON {
  68718. /** @hidden */
  68719. export var clipPlaneFragmentDeclaration2: {
  68720. name: string;
  68721. shader: string;
  68722. };
  68723. }
  68724. declare module BABYLON {
  68725. /** @hidden */
  68726. export var gpuRenderParticlesPixelShader: {
  68727. name: string;
  68728. shader: string;
  68729. };
  68730. }
  68731. declare module BABYLON {
  68732. /** @hidden */
  68733. export var clipPlaneVertexDeclaration2: {
  68734. name: string;
  68735. shader: string;
  68736. };
  68737. }
  68738. declare module BABYLON {
  68739. /** @hidden */
  68740. export var gpuRenderParticlesVertexShader: {
  68741. name: string;
  68742. shader: string;
  68743. };
  68744. }
  68745. declare module BABYLON {
  68746. /**
  68747. * This represents a GPU particle system in Babylon
  68748. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68749. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68750. */
  68751. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68752. /**
  68753. * The layer mask we are rendering the particles through.
  68754. */
  68755. layerMask: number;
  68756. private _capacity;
  68757. private _activeCount;
  68758. private _currentActiveCount;
  68759. private _accumulatedCount;
  68760. private _renderEffect;
  68761. private _updateEffect;
  68762. private _buffer0;
  68763. private _buffer1;
  68764. private _spriteBuffer;
  68765. private _updateVAO;
  68766. private _renderVAO;
  68767. private _targetIndex;
  68768. private _sourceBuffer;
  68769. private _targetBuffer;
  68770. private _currentRenderId;
  68771. private _started;
  68772. private _stopped;
  68773. private _timeDelta;
  68774. private _randomTexture;
  68775. private _randomTexture2;
  68776. private _attributesStrideSize;
  68777. private _updateEffectOptions;
  68778. private _randomTextureSize;
  68779. private _actualFrame;
  68780. private _customEffect;
  68781. private readonly _rawTextureWidth;
  68782. /**
  68783. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68784. */
  68785. static get IsSupported(): boolean;
  68786. /**
  68787. * An event triggered when the system is disposed.
  68788. */
  68789. onDisposeObservable: Observable<IParticleSystem>;
  68790. /**
  68791. * An event triggered when the system is stopped
  68792. */
  68793. onStoppedObservable: Observable<IParticleSystem>;
  68794. /**
  68795. * Gets the maximum number of particles active at the same time.
  68796. * @returns The max number of active particles.
  68797. */
  68798. getCapacity(): number;
  68799. /**
  68800. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68801. * to override the particles.
  68802. */
  68803. forceDepthWrite: boolean;
  68804. /**
  68805. * Gets or set the number of active particles
  68806. */
  68807. get activeParticleCount(): number;
  68808. set activeParticleCount(value: number);
  68809. private _preWarmDone;
  68810. /**
  68811. * Specifies if the particles are updated in emitter local space or world space.
  68812. */
  68813. isLocal: boolean;
  68814. /** Gets or sets a matrix to use to compute projection */
  68815. defaultProjectionMatrix: Matrix;
  68816. /**
  68817. * Is this system ready to be used/rendered
  68818. * @return true if the system is ready
  68819. */
  68820. isReady(): boolean;
  68821. /**
  68822. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68823. * @returns True if it has been started, otherwise false.
  68824. */
  68825. isStarted(): boolean;
  68826. /**
  68827. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68828. * @returns True if it has been stopped, otherwise false.
  68829. */
  68830. isStopped(): boolean;
  68831. /**
  68832. * Gets a boolean indicating that the system is stopping
  68833. * @returns true if the system is currently stopping
  68834. */
  68835. isStopping(): boolean;
  68836. /**
  68837. * Gets the number of particles active at the same time.
  68838. * @returns The number of active particles.
  68839. */
  68840. getActiveCount(): number;
  68841. /**
  68842. * Starts the particle system and begins to emit
  68843. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68844. */
  68845. start(delay?: number): void;
  68846. /**
  68847. * Stops the particle system.
  68848. */
  68849. stop(): void;
  68850. /**
  68851. * Remove all active particles
  68852. */
  68853. reset(): void;
  68854. /**
  68855. * Returns the string "GPUParticleSystem"
  68856. * @returns a string containing the class name
  68857. */
  68858. getClassName(): string;
  68859. /**
  68860. * Gets the custom effect used to render the particles
  68861. * @param blendMode Blend mode for which the effect should be retrieved
  68862. * @returns The effect
  68863. */
  68864. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68865. /**
  68866. * Sets the custom effect used to render the particles
  68867. * @param effect The effect to set
  68868. * @param blendMode Blend mode for which the effect should be set
  68869. */
  68870. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68871. /** @hidden */
  68872. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68873. /**
  68874. * Observable that will be called just before the particles are drawn
  68875. */
  68876. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68877. /**
  68878. * Gets the name of the particle vertex shader
  68879. */
  68880. get vertexShaderName(): string;
  68881. private _colorGradientsTexture;
  68882. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68883. /**
  68884. * Adds a new color gradient
  68885. * @param gradient defines the gradient to use (between 0 and 1)
  68886. * @param color1 defines the color to affect to the specified gradient
  68887. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68888. * @returns the current particle system
  68889. */
  68890. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68891. private _refreshColorGradient;
  68892. /** Force the system to rebuild all gradients that need to be resync */
  68893. forceRefreshGradients(): void;
  68894. /**
  68895. * Remove a specific color gradient
  68896. * @param gradient defines the gradient to remove
  68897. * @returns the current particle system
  68898. */
  68899. removeColorGradient(gradient: number): GPUParticleSystem;
  68900. private _angularSpeedGradientsTexture;
  68901. private _sizeGradientsTexture;
  68902. private _velocityGradientsTexture;
  68903. private _limitVelocityGradientsTexture;
  68904. private _dragGradientsTexture;
  68905. private _addFactorGradient;
  68906. /**
  68907. * Adds a new size gradient
  68908. * @param gradient defines the gradient to use (between 0 and 1)
  68909. * @param factor defines the size factor to affect to the specified gradient
  68910. * @returns the current particle system
  68911. */
  68912. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68913. /**
  68914. * Remove a specific size gradient
  68915. * @param gradient defines the gradient to remove
  68916. * @returns the current particle system
  68917. */
  68918. removeSizeGradient(gradient: number): GPUParticleSystem;
  68919. private _refreshFactorGradient;
  68920. /**
  68921. * Adds a new angular speed gradient
  68922. * @param gradient defines the gradient to use (between 0 and 1)
  68923. * @param factor defines the angular speed to affect to the specified gradient
  68924. * @returns the current particle system
  68925. */
  68926. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68927. /**
  68928. * Remove a specific angular speed gradient
  68929. * @param gradient defines the gradient to remove
  68930. * @returns the current particle system
  68931. */
  68932. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68933. /**
  68934. * Adds a new velocity gradient
  68935. * @param gradient defines the gradient to use (between 0 and 1)
  68936. * @param factor defines the velocity to affect to the specified gradient
  68937. * @returns the current particle system
  68938. */
  68939. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68940. /**
  68941. * Remove a specific velocity gradient
  68942. * @param gradient defines the gradient to remove
  68943. * @returns the current particle system
  68944. */
  68945. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68946. /**
  68947. * Adds a new limit velocity gradient
  68948. * @param gradient defines the gradient to use (between 0 and 1)
  68949. * @param factor defines the limit velocity value to affect to the specified gradient
  68950. * @returns the current particle system
  68951. */
  68952. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68953. /**
  68954. * Remove a specific limit velocity gradient
  68955. * @param gradient defines the gradient to remove
  68956. * @returns the current particle system
  68957. */
  68958. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68959. /**
  68960. * Adds a new drag gradient
  68961. * @param gradient defines the gradient to use (between 0 and 1)
  68962. * @param factor defines the drag value to affect to the specified gradient
  68963. * @returns the current particle system
  68964. */
  68965. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68966. /**
  68967. * Remove a specific drag gradient
  68968. * @param gradient defines the gradient to remove
  68969. * @returns the current particle system
  68970. */
  68971. removeDragGradient(gradient: number): GPUParticleSystem;
  68972. /**
  68973. * Not supported by GPUParticleSystem
  68974. * @param gradient defines the gradient to use (between 0 and 1)
  68975. * @param factor defines the emit rate value to affect to the specified gradient
  68976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68977. * @returns the current particle system
  68978. */
  68979. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68980. /**
  68981. * Not supported by GPUParticleSystem
  68982. * @param gradient defines the gradient to remove
  68983. * @returns the current particle system
  68984. */
  68985. removeEmitRateGradient(gradient: number): IParticleSystem;
  68986. /**
  68987. * Not supported by GPUParticleSystem
  68988. * @param gradient defines the gradient to use (between 0 and 1)
  68989. * @param factor defines the start size value to affect to the specified gradient
  68990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68991. * @returns the current particle system
  68992. */
  68993. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68994. /**
  68995. * Not supported by GPUParticleSystem
  68996. * @param gradient defines the gradient to remove
  68997. * @returns the current particle system
  68998. */
  68999. removeStartSizeGradient(gradient: number): IParticleSystem;
  69000. /**
  69001. * Not supported by GPUParticleSystem
  69002. * @param gradient defines the gradient to use (between 0 and 1)
  69003. * @param min defines the color remap minimal range
  69004. * @param max defines the color remap maximal range
  69005. * @returns the current particle system
  69006. */
  69007. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69008. /**
  69009. * Not supported by GPUParticleSystem
  69010. * @param gradient defines the gradient to remove
  69011. * @returns the current particle system
  69012. */
  69013. removeColorRemapGradient(): IParticleSystem;
  69014. /**
  69015. * Not supported by GPUParticleSystem
  69016. * @param gradient defines the gradient to use (between 0 and 1)
  69017. * @param min defines the alpha remap minimal range
  69018. * @param max defines the alpha remap maximal range
  69019. * @returns the current particle system
  69020. */
  69021. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69022. /**
  69023. * Not supported by GPUParticleSystem
  69024. * @param gradient defines the gradient to remove
  69025. * @returns the current particle system
  69026. */
  69027. removeAlphaRemapGradient(): IParticleSystem;
  69028. /**
  69029. * Not supported by GPUParticleSystem
  69030. * @param gradient defines the gradient to use (between 0 and 1)
  69031. * @param color defines the color to affect to the specified gradient
  69032. * @returns the current particle system
  69033. */
  69034. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69035. /**
  69036. * Not supported by GPUParticleSystem
  69037. * @param gradient defines the gradient to remove
  69038. * @returns the current particle system
  69039. */
  69040. removeRampGradient(): IParticleSystem;
  69041. /**
  69042. * Not supported by GPUParticleSystem
  69043. * @returns the list of ramp gradients
  69044. */
  69045. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69046. /**
  69047. * Not supported by GPUParticleSystem
  69048. * Gets or sets a boolean indicating that ramp gradients must be used
  69049. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69050. */
  69051. get useRampGradients(): boolean;
  69052. set useRampGradients(value: boolean);
  69053. /**
  69054. * Not supported by GPUParticleSystem
  69055. * @param gradient defines the gradient to use (between 0 and 1)
  69056. * @param factor defines the life time factor to affect to the specified gradient
  69057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69058. * @returns the current particle system
  69059. */
  69060. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69061. /**
  69062. * Not supported by GPUParticleSystem
  69063. * @param gradient defines the gradient to remove
  69064. * @returns the current particle system
  69065. */
  69066. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69067. /**
  69068. * Instantiates a GPU particle system.
  69069. * 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.
  69070. * @param name The name of the particle system
  69071. * @param options The options used to create the system
  69072. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69073. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69074. * @param customEffect a custom effect used to change the way particles are rendered by default
  69075. */
  69076. constructor(name: string, options: Partial<{
  69077. capacity: number;
  69078. randomTextureSize: number;
  69079. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69080. protected _reset(): void;
  69081. private _createUpdateVAO;
  69082. private _createRenderVAO;
  69083. private _initialize;
  69084. /** @hidden */
  69085. _recreateUpdateEffect(): void;
  69086. private _getEffect;
  69087. /**
  69088. * Fill the defines array according to the current settings of the particle system
  69089. * @param defines Array to be updated
  69090. * @param blendMode blend mode to take into account when updating the array
  69091. */
  69092. fillDefines(defines: Array<string>, blendMode?: number): void;
  69093. /**
  69094. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69095. * @param uniforms Uniforms array to fill
  69096. * @param attributes Attributes array to fill
  69097. * @param samplers Samplers array to fill
  69098. */
  69099. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69100. /** @hidden */
  69101. _recreateRenderEffect(): Effect;
  69102. /**
  69103. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69104. * @param preWarm defines if we are in the pre-warmimg phase
  69105. */
  69106. animate(preWarm?: boolean): void;
  69107. private _createFactorGradientTexture;
  69108. private _createSizeGradientTexture;
  69109. private _createAngularSpeedGradientTexture;
  69110. private _createVelocityGradientTexture;
  69111. private _createLimitVelocityGradientTexture;
  69112. private _createDragGradientTexture;
  69113. private _createColorGradientTexture;
  69114. /**
  69115. * Renders the particle system in its current state
  69116. * @param preWarm defines if the system should only update the particles but not render them
  69117. * @returns the current number of particles
  69118. */
  69119. render(preWarm?: boolean): number;
  69120. /**
  69121. * Rebuilds the particle system
  69122. */
  69123. rebuild(): void;
  69124. private _releaseBuffers;
  69125. private _releaseVAOs;
  69126. /**
  69127. * Disposes the particle system and free the associated resources
  69128. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69129. */
  69130. dispose(disposeTexture?: boolean): void;
  69131. /**
  69132. * Clones the particle system.
  69133. * @param name The name of the cloned object
  69134. * @param newEmitter The new emitter to use
  69135. * @returns the cloned particle system
  69136. */
  69137. clone(name: string, newEmitter: any): GPUParticleSystem;
  69138. /**
  69139. * Serializes the particle system to a JSON object
  69140. * @param serializeTexture defines if the texture must be serialized as well
  69141. * @returns the JSON object
  69142. */
  69143. serialize(serializeTexture?: boolean): any;
  69144. /**
  69145. * Parses a JSON object to create a GPU particle system.
  69146. * @param parsedParticleSystem The JSON object to parse
  69147. * @param sceneOrEngine The scene or the engine to create the particle system in
  69148. * @param rootUrl The root url to use to load external dependencies like texture
  69149. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69150. * @returns the parsed GPU particle system
  69151. */
  69152. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69153. }
  69154. }
  69155. declare module BABYLON {
  69156. /**
  69157. * Represents a set of particle systems working together to create a specific effect
  69158. */
  69159. export class ParticleSystemSet implements IDisposable {
  69160. /**
  69161. * Gets or sets base Assets URL
  69162. */
  69163. static BaseAssetsUrl: string;
  69164. private _emitterCreationOptions;
  69165. private _emitterNode;
  69166. /**
  69167. * Gets the particle system list
  69168. */
  69169. systems: IParticleSystem[];
  69170. /**
  69171. * Gets the emitter node used with this set
  69172. */
  69173. get emitterNode(): Nullable<TransformNode>;
  69174. /**
  69175. * Creates a new emitter mesh as a sphere
  69176. * @param options defines the options used to create the sphere
  69177. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69178. * @param scene defines the hosting scene
  69179. */
  69180. setEmitterAsSphere(options: {
  69181. diameter: number;
  69182. segments: number;
  69183. color: Color3;
  69184. }, renderingGroupId: number, scene: Scene): void;
  69185. /**
  69186. * Starts all particle systems of the set
  69187. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69188. */
  69189. start(emitter?: AbstractMesh): void;
  69190. /**
  69191. * Release all associated resources
  69192. */
  69193. dispose(): void;
  69194. /**
  69195. * Serialize the set into a JSON compatible object
  69196. * @param serializeTexture defines if the texture must be serialized as well
  69197. * @returns a JSON compatible representation of the set
  69198. */
  69199. serialize(serializeTexture?: boolean): any;
  69200. /**
  69201. * Parse a new ParticleSystemSet from a serialized source
  69202. * @param data defines a JSON compatible representation of the set
  69203. * @param scene defines the hosting scene
  69204. * @param gpu defines if we want GPU particles or CPU particles
  69205. * @returns a new ParticleSystemSet
  69206. */
  69207. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69208. }
  69209. }
  69210. declare module BABYLON {
  69211. /**
  69212. * This class is made for on one-liner static method to help creating particle system set.
  69213. */
  69214. export class ParticleHelper {
  69215. /**
  69216. * Gets or sets base Assets URL
  69217. */
  69218. static BaseAssetsUrl: string;
  69219. /** Define the Url to load snippets */
  69220. static SnippetUrl: string;
  69221. /**
  69222. * Create a default particle system that you can tweak
  69223. * @param emitter defines the emitter to use
  69224. * @param capacity defines the system capacity (default is 500 particles)
  69225. * @param scene defines the hosting scene
  69226. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69227. * @returns the new Particle system
  69228. */
  69229. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69230. /**
  69231. * This is the main static method (one-liner) of this helper to create different particle systems
  69232. * @param type This string represents the type to the particle system to create
  69233. * @param scene The scene where the particle system should live
  69234. * @param gpu If the system will use gpu
  69235. * @returns the ParticleSystemSet created
  69236. */
  69237. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69238. /**
  69239. * Static function used to export a particle system to a ParticleSystemSet variable.
  69240. * Please note that the emitter shape is not exported
  69241. * @param systems defines the particle systems to export
  69242. * @returns the created particle system set
  69243. */
  69244. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69245. /**
  69246. * Creates a particle system from a snippet saved in a remote file
  69247. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69248. * @param url defines the url to load from
  69249. * @param scene defines the hosting scene
  69250. * @param gpu If the system will use gpu
  69251. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69252. * @returns a promise that will resolve to the new particle system
  69253. */
  69254. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69255. /**
  69256. * Creates a particle system from a snippet saved by the particle system editor
  69257. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69258. * @param scene defines the hosting scene
  69259. * @param gpu If the system will use gpu
  69260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69261. * @returns a promise that will resolve to the new particle system
  69262. */
  69263. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69264. }
  69265. }
  69266. declare module BABYLON {
  69267. interface Engine {
  69268. /**
  69269. * Create an effect to use with particle systems.
  69270. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69271. * the particle system for which you want to create a custom effect in the last parameter
  69272. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69273. * @param uniformsNames defines a list of attribute names
  69274. * @param samplers defines an array of string used to represent textures
  69275. * @param defines defines the string containing the defines to use to compile the shaders
  69276. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69277. * @param onCompiled defines a function to call when the effect creation is successful
  69278. * @param onError defines a function to call when the effect creation has failed
  69279. * @param particleSystem the particle system you want to create the effect for
  69280. * @returns the new Effect
  69281. */
  69282. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69283. }
  69284. interface Mesh {
  69285. /**
  69286. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69287. * @returns an array of IParticleSystem
  69288. */
  69289. getEmittedParticleSystems(): IParticleSystem[];
  69290. /**
  69291. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69292. * @returns an array of IParticleSystem
  69293. */
  69294. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69295. }
  69296. }
  69297. declare module BABYLON {
  69298. /** Defines the 4 color options */
  69299. export enum PointColor {
  69300. /** color value */
  69301. Color = 2,
  69302. /** uv value */
  69303. UV = 1,
  69304. /** random value */
  69305. Random = 0,
  69306. /** stated value */
  69307. Stated = 3
  69308. }
  69309. /**
  69310. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69311. * 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.
  69312. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69313. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69314. *
  69315. * Full documentation here : TO BE ENTERED
  69316. */
  69317. export class PointsCloudSystem implements IDisposable {
  69318. /**
  69319. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69320. * Example : var p = SPS.particles[i];
  69321. */
  69322. particles: CloudPoint[];
  69323. /**
  69324. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69325. */
  69326. nbParticles: number;
  69327. /**
  69328. * This a counter for your own usage. It's not set by any SPS functions.
  69329. */
  69330. counter: number;
  69331. /**
  69332. * The PCS name. This name is also given to the underlying mesh.
  69333. */
  69334. name: string;
  69335. /**
  69336. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69337. */
  69338. mesh: Mesh;
  69339. /**
  69340. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69341. * Please read :
  69342. */
  69343. vars: any;
  69344. /**
  69345. * @hidden
  69346. */
  69347. _size: number;
  69348. private _scene;
  69349. private _promises;
  69350. private _positions;
  69351. private _indices;
  69352. private _normals;
  69353. private _colors;
  69354. private _uvs;
  69355. private _indices32;
  69356. private _positions32;
  69357. private _colors32;
  69358. private _uvs32;
  69359. private _updatable;
  69360. private _isVisibilityBoxLocked;
  69361. private _alwaysVisible;
  69362. private _groups;
  69363. private _groupCounter;
  69364. private _computeParticleColor;
  69365. private _computeParticleTexture;
  69366. private _computeParticleRotation;
  69367. private _computeBoundingBox;
  69368. private _isReady;
  69369. /**
  69370. * Creates a PCS (Points Cloud System) object
  69371. * @param name (String) is the PCS name, this will be the underlying mesh name
  69372. * @param pointSize (number) is the size for each point
  69373. * @param scene (Scene) is the scene in which the PCS is added
  69374. * @param options defines the options of the PCS e.g.
  69375. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69376. */
  69377. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69378. updatable?: boolean;
  69379. });
  69380. /**
  69381. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69382. * If no points were added to the PCS, the returned mesh is just a single point.
  69383. * @returns a promise for the created mesh
  69384. */
  69385. buildMeshAsync(): Promise<Mesh>;
  69386. /**
  69387. * @hidden
  69388. */
  69389. private _buildMesh;
  69390. private _addParticle;
  69391. private _randomUnitVector;
  69392. private _getColorIndicesForCoord;
  69393. private _setPointsColorOrUV;
  69394. private _colorFromTexture;
  69395. private _calculateDensity;
  69396. /**
  69397. * Adds points to the PCS in random positions within a unit sphere
  69398. * @param nb (positive integer) the number of particles to be created from this model
  69399. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69400. * @returns the number of groups in the system
  69401. */
  69402. addPoints(nb: number, pointFunction?: any): number;
  69403. /**
  69404. * Adds points to the PCS from the surface of the model shape
  69405. * @param mesh is any Mesh object that will be used as a surface model for the points
  69406. * @param nb (positive integer) the number of particles to be created from this model
  69407. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69408. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69409. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69410. * @returns the number of groups in the system
  69411. */
  69412. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69413. /**
  69414. * Adds points to the PCS inside the model shape
  69415. * @param mesh is any Mesh object that will be used as a surface model for the points
  69416. * @param nb (positive integer) the number of particles to be created from this model
  69417. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69418. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69419. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69420. * @returns the number of groups in the system
  69421. */
  69422. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69423. /**
  69424. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69425. * This method calls `updateParticle()` for each particle of the SPS.
  69426. * For an animated SPS, it is usually called within the render loop.
  69427. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69428. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69429. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69430. * @returns the PCS.
  69431. */
  69432. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69433. /**
  69434. * Disposes the PCS.
  69435. */
  69436. dispose(): void;
  69437. /**
  69438. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69439. * doc :
  69440. * @returns the PCS.
  69441. */
  69442. refreshVisibleSize(): PointsCloudSystem;
  69443. /**
  69444. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69445. * @param size the size (float) of the visibility box
  69446. * note : this doesn't lock the PCS mesh bounding box.
  69447. * doc :
  69448. */
  69449. setVisibilityBox(size: number): void;
  69450. /**
  69451. * Gets whether the PCS is always visible or not
  69452. * doc :
  69453. */
  69454. get isAlwaysVisible(): boolean;
  69455. /**
  69456. * Sets the PCS as always visible or not
  69457. * doc :
  69458. */
  69459. set isAlwaysVisible(val: boolean);
  69460. /**
  69461. * Tells to `setParticles()` to compute the particle rotations or not
  69462. * Default value : false. The PCS is faster when it's set to false
  69463. * Note : particle rotations are only applied to parent particles
  69464. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69465. */
  69466. set computeParticleRotation(val: boolean);
  69467. /**
  69468. * Tells to `setParticles()` to compute the particle colors or not.
  69469. * Default value : true. The PCS is faster when it's set to false.
  69470. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69471. */
  69472. set computeParticleColor(val: boolean);
  69473. set computeParticleTexture(val: boolean);
  69474. /**
  69475. * Gets if `setParticles()` computes the particle colors or not.
  69476. * Default value : false. The PCS is faster when it's set to false.
  69477. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69478. */
  69479. get computeParticleColor(): boolean;
  69480. /**
  69481. * Gets if `setParticles()` computes the particle textures or not.
  69482. * Default value : false. The PCS is faster when it's set to false.
  69483. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69484. */
  69485. get computeParticleTexture(): boolean;
  69486. /**
  69487. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69488. */
  69489. set computeBoundingBox(val: boolean);
  69490. /**
  69491. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69492. */
  69493. get computeBoundingBox(): boolean;
  69494. /**
  69495. * This function does nothing. It may be overwritten to set all the particle first values.
  69496. * The PCS doesn't call this function, you may have to call it by your own.
  69497. * doc :
  69498. */
  69499. initParticles(): void;
  69500. /**
  69501. * This function does nothing. It may be overwritten to recycle a particle
  69502. * The PCS doesn't call this function, you can to call it
  69503. * doc :
  69504. * @param particle The particle to recycle
  69505. * @returns the recycled particle
  69506. */
  69507. recycleParticle(particle: CloudPoint): CloudPoint;
  69508. /**
  69509. * Updates a particle : this function should be overwritten by the user.
  69510. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69511. * doc :
  69512. * @example : just set a particle position or velocity and recycle conditions
  69513. * @param particle The particle to update
  69514. * @returns the updated particle
  69515. */
  69516. updateParticle(particle: CloudPoint): CloudPoint;
  69517. /**
  69518. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69519. * This does nothing and may be overwritten by the user.
  69520. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69521. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69522. * @param update the boolean update value actually passed to setParticles()
  69523. */
  69524. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69525. /**
  69526. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69527. * This will be passed three parameters.
  69528. * This does nothing and may be overwritten by the user.
  69529. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69530. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69531. * @param update the boolean update value actually passed to setParticles()
  69532. */
  69533. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69534. }
  69535. }
  69536. declare module BABYLON {
  69537. /**
  69538. * Represents one particle of a points cloud system.
  69539. */
  69540. export class CloudPoint {
  69541. /**
  69542. * particle global index
  69543. */
  69544. idx: number;
  69545. /**
  69546. * The color of the particle
  69547. */
  69548. color: Nullable<Color4>;
  69549. /**
  69550. * The world space position of the particle.
  69551. */
  69552. position: Vector3;
  69553. /**
  69554. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69555. */
  69556. rotation: Vector3;
  69557. /**
  69558. * The world space rotation quaternion of the particle.
  69559. */
  69560. rotationQuaternion: Nullable<Quaternion>;
  69561. /**
  69562. * The uv of the particle.
  69563. */
  69564. uv: Nullable<Vector2>;
  69565. /**
  69566. * The current speed of the particle.
  69567. */
  69568. velocity: Vector3;
  69569. /**
  69570. * The pivot point in the particle local space.
  69571. */
  69572. pivot: Vector3;
  69573. /**
  69574. * Must the particle be translated from its pivot point in its local space ?
  69575. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69576. * Default : false
  69577. */
  69578. translateFromPivot: boolean;
  69579. /**
  69580. * Index of this particle in the global "positions" array (Internal use)
  69581. * @hidden
  69582. */
  69583. _pos: number;
  69584. /**
  69585. * @hidden Index of this particle in the global "indices" array (Internal use)
  69586. */
  69587. _ind: number;
  69588. /**
  69589. * Group this particle belongs to
  69590. */
  69591. _group: PointsGroup;
  69592. /**
  69593. * Group id of this particle
  69594. */
  69595. groupId: number;
  69596. /**
  69597. * Index of the particle in its group id (Internal use)
  69598. */
  69599. idxInGroup: number;
  69600. /**
  69601. * @hidden Particle BoundingInfo object (Internal use)
  69602. */
  69603. _boundingInfo: BoundingInfo;
  69604. /**
  69605. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69606. */
  69607. _pcs: PointsCloudSystem;
  69608. /**
  69609. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69610. */
  69611. _stillInvisible: boolean;
  69612. /**
  69613. * @hidden Last computed particle rotation matrix
  69614. */
  69615. _rotationMatrix: number[];
  69616. /**
  69617. * Parent particle Id, if any.
  69618. * Default null.
  69619. */
  69620. parentId: Nullable<number>;
  69621. /**
  69622. * @hidden Internal global position in the PCS.
  69623. */
  69624. _globalPosition: Vector3;
  69625. /**
  69626. * Creates a Point Cloud object.
  69627. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69628. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69629. * @param group (PointsGroup) is the group the particle belongs to
  69630. * @param groupId (integer) is the group identifier in the PCS.
  69631. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69632. * @param pcs defines the PCS it is associated to
  69633. */
  69634. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69635. /**
  69636. * get point size
  69637. */
  69638. get size(): Vector3;
  69639. /**
  69640. * Set point size
  69641. */
  69642. set size(scale: Vector3);
  69643. /**
  69644. * Legacy support, changed quaternion to rotationQuaternion
  69645. */
  69646. get quaternion(): Nullable<Quaternion>;
  69647. /**
  69648. * Legacy support, changed quaternion to rotationQuaternion
  69649. */
  69650. set quaternion(q: Nullable<Quaternion>);
  69651. /**
  69652. * Returns a boolean. True if the particle intersects a mesh, else false
  69653. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69654. * @param target is the object (point or mesh) what the intersection is computed against
  69655. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69656. * @returns true if it intersects
  69657. */
  69658. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69659. /**
  69660. * get the rotation matrix of the particle
  69661. * @hidden
  69662. */
  69663. getRotationMatrix(m: Matrix): void;
  69664. }
  69665. /**
  69666. * Represents a group of points in a points cloud system
  69667. * * PCS internal tool, don't use it manually.
  69668. */
  69669. export class PointsGroup {
  69670. /**
  69671. * The group id
  69672. * @hidden
  69673. */
  69674. groupID: number;
  69675. /**
  69676. * image data for group (internal use)
  69677. * @hidden
  69678. */
  69679. _groupImageData: Nullable<ArrayBufferView>;
  69680. /**
  69681. * Image Width (internal use)
  69682. * @hidden
  69683. */
  69684. _groupImgWidth: number;
  69685. /**
  69686. * Image Height (internal use)
  69687. * @hidden
  69688. */
  69689. _groupImgHeight: number;
  69690. /**
  69691. * Custom position function (internal use)
  69692. * @hidden
  69693. */
  69694. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69695. /**
  69696. * density per facet for surface points
  69697. * @hidden
  69698. */
  69699. _groupDensity: number[];
  69700. /**
  69701. * Only when points are colored by texture carries pointer to texture list array
  69702. * @hidden
  69703. */
  69704. _textureNb: number;
  69705. /**
  69706. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69707. * PCS internal tool, don't use it manually.
  69708. * @hidden
  69709. */
  69710. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69711. }
  69712. }
  69713. declare module BABYLON {
  69714. interface Scene {
  69715. /** @hidden (Backing field) */
  69716. _physicsEngine: Nullable<IPhysicsEngine>;
  69717. /** @hidden */
  69718. _physicsTimeAccumulator: number;
  69719. /**
  69720. * Gets the current physics engine
  69721. * @returns a IPhysicsEngine or null if none attached
  69722. */
  69723. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69724. /**
  69725. * Enables physics to the current scene
  69726. * @param gravity defines the scene's gravity for the physics engine
  69727. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69728. * @return a boolean indicating if the physics engine was initialized
  69729. */
  69730. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69731. /**
  69732. * Disables and disposes the physics engine associated with the scene
  69733. */
  69734. disablePhysicsEngine(): void;
  69735. /**
  69736. * Gets a boolean indicating if there is an active physics engine
  69737. * @returns a boolean indicating if there is an active physics engine
  69738. */
  69739. isPhysicsEnabled(): boolean;
  69740. /**
  69741. * Deletes a physics compound impostor
  69742. * @param compound defines the compound to delete
  69743. */
  69744. deleteCompoundImpostor(compound: any): void;
  69745. /**
  69746. * An event triggered when physic simulation is about to be run
  69747. */
  69748. onBeforePhysicsObservable: Observable<Scene>;
  69749. /**
  69750. * An event triggered when physic simulation has been done
  69751. */
  69752. onAfterPhysicsObservable: Observable<Scene>;
  69753. }
  69754. interface AbstractMesh {
  69755. /** @hidden */
  69756. _physicsImpostor: Nullable<PhysicsImpostor>;
  69757. /**
  69758. * Gets or sets impostor used for physic simulation
  69759. * @see https://doc.babylonjs.com/features/physics_engine
  69760. */
  69761. physicsImpostor: Nullable<PhysicsImpostor>;
  69762. /**
  69763. * Gets the current physics impostor
  69764. * @see https://doc.babylonjs.com/features/physics_engine
  69765. * @returns a physics impostor or null
  69766. */
  69767. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69768. /** Apply a physic impulse to the mesh
  69769. * @param force defines the force to apply
  69770. * @param contactPoint defines where to apply the force
  69771. * @returns the current mesh
  69772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69773. */
  69774. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69775. /**
  69776. * Creates a physic joint between two meshes
  69777. * @param otherMesh defines the other mesh to use
  69778. * @param pivot1 defines the pivot to use on this mesh
  69779. * @param pivot2 defines the pivot to use on the other mesh
  69780. * @param options defines additional options (can be plugin dependent)
  69781. * @returns the current mesh
  69782. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69783. */
  69784. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69785. /** @hidden */
  69786. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69787. }
  69788. /**
  69789. * Defines the physics engine scene component responsible to manage a physics engine
  69790. */
  69791. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69792. /**
  69793. * The component name helpful to identify the component in the list of scene components.
  69794. */
  69795. readonly name: string;
  69796. /**
  69797. * The scene the component belongs to.
  69798. */
  69799. scene: Scene;
  69800. /**
  69801. * Creates a new instance of the component for the given scene
  69802. * @param scene Defines the scene to register the component in
  69803. */
  69804. constructor(scene: Scene);
  69805. /**
  69806. * Registers the component in a given scene
  69807. */
  69808. register(): void;
  69809. /**
  69810. * Rebuilds the elements related to this component in case of
  69811. * context lost for instance.
  69812. */
  69813. rebuild(): void;
  69814. /**
  69815. * Disposes the component and the associated ressources
  69816. */
  69817. dispose(): void;
  69818. }
  69819. }
  69820. declare module BABYLON {
  69821. /**
  69822. * A helper for physics simulations
  69823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69824. */
  69825. export class PhysicsHelper {
  69826. private _scene;
  69827. private _physicsEngine;
  69828. /**
  69829. * Initializes the Physics helper
  69830. * @param scene Babylon.js scene
  69831. */
  69832. constructor(scene: Scene);
  69833. /**
  69834. * Applies a radial explosion impulse
  69835. * @param origin the origin of the explosion
  69836. * @param radiusOrEventOptions the radius or the options of radial explosion
  69837. * @param strength the explosion strength
  69838. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69839. * @returns A physics radial explosion event, or null
  69840. */
  69841. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69842. /**
  69843. * Applies a radial explosion force
  69844. * @param origin the origin of the explosion
  69845. * @param radiusOrEventOptions the radius or the options of radial explosion
  69846. * @param strength the explosion strength
  69847. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69848. * @returns A physics radial explosion event, or null
  69849. */
  69850. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69851. /**
  69852. * Creates a gravitational field
  69853. * @param origin the origin of the explosion
  69854. * @param radiusOrEventOptions the radius or the options of radial explosion
  69855. * @param strength the explosion strength
  69856. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69857. * @returns A physics gravitational field event, or null
  69858. */
  69859. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69860. /**
  69861. * Creates a physics updraft event
  69862. * @param origin the origin of the updraft
  69863. * @param radiusOrEventOptions the radius or the options of the updraft
  69864. * @param strength the strength of the updraft
  69865. * @param height the height of the updraft
  69866. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69867. * @returns A physics updraft event, or null
  69868. */
  69869. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69870. /**
  69871. * Creates a physics vortex event
  69872. * @param origin the of the vortex
  69873. * @param radiusOrEventOptions the radius or the options of the vortex
  69874. * @param strength the strength of the vortex
  69875. * @param height the height of the vortex
  69876. * @returns a Physics vortex event, or null
  69877. * A physics vortex event or null
  69878. */
  69879. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69880. }
  69881. /**
  69882. * Represents a physics radial explosion event
  69883. */
  69884. class PhysicsRadialExplosionEvent {
  69885. private _scene;
  69886. private _options;
  69887. private _sphere;
  69888. private _dataFetched;
  69889. /**
  69890. * Initializes a radial explosioin event
  69891. * @param _scene BabylonJS scene
  69892. * @param _options The options for the vortex event
  69893. */
  69894. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69895. /**
  69896. * Returns the data related to the radial explosion event (sphere).
  69897. * @returns The radial explosion event data
  69898. */
  69899. getData(): PhysicsRadialExplosionEventData;
  69900. /**
  69901. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69902. * @param impostor A physics imposter
  69903. * @param origin the origin of the explosion
  69904. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69905. */
  69906. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69907. /**
  69908. * Triggers affecterd impostors callbacks
  69909. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69910. */
  69911. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69912. /**
  69913. * Disposes the sphere.
  69914. * @param force Specifies if the sphere should be disposed by force
  69915. */
  69916. dispose(force?: boolean): void;
  69917. /*** Helpers ***/
  69918. private _prepareSphere;
  69919. private _intersectsWithSphere;
  69920. }
  69921. /**
  69922. * Represents a gravitational field event
  69923. */
  69924. class PhysicsGravitationalFieldEvent {
  69925. private _physicsHelper;
  69926. private _scene;
  69927. private _origin;
  69928. private _options;
  69929. private _tickCallback;
  69930. private _sphere;
  69931. private _dataFetched;
  69932. /**
  69933. * Initializes the physics gravitational field event
  69934. * @param _physicsHelper A physics helper
  69935. * @param _scene BabylonJS scene
  69936. * @param _origin The origin position of the gravitational field event
  69937. * @param _options The options for the vortex event
  69938. */
  69939. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69940. /**
  69941. * Returns the data related to the gravitational field event (sphere).
  69942. * @returns A gravitational field event
  69943. */
  69944. getData(): PhysicsGravitationalFieldEventData;
  69945. /**
  69946. * Enables the gravitational field.
  69947. */
  69948. enable(): void;
  69949. /**
  69950. * Disables the gravitational field.
  69951. */
  69952. disable(): void;
  69953. /**
  69954. * Disposes the sphere.
  69955. * @param force The force to dispose from the gravitational field event
  69956. */
  69957. dispose(force?: boolean): void;
  69958. private _tick;
  69959. }
  69960. /**
  69961. * Represents a physics updraft event
  69962. */
  69963. class PhysicsUpdraftEvent {
  69964. private _scene;
  69965. private _origin;
  69966. private _options;
  69967. private _physicsEngine;
  69968. private _originTop;
  69969. private _originDirection;
  69970. private _tickCallback;
  69971. private _cylinder;
  69972. private _cylinderPosition;
  69973. private _dataFetched;
  69974. /**
  69975. * Initializes the physics updraft event
  69976. * @param _scene BabylonJS scene
  69977. * @param _origin The origin position of the updraft
  69978. * @param _options The options for the updraft event
  69979. */
  69980. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69981. /**
  69982. * Returns the data related to the updraft event (cylinder).
  69983. * @returns A physics updraft event
  69984. */
  69985. getData(): PhysicsUpdraftEventData;
  69986. /**
  69987. * Enables the updraft.
  69988. */
  69989. enable(): void;
  69990. /**
  69991. * Disables the updraft.
  69992. */
  69993. disable(): void;
  69994. /**
  69995. * Disposes the cylinder.
  69996. * @param force Specifies if the updraft should be disposed by force
  69997. */
  69998. dispose(force?: boolean): void;
  69999. private getImpostorHitData;
  70000. private _tick;
  70001. /*** Helpers ***/
  70002. private _prepareCylinder;
  70003. private _intersectsWithCylinder;
  70004. }
  70005. /**
  70006. * Represents a physics vortex event
  70007. */
  70008. class PhysicsVortexEvent {
  70009. private _scene;
  70010. private _origin;
  70011. private _options;
  70012. private _physicsEngine;
  70013. private _originTop;
  70014. private _tickCallback;
  70015. private _cylinder;
  70016. private _cylinderPosition;
  70017. private _dataFetched;
  70018. /**
  70019. * Initializes the physics vortex event
  70020. * @param _scene The BabylonJS scene
  70021. * @param _origin The origin position of the vortex
  70022. * @param _options The options for the vortex event
  70023. */
  70024. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70025. /**
  70026. * Returns the data related to the vortex event (cylinder).
  70027. * @returns The physics vortex event data
  70028. */
  70029. getData(): PhysicsVortexEventData;
  70030. /**
  70031. * Enables the vortex.
  70032. */
  70033. enable(): void;
  70034. /**
  70035. * Disables the cortex.
  70036. */
  70037. disable(): void;
  70038. /**
  70039. * Disposes the sphere.
  70040. * @param force
  70041. */
  70042. dispose(force?: boolean): void;
  70043. private getImpostorHitData;
  70044. private _tick;
  70045. /*** Helpers ***/
  70046. private _prepareCylinder;
  70047. private _intersectsWithCylinder;
  70048. }
  70049. /**
  70050. * Options fot the radial explosion event
  70051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70052. */
  70053. export class PhysicsRadialExplosionEventOptions {
  70054. /**
  70055. * The radius of the sphere for the radial explosion.
  70056. */
  70057. radius: number;
  70058. /**
  70059. * The strenth of the explosion.
  70060. */
  70061. strength: number;
  70062. /**
  70063. * The strenght of the force in correspondence to the distance of the affected object
  70064. */
  70065. falloff: PhysicsRadialImpulseFalloff;
  70066. /**
  70067. * Sphere options for the radial explosion.
  70068. */
  70069. sphere: {
  70070. segments: number;
  70071. diameter: number;
  70072. };
  70073. /**
  70074. * Sphere options for the radial explosion.
  70075. */
  70076. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70077. }
  70078. /**
  70079. * Options fot the updraft event
  70080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70081. */
  70082. export class PhysicsUpdraftEventOptions {
  70083. /**
  70084. * The radius of the cylinder for the vortex
  70085. */
  70086. radius: number;
  70087. /**
  70088. * The strenth of the updraft.
  70089. */
  70090. strength: number;
  70091. /**
  70092. * The height of the cylinder for the updraft.
  70093. */
  70094. height: number;
  70095. /**
  70096. * The mode for the the updraft.
  70097. */
  70098. updraftMode: PhysicsUpdraftMode;
  70099. }
  70100. /**
  70101. * Options fot the vortex event
  70102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70103. */
  70104. export class PhysicsVortexEventOptions {
  70105. /**
  70106. * The radius of the cylinder for the vortex
  70107. */
  70108. radius: number;
  70109. /**
  70110. * The strenth of the vortex.
  70111. */
  70112. strength: number;
  70113. /**
  70114. * The height of the cylinder for the vortex.
  70115. */
  70116. height: number;
  70117. /**
  70118. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70119. */
  70120. centripetalForceThreshold: number;
  70121. /**
  70122. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70123. */
  70124. centripetalForceMultiplier: number;
  70125. /**
  70126. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70127. */
  70128. centrifugalForceMultiplier: number;
  70129. /**
  70130. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70131. */
  70132. updraftForceMultiplier: number;
  70133. }
  70134. /**
  70135. * The strenght of the force in correspondence to the distance of the affected object
  70136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70137. */
  70138. export enum PhysicsRadialImpulseFalloff {
  70139. /** Defines that impulse is constant in strength across it's whole radius */
  70140. Constant = 0,
  70141. /** Defines that impulse gets weaker if it's further from the origin */
  70142. Linear = 1
  70143. }
  70144. /**
  70145. * The strength of the force in correspondence to the distance of the affected object
  70146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70147. */
  70148. export enum PhysicsUpdraftMode {
  70149. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70150. Center = 0,
  70151. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70152. Perpendicular = 1
  70153. }
  70154. /**
  70155. * Interface for a physics hit data
  70156. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70157. */
  70158. export interface PhysicsHitData {
  70159. /**
  70160. * The force applied at the contact point
  70161. */
  70162. force: Vector3;
  70163. /**
  70164. * The contact point
  70165. */
  70166. contactPoint: Vector3;
  70167. /**
  70168. * The distance from the origin to the contact point
  70169. */
  70170. distanceFromOrigin: number;
  70171. }
  70172. /**
  70173. * Interface for radial explosion event data
  70174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70175. */
  70176. export interface PhysicsRadialExplosionEventData {
  70177. /**
  70178. * A sphere used for the radial explosion event
  70179. */
  70180. sphere: Mesh;
  70181. }
  70182. /**
  70183. * Interface for gravitational field event data
  70184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70185. */
  70186. export interface PhysicsGravitationalFieldEventData {
  70187. /**
  70188. * A sphere mesh used for the gravitational field event
  70189. */
  70190. sphere: Mesh;
  70191. }
  70192. /**
  70193. * Interface for updraft event data
  70194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70195. */
  70196. export interface PhysicsUpdraftEventData {
  70197. /**
  70198. * A cylinder used for the updraft event
  70199. */
  70200. cylinder: Mesh;
  70201. }
  70202. /**
  70203. * Interface for vortex event data
  70204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70205. */
  70206. export interface PhysicsVortexEventData {
  70207. /**
  70208. * A cylinder used for the vortex event
  70209. */
  70210. cylinder: Mesh;
  70211. }
  70212. /**
  70213. * Interface for an affected physics impostor
  70214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70215. */
  70216. export interface PhysicsAffectedImpostorWithData {
  70217. /**
  70218. * The impostor affected by the effect
  70219. */
  70220. impostor: PhysicsImpostor;
  70221. /**
  70222. * The data about the hit/horce from the explosion
  70223. */
  70224. hitData: PhysicsHitData;
  70225. }
  70226. }
  70227. declare module BABYLON {
  70228. /** @hidden */
  70229. export var blackAndWhitePixelShader: {
  70230. name: string;
  70231. shader: string;
  70232. };
  70233. }
  70234. declare module BABYLON {
  70235. /**
  70236. * Post process used to render in black and white
  70237. */
  70238. export class BlackAndWhitePostProcess extends PostProcess {
  70239. /**
  70240. * Linear about to convert he result to black and white (default: 1)
  70241. */
  70242. degree: number;
  70243. /**
  70244. * Gets a string identifying the name of the class
  70245. * @returns "BlackAndWhitePostProcess" string
  70246. */
  70247. getClassName(): string;
  70248. /**
  70249. * Creates a black and white post process
  70250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70251. * @param name The name of the effect.
  70252. * @param options The required width/height ratio to downsize to before computing the render pass.
  70253. * @param camera The camera to apply the render pass to.
  70254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70255. * @param engine The engine which the post process will be applied. (default: current engine)
  70256. * @param reusable If the post process can be reused on the same frame. (default: false)
  70257. */
  70258. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70259. /** @hidden */
  70260. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70261. }
  70262. }
  70263. declare module BABYLON {
  70264. /**
  70265. * This represents a set of one or more post processes in Babylon.
  70266. * A post process can be used to apply a shader to a texture after it is rendered.
  70267. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70268. */
  70269. export class PostProcessRenderEffect {
  70270. private _postProcesses;
  70271. private _getPostProcesses;
  70272. private _singleInstance;
  70273. private _cameras;
  70274. private _indicesForCamera;
  70275. /**
  70276. * Name of the effect
  70277. * @hidden
  70278. */
  70279. _name: string;
  70280. /**
  70281. * Instantiates a post process render effect.
  70282. * A post process can be used to apply a shader to a texture after it is rendered.
  70283. * @param engine The engine the effect is tied to
  70284. * @param name The name of the effect
  70285. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70286. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70287. */
  70288. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70289. /**
  70290. * Checks if all the post processes in the effect are supported.
  70291. */
  70292. get isSupported(): boolean;
  70293. /**
  70294. * Updates the current state of the effect
  70295. * @hidden
  70296. */
  70297. _update(): void;
  70298. /**
  70299. * Attaches the effect on cameras
  70300. * @param cameras The camera to attach to.
  70301. * @hidden
  70302. */
  70303. _attachCameras(cameras: Camera): void;
  70304. /**
  70305. * Attaches the effect on cameras
  70306. * @param cameras The camera to attach to.
  70307. * @hidden
  70308. */
  70309. _attachCameras(cameras: Camera[]): void;
  70310. /**
  70311. * Detaches the effect on cameras
  70312. * @param cameras The camera to detatch from.
  70313. * @hidden
  70314. */
  70315. _detachCameras(cameras: Camera): void;
  70316. /**
  70317. * Detatches the effect on cameras
  70318. * @param cameras The camera to detatch from.
  70319. * @hidden
  70320. */
  70321. _detachCameras(cameras: Camera[]): void;
  70322. /**
  70323. * Enables the effect on given cameras
  70324. * @param cameras The camera to enable.
  70325. * @hidden
  70326. */
  70327. _enable(cameras: Camera): void;
  70328. /**
  70329. * Enables the effect on given cameras
  70330. * @param cameras The camera to enable.
  70331. * @hidden
  70332. */
  70333. _enable(cameras: Nullable<Camera[]>): void;
  70334. /**
  70335. * Disables the effect on the given cameras
  70336. * @param cameras The camera to disable.
  70337. * @hidden
  70338. */
  70339. _disable(cameras: Camera): void;
  70340. /**
  70341. * Disables the effect on the given cameras
  70342. * @param cameras The camera to disable.
  70343. * @hidden
  70344. */
  70345. _disable(cameras: Nullable<Camera[]>): void;
  70346. /**
  70347. * Gets a list of the post processes contained in the effect.
  70348. * @param camera The camera to get the post processes on.
  70349. * @returns The list of the post processes in the effect.
  70350. */
  70351. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70352. }
  70353. }
  70354. declare module BABYLON {
  70355. /** @hidden */
  70356. export var extractHighlightsPixelShader: {
  70357. name: string;
  70358. shader: string;
  70359. };
  70360. }
  70361. declare module BABYLON {
  70362. /**
  70363. * 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.
  70364. */
  70365. export class ExtractHighlightsPostProcess extends PostProcess {
  70366. /**
  70367. * The luminance threshold, pixels below this value will be set to black.
  70368. */
  70369. threshold: number;
  70370. /** @hidden */
  70371. _exposure: number;
  70372. /**
  70373. * Post process which has the input texture to be used when performing highlight extraction
  70374. * @hidden
  70375. */
  70376. _inputPostProcess: Nullable<PostProcess>;
  70377. /**
  70378. * Gets a string identifying the name of the class
  70379. * @returns "ExtractHighlightsPostProcess" string
  70380. */
  70381. getClassName(): string;
  70382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70383. }
  70384. }
  70385. declare module BABYLON {
  70386. /** @hidden */
  70387. export var bloomMergePixelShader: {
  70388. name: string;
  70389. shader: string;
  70390. };
  70391. }
  70392. declare module BABYLON {
  70393. /**
  70394. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70395. */
  70396. export class BloomMergePostProcess extends PostProcess {
  70397. /** Weight of the bloom to be added to the original input. */
  70398. weight: number;
  70399. /**
  70400. * Gets a string identifying the name of the class
  70401. * @returns "BloomMergePostProcess" string
  70402. */
  70403. getClassName(): string;
  70404. /**
  70405. * Creates a new instance of @see BloomMergePostProcess
  70406. * @param name The name of the effect.
  70407. * @param originalFromInput Post process which's input will be used for the merge.
  70408. * @param blurred Blurred highlights post process which's output will be used.
  70409. * @param weight Weight of the bloom to be added to the original input.
  70410. * @param options The required width/height ratio to downsize to before computing the render pass.
  70411. * @param camera The camera to apply the render pass to.
  70412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70413. * @param engine The engine which the post process will be applied. (default: current engine)
  70414. * @param reusable If the post process can be reused on the same frame. (default: false)
  70415. * @param textureType Type of textures used when performing the post process. (default: 0)
  70416. * @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)
  70417. */
  70418. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70419. /** Weight of the bloom to be added to the original input. */
  70420. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70421. }
  70422. }
  70423. declare module BABYLON {
  70424. /**
  70425. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70426. */
  70427. export class BloomEffect extends PostProcessRenderEffect {
  70428. private bloomScale;
  70429. /**
  70430. * @hidden Internal
  70431. */
  70432. _effects: Array<PostProcess>;
  70433. /**
  70434. * @hidden Internal
  70435. */
  70436. _downscale: ExtractHighlightsPostProcess;
  70437. private _blurX;
  70438. private _blurY;
  70439. private _merge;
  70440. /**
  70441. * The luminance threshold to find bright areas of the image to bloom.
  70442. */
  70443. get threshold(): number;
  70444. set threshold(value: number);
  70445. /**
  70446. * The strength of the bloom.
  70447. */
  70448. get weight(): number;
  70449. set weight(value: number);
  70450. /**
  70451. * Specifies the size of the bloom blur kernel, relative to the final output size
  70452. */
  70453. get kernel(): number;
  70454. set kernel(value: number);
  70455. /**
  70456. * Creates a new instance of @see BloomEffect
  70457. * @param scene The scene the effect belongs to.
  70458. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70459. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70460. * @param bloomWeight The the strength of bloom.
  70461. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70462. * @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)
  70463. */
  70464. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70465. /**
  70466. * Disposes each of the internal effects for a given camera.
  70467. * @param camera The camera to dispose the effect on.
  70468. */
  70469. disposeEffects(camera: Camera): void;
  70470. /**
  70471. * @hidden Internal
  70472. */
  70473. _updateEffects(): void;
  70474. /**
  70475. * Internal
  70476. * @returns if all the contained post processes are ready.
  70477. * @hidden
  70478. */
  70479. _isReady(): boolean;
  70480. }
  70481. }
  70482. declare module BABYLON {
  70483. /** @hidden */
  70484. export var chromaticAberrationPixelShader: {
  70485. name: string;
  70486. shader: string;
  70487. };
  70488. }
  70489. declare module BABYLON {
  70490. /**
  70491. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70492. */
  70493. export class ChromaticAberrationPostProcess extends PostProcess {
  70494. /**
  70495. * The amount of seperation of rgb channels (default: 30)
  70496. */
  70497. aberrationAmount: number;
  70498. /**
  70499. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70500. */
  70501. radialIntensity: number;
  70502. /**
  70503. * 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))
  70504. */
  70505. direction: Vector2;
  70506. /**
  70507. * 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))
  70508. */
  70509. centerPosition: Vector2;
  70510. /** The width of the screen to apply the effect on */
  70511. screenWidth: number;
  70512. /** The height of the screen to apply the effect on */
  70513. screenHeight: number;
  70514. /**
  70515. * Gets a string identifying the name of the class
  70516. * @returns "ChromaticAberrationPostProcess" string
  70517. */
  70518. getClassName(): string;
  70519. /**
  70520. * Creates a new instance ChromaticAberrationPostProcess
  70521. * @param name The name of the effect.
  70522. * @param screenWidth The width of the screen to apply the effect on.
  70523. * @param screenHeight The height of the screen to apply the effect on.
  70524. * @param options The required width/height ratio to downsize to before computing the render pass.
  70525. * @param camera The camera to apply the render pass to.
  70526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70527. * @param engine The engine which the post process will be applied. (default: current engine)
  70528. * @param reusable If the post process can be reused on the same frame. (default: false)
  70529. * @param textureType Type of textures used when performing the post process. (default: 0)
  70530. * @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)
  70531. */
  70532. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70533. /** @hidden */
  70534. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70535. }
  70536. }
  70537. declare module BABYLON {
  70538. /** @hidden */
  70539. export var circleOfConfusionPixelShader: {
  70540. name: string;
  70541. shader: string;
  70542. };
  70543. }
  70544. declare module BABYLON {
  70545. /**
  70546. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70547. */
  70548. export class CircleOfConfusionPostProcess extends PostProcess {
  70549. /**
  70550. * 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.
  70551. */
  70552. lensSize: number;
  70553. /**
  70554. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70555. */
  70556. fStop: number;
  70557. /**
  70558. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70559. */
  70560. focusDistance: number;
  70561. /**
  70562. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70563. */
  70564. focalLength: number;
  70565. /**
  70566. * Gets a string identifying the name of the class
  70567. * @returns "CircleOfConfusionPostProcess" string
  70568. */
  70569. getClassName(): string;
  70570. private _depthTexture;
  70571. /**
  70572. * Creates a new instance CircleOfConfusionPostProcess
  70573. * @param name The name of the effect.
  70574. * @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.
  70575. * @param options The required width/height ratio to downsize to before computing the render pass.
  70576. * @param camera The camera to apply the render pass to.
  70577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70578. * @param engine The engine which the post process will be applied. (default: current engine)
  70579. * @param reusable If the post process can be reused on the same frame. (default: false)
  70580. * @param textureType Type of textures used when performing the post process. (default: 0)
  70581. * @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)
  70582. */
  70583. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70584. /**
  70585. * 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.
  70586. */
  70587. set depthTexture(value: RenderTargetTexture);
  70588. }
  70589. }
  70590. declare module BABYLON {
  70591. /** @hidden */
  70592. export var colorCorrectionPixelShader: {
  70593. name: string;
  70594. shader: string;
  70595. };
  70596. }
  70597. declare module BABYLON {
  70598. /**
  70599. *
  70600. * This post-process allows the modification of rendered colors by using
  70601. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70602. *
  70603. * The object needs to be provided an url to a texture containing the color
  70604. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70605. * Use an image editing software to tweak the LUT to match your needs.
  70606. *
  70607. * For an example of a color LUT, see here:
  70608. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70609. * For explanations on color grading, see here:
  70610. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70611. *
  70612. */
  70613. export class ColorCorrectionPostProcess extends PostProcess {
  70614. private _colorTableTexture;
  70615. /**
  70616. * Gets the color table url used to create the LUT texture
  70617. */
  70618. colorTableUrl: string;
  70619. /**
  70620. * Gets a string identifying the name of the class
  70621. * @returns "ColorCorrectionPostProcess" string
  70622. */
  70623. getClassName(): string;
  70624. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70625. /** @hidden */
  70626. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70627. }
  70628. }
  70629. declare module BABYLON {
  70630. /** @hidden */
  70631. export var convolutionPixelShader: {
  70632. name: string;
  70633. shader: string;
  70634. };
  70635. }
  70636. declare module BABYLON {
  70637. /**
  70638. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70639. * input texture to perform effects such as edge detection or sharpening
  70640. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70641. */
  70642. export class ConvolutionPostProcess extends PostProcess {
  70643. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70644. kernel: number[];
  70645. /**
  70646. * Gets a string identifying the name of the class
  70647. * @returns "ConvolutionPostProcess" string
  70648. */
  70649. getClassName(): string;
  70650. /**
  70651. * Creates a new instance ConvolutionPostProcess
  70652. * @param name The name of the effect.
  70653. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70654. * @param options The required width/height ratio to downsize to before computing the render pass.
  70655. * @param camera The camera to apply the render pass to.
  70656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70657. * @param engine The engine which the post process will be applied. (default: current engine)
  70658. * @param reusable If the post process can be reused on the same frame. (default: false)
  70659. * @param textureType Type of textures used when performing the post process. (default: 0)
  70660. */
  70661. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70662. /** @hidden */
  70663. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70664. /**
  70665. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70666. */
  70667. static EdgeDetect0Kernel: number[];
  70668. /**
  70669. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70670. */
  70671. static EdgeDetect1Kernel: number[];
  70672. /**
  70673. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70674. */
  70675. static EdgeDetect2Kernel: number[];
  70676. /**
  70677. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70678. */
  70679. static SharpenKernel: number[];
  70680. /**
  70681. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70682. */
  70683. static EmbossKernel: number[];
  70684. /**
  70685. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70686. */
  70687. static GaussianKernel: number[];
  70688. }
  70689. }
  70690. declare module BABYLON {
  70691. /**
  70692. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70693. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70694. * based on samples that have a large difference in distance than the center pixel.
  70695. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70696. */
  70697. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70698. /**
  70699. * The direction the blur should be applied
  70700. */
  70701. direction: Vector2;
  70702. /**
  70703. * Gets a string identifying the name of the class
  70704. * @returns "DepthOfFieldBlurPostProcess" string
  70705. */
  70706. getClassName(): string;
  70707. /**
  70708. * Creates a new instance CircleOfConfusionPostProcess
  70709. * @param name The name of the effect.
  70710. * @param scene The scene the effect belongs to.
  70711. * @param direction The direction the blur should be applied.
  70712. * @param kernel The size of the kernel used to blur.
  70713. * @param options The required width/height ratio to downsize to before computing the render pass.
  70714. * @param camera The camera to apply the render pass to.
  70715. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70716. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70717. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70718. * @param engine The engine which the post process will be applied. (default: current engine)
  70719. * @param reusable If the post process can be reused on the same frame. (default: false)
  70720. * @param textureType Type of textures used when performing the post process. (default: 0)
  70721. * @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)
  70722. */
  70723. 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);
  70724. }
  70725. }
  70726. declare module BABYLON {
  70727. /** @hidden */
  70728. export var depthOfFieldMergePixelShader: {
  70729. name: string;
  70730. shader: string;
  70731. };
  70732. }
  70733. declare module BABYLON {
  70734. /**
  70735. * Options to be set when merging outputs from the default pipeline.
  70736. */
  70737. export class DepthOfFieldMergePostProcessOptions {
  70738. /**
  70739. * The original image to merge on top of
  70740. */
  70741. originalFromInput: PostProcess;
  70742. /**
  70743. * Parameters to perform the merge of the depth of field effect
  70744. */
  70745. depthOfField?: {
  70746. circleOfConfusion: PostProcess;
  70747. blurSteps: Array<PostProcess>;
  70748. };
  70749. /**
  70750. * Parameters to perform the merge of bloom effect
  70751. */
  70752. bloom?: {
  70753. blurred: PostProcess;
  70754. weight: number;
  70755. };
  70756. }
  70757. /**
  70758. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70759. */
  70760. export class DepthOfFieldMergePostProcess extends PostProcess {
  70761. private blurSteps;
  70762. /**
  70763. * Gets a string identifying the name of the class
  70764. * @returns "DepthOfFieldMergePostProcess" string
  70765. */
  70766. getClassName(): string;
  70767. /**
  70768. * Creates a new instance of DepthOfFieldMergePostProcess
  70769. * @param name The name of the effect.
  70770. * @param originalFromInput Post process which's input will be used for the merge.
  70771. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70772. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70773. * @param options The required width/height ratio to downsize to before computing the render pass.
  70774. * @param camera The camera to apply the render pass to.
  70775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70776. * @param engine The engine which the post process will be applied. (default: current engine)
  70777. * @param reusable If the post process can be reused on the same frame. (default: false)
  70778. * @param textureType Type of textures used when performing the post process. (default: 0)
  70779. * @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)
  70780. */
  70781. 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);
  70782. /**
  70783. * Updates the effect with the current post process compile time values and recompiles the shader.
  70784. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70785. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70786. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70787. * @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
  70788. * @param onCompiled Called when the shader has been compiled.
  70789. * @param onError Called if there is an error when compiling a shader.
  70790. */
  70791. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70792. }
  70793. }
  70794. declare module BABYLON {
  70795. /**
  70796. * Specifies the level of max blur that should be applied when using the depth of field effect
  70797. */
  70798. export enum DepthOfFieldEffectBlurLevel {
  70799. /**
  70800. * Subtle blur
  70801. */
  70802. Low = 0,
  70803. /**
  70804. * Medium blur
  70805. */
  70806. Medium = 1,
  70807. /**
  70808. * Large blur
  70809. */
  70810. High = 2
  70811. }
  70812. /**
  70813. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70814. */
  70815. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70816. private _circleOfConfusion;
  70817. /**
  70818. * @hidden Internal, blurs from high to low
  70819. */
  70820. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70821. private _depthOfFieldBlurY;
  70822. private _dofMerge;
  70823. /**
  70824. * @hidden Internal post processes in depth of field effect
  70825. */
  70826. _effects: Array<PostProcess>;
  70827. /**
  70828. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70829. */
  70830. set focalLength(value: number);
  70831. get focalLength(): number;
  70832. /**
  70833. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70834. */
  70835. set fStop(value: number);
  70836. get fStop(): number;
  70837. /**
  70838. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70839. */
  70840. set focusDistance(value: number);
  70841. get focusDistance(): number;
  70842. /**
  70843. * 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.
  70844. */
  70845. set lensSize(value: number);
  70846. get lensSize(): number;
  70847. /**
  70848. * Creates a new instance DepthOfFieldEffect
  70849. * @param scene The scene the effect belongs to.
  70850. * @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.
  70851. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70852. * @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)
  70853. */
  70854. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70855. /**
  70856. * Get the current class name of the current effet
  70857. * @returns "DepthOfFieldEffect"
  70858. */
  70859. getClassName(): string;
  70860. /**
  70861. * 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.
  70862. */
  70863. set depthTexture(value: RenderTargetTexture);
  70864. /**
  70865. * Disposes each of the internal effects for a given camera.
  70866. * @param camera The camera to dispose the effect on.
  70867. */
  70868. disposeEffects(camera: Camera): void;
  70869. /**
  70870. * @hidden Internal
  70871. */
  70872. _updateEffects(): void;
  70873. /**
  70874. * Internal
  70875. * @returns if all the contained post processes are ready.
  70876. * @hidden
  70877. */
  70878. _isReady(): boolean;
  70879. }
  70880. }
  70881. declare module BABYLON {
  70882. /** @hidden */
  70883. export var displayPassPixelShader: {
  70884. name: string;
  70885. shader: string;
  70886. };
  70887. }
  70888. declare module BABYLON {
  70889. /**
  70890. * DisplayPassPostProcess which produces an output the same as it's input
  70891. */
  70892. export class DisplayPassPostProcess extends PostProcess {
  70893. /**
  70894. * Gets a string identifying the name of the class
  70895. * @returns "DisplayPassPostProcess" string
  70896. */
  70897. getClassName(): string;
  70898. /**
  70899. * Creates the DisplayPassPostProcess
  70900. * @param name The name of the effect.
  70901. * @param options The required width/height ratio to downsize to before computing the render pass.
  70902. * @param camera The camera to apply the render pass to.
  70903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70904. * @param engine The engine which the post process will be applied. (default: current engine)
  70905. * @param reusable If the post process can be reused on the same frame. (default: false)
  70906. */
  70907. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70908. /** @hidden */
  70909. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /** @hidden */
  70914. export var filterPixelShader: {
  70915. name: string;
  70916. shader: string;
  70917. };
  70918. }
  70919. declare module BABYLON {
  70920. /**
  70921. * Applies a kernel filter to the image
  70922. */
  70923. export class FilterPostProcess extends PostProcess {
  70924. /** The matrix to be applied to the image */
  70925. kernelMatrix: Matrix;
  70926. /**
  70927. * Gets a string identifying the name of the class
  70928. * @returns "FilterPostProcess" string
  70929. */
  70930. getClassName(): string;
  70931. /**
  70932. *
  70933. * @param name The name of the effect.
  70934. * @param kernelMatrix The matrix to be applied to the image
  70935. * @param options The required width/height ratio to downsize to before computing the render pass.
  70936. * @param camera The camera to apply the render pass to.
  70937. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70938. * @param engine The engine which the post process will be applied. (default: current engine)
  70939. * @param reusable If the post process can be reused on the same frame. (default: false)
  70940. */
  70941. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70942. /** @hidden */
  70943. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70944. }
  70945. }
  70946. declare module BABYLON {
  70947. /** @hidden */
  70948. export var fxaaPixelShader: {
  70949. name: string;
  70950. shader: string;
  70951. };
  70952. }
  70953. declare module BABYLON {
  70954. /** @hidden */
  70955. export var fxaaVertexShader: {
  70956. name: string;
  70957. shader: string;
  70958. };
  70959. }
  70960. declare module BABYLON {
  70961. /**
  70962. * Fxaa post process
  70963. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70964. */
  70965. export class FxaaPostProcess extends PostProcess {
  70966. /**
  70967. * Gets a string identifying the name of the class
  70968. * @returns "FxaaPostProcess" string
  70969. */
  70970. getClassName(): string;
  70971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70972. private _getDefines;
  70973. /** @hidden */
  70974. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70975. }
  70976. }
  70977. declare module BABYLON {
  70978. /** @hidden */
  70979. export var grainPixelShader: {
  70980. name: string;
  70981. shader: string;
  70982. };
  70983. }
  70984. declare module BABYLON {
  70985. /**
  70986. * The GrainPostProcess adds noise to the image at mid luminance levels
  70987. */
  70988. export class GrainPostProcess extends PostProcess {
  70989. /**
  70990. * The intensity of the grain added (default: 30)
  70991. */
  70992. intensity: number;
  70993. /**
  70994. * If the grain should be randomized on every frame
  70995. */
  70996. animated: boolean;
  70997. /**
  70998. * Gets a string identifying the name of the class
  70999. * @returns "GrainPostProcess" string
  71000. */
  71001. getClassName(): string;
  71002. /**
  71003. * Creates a new instance of @see GrainPostProcess
  71004. * @param name The name of the effect.
  71005. * @param options The required width/height ratio to downsize to before computing the render pass.
  71006. * @param camera The camera to apply the render pass to.
  71007. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71008. * @param engine The engine which the post process will be applied. (default: current engine)
  71009. * @param reusable If the post process can be reused on the same frame. (default: false)
  71010. * @param textureType Type of textures used when performing the post process. (default: 0)
  71011. * @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)
  71012. */
  71013. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71014. /** @hidden */
  71015. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71016. }
  71017. }
  71018. declare module BABYLON {
  71019. /** @hidden */
  71020. export var highlightsPixelShader: {
  71021. name: string;
  71022. shader: string;
  71023. };
  71024. }
  71025. declare module BABYLON {
  71026. /**
  71027. * Extracts highlights from the image
  71028. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71029. */
  71030. export class HighlightsPostProcess extends PostProcess {
  71031. /**
  71032. * Gets a string identifying the name of the class
  71033. * @returns "HighlightsPostProcess" string
  71034. */
  71035. getClassName(): string;
  71036. /**
  71037. * Extracts highlights from the image
  71038. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71039. * @param name The name of the effect.
  71040. * @param options The required width/height ratio to downsize to before computing the render pass.
  71041. * @param camera The camera to apply the render pass to.
  71042. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71043. * @param engine The engine which the post process will be applied. (default: current engine)
  71044. * @param reusable If the post process can be reused on the same frame. (default: false)
  71045. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71046. */
  71047. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71048. }
  71049. }
  71050. declare module BABYLON {
  71051. /**
  71052. * Contains all parameters needed for the prepass to perform
  71053. * motion blur
  71054. */
  71055. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71056. /**
  71057. * Is motion blur enabled
  71058. */
  71059. enabled: boolean;
  71060. /**
  71061. * Name of the configuration
  71062. */
  71063. name: string;
  71064. /**
  71065. * Textures that should be present in the MRT for this effect to work
  71066. */
  71067. readonly texturesRequired: number[];
  71068. }
  71069. }
  71070. declare module BABYLON {
  71071. interface Scene {
  71072. /** @hidden (Backing field) */
  71073. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71074. /**
  71075. * Gets or Sets the current geometry buffer associated to the scene.
  71076. */
  71077. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71078. /**
  71079. * Enables a GeometryBufferRender and associates it with the scene
  71080. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71081. * @returns the GeometryBufferRenderer
  71082. */
  71083. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71084. /**
  71085. * Disables the GeometryBufferRender associated with the scene
  71086. */
  71087. disableGeometryBufferRenderer(): void;
  71088. }
  71089. /**
  71090. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71091. * in several rendering techniques.
  71092. */
  71093. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71094. /**
  71095. * The component name helpful to identify the component in the list of scene components.
  71096. */
  71097. readonly name: string;
  71098. /**
  71099. * The scene the component belongs to.
  71100. */
  71101. scene: Scene;
  71102. /**
  71103. * Creates a new instance of the component for the given scene
  71104. * @param scene Defines the scene to register the component in
  71105. */
  71106. constructor(scene: Scene);
  71107. /**
  71108. * Registers the component in a given scene
  71109. */
  71110. register(): void;
  71111. /**
  71112. * Rebuilds the elements related to this component in case of
  71113. * context lost for instance.
  71114. */
  71115. rebuild(): void;
  71116. /**
  71117. * Disposes the component and the associated ressources
  71118. */
  71119. dispose(): void;
  71120. private _gatherRenderTargets;
  71121. }
  71122. }
  71123. declare module BABYLON {
  71124. /** @hidden */
  71125. export var motionBlurPixelShader: {
  71126. name: string;
  71127. shader: string;
  71128. };
  71129. }
  71130. declare module BABYLON {
  71131. /**
  71132. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71133. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71134. * As an example, all you have to do is to create the post-process:
  71135. * var mb = new BABYLON.MotionBlurPostProcess(
  71136. * 'mb', // The name of the effect.
  71137. * scene, // The scene containing the objects to blur according to their velocity.
  71138. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71139. * camera // The camera to apply the render pass to.
  71140. * );
  71141. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71142. */
  71143. export class MotionBlurPostProcess extends PostProcess {
  71144. /**
  71145. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71146. */
  71147. motionStrength: number;
  71148. /**
  71149. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71150. */
  71151. get motionBlurSamples(): number;
  71152. /**
  71153. * Sets the number of iterations to be used for motion blur quality
  71154. */
  71155. set motionBlurSamples(samples: number);
  71156. private _motionBlurSamples;
  71157. private _forceGeometryBuffer;
  71158. private _geometryBufferRenderer;
  71159. private _prePassRenderer;
  71160. /**
  71161. * Gets a string identifying the name of the class
  71162. * @returns "MotionBlurPostProcess" string
  71163. */
  71164. getClassName(): string;
  71165. /**
  71166. * Creates a new instance MotionBlurPostProcess
  71167. * @param name The name of the effect.
  71168. * @param scene The scene containing the objects to blur according to their velocity.
  71169. * @param options The required width/height ratio to downsize to before computing the render pass.
  71170. * @param camera The camera to apply the render pass to.
  71171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71172. * @param engine The engine which the post process will be applied. (default: current engine)
  71173. * @param reusable If the post process can be reused on the same frame. (default: false)
  71174. * @param textureType Type of textures used when performing the post process. (default: 0)
  71175. * @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)
  71176. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71177. */
  71178. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71179. /**
  71180. * Excludes the given skinned mesh from computing bones velocities.
  71181. * 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.
  71182. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71183. */
  71184. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71185. /**
  71186. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71187. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71188. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71189. */
  71190. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71191. /**
  71192. * Disposes the post process.
  71193. * @param camera The camera to dispose the post process on.
  71194. */
  71195. dispose(camera?: Camera): void;
  71196. /** @hidden */
  71197. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71198. }
  71199. }
  71200. declare module BABYLON {
  71201. /** @hidden */
  71202. export var refractionPixelShader: {
  71203. name: string;
  71204. shader: string;
  71205. };
  71206. }
  71207. declare module BABYLON {
  71208. /**
  71209. * Post process which applies a refractin texture
  71210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71211. */
  71212. export class RefractionPostProcess extends PostProcess {
  71213. private _refTexture;
  71214. private _ownRefractionTexture;
  71215. /** the base color of the refraction (used to taint the rendering) */
  71216. color: Color3;
  71217. /** simulated refraction depth */
  71218. depth: number;
  71219. /** the coefficient of the base color (0 to remove base color tainting) */
  71220. colorLevel: number;
  71221. /** Gets the url used to load the refraction texture */
  71222. refractionTextureUrl: string;
  71223. /**
  71224. * Gets or sets the refraction texture
  71225. * Please note that you are responsible for disposing the texture if you set it manually
  71226. */
  71227. get refractionTexture(): Texture;
  71228. set refractionTexture(value: Texture);
  71229. /**
  71230. * Gets a string identifying the name of the class
  71231. * @returns "RefractionPostProcess" string
  71232. */
  71233. getClassName(): string;
  71234. /**
  71235. * Initializes the RefractionPostProcess
  71236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71237. * @param name The name of the effect.
  71238. * @param refractionTextureUrl Url of the refraction texture to use
  71239. * @param color the base color of the refraction (used to taint the rendering)
  71240. * @param depth simulated refraction depth
  71241. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71242. * @param camera The camera to apply the render pass to.
  71243. * @param options The required width/height ratio to downsize to before computing the render pass.
  71244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71245. * @param engine The engine which the post process will be applied. (default: current engine)
  71246. * @param reusable If the post process can be reused on the same frame. (default: false)
  71247. */
  71248. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71249. /**
  71250. * Disposes of the post process
  71251. * @param camera Camera to dispose post process on
  71252. */
  71253. dispose(camera: Camera): void;
  71254. /** @hidden */
  71255. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71256. }
  71257. }
  71258. declare module BABYLON {
  71259. /** @hidden */
  71260. export var sharpenPixelShader: {
  71261. name: string;
  71262. shader: string;
  71263. };
  71264. }
  71265. declare module BABYLON {
  71266. /**
  71267. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71268. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71269. */
  71270. export class SharpenPostProcess extends PostProcess {
  71271. /**
  71272. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71273. */
  71274. colorAmount: number;
  71275. /**
  71276. * How much sharpness should be applied (default: 0.3)
  71277. */
  71278. edgeAmount: number;
  71279. /**
  71280. * Gets a string identifying the name of the class
  71281. * @returns "SharpenPostProcess" string
  71282. */
  71283. getClassName(): string;
  71284. /**
  71285. * Creates a new instance ConvolutionPostProcess
  71286. * @param name The name of the effect.
  71287. * @param options The required width/height ratio to downsize to before computing the render pass.
  71288. * @param camera The camera to apply the render pass to.
  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. * @param textureType Type of textures used when performing the post process. (default: 0)
  71293. * @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)
  71294. */
  71295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71296. /** @hidden */
  71297. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71298. }
  71299. }
  71300. declare module BABYLON {
  71301. /**
  71302. * PostProcessRenderPipeline
  71303. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71304. */
  71305. export class PostProcessRenderPipeline {
  71306. private engine;
  71307. private _renderEffects;
  71308. private _renderEffectsForIsolatedPass;
  71309. /**
  71310. * List of inspectable custom properties (used by the Inspector)
  71311. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71312. */
  71313. inspectableCustomProperties: IInspectable[];
  71314. /**
  71315. * @hidden
  71316. */
  71317. protected _cameras: Camera[];
  71318. /** @hidden */
  71319. _name: string;
  71320. /**
  71321. * Gets pipeline name
  71322. */
  71323. get name(): string;
  71324. /** Gets the list of attached cameras */
  71325. get cameras(): Camera[];
  71326. /**
  71327. * Initializes a PostProcessRenderPipeline
  71328. * @param engine engine to add the pipeline to
  71329. * @param name name of the pipeline
  71330. */
  71331. constructor(engine: Engine, name: string);
  71332. /**
  71333. * Gets the class name
  71334. * @returns "PostProcessRenderPipeline"
  71335. */
  71336. getClassName(): string;
  71337. /**
  71338. * If all the render effects in the pipeline are supported
  71339. */
  71340. get isSupported(): boolean;
  71341. /**
  71342. * Adds an effect to the pipeline
  71343. * @param renderEffect the effect to add
  71344. */
  71345. addEffect(renderEffect: PostProcessRenderEffect): void;
  71346. /** @hidden */
  71347. _rebuild(): void;
  71348. /** @hidden */
  71349. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71350. /** @hidden */
  71351. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71352. /** @hidden */
  71353. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71354. /** @hidden */
  71355. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71356. /** @hidden */
  71357. _attachCameras(cameras: Camera, unique: boolean): void;
  71358. /** @hidden */
  71359. _attachCameras(cameras: Camera[], unique: boolean): void;
  71360. /** @hidden */
  71361. _detachCameras(cameras: Camera): void;
  71362. /** @hidden */
  71363. _detachCameras(cameras: Nullable<Camera[]>): void;
  71364. /** @hidden */
  71365. _update(): void;
  71366. /** @hidden */
  71367. _reset(): void;
  71368. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71369. /**
  71370. * Sets the required values to the prepass renderer.
  71371. * @param prePassRenderer defines the prepass renderer to setup.
  71372. * @returns true if the pre pass is needed.
  71373. */
  71374. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71375. /**
  71376. * Disposes of the pipeline
  71377. */
  71378. dispose(): void;
  71379. }
  71380. }
  71381. declare module BABYLON {
  71382. /**
  71383. * PostProcessRenderPipelineManager class
  71384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71385. */
  71386. export class PostProcessRenderPipelineManager {
  71387. private _renderPipelines;
  71388. /**
  71389. * Initializes a PostProcessRenderPipelineManager
  71390. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71391. */
  71392. constructor();
  71393. /**
  71394. * Gets the list of supported render pipelines
  71395. */
  71396. get supportedPipelines(): PostProcessRenderPipeline[];
  71397. /**
  71398. * Adds a pipeline to the manager
  71399. * @param renderPipeline The pipeline to add
  71400. */
  71401. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71402. /**
  71403. * Attaches a camera to the pipeline
  71404. * @param renderPipelineName The name of the pipeline to attach to
  71405. * @param cameras the camera to attach
  71406. * @param unique if the camera can be attached multiple times to the pipeline
  71407. */
  71408. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71409. /**
  71410. * Detaches a camera from the pipeline
  71411. * @param renderPipelineName The name of the pipeline to detach from
  71412. * @param cameras the camera to detach
  71413. */
  71414. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71415. /**
  71416. * Enables an effect by name on a pipeline
  71417. * @param renderPipelineName the name of the pipeline to enable the effect in
  71418. * @param renderEffectName the name of the effect to enable
  71419. * @param cameras the cameras that the effect should be enabled on
  71420. */
  71421. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71422. /**
  71423. * Disables an effect by name on a pipeline
  71424. * @param renderPipelineName the name of the pipeline to disable the effect in
  71425. * @param renderEffectName the name of the effect to disable
  71426. * @param cameras the cameras that the effect should be disabled on
  71427. */
  71428. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71429. /**
  71430. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71431. */
  71432. update(): void;
  71433. /** @hidden */
  71434. _rebuild(): void;
  71435. /**
  71436. * Disposes of the manager and pipelines
  71437. */
  71438. dispose(): void;
  71439. }
  71440. }
  71441. declare module BABYLON {
  71442. interface Scene {
  71443. /** @hidden (Backing field) */
  71444. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71445. /**
  71446. * Gets the postprocess render pipeline manager
  71447. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71448. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71449. */
  71450. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71451. }
  71452. /**
  71453. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71454. */
  71455. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71456. /**
  71457. * The component name helpfull to identify the component in the list of scene components.
  71458. */
  71459. readonly name: string;
  71460. /**
  71461. * The scene the component belongs to.
  71462. */
  71463. scene: Scene;
  71464. /**
  71465. * Creates a new instance of the component for the given scene
  71466. * @param scene Defines the scene to register the component in
  71467. */
  71468. constructor(scene: Scene);
  71469. /**
  71470. * Registers the component in a given scene
  71471. */
  71472. register(): void;
  71473. /**
  71474. * Rebuilds the elements related to this component in case of
  71475. * context lost for instance.
  71476. */
  71477. rebuild(): void;
  71478. /**
  71479. * Disposes the component and the associated ressources
  71480. */
  71481. dispose(): void;
  71482. private _gatherRenderTargets;
  71483. }
  71484. }
  71485. declare module BABYLON {
  71486. /**
  71487. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71488. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71489. */
  71490. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71491. private _scene;
  71492. private _camerasToBeAttached;
  71493. /**
  71494. * ID of the sharpen post process,
  71495. */
  71496. private readonly SharpenPostProcessId;
  71497. /**
  71498. * @ignore
  71499. * ID of the image processing post process;
  71500. */
  71501. readonly ImageProcessingPostProcessId: string;
  71502. /**
  71503. * @ignore
  71504. * ID of the Fast Approximate Anti-Aliasing post process;
  71505. */
  71506. readonly FxaaPostProcessId: string;
  71507. /**
  71508. * ID of the chromatic aberration post process,
  71509. */
  71510. private readonly ChromaticAberrationPostProcessId;
  71511. /**
  71512. * ID of the grain post process
  71513. */
  71514. private readonly GrainPostProcessId;
  71515. /**
  71516. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71517. */
  71518. sharpen: SharpenPostProcess;
  71519. private _sharpenEffect;
  71520. private bloom;
  71521. /**
  71522. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71523. */
  71524. depthOfField: DepthOfFieldEffect;
  71525. /**
  71526. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71527. */
  71528. fxaa: FxaaPostProcess;
  71529. /**
  71530. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71531. */
  71532. imageProcessing: ImageProcessingPostProcess;
  71533. /**
  71534. * Chromatic aberration post process which will shift rgb colors in the image
  71535. */
  71536. chromaticAberration: ChromaticAberrationPostProcess;
  71537. private _chromaticAberrationEffect;
  71538. /**
  71539. * Grain post process which add noise to the image
  71540. */
  71541. grain: GrainPostProcess;
  71542. private _grainEffect;
  71543. /**
  71544. * Glow post process which adds a glow to emissive areas of the image
  71545. */
  71546. private _glowLayer;
  71547. /**
  71548. * Animations which can be used to tweak settings over a period of time
  71549. */
  71550. animations: Animation[];
  71551. private _imageProcessingConfigurationObserver;
  71552. private _sharpenEnabled;
  71553. private _bloomEnabled;
  71554. private _depthOfFieldEnabled;
  71555. private _depthOfFieldBlurLevel;
  71556. private _fxaaEnabled;
  71557. private _imageProcessingEnabled;
  71558. private _defaultPipelineTextureType;
  71559. private _bloomScale;
  71560. private _chromaticAberrationEnabled;
  71561. private _grainEnabled;
  71562. private _buildAllowed;
  71563. /**
  71564. * This is triggered each time the pipeline has been built.
  71565. */
  71566. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71567. /**
  71568. * Gets active scene
  71569. */
  71570. get scene(): Scene;
  71571. /**
  71572. * Enable or disable the sharpen process from the pipeline
  71573. */
  71574. set sharpenEnabled(enabled: boolean);
  71575. get sharpenEnabled(): boolean;
  71576. private _resizeObserver;
  71577. private _hardwareScaleLevel;
  71578. private _bloomKernel;
  71579. /**
  71580. * Specifies the size of the bloom blur kernel, relative to the final output size
  71581. */
  71582. get bloomKernel(): number;
  71583. set bloomKernel(value: number);
  71584. /**
  71585. * Specifies the weight of the bloom in the final rendering
  71586. */
  71587. private _bloomWeight;
  71588. /**
  71589. * Specifies the luma threshold for the area that will be blurred by the bloom
  71590. */
  71591. private _bloomThreshold;
  71592. private _hdr;
  71593. /**
  71594. * The strength of the bloom.
  71595. */
  71596. set bloomWeight(value: number);
  71597. get bloomWeight(): number;
  71598. /**
  71599. * The strength of the bloom.
  71600. */
  71601. set bloomThreshold(value: number);
  71602. get bloomThreshold(): number;
  71603. /**
  71604. * The scale of the bloom, lower value will provide better performance.
  71605. */
  71606. set bloomScale(value: number);
  71607. get bloomScale(): number;
  71608. /**
  71609. * Enable or disable the bloom from the pipeline
  71610. */
  71611. set bloomEnabled(enabled: boolean);
  71612. get bloomEnabled(): boolean;
  71613. private _rebuildBloom;
  71614. /**
  71615. * If the depth of field is enabled.
  71616. */
  71617. get depthOfFieldEnabled(): boolean;
  71618. set depthOfFieldEnabled(enabled: boolean);
  71619. /**
  71620. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71621. */
  71622. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71623. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71624. /**
  71625. * If the anti aliasing is enabled.
  71626. */
  71627. set fxaaEnabled(enabled: boolean);
  71628. get fxaaEnabled(): boolean;
  71629. private _samples;
  71630. /**
  71631. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71632. */
  71633. set samples(sampleCount: number);
  71634. get samples(): number;
  71635. /**
  71636. * If image processing is enabled.
  71637. */
  71638. set imageProcessingEnabled(enabled: boolean);
  71639. get imageProcessingEnabled(): boolean;
  71640. /**
  71641. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71642. */
  71643. set glowLayerEnabled(enabled: boolean);
  71644. get glowLayerEnabled(): boolean;
  71645. /**
  71646. * Gets the glow layer (or null if not defined)
  71647. */
  71648. get glowLayer(): Nullable<GlowLayer>;
  71649. /**
  71650. * Enable or disable the chromaticAberration process from the pipeline
  71651. */
  71652. set chromaticAberrationEnabled(enabled: boolean);
  71653. get chromaticAberrationEnabled(): boolean;
  71654. /**
  71655. * Enable or disable the grain process from the pipeline
  71656. */
  71657. set grainEnabled(enabled: boolean);
  71658. get grainEnabled(): boolean;
  71659. /**
  71660. * @constructor
  71661. * @param name - The rendering pipeline name (default: "")
  71662. * @param hdr - If high dynamic range textures should be used (default: true)
  71663. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71664. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71665. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71666. */
  71667. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71668. /**
  71669. * Get the class name
  71670. * @returns "DefaultRenderingPipeline"
  71671. */
  71672. getClassName(): string;
  71673. /**
  71674. * Force the compilation of the entire pipeline.
  71675. */
  71676. prepare(): void;
  71677. private _hasCleared;
  71678. private _prevPostProcess;
  71679. private _prevPrevPostProcess;
  71680. private _setAutoClearAndTextureSharing;
  71681. private _depthOfFieldSceneObserver;
  71682. private _buildPipeline;
  71683. private _disposePostProcesses;
  71684. /**
  71685. * Adds a camera to the pipeline
  71686. * @param camera the camera to be added
  71687. */
  71688. addCamera(camera: Camera): void;
  71689. /**
  71690. * Removes a camera from the pipeline
  71691. * @param camera the camera to remove
  71692. */
  71693. removeCamera(camera: Camera): void;
  71694. /**
  71695. * Dispose of the pipeline and stop all post processes
  71696. */
  71697. dispose(): void;
  71698. /**
  71699. * Serialize the rendering pipeline (Used when exporting)
  71700. * @returns the serialized object
  71701. */
  71702. serialize(): any;
  71703. /**
  71704. * Parse the serialized pipeline
  71705. * @param source Source pipeline.
  71706. * @param scene The scene to load the pipeline to.
  71707. * @param rootUrl The URL of the serialized pipeline.
  71708. * @returns An instantiated pipeline from the serialized object.
  71709. */
  71710. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71711. }
  71712. }
  71713. declare module BABYLON {
  71714. /** @hidden */
  71715. export var lensHighlightsPixelShader: {
  71716. name: string;
  71717. shader: string;
  71718. };
  71719. }
  71720. declare module BABYLON {
  71721. /** @hidden */
  71722. export var depthOfFieldPixelShader: {
  71723. name: string;
  71724. shader: string;
  71725. };
  71726. }
  71727. declare module BABYLON {
  71728. /**
  71729. * BABYLON.JS Chromatic Aberration GLSL Shader
  71730. * Author: Olivier Guyot
  71731. * Separates very slightly R, G and B colors on the edges of the screen
  71732. * Inspired by Francois Tarlier & Martins Upitis
  71733. */
  71734. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71735. /**
  71736. * @ignore
  71737. * The chromatic aberration PostProcess id in the pipeline
  71738. */
  71739. LensChromaticAberrationEffect: string;
  71740. /**
  71741. * @ignore
  71742. * The highlights enhancing PostProcess id in the pipeline
  71743. */
  71744. HighlightsEnhancingEffect: string;
  71745. /**
  71746. * @ignore
  71747. * The depth-of-field PostProcess id in the pipeline
  71748. */
  71749. LensDepthOfFieldEffect: string;
  71750. private _scene;
  71751. private _depthTexture;
  71752. private _grainTexture;
  71753. private _chromaticAberrationPostProcess;
  71754. private _highlightsPostProcess;
  71755. private _depthOfFieldPostProcess;
  71756. private _edgeBlur;
  71757. private _grainAmount;
  71758. private _chromaticAberration;
  71759. private _distortion;
  71760. private _highlightsGain;
  71761. private _highlightsThreshold;
  71762. private _dofDistance;
  71763. private _dofAperture;
  71764. private _dofDarken;
  71765. private _dofPentagon;
  71766. private _blurNoise;
  71767. /**
  71768. * @constructor
  71769. *
  71770. * Effect parameters are as follow:
  71771. * {
  71772. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71773. * edge_blur: number; // from 0 to x (1 for realism)
  71774. * distortion: number; // from 0 to x (1 for realism)
  71775. * grain_amount: number; // from 0 to 1
  71776. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71777. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71778. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71779. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71780. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71781. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71782. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71783. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71784. * }
  71785. * Note: if an effect parameter is unset, effect is disabled
  71786. *
  71787. * @param name The rendering pipeline name
  71788. * @param parameters - An object containing all parameters (see above)
  71789. * @param scene The scene linked to this pipeline
  71790. * @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)
  71791. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71792. */
  71793. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71794. /**
  71795. * Get the class name
  71796. * @returns "LensRenderingPipeline"
  71797. */
  71798. getClassName(): string;
  71799. /**
  71800. * Gets associated scene
  71801. */
  71802. get scene(): Scene;
  71803. /**
  71804. * Gets or sets the edge blur
  71805. */
  71806. get edgeBlur(): number;
  71807. set edgeBlur(value: number);
  71808. /**
  71809. * Gets or sets the grain amount
  71810. */
  71811. get grainAmount(): number;
  71812. set grainAmount(value: number);
  71813. /**
  71814. * Gets or sets the chromatic aberration amount
  71815. */
  71816. get chromaticAberration(): number;
  71817. set chromaticAberration(value: number);
  71818. /**
  71819. * Gets or sets the depth of field aperture
  71820. */
  71821. get dofAperture(): number;
  71822. set dofAperture(value: number);
  71823. /**
  71824. * Gets or sets the edge distortion
  71825. */
  71826. get edgeDistortion(): number;
  71827. set edgeDistortion(value: number);
  71828. /**
  71829. * Gets or sets the depth of field distortion
  71830. */
  71831. get dofDistortion(): number;
  71832. set dofDistortion(value: number);
  71833. /**
  71834. * Gets or sets the darken out of focus amount
  71835. */
  71836. get darkenOutOfFocus(): number;
  71837. set darkenOutOfFocus(value: number);
  71838. /**
  71839. * Gets or sets a boolean indicating if blur noise is enabled
  71840. */
  71841. get blurNoise(): boolean;
  71842. set blurNoise(value: boolean);
  71843. /**
  71844. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71845. */
  71846. get pentagonBokeh(): boolean;
  71847. set pentagonBokeh(value: boolean);
  71848. /**
  71849. * Gets or sets the highlight grain amount
  71850. */
  71851. get highlightsGain(): number;
  71852. set highlightsGain(value: number);
  71853. /**
  71854. * Gets or sets the highlight threshold
  71855. */
  71856. get highlightsThreshold(): number;
  71857. set highlightsThreshold(value: number);
  71858. /**
  71859. * Sets the amount of blur at the edges
  71860. * @param amount blur amount
  71861. */
  71862. setEdgeBlur(amount: number): void;
  71863. /**
  71864. * Sets edge blur to 0
  71865. */
  71866. disableEdgeBlur(): void;
  71867. /**
  71868. * Sets the amout of grain
  71869. * @param amount Amount of grain
  71870. */
  71871. setGrainAmount(amount: number): void;
  71872. /**
  71873. * Set grain amount to 0
  71874. */
  71875. disableGrain(): void;
  71876. /**
  71877. * Sets the chromatic aberration amount
  71878. * @param amount amount of chromatic aberration
  71879. */
  71880. setChromaticAberration(amount: number): void;
  71881. /**
  71882. * Sets chromatic aberration amount to 0
  71883. */
  71884. disableChromaticAberration(): void;
  71885. /**
  71886. * Sets the EdgeDistortion amount
  71887. * @param amount amount of EdgeDistortion
  71888. */
  71889. setEdgeDistortion(amount: number): void;
  71890. /**
  71891. * Sets edge distortion to 0
  71892. */
  71893. disableEdgeDistortion(): void;
  71894. /**
  71895. * Sets the FocusDistance amount
  71896. * @param amount amount of FocusDistance
  71897. */
  71898. setFocusDistance(amount: number): void;
  71899. /**
  71900. * Disables depth of field
  71901. */
  71902. disableDepthOfField(): void;
  71903. /**
  71904. * Sets the Aperture amount
  71905. * @param amount amount of Aperture
  71906. */
  71907. setAperture(amount: number): void;
  71908. /**
  71909. * Sets the DarkenOutOfFocus amount
  71910. * @param amount amount of DarkenOutOfFocus
  71911. */
  71912. setDarkenOutOfFocus(amount: number): void;
  71913. private _pentagonBokehIsEnabled;
  71914. /**
  71915. * Creates a pentagon bokeh effect
  71916. */
  71917. enablePentagonBokeh(): void;
  71918. /**
  71919. * Disables the pentagon bokeh effect
  71920. */
  71921. disablePentagonBokeh(): void;
  71922. /**
  71923. * Enables noise blur
  71924. */
  71925. enableNoiseBlur(): void;
  71926. /**
  71927. * Disables noise blur
  71928. */
  71929. disableNoiseBlur(): void;
  71930. /**
  71931. * Sets the HighlightsGain amount
  71932. * @param amount amount of HighlightsGain
  71933. */
  71934. setHighlightsGain(amount: number): void;
  71935. /**
  71936. * Sets the HighlightsThreshold amount
  71937. * @param amount amount of HighlightsThreshold
  71938. */
  71939. setHighlightsThreshold(amount: number): void;
  71940. /**
  71941. * Disables highlights
  71942. */
  71943. disableHighlights(): void;
  71944. /**
  71945. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71946. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71947. */
  71948. dispose(disableDepthRender?: boolean): void;
  71949. private _createChromaticAberrationPostProcess;
  71950. private _createHighlightsPostProcess;
  71951. private _createDepthOfFieldPostProcess;
  71952. private _createGrainTexture;
  71953. }
  71954. }
  71955. declare module BABYLON {
  71956. /**
  71957. * Contains all parameters needed for the prepass to perform
  71958. * screen space subsurface scattering
  71959. */
  71960. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71961. /**
  71962. * Is subsurface enabled
  71963. */
  71964. enabled: boolean;
  71965. /**
  71966. * Name of the configuration
  71967. */
  71968. name: string;
  71969. /**
  71970. * Textures that should be present in the MRT for this effect to work
  71971. */
  71972. readonly texturesRequired: number[];
  71973. }
  71974. }
  71975. declare module BABYLON {
  71976. /** @hidden */
  71977. export var ssao2PixelShader: {
  71978. name: string;
  71979. shader: string;
  71980. };
  71981. }
  71982. declare module BABYLON {
  71983. /** @hidden */
  71984. export var ssaoCombinePixelShader: {
  71985. name: string;
  71986. shader: string;
  71987. };
  71988. }
  71989. declare module BABYLON {
  71990. /**
  71991. * Render pipeline to produce ssao effect
  71992. */
  71993. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71994. /**
  71995. * @ignore
  71996. * The PassPostProcess id in the pipeline that contains the original scene color
  71997. */
  71998. SSAOOriginalSceneColorEffect: string;
  71999. /**
  72000. * @ignore
  72001. * The SSAO PostProcess id in the pipeline
  72002. */
  72003. SSAORenderEffect: string;
  72004. /**
  72005. * @ignore
  72006. * The horizontal blur PostProcess id in the pipeline
  72007. */
  72008. SSAOBlurHRenderEffect: string;
  72009. /**
  72010. * @ignore
  72011. * The vertical blur PostProcess id in the pipeline
  72012. */
  72013. SSAOBlurVRenderEffect: string;
  72014. /**
  72015. * @ignore
  72016. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72017. */
  72018. SSAOCombineRenderEffect: string;
  72019. /**
  72020. * The output strength of the SSAO post-process. Default value is 1.0.
  72021. */
  72022. totalStrength: number;
  72023. /**
  72024. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72025. */
  72026. maxZ: number;
  72027. /**
  72028. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72029. */
  72030. minZAspect: number;
  72031. private _samples;
  72032. /**
  72033. * Number of samples used for the SSAO calculations. Default value is 8
  72034. */
  72035. set samples(n: number);
  72036. get samples(): number;
  72037. private _textureSamples;
  72038. /**
  72039. * Number of samples to use for antialiasing
  72040. */
  72041. set textureSamples(n: number);
  72042. get textureSamples(): number;
  72043. /**
  72044. * Force rendering the geometry through geometry buffer
  72045. */
  72046. private _forceGeometryBuffer;
  72047. /**
  72048. * Ratio object used for SSAO ratio and blur ratio
  72049. */
  72050. private _ratio;
  72051. /**
  72052. * Dynamically generated sphere sampler.
  72053. */
  72054. private _sampleSphere;
  72055. /**
  72056. * Blur filter offsets
  72057. */
  72058. private _samplerOffsets;
  72059. private _expensiveBlur;
  72060. /**
  72061. * If bilateral blur should be used
  72062. */
  72063. set expensiveBlur(b: boolean);
  72064. get expensiveBlur(): boolean;
  72065. /**
  72066. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72067. */
  72068. radius: number;
  72069. /**
  72070. * The base color of the SSAO post-process
  72071. * The final result is "base + ssao" between [0, 1]
  72072. */
  72073. base: number;
  72074. /**
  72075. * Support test.
  72076. */
  72077. static get IsSupported(): boolean;
  72078. private _scene;
  72079. private _randomTexture;
  72080. private _originalColorPostProcess;
  72081. private _ssaoPostProcess;
  72082. private _blurHPostProcess;
  72083. private _blurVPostProcess;
  72084. private _ssaoCombinePostProcess;
  72085. private _prePassRenderer;
  72086. /**
  72087. * Gets active scene
  72088. */
  72089. get scene(): Scene;
  72090. /**
  72091. * @constructor
  72092. * @param name The rendering pipeline name
  72093. * @param scene The scene linked to this pipeline
  72094. * @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 }
  72095. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72096. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72097. */
  72098. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72099. /**
  72100. * Get the class name
  72101. * @returns "SSAO2RenderingPipeline"
  72102. */
  72103. getClassName(): string;
  72104. /**
  72105. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72106. */
  72107. dispose(disableGeometryBufferRenderer?: boolean): void;
  72108. private _createBlurPostProcess;
  72109. /** @hidden */
  72110. _rebuild(): void;
  72111. private _bits;
  72112. private _radicalInverse_VdC;
  72113. private _hammersley;
  72114. private _hemisphereSample_uniform;
  72115. private _generateHemisphere;
  72116. private _getDefinesForSSAO;
  72117. private _createSSAOPostProcess;
  72118. private _createSSAOCombinePostProcess;
  72119. private _createRandomTexture;
  72120. /**
  72121. * Serialize the rendering pipeline (Used when exporting)
  72122. * @returns the serialized object
  72123. */
  72124. serialize(): any;
  72125. /**
  72126. * Parse the serialized pipeline
  72127. * @param source Source pipeline.
  72128. * @param scene The scene to load the pipeline to.
  72129. * @param rootUrl The URL of the serialized pipeline.
  72130. * @returns An instantiated pipeline from the serialized object.
  72131. */
  72132. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72133. }
  72134. }
  72135. declare module BABYLON {
  72136. /** @hidden */
  72137. export var ssaoPixelShader: {
  72138. name: string;
  72139. shader: string;
  72140. };
  72141. }
  72142. declare module BABYLON {
  72143. /**
  72144. * Render pipeline to produce ssao effect
  72145. */
  72146. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72147. /**
  72148. * @ignore
  72149. * The PassPostProcess id in the pipeline that contains the original scene color
  72150. */
  72151. SSAOOriginalSceneColorEffect: string;
  72152. /**
  72153. * @ignore
  72154. * The SSAO PostProcess id in the pipeline
  72155. */
  72156. SSAORenderEffect: string;
  72157. /**
  72158. * @ignore
  72159. * The horizontal blur PostProcess id in the pipeline
  72160. */
  72161. SSAOBlurHRenderEffect: string;
  72162. /**
  72163. * @ignore
  72164. * The vertical blur PostProcess id in the pipeline
  72165. */
  72166. SSAOBlurVRenderEffect: string;
  72167. /**
  72168. * @ignore
  72169. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72170. */
  72171. SSAOCombineRenderEffect: string;
  72172. /**
  72173. * The output strength of the SSAO post-process. Default value is 1.0.
  72174. */
  72175. totalStrength: number;
  72176. /**
  72177. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72178. */
  72179. radius: number;
  72180. /**
  72181. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72182. * Must not be equal to fallOff and superior to fallOff.
  72183. * Default value is 0.0075
  72184. */
  72185. area: number;
  72186. /**
  72187. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72188. * Must not be equal to area and inferior to area.
  72189. * Default value is 0.000001
  72190. */
  72191. fallOff: number;
  72192. /**
  72193. * The base color of the SSAO post-process
  72194. * The final result is "base + ssao" between [0, 1]
  72195. */
  72196. base: number;
  72197. private _scene;
  72198. private _depthTexture;
  72199. private _randomTexture;
  72200. private _originalColorPostProcess;
  72201. private _ssaoPostProcess;
  72202. private _blurHPostProcess;
  72203. private _blurVPostProcess;
  72204. private _ssaoCombinePostProcess;
  72205. private _firstUpdate;
  72206. /**
  72207. * Gets active scene
  72208. */
  72209. get scene(): Scene;
  72210. /**
  72211. * @constructor
  72212. * @param name - The rendering pipeline name
  72213. * @param scene - The scene linked to this pipeline
  72214. * @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 }
  72215. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72216. */
  72217. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72218. /**
  72219. * Get the class name
  72220. * @returns "SSAORenderingPipeline"
  72221. */
  72222. getClassName(): string;
  72223. /**
  72224. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72225. */
  72226. dispose(disableDepthRender?: boolean): void;
  72227. private _createBlurPostProcess;
  72228. /** @hidden */
  72229. _rebuild(): void;
  72230. private _createSSAOPostProcess;
  72231. private _createSSAOCombinePostProcess;
  72232. private _createRandomTexture;
  72233. }
  72234. }
  72235. declare module BABYLON {
  72236. /**
  72237. * Contains all parameters needed for the prepass to perform
  72238. * screen space reflections
  72239. */
  72240. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72241. /**
  72242. * Is ssr enabled
  72243. */
  72244. enabled: boolean;
  72245. /**
  72246. * Name of the configuration
  72247. */
  72248. name: string;
  72249. /**
  72250. * Textures that should be present in the MRT for this effect to work
  72251. */
  72252. readonly texturesRequired: number[];
  72253. }
  72254. }
  72255. declare module BABYLON {
  72256. /** @hidden */
  72257. export var screenSpaceReflectionPixelShader: {
  72258. name: string;
  72259. shader: string;
  72260. };
  72261. }
  72262. declare module BABYLON {
  72263. /**
  72264. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72265. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72266. */
  72267. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72268. /**
  72269. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72270. */
  72271. threshold: number;
  72272. /**
  72273. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72274. */
  72275. strength: number;
  72276. /**
  72277. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72278. */
  72279. reflectionSpecularFalloffExponent: number;
  72280. /**
  72281. * 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]
  72282. */
  72283. step: number;
  72284. /**
  72285. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72286. */
  72287. roughnessFactor: number;
  72288. private _forceGeometryBuffer;
  72289. private _geometryBufferRenderer;
  72290. private _prePassRenderer;
  72291. private _enableSmoothReflections;
  72292. private _reflectionSamples;
  72293. private _smoothSteps;
  72294. /**
  72295. * Gets a string identifying the name of the class
  72296. * @returns "ScreenSpaceReflectionPostProcess" string
  72297. */
  72298. getClassName(): string;
  72299. /**
  72300. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72301. * @param name The name of the effect.
  72302. * @param scene The scene containing the objects to calculate reflections.
  72303. * @param options The required width/height ratio to downsize to before computing the render pass.
  72304. * @param camera The camera to apply the render pass to.
  72305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72306. * @param engine The engine which the post process will be applied. (default: current engine)
  72307. * @param reusable If the post process can be reused on the same frame. (default: false)
  72308. * @param textureType Type of textures used when performing the post process. (default: 0)
  72309. * @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)
  72310. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72311. */
  72312. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72313. /**
  72314. * Gets wether or not smoothing reflections is enabled.
  72315. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72316. */
  72317. get enableSmoothReflections(): boolean;
  72318. /**
  72319. * Sets wether or not smoothing reflections is enabled.
  72320. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72321. */
  72322. set enableSmoothReflections(enabled: boolean);
  72323. /**
  72324. * Gets the number of samples taken while computing reflections. More samples count is high,
  72325. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72326. */
  72327. get reflectionSamples(): number;
  72328. /**
  72329. * Sets the number of samples taken while computing reflections. More samples count is high,
  72330. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72331. */
  72332. set reflectionSamples(samples: number);
  72333. /**
  72334. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72335. * more the post-process will require GPU power and can generate a drop in FPS.
  72336. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72337. */
  72338. get smoothSteps(): number;
  72339. set smoothSteps(steps: number);
  72340. private _updateEffectDefines;
  72341. /** @hidden */
  72342. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72343. }
  72344. }
  72345. declare module BABYLON {
  72346. /** @hidden */
  72347. export var standardPixelShader: {
  72348. name: string;
  72349. shader: string;
  72350. };
  72351. }
  72352. declare module BABYLON {
  72353. /**
  72354. * Standard rendering pipeline
  72355. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72356. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72357. */
  72358. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72359. /**
  72360. * Public members
  72361. */
  72362. /**
  72363. * Post-process which contains the original scene color before the pipeline applies all the effects
  72364. */
  72365. originalPostProcess: Nullable<PostProcess>;
  72366. /**
  72367. * Post-process used to down scale an image x4
  72368. */
  72369. downSampleX4PostProcess: Nullable<PostProcess>;
  72370. /**
  72371. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72372. */
  72373. brightPassPostProcess: Nullable<PostProcess>;
  72374. /**
  72375. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72376. */
  72377. blurHPostProcesses: PostProcess[];
  72378. /**
  72379. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72380. */
  72381. blurVPostProcesses: PostProcess[];
  72382. /**
  72383. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72384. */
  72385. textureAdderPostProcess: Nullable<PostProcess>;
  72386. /**
  72387. * Post-process used to create volumetric lighting effect
  72388. */
  72389. volumetricLightPostProcess: Nullable<PostProcess>;
  72390. /**
  72391. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72392. */
  72393. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72394. /**
  72395. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72396. */
  72397. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72398. /**
  72399. * Post-process used to merge the volumetric light effect and the real scene color
  72400. */
  72401. volumetricLightMergePostProces: Nullable<PostProcess>;
  72402. /**
  72403. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72404. */
  72405. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72406. /**
  72407. * Base post-process used to calculate the average luminance of the final image for HDR
  72408. */
  72409. luminancePostProcess: Nullable<PostProcess>;
  72410. /**
  72411. * Post-processes used to create down sample post-processes in order to get
  72412. * the average luminance of the final image for HDR
  72413. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72414. */
  72415. luminanceDownSamplePostProcesses: PostProcess[];
  72416. /**
  72417. * Post-process used to create a HDR effect (light adaptation)
  72418. */
  72419. hdrPostProcess: Nullable<PostProcess>;
  72420. /**
  72421. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72422. */
  72423. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72424. /**
  72425. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72426. */
  72427. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72428. /**
  72429. * Post-process used to merge the final HDR post-process and the real scene color
  72430. */
  72431. hdrFinalPostProcess: Nullable<PostProcess>;
  72432. /**
  72433. * Post-process used to create a lens flare effect
  72434. */
  72435. lensFlarePostProcess: Nullable<PostProcess>;
  72436. /**
  72437. * Post-process that merges the result of the lens flare post-process and the real scene color
  72438. */
  72439. lensFlareComposePostProcess: Nullable<PostProcess>;
  72440. /**
  72441. * Post-process used to create a motion blur effect
  72442. */
  72443. motionBlurPostProcess: Nullable<PostProcess>;
  72444. /**
  72445. * Post-process used to create a depth of field effect
  72446. */
  72447. depthOfFieldPostProcess: Nullable<PostProcess>;
  72448. /**
  72449. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72450. */
  72451. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72452. /**
  72453. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72454. */
  72455. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72456. /**
  72457. * Represents the brightness threshold in order to configure the illuminated surfaces
  72458. */
  72459. brightThreshold: number;
  72460. /**
  72461. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72462. */
  72463. blurWidth: number;
  72464. /**
  72465. * Sets if the blur for highlighted surfaces must be only horizontal
  72466. */
  72467. horizontalBlur: boolean;
  72468. /**
  72469. * Gets the overall exposure used by the pipeline
  72470. */
  72471. get exposure(): number;
  72472. /**
  72473. * Sets the overall exposure used by the pipeline
  72474. */
  72475. set exposure(value: number);
  72476. /**
  72477. * Texture used typically to simulate "dirty" on camera lens
  72478. */
  72479. lensTexture: Nullable<Texture>;
  72480. /**
  72481. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72482. */
  72483. volumetricLightCoefficient: number;
  72484. /**
  72485. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72486. */
  72487. volumetricLightPower: number;
  72488. /**
  72489. * Used the set the blur intensity to smooth the volumetric lights
  72490. */
  72491. volumetricLightBlurScale: number;
  72492. /**
  72493. * Light (spot or directional) used to generate the volumetric lights rays
  72494. * The source light must have a shadow generate so the pipeline can get its
  72495. * depth map
  72496. */
  72497. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72498. /**
  72499. * For eye adaptation, represents the minimum luminance the eye can see
  72500. */
  72501. hdrMinimumLuminance: number;
  72502. /**
  72503. * For eye adaptation, represents the decrease luminance speed
  72504. */
  72505. hdrDecreaseRate: number;
  72506. /**
  72507. * For eye adaptation, represents the increase luminance speed
  72508. */
  72509. hdrIncreaseRate: number;
  72510. /**
  72511. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72512. */
  72513. get hdrAutoExposure(): boolean;
  72514. /**
  72515. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72516. */
  72517. set hdrAutoExposure(value: boolean);
  72518. /**
  72519. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72520. */
  72521. lensColorTexture: Nullable<Texture>;
  72522. /**
  72523. * The overall strengh for the lens flare effect
  72524. */
  72525. lensFlareStrength: number;
  72526. /**
  72527. * Dispersion coefficient for lens flare ghosts
  72528. */
  72529. lensFlareGhostDispersal: number;
  72530. /**
  72531. * Main lens flare halo width
  72532. */
  72533. lensFlareHaloWidth: number;
  72534. /**
  72535. * Based on the lens distortion effect, defines how much the lens flare result
  72536. * is distorted
  72537. */
  72538. lensFlareDistortionStrength: number;
  72539. /**
  72540. * Configures the blur intensity used for for lens flare (halo)
  72541. */
  72542. lensFlareBlurWidth: number;
  72543. /**
  72544. * Lens star texture must be used to simulate rays on the flares and is available
  72545. * in the documentation
  72546. */
  72547. lensStarTexture: Nullable<Texture>;
  72548. /**
  72549. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72550. * flare effect by taking account of the dirt texture
  72551. */
  72552. lensFlareDirtTexture: Nullable<Texture>;
  72553. /**
  72554. * Represents the focal length for the depth of field effect
  72555. */
  72556. depthOfFieldDistance: number;
  72557. /**
  72558. * Represents the blur intensity for the blurred part of the depth of field effect
  72559. */
  72560. depthOfFieldBlurWidth: number;
  72561. /**
  72562. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72563. */
  72564. get motionStrength(): number;
  72565. /**
  72566. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72567. */
  72568. set motionStrength(strength: number);
  72569. /**
  72570. * Gets wether or not the motion blur post-process is object based or screen based.
  72571. */
  72572. get objectBasedMotionBlur(): boolean;
  72573. /**
  72574. * Sets wether or not the motion blur post-process should be object based or screen based
  72575. */
  72576. set objectBasedMotionBlur(value: boolean);
  72577. /**
  72578. * List of animations for the pipeline (IAnimatable implementation)
  72579. */
  72580. animations: Animation[];
  72581. /**
  72582. * Private members
  72583. */
  72584. private _scene;
  72585. private _currentDepthOfFieldSource;
  72586. private _basePostProcess;
  72587. private _fixedExposure;
  72588. private _currentExposure;
  72589. private _hdrAutoExposure;
  72590. private _hdrCurrentLuminance;
  72591. private _motionStrength;
  72592. private _isObjectBasedMotionBlur;
  72593. private _floatTextureType;
  72594. private _camerasToBeAttached;
  72595. private _ratio;
  72596. private _bloomEnabled;
  72597. private _depthOfFieldEnabled;
  72598. private _vlsEnabled;
  72599. private _lensFlareEnabled;
  72600. private _hdrEnabled;
  72601. private _motionBlurEnabled;
  72602. private _fxaaEnabled;
  72603. private _screenSpaceReflectionsEnabled;
  72604. private _motionBlurSamples;
  72605. private _volumetricLightStepsCount;
  72606. private _samples;
  72607. /**
  72608. * @ignore
  72609. * Specifies if the bloom pipeline is enabled
  72610. */
  72611. get BloomEnabled(): boolean;
  72612. set BloomEnabled(enabled: boolean);
  72613. /**
  72614. * @ignore
  72615. * Specifies if the depth of field pipeline is enabed
  72616. */
  72617. get DepthOfFieldEnabled(): boolean;
  72618. set DepthOfFieldEnabled(enabled: boolean);
  72619. /**
  72620. * @ignore
  72621. * Specifies if the lens flare pipeline is enabed
  72622. */
  72623. get LensFlareEnabled(): boolean;
  72624. set LensFlareEnabled(enabled: boolean);
  72625. /**
  72626. * @ignore
  72627. * Specifies if the HDR pipeline is enabled
  72628. */
  72629. get HDREnabled(): boolean;
  72630. set HDREnabled(enabled: boolean);
  72631. /**
  72632. * @ignore
  72633. * Specifies if the volumetric lights scattering effect is enabled
  72634. */
  72635. get VLSEnabled(): boolean;
  72636. set VLSEnabled(enabled: boolean);
  72637. /**
  72638. * @ignore
  72639. * Specifies if the motion blur effect is enabled
  72640. */
  72641. get MotionBlurEnabled(): boolean;
  72642. set MotionBlurEnabled(enabled: boolean);
  72643. /**
  72644. * Specifies if anti-aliasing is enabled
  72645. */
  72646. get fxaaEnabled(): boolean;
  72647. set fxaaEnabled(enabled: boolean);
  72648. /**
  72649. * Specifies if screen space reflections are enabled.
  72650. */
  72651. get screenSpaceReflectionsEnabled(): boolean;
  72652. set screenSpaceReflectionsEnabled(enabled: boolean);
  72653. /**
  72654. * Specifies the number of steps used to calculate the volumetric lights
  72655. * Typically in interval [50, 200]
  72656. */
  72657. get volumetricLightStepsCount(): number;
  72658. set volumetricLightStepsCount(count: number);
  72659. /**
  72660. * Specifies the number of samples used for the motion blur effect
  72661. * Typically in interval [16, 64]
  72662. */
  72663. get motionBlurSamples(): number;
  72664. set motionBlurSamples(samples: number);
  72665. /**
  72666. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72667. */
  72668. get samples(): number;
  72669. set samples(sampleCount: number);
  72670. /**
  72671. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72672. * @constructor
  72673. * @param name The rendering pipeline name
  72674. * @param scene The scene linked to this pipeline
  72675. * @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)
  72676. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72677. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72678. */
  72679. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72680. private _buildPipeline;
  72681. private _createDownSampleX4PostProcess;
  72682. private _createBrightPassPostProcess;
  72683. private _createBlurPostProcesses;
  72684. private _createTextureAdderPostProcess;
  72685. private _createVolumetricLightPostProcess;
  72686. private _createLuminancePostProcesses;
  72687. private _createHdrPostProcess;
  72688. private _createLensFlarePostProcess;
  72689. private _createDepthOfFieldPostProcess;
  72690. private _createMotionBlurPostProcess;
  72691. private _getDepthTexture;
  72692. private _disposePostProcesses;
  72693. /**
  72694. * Dispose of the pipeline and stop all post processes
  72695. */
  72696. dispose(): void;
  72697. /**
  72698. * Serialize the rendering pipeline (Used when exporting)
  72699. * @returns the serialized object
  72700. */
  72701. serialize(): any;
  72702. /**
  72703. * Parse the serialized pipeline
  72704. * @param source Source pipeline.
  72705. * @param scene The scene to load the pipeline to.
  72706. * @param rootUrl The URL of the serialized pipeline.
  72707. * @returns An instantiated pipeline from the serialized object.
  72708. */
  72709. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72710. /**
  72711. * Luminance steps
  72712. */
  72713. static LuminanceSteps: number;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /** @hidden */
  72718. export var stereoscopicInterlacePixelShader: {
  72719. name: string;
  72720. shader: string;
  72721. };
  72722. }
  72723. declare module BABYLON {
  72724. /**
  72725. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72726. */
  72727. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72728. private _stepSize;
  72729. private _passedProcess;
  72730. /**
  72731. * Gets a string identifying the name of the class
  72732. * @returns "StereoscopicInterlacePostProcessI" string
  72733. */
  72734. getClassName(): string;
  72735. /**
  72736. * Initializes a StereoscopicInterlacePostProcessI
  72737. * @param name The name of the effect.
  72738. * @param rigCameras The rig cameras to be appled to the post process
  72739. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72740. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72741. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72742. * @param engine The engine which the post process will be applied. (default: current engine)
  72743. * @param reusable If the post process can be reused on the same frame. (default: false)
  72744. */
  72745. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72746. }
  72747. /**
  72748. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72749. */
  72750. export class StereoscopicInterlacePostProcess extends PostProcess {
  72751. private _stepSize;
  72752. private _passedProcess;
  72753. /**
  72754. * Gets a string identifying the name of the class
  72755. * @returns "StereoscopicInterlacePostProcess" string
  72756. */
  72757. getClassName(): string;
  72758. /**
  72759. * Initializes a StereoscopicInterlacePostProcess
  72760. * @param name The name of the effect.
  72761. * @param rigCameras The rig cameras to be appled to the post process
  72762. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72764. * @param engine The engine which the post process will be applied. (default: current engine)
  72765. * @param reusable If the post process can be reused on the same frame. (default: false)
  72766. */
  72767. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72768. }
  72769. }
  72770. declare module BABYLON {
  72771. /** @hidden */
  72772. export var tonemapPixelShader: {
  72773. name: string;
  72774. shader: string;
  72775. };
  72776. }
  72777. declare module BABYLON {
  72778. /** Defines operator used for tonemapping */
  72779. export enum TonemappingOperator {
  72780. /** Hable */
  72781. Hable = 0,
  72782. /** Reinhard */
  72783. Reinhard = 1,
  72784. /** HejiDawson */
  72785. HejiDawson = 2,
  72786. /** Photographic */
  72787. Photographic = 3
  72788. }
  72789. /**
  72790. * Defines a post process to apply tone mapping
  72791. */
  72792. export class TonemapPostProcess extends PostProcess {
  72793. private _operator;
  72794. /** Defines the required exposure adjustement */
  72795. exposureAdjustment: number;
  72796. /**
  72797. * Gets a string identifying the name of the class
  72798. * @returns "TonemapPostProcess" string
  72799. */
  72800. getClassName(): string;
  72801. /**
  72802. * Creates a new TonemapPostProcess
  72803. * @param name defines the name of the postprocess
  72804. * @param _operator defines the operator to use
  72805. * @param exposureAdjustment defines the required exposure adjustement
  72806. * @param camera defines the camera to use (can be null)
  72807. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72808. * @param engine defines the hosting engine (can be ignore if camera is set)
  72809. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72810. */
  72811. constructor(name: string, _operator: TonemappingOperator,
  72812. /** Defines the required exposure adjustement */
  72813. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72814. }
  72815. }
  72816. declare module BABYLON {
  72817. /** @hidden */
  72818. export var volumetricLightScatteringPixelShader: {
  72819. name: string;
  72820. shader: string;
  72821. };
  72822. }
  72823. declare module BABYLON {
  72824. /** @hidden */
  72825. export var volumetricLightScatteringPassVertexShader: {
  72826. name: string;
  72827. shader: string;
  72828. };
  72829. }
  72830. declare module BABYLON {
  72831. /** @hidden */
  72832. export var volumetricLightScatteringPassPixelShader: {
  72833. name: string;
  72834. shader: string;
  72835. };
  72836. }
  72837. declare module BABYLON {
  72838. /**
  72839. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72840. */
  72841. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72842. private _volumetricLightScatteringPass;
  72843. private _volumetricLightScatteringRTT;
  72844. private _viewPort;
  72845. private _screenCoordinates;
  72846. private _cachedDefines;
  72847. /**
  72848. * If not undefined, the mesh position is computed from the attached node position
  72849. */
  72850. attachedNode: {
  72851. position: Vector3;
  72852. };
  72853. /**
  72854. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72855. */
  72856. customMeshPosition: Vector3;
  72857. /**
  72858. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72859. */
  72860. useCustomMeshPosition: boolean;
  72861. /**
  72862. * If the post-process should inverse the light scattering direction
  72863. */
  72864. invert: boolean;
  72865. /**
  72866. * The internal mesh used by the post-process
  72867. */
  72868. mesh: Mesh;
  72869. /**
  72870. * @hidden
  72871. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72872. */
  72873. get useDiffuseColor(): boolean;
  72874. set useDiffuseColor(useDiffuseColor: boolean);
  72875. /**
  72876. * Array containing the excluded meshes not rendered in the internal pass
  72877. */
  72878. excludedMeshes: AbstractMesh[];
  72879. /**
  72880. * Controls the overall intensity of the post-process
  72881. */
  72882. exposure: number;
  72883. /**
  72884. * Dissipates each sample's contribution in range [0, 1]
  72885. */
  72886. decay: number;
  72887. /**
  72888. * Controls the overall intensity of each sample
  72889. */
  72890. weight: number;
  72891. /**
  72892. * Controls the density of each sample
  72893. */
  72894. density: number;
  72895. /**
  72896. * @constructor
  72897. * @param name The post-process name
  72898. * @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)
  72899. * @param camera The camera that the post-process will be attached to
  72900. * @param mesh The mesh used to create the light scattering
  72901. * @param samples The post-process quality, default 100
  72902. * @param samplingModeThe post-process filtering mode
  72903. * @param engine The babylon engine
  72904. * @param reusable If the post-process is reusable
  72905. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72906. */
  72907. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72908. /**
  72909. * Returns the string "VolumetricLightScatteringPostProcess"
  72910. * @returns "VolumetricLightScatteringPostProcess"
  72911. */
  72912. getClassName(): string;
  72913. private _isReady;
  72914. /**
  72915. * Sets the new light position for light scattering effect
  72916. * @param position The new custom light position
  72917. */
  72918. setCustomMeshPosition(position: Vector3): void;
  72919. /**
  72920. * Returns the light position for light scattering effect
  72921. * @return Vector3 The custom light position
  72922. */
  72923. getCustomMeshPosition(): Vector3;
  72924. /**
  72925. * Disposes the internal assets and detaches the post-process from the camera
  72926. */
  72927. dispose(camera: Camera): void;
  72928. /**
  72929. * Returns the render target texture used by the post-process
  72930. * @return the render target texture used by the post-process
  72931. */
  72932. getPass(): RenderTargetTexture;
  72933. private _meshExcluded;
  72934. private _createPass;
  72935. private _updateMeshScreenCoordinates;
  72936. /**
  72937. * Creates a default mesh for the Volumeric Light Scattering post-process
  72938. * @param name The mesh name
  72939. * @param scene The scene where to create the mesh
  72940. * @return the default mesh
  72941. */
  72942. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72943. }
  72944. }
  72945. declare module BABYLON {
  72946. /** @hidden */
  72947. export var screenSpaceCurvaturePixelShader: {
  72948. name: string;
  72949. shader: string;
  72950. };
  72951. }
  72952. declare module BABYLON {
  72953. /**
  72954. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72955. */
  72956. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72957. /**
  72958. * Defines how much ridge the curvature effect displays.
  72959. */
  72960. ridge: number;
  72961. /**
  72962. * Defines how much valley the curvature effect displays.
  72963. */
  72964. valley: number;
  72965. private _geometryBufferRenderer;
  72966. /**
  72967. * Gets a string identifying the name of the class
  72968. * @returns "ScreenSpaceCurvaturePostProcess" string
  72969. */
  72970. getClassName(): string;
  72971. /**
  72972. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72973. * @param name The name of the effect.
  72974. * @param scene The scene containing the objects to blur according to their velocity.
  72975. * @param options The required width/height ratio to downsize to before computing the render pass.
  72976. * @param camera The camera to apply the render pass to.
  72977. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72978. * @param engine The engine which the post process will be applied. (default: current engine)
  72979. * @param reusable If the post process can be reused on the same frame. (default: false)
  72980. * @param textureType Type of textures used when performing the post process. (default: 0)
  72981. * @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)
  72982. */
  72983. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72984. /**
  72985. * Support test.
  72986. */
  72987. static get IsSupported(): boolean;
  72988. /** @hidden */
  72989. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72990. }
  72991. }
  72992. declare module BABYLON {
  72993. interface Scene {
  72994. /** @hidden (Backing field) */
  72995. _boundingBoxRenderer: BoundingBoxRenderer;
  72996. /** @hidden (Backing field) */
  72997. _forceShowBoundingBoxes: boolean;
  72998. /**
  72999. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73000. */
  73001. forceShowBoundingBoxes: boolean;
  73002. /**
  73003. * Gets the bounding box renderer associated with the scene
  73004. * @returns a BoundingBoxRenderer
  73005. */
  73006. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73007. }
  73008. interface AbstractMesh {
  73009. /** @hidden (Backing field) */
  73010. _showBoundingBox: boolean;
  73011. /**
  73012. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73013. */
  73014. showBoundingBox: boolean;
  73015. }
  73016. /**
  73017. * Component responsible of rendering the bounding box of the meshes in a scene.
  73018. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73019. */
  73020. export class BoundingBoxRenderer implements ISceneComponent {
  73021. /**
  73022. * The component name helpfull to identify the component in the list of scene components.
  73023. */
  73024. readonly name: string;
  73025. /**
  73026. * The scene the component belongs to.
  73027. */
  73028. scene: Scene;
  73029. /**
  73030. * Color of the bounding box lines placed in front of an object
  73031. */
  73032. frontColor: Color3;
  73033. /**
  73034. * Color of the bounding box lines placed behind an object
  73035. */
  73036. backColor: Color3;
  73037. /**
  73038. * Defines if the renderer should show the back lines or not
  73039. */
  73040. showBackLines: boolean;
  73041. /**
  73042. * Observable raised before rendering a bounding box
  73043. */
  73044. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73045. /**
  73046. * Observable raised after rendering a bounding box
  73047. */
  73048. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73049. /**
  73050. * Observable raised after resources are created
  73051. */
  73052. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73053. /**
  73054. * When false, no bounding boxes will be rendered
  73055. */
  73056. enabled: boolean;
  73057. /**
  73058. * @hidden
  73059. */
  73060. renderList: SmartArray<BoundingBox>;
  73061. private _colorShader;
  73062. private _vertexBuffers;
  73063. private _indexBuffer;
  73064. private _fillIndexBuffer;
  73065. private _fillIndexData;
  73066. /**
  73067. * Instantiates a new bounding box renderer in a scene.
  73068. * @param scene the scene the renderer renders in
  73069. */
  73070. constructor(scene: Scene);
  73071. /**
  73072. * Registers the component in a given scene
  73073. */
  73074. register(): void;
  73075. private _evaluateSubMesh;
  73076. private _preActiveMesh;
  73077. private _prepareResources;
  73078. private _createIndexBuffer;
  73079. /**
  73080. * Rebuilds the elements related to this component in case of
  73081. * context lost for instance.
  73082. */
  73083. rebuild(): void;
  73084. /**
  73085. * @hidden
  73086. */
  73087. reset(): void;
  73088. /**
  73089. * Render the bounding boxes of a specific rendering group
  73090. * @param renderingGroupId defines the rendering group to render
  73091. */
  73092. render(renderingGroupId: number): void;
  73093. /**
  73094. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73095. * @param mesh Define the mesh to render the occlusion bounding box for
  73096. */
  73097. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73098. /**
  73099. * Dispose and release the resources attached to this renderer.
  73100. */
  73101. dispose(): void;
  73102. }
  73103. }
  73104. declare module BABYLON {
  73105. interface Scene {
  73106. /** @hidden (Backing field) */
  73107. _depthRenderer: {
  73108. [id: string]: DepthRenderer;
  73109. };
  73110. /**
  73111. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73112. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73113. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73114. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73115. * @returns the created depth renderer
  73116. */
  73117. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73118. /**
  73119. * Disables a depth renderer for a given camera
  73120. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73121. */
  73122. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73123. }
  73124. /**
  73125. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73126. * in several rendering techniques.
  73127. */
  73128. export class DepthRendererSceneComponent implements ISceneComponent {
  73129. /**
  73130. * The component name helpfull to identify the component in the list of scene components.
  73131. */
  73132. readonly name: string;
  73133. /**
  73134. * The scene the component belongs to.
  73135. */
  73136. scene: Scene;
  73137. /**
  73138. * Creates a new instance of the component for the given scene
  73139. * @param scene Defines the scene to register the component in
  73140. */
  73141. constructor(scene: Scene);
  73142. /**
  73143. * Registers the component in a given scene
  73144. */
  73145. register(): void;
  73146. /**
  73147. * Rebuilds the elements related to this component in case of
  73148. * context lost for instance.
  73149. */
  73150. rebuild(): void;
  73151. /**
  73152. * Disposes the component and the associated ressources
  73153. */
  73154. dispose(): void;
  73155. private _gatherRenderTargets;
  73156. private _gatherActiveCameraRenderTargets;
  73157. }
  73158. }
  73159. declare module BABYLON {
  73160. interface AbstractScene {
  73161. /** @hidden (Backing field) */
  73162. _prePassRenderer: Nullable<PrePassRenderer>;
  73163. /**
  73164. * Gets or Sets the current prepass renderer associated to the scene.
  73165. */
  73166. prePassRenderer: Nullable<PrePassRenderer>;
  73167. /**
  73168. * Enables the prepass and associates it with the scene
  73169. * @returns the PrePassRenderer
  73170. */
  73171. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73172. /**
  73173. * Disables the prepass associated with the scene
  73174. */
  73175. disablePrePassRenderer(): void;
  73176. }
  73177. /**
  73178. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73179. * in several rendering techniques.
  73180. */
  73181. export class PrePassRendererSceneComponent implements ISceneComponent {
  73182. /**
  73183. * The component name helpful to identify the component in the list of scene components.
  73184. */
  73185. readonly name: string;
  73186. /**
  73187. * The scene the component belongs to.
  73188. */
  73189. scene: Scene;
  73190. /**
  73191. * Creates a new instance of the component for the given scene
  73192. * @param scene Defines the scene to register the component in
  73193. */
  73194. constructor(scene: Scene);
  73195. /**
  73196. * Registers the component in a given scene
  73197. */
  73198. register(): void;
  73199. private _beforeCameraDraw;
  73200. private _afterCameraDraw;
  73201. private _beforeClearStage;
  73202. /**
  73203. * Rebuilds the elements related to this component in case of
  73204. * context lost for instance.
  73205. */
  73206. rebuild(): void;
  73207. /**
  73208. * Disposes the component and the associated ressources
  73209. */
  73210. dispose(): void;
  73211. }
  73212. }
  73213. declare module BABYLON {
  73214. /** @hidden */
  73215. export var fibonacci: {
  73216. name: string;
  73217. shader: string;
  73218. };
  73219. }
  73220. declare module BABYLON {
  73221. /** @hidden */
  73222. export var diffusionProfile: {
  73223. name: string;
  73224. shader: string;
  73225. };
  73226. }
  73227. declare module BABYLON {
  73228. /** @hidden */
  73229. export var subSurfaceScatteringPixelShader: {
  73230. name: string;
  73231. shader: string;
  73232. };
  73233. }
  73234. declare module BABYLON {
  73235. /**
  73236. * Sub surface scattering post process
  73237. */
  73238. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73239. /**
  73240. * Gets a string identifying the name of the class
  73241. * @returns "SubSurfaceScatteringPostProcess" string
  73242. */
  73243. getClassName(): string;
  73244. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73245. }
  73246. }
  73247. declare module BABYLON {
  73248. /**
  73249. * Contains all parameters needed for the prepass to perform
  73250. * screen space subsurface scattering
  73251. */
  73252. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73253. /** @hidden */
  73254. static _SceneComponentInitialization: (scene: Scene) => void;
  73255. private _ssDiffusionS;
  73256. private _ssFilterRadii;
  73257. private _ssDiffusionD;
  73258. /**
  73259. * Post process to attach for screen space subsurface scattering
  73260. */
  73261. postProcess: SubSurfaceScatteringPostProcess;
  73262. /**
  73263. * Diffusion profile color for subsurface scattering
  73264. */
  73265. get ssDiffusionS(): number[];
  73266. /**
  73267. * Diffusion profile max color channel value for subsurface scattering
  73268. */
  73269. get ssDiffusionD(): number[];
  73270. /**
  73271. * Diffusion profile filter radius for subsurface scattering
  73272. */
  73273. get ssFilterRadii(): number[];
  73274. /**
  73275. * Is subsurface enabled
  73276. */
  73277. enabled: boolean;
  73278. /**
  73279. * Name of the configuration
  73280. */
  73281. name: string;
  73282. /**
  73283. * Diffusion profile colors for subsurface scattering
  73284. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73285. * See ...
  73286. * Note that you can only store up to 5 of them
  73287. */
  73288. ssDiffusionProfileColors: Color3[];
  73289. /**
  73290. * Defines the ratio real world => scene units.
  73291. * Used for subsurface scattering
  73292. */
  73293. metersPerUnit: number;
  73294. /**
  73295. * Textures that should be present in the MRT for this effect to work
  73296. */
  73297. readonly texturesRequired: number[];
  73298. private _scene;
  73299. /**
  73300. * Builds a subsurface configuration object
  73301. * @param scene The scene
  73302. */
  73303. constructor(scene: Scene);
  73304. /**
  73305. * Adds a new diffusion profile.
  73306. * Useful for more realistic subsurface scattering on diverse materials.
  73307. * @param color The color of the diffusion profile. Should be the average color of the material.
  73308. * @return The index of the diffusion profile for the material subsurface configuration
  73309. */
  73310. addDiffusionProfile(color: Color3): number;
  73311. /**
  73312. * Creates the sss post process
  73313. * @return The created post process
  73314. */
  73315. createPostProcess(): SubSurfaceScatteringPostProcess;
  73316. /**
  73317. * Deletes all diffusion profiles.
  73318. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73319. */
  73320. clearAllDiffusionProfiles(): void;
  73321. /**
  73322. * Disposes this object
  73323. */
  73324. dispose(): void;
  73325. /**
  73326. * @hidden
  73327. * https://zero-radiance.github.io/post/sampling-diffusion/
  73328. *
  73329. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73330. * ------------------------------------------------------------------------------------
  73331. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73332. * PDF[r, phi, s] = r * R[r, phi, s]
  73333. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73334. * ------------------------------------------------------------------------------------
  73335. * We importance sample the color channel with the widest scattering distance.
  73336. */
  73337. getDiffusionProfileParameters(color: Color3): number;
  73338. /**
  73339. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73340. * 'u' is the random number (the value of the CDF): [0, 1).
  73341. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73342. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73343. */
  73344. private _sampleBurleyDiffusionProfile;
  73345. }
  73346. }
  73347. declare module BABYLON {
  73348. interface AbstractScene {
  73349. /** @hidden (Backing field) */
  73350. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73351. /**
  73352. * Gets or Sets the current prepass renderer associated to the scene.
  73353. */
  73354. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73355. /**
  73356. * Enables the subsurface effect for prepass
  73357. * @returns the SubSurfaceConfiguration
  73358. */
  73359. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73360. /**
  73361. * Disables the subsurface effect for prepass
  73362. */
  73363. disableSubSurfaceForPrePass(): void;
  73364. }
  73365. /**
  73366. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73367. * in several rendering techniques.
  73368. */
  73369. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73370. /**
  73371. * The component name helpful to identify the component in the list of scene components.
  73372. */
  73373. readonly name: string;
  73374. /**
  73375. * The scene the component belongs to.
  73376. */
  73377. scene: Scene;
  73378. /**
  73379. * Creates a new instance of the component for the given scene
  73380. * @param scene Defines the scene to register the component in
  73381. */
  73382. constructor(scene: Scene);
  73383. /**
  73384. * Registers the component in a given scene
  73385. */
  73386. register(): void;
  73387. /**
  73388. * Serializes the component data to the specified json object
  73389. * @param serializationObject The object to serialize to
  73390. */
  73391. serialize(serializationObject: any): void;
  73392. /**
  73393. * Adds all the elements from the container to the scene
  73394. * @param container the container holding the elements
  73395. */
  73396. addFromContainer(container: AbstractScene): void;
  73397. /**
  73398. * Removes all the elements in the container from the scene
  73399. * @param container contains the elements to remove
  73400. * @param dispose if the removed element should be disposed (default: false)
  73401. */
  73402. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73403. /**
  73404. * Rebuilds the elements related to this component in case of
  73405. * context lost for instance.
  73406. */
  73407. rebuild(): void;
  73408. /**
  73409. * Disposes the component and the associated ressources
  73410. */
  73411. dispose(): void;
  73412. }
  73413. }
  73414. declare module BABYLON {
  73415. /** @hidden */
  73416. export var outlinePixelShader: {
  73417. name: string;
  73418. shader: string;
  73419. };
  73420. }
  73421. declare module BABYLON {
  73422. /** @hidden */
  73423. export var outlineVertexShader: {
  73424. name: string;
  73425. shader: string;
  73426. };
  73427. }
  73428. declare module BABYLON {
  73429. interface Scene {
  73430. /** @hidden */
  73431. _outlineRenderer: OutlineRenderer;
  73432. /**
  73433. * Gets the outline renderer associated with the scene
  73434. * @returns a OutlineRenderer
  73435. */
  73436. getOutlineRenderer(): OutlineRenderer;
  73437. }
  73438. interface AbstractMesh {
  73439. /** @hidden (Backing field) */
  73440. _renderOutline: boolean;
  73441. /**
  73442. * Gets or sets a boolean indicating if the outline must be rendered as well
  73443. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73444. */
  73445. renderOutline: boolean;
  73446. /** @hidden (Backing field) */
  73447. _renderOverlay: boolean;
  73448. /**
  73449. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73450. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73451. */
  73452. renderOverlay: boolean;
  73453. }
  73454. /**
  73455. * This class is responsible to draw bothe outline/overlay of meshes.
  73456. * It should not be used directly but through the available method on mesh.
  73457. */
  73458. export class OutlineRenderer implements ISceneComponent {
  73459. /**
  73460. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73461. */
  73462. private static _StencilReference;
  73463. /**
  73464. * The name of the component. Each component must have a unique name.
  73465. */
  73466. name: string;
  73467. /**
  73468. * The scene the component belongs to.
  73469. */
  73470. scene: Scene;
  73471. /**
  73472. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73473. */
  73474. zOffset: number;
  73475. private _engine;
  73476. private _effect;
  73477. private _cachedDefines;
  73478. private _savedDepthWrite;
  73479. /**
  73480. * Instantiates a new outline renderer. (There could be only one per scene).
  73481. * @param scene Defines the scene it belongs to
  73482. */
  73483. constructor(scene: Scene);
  73484. /**
  73485. * Register the component to one instance of a scene.
  73486. */
  73487. register(): void;
  73488. /**
  73489. * Rebuilds the elements related to this component in case of
  73490. * context lost for instance.
  73491. */
  73492. rebuild(): void;
  73493. /**
  73494. * Disposes the component and the associated ressources.
  73495. */
  73496. dispose(): void;
  73497. /**
  73498. * Renders the outline in the canvas.
  73499. * @param subMesh Defines the sumesh to render
  73500. * @param batch Defines the batch of meshes in case of instances
  73501. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73502. */
  73503. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73504. /**
  73505. * Returns whether or not the outline renderer is ready for a given submesh.
  73506. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73507. * @param subMesh Defines the submesh to check readyness for
  73508. * @param useInstances Defines wheter wee are trying to render instances or not
  73509. * @returns true if ready otherwise false
  73510. */
  73511. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73512. private _beforeRenderingMesh;
  73513. private _afterRenderingMesh;
  73514. }
  73515. }
  73516. declare module BABYLON {
  73517. /**
  73518. * Defines the basic options interface of a Sprite Frame Source Size.
  73519. */
  73520. export interface ISpriteJSONSpriteSourceSize {
  73521. /**
  73522. * number of the original width of the Frame
  73523. */
  73524. w: number;
  73525. /**
  73526. * number of the original height of the Frame
  73527. */
  73528. h: number;
  73529. }
  73530. /**
  73531. * Defines the basic options interface of a Sprite Frame Data.
  73532. */
  73533. export interface ISpriteJSONSpriteFrameData {
  73534. /**
  73535. * number of the x offset of the Frame
  73536. */
  73537. x: number;
  73538. /**
  73539. * number of the y offset of the Frame
  73540. */
  73541. y: number;
  73542. /**
  73543. * number of the width of the Frame
  73544. */
  73545. w: number;
  73546. /**
  73547. * number of the height of the Frame
  73548. */
  73549. h: number;
  73550. }
  73551. /**
  73552. * Defines the basic options interface of a JSON Sprite.
  73553. */
  73554. export interface ISpriteJSONSprite {
  73555. /**
  73556. * string name of the Frame
  73557. */
  73558. filename: string;
  73559. /**
  73560. * ISpriteJSONSpriteFrame basic object of the frame data
  73561. */
  73562. frame: ISpriteJSONSpriteFrameData;
  73563. /**
  73564. * boolean to flag is the frame was rotated.
  73565. */
  73566. rotated: boolean;
  73567. /**
  73568. * boolean to flag is the frame was trimmed.
  73569. */
  73570. trimmed: boolean;
  73571. /**
  73572. * ISpriteJSONSpriteFrame basic object of the source data
  73573. */
  73574. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73575. /**
  73576. * ISpriteJSONSpriteFrame basic object of the source data
  73577. */
  73578. sourceSize: ISpriteJSONSpriteSourceSize;
  73579. }
  73580. /**
  73581. * Defines the basic options interface of a JSON atlas.
  73582. */
  73583. export interface ISpriteJSONAtlas {
  73584. /**
  73585. * Array of objects that contain the frame data.
  73586. */
  73587. frames: Array<ISpriteJSONSprite>;
  73588. /**
  73589. * object basic object containing the sprite meta data.
  73590. */
  73591. meta?: object;
  73592. }
  73593. }
  73594. declare module BABYLON {
  73595. /** @hidden */
  73596. export var spriteMapPixelShader: {
  73597. name: string;
  73598. shader: string;
  73599. };
  73600. }
  73601. declare module BABYLON {
  73602. /** @hidden */
  73603. export var spriteMapVertexShader: {
  73604. name: string;
  73605. shader: string;
  73606. };
  73607. }
  73608. declare module BABYLON {
  73609. /**
  73610. * Defines the basic options interface of a SpriteMap
  73611. */
  73612. export interface ISpriteMapOptions {
  73613. /**
  73614. * Vector2 of the number of cells in the grid.
  73615. */
  73616. stageSize?: Vector2;
  73617. /**
  73618. * Vector2 of the size of the output plane in World Units.
  73619. */
  73620. outputSize?: Vector2;
  73621. /**
  73622. * Vector3 of the position of the output plane in World Units.
  73623. */
  73624. outputPosition?: Vector3;
  73625. /**
  73626. * Vector3 of the rotation of the output plane.
  73627. */
  73628. outputRotation?: Vector3;
  73629. /**
  73630. * number of layers that the system will reserve in resources.
  73631. */
  73632. layerCount?: number;
  73633. /**
  73634. * number of max animation frames a single cell will reserve in resources.
  73635. */
  73636. maxAnimationFrames?: number;
  73637. /**
  73638. * number cell index of the base tile when the system compiles.
  73639. */
  73640. baseTile?: number;
  73641. /**
  73642. * boolean flip the sprite after its been repositioned by the framing data.
  73643. */
  73644. flipU?: boolean;
  73645. /**
  73646. * Vector3 scalar of the global RGB values of the SpriteMap.
  73647. */
  73648. colorMultiply?: Vector3;
  73649. }
  73650. /**
  73651. * Defines the IDisposable interface in order to be cleanable from resources.
  73652. */
  73653. export interface ISpriteMap extends IDisposable {
  73654. /**
  73655. * String name of the SpriteMap.
  73656. */
  73657. name: string;
  73658. /**
  73659. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73660. */
  73661. atlasJSON: ISpriteJSONAtlas;
  73662. /**
  73663. * Texture of the SpriteMap.
  73664. */
  73665. spriteSheet: Texture;
  73666. /**
  73667. * The parameters to initialize the SpriteMap with.
  73668. */
  73669. options: ISpriteMapOptions;
  73670. }
  73671. /**
  73672. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73673. */
  73674. export class SpriteMap implements ISpriteMap {
  73675. /** The Name of the spriteMap */
  73676. name: string;
  73677. /** The JSON file with the frame and meta data */
  73678. atlasJSON: ISpriteJSONAtlas;
  73679. /** The systems Sprite Sheet Texture */
  73680. spriteSheet: Texture;
  73681. /** Arguments passed with the Constructor */
  73682. options: ISpriteMapOptions;
  73683. /** Public Sprite Storage array, parsed from atlasJSON */
  73684. sprites: Array<ISpriteJSONSprite>;
  73685. /** Returns the Number of Sprites in the System */
  73686. get spriteCount(): number;
  73687. /** Returns the Position of Output Plane*/
  73688. get position(): Vector3;
  73689. /** Returns the Position of Output Plane*/
  73690. set position(v: Vector3);
  73691. /** Returns the Rotation of Output Plane*/
  73692. get rotation(): Vector3;
  73693. /** Returns the Rotation of Output Plane*/
  73694. set rotation(v: Vector3);
  73695. /** Sets the AnimationMap*/
  73696. get animationMap(): RawTexture;
  73697. /** Sets the AnimationMap*/
  73698. set animationMap(v: RawTexture);
  73699. /** Scene that the SpriteMap was created in */
  73700. private _scene;
  73701. /** Texture Buffer of Float32 that holds tile frame data*/
  73702. private _frameMap;
  73703. /** Texture Buffers of Float32 that holds tileMap data*/
  73704. private _tileMaps;
  73705. /** Texture Buffer of Float32 that holds Animation Data*/
  73706. private _animationMap;
  73707. /** Custom ShaderMaterial Central to the System*/
  73708. private _material;
  73709. /** Custom ShaderMaterial Central to the System*/
  73710. private _output;
  73711. /** Systems Time Ticker*/
  73712. private _time;
  73713. /**
  73714. * Creates a new SpriteMap
  73715. * @param name defines the SpriteMaps Name
  73716. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73717. * @param spriteSheet is the Texture that the Sprites are on.
  73718. * @param options a basic deployment configuration
  73719. * @param scene The Scene that the map is deployed on
  73720. */
  73721. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73722. /**
  73723. * Returns tileID location
  73724. * @returns Vector2 the cell position ID
  73725. */
  73726. getTileID(): Vector2;
  73727. /**
  73728. * Gets the UV location of the mouse over the SpriteMap.
  73729. * @returns Vector2 the UV position of the mouse interaction
  73730. */
  73731. getMousePosition(): Vector2;
  73732. /**
  73733. * Creates the "frame" texture Buffer
  73734. * -------------------------------------
  73735. * Structure of frames
  73736. * "filename": "Falling-Water-2.png",
  73737. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73738. * "rotated": true,
  73739. * "trimmed": true,
  73740. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73741. * "sourceSize": {"w":32,"h":32}
  73742. * @returns RawTexture of the frameMap
  73743. */
  73744. private _createFrameBuffer;
  73745. /**
  73746. * Creates the tileMap texture Buffer
  73747. * @param buffer normally and array of numbers, or a false to generate from scratch
  73748. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73749. * @returns RawTexture of the tileMap
  73750. */
  73751. private _createTileBuffer;
  73752. /**
  73753. * Modifies the data of the tileMaps
  73754. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73755. * @param pos is the iVector2 Coordinates of the Tile
  73756. * @param tile The SpriteIndex of the new Tile
  73757. */
  73758. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73759. /**
  73760. * Creates the animationMap texture Buffer
  73761. * @param buffer normally and array of numbers, or a false to generate from scratch
  73762. * @returns RawTexture of the animationMap
  73763. */
  73764. private _createTileAnimationBuffer;
  73765. /**
  73766. * Modifies the data of the animationMap
  73767. * @param cellID is the Index of the Sprite
  73768. * @param _frame is the target Animation frame
  73769. * @param toCell is the Target Index of the next frame of the animation
  73770. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73771. * @param speed is a global scalar of the time variable on the map.
  73772. */
  73773. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73774. /**
  73775. * Exports the .tilemaps file
  73776. */
  73777. saveTileMaps(): void;
  73778. /**
  73779. * Imports the .tilemaps file
  73780. * @param url of the .tilemaps file
  73781. */
  73782. loadTileMaps(url: string): void;
  73783. /**
  73784. * Release associated resources
  73785. */
  73786. dispose(): void;
  73787. }
  73788. }
  73789. declare module BABYLON {
  73790. /**
  73791. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73792. * @see https://doc.babylonjs.com/babylon101/sprites
  73793. */
  73794. export class SpritePackedManager extends SpriteManager {
  73795. /** defines the packed manager's name */
  73796. name: string;
  73797. /**
  73798. * Creates a new sprite manager from a packed sprite sheet
  73799. * @param name defines the manager's name
  73800. * @param imgUrl defines the sprite sheet url
  73801. * @param capacity defines the maximum allowed number of sprites
  73802. * @param scene defines the hosting scene
  73803. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73804. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73805. * @param samplingMode defines the smapling mode to use with spritesheet
  73806. * @param fromPacked set to true; do not alter
  73807. */
  73808. constructor(
  73809. /** defines the packed manager's name */
  73810. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Defines the list of states available for a task inside a AssetsManager
  73816. */
  73817. export enum AssetTaskState {
  73818. /**
  73819. * Initialization
  73820. */
  73821. INIT = 0,
  73822. /**
  73823. * Running
  73824. */
  73825. RUNNING = 1,
  73826. /**
  73827. * Done
  73828. */
  73829. DONE = 2,
  73830. /**
  73831. * Error
  73832. */
  73833. ERROR = 3
  73834. }
  73835. /**
  73836. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73837. */
  73838. export abstract class AbstractAssetTask {
  73839. /**
  73840. * Task name
  73841. */ name: string;
  73842. /**
  73843. * Callback called when the task is successful
  73844. */
  73845. onSuccess: (task: any) => void;
  73846. /**
  73847. * Callback called when the task is not successful
  73848. */
  73849. onError: (task: any, message?: string, exception?: any) => void;
  73850. /**
  73851. * Creates a new AssetsManager
  73852. * @param name defines the name of the task
  73853. */
  73854. constructor(
  73855. /**
  73856. * Task name
  73857. */ name: string);
  73858. private _isCompleted;
  73859. private _taskState;
  73860. private _errorObject;
  73861. /**
  73862. * Get if the task is completed
  73863. */
  73864. get isCompleted(): boolean;
  73865. /**
  73866. * Gets the current state of the task
  73867. */
  73868. get taskState(): AssetTaskState;
  73869. /**
  73870. * Gets the current error object (if task is in error)
  73871. */
  73872. get errorObject(): {
  73873. message?: string;
  73874. exception?: any;
  73875. };
  73876. /**
  73877. * Internal only
  73878. * @hidden
  73879. */
  73880. _setErrorObject(message?: string, exception?: any): void;
  73881. /**
  73882. * Execute the current task
  73883. * @param scene defines the scene where you want your assets to be loaded
  73884. * @param onSuccess is a callback called when the task is successfully executed
  73885. * @param onError is a callback called if an error occurs
  73886. */
  73887. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73888. /**
  73889. * Execute the current task
  73890. * @param scene defines the scene where you want your assets to be loaded
  73891. * @param onSuccess is a callback called when the task is successfully executed
  73892. * @param onError is a callback called if an error occurs
  73893. */
  73894. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73895. /**
  73896. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73897. * This can be used with failed tasks that have the reason for failure fixed.
  73898. */
  73899. reset(): void;
  73900. private onErrorCallback;
  73901. private onDoneCallback;
  73902. }
  73903. /**
  73904. * Define the interface used by progress events raised during assets loading
  73905. */
  73906. export interface IAssetsProgressEvent {
  73907. /**
  73908. * Defines the number of remaining tasks to process
  73909. */
  73910. remainingCount: number;
  73911. /**
  73912. * Defines the total number of tasks
  73913. */
  73914. totalCount: number;
  73915. /**
  73916. * Defines the task that was just processed
  73917. */
  73918. task: AbstractAssetTask;
  73919. }
  73920. /**
  73921. * Class used to share progress information about assets loading
  73922. */
  73923. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73924. /**
  73925. * Defines the number of remaining tasks to process
  73926. */
  73927. remainingCount: number;
  73928. /**
  73929. * Defines the total number of tasks
  73930. */
  73931. totalCount: number;
  73932. /**
  73933. * Defines the task that was just processed
  73934. */
  73935. task: AbstractAssetTask;
  73936. /**
  73937. * Creates a AssetsProgressEvent
  73938. * @param remainingCount defines the number of remaining tasks to process
  73939. * @param totalCount defines the total number of tasks
  73940. * @param task defines the task that was just processed
  73941. */
  73942. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73943. }
  73944. /**
  73945. * Define a task used by AssetsManager to load assets into a container
  73946. */
  73947. export class ContainerAssetTask extends AbstractAssetTask {
  73948. /**
  73949. * Defines the name of the task
  73950. */
  73951. name: string;
  73952. /**
  73953. * Defines the list of mesh's names you want to load
  73954. */
  73955. meshesNames: any;
  73956. /**
  73957. * Defines the root url to use as a base to load your meshes and associated resources
  73958. */
  73959. rootUrl: string;
  73960. /**
  73961. * Defines the filename or File of the scene to load from
  73962. */
  73963. sceneFilename: string | File;
  73964. /**
  73965. * Get the loaded asset container
  73966. */
  73967. loadedContainer: AssetContainer;
  73968. /**
  73969. * Gets the list of loaded meshes
  73970. */
  73971. loadedMeshes: Array<AbstractMesh>;
  73972. /**
  73973. * Gets the list of loaded particle systems
  73974. */
  73975. loadedParticleSystems: Array<IParticleSystem>;
  73976. /**
  73977. * Gets the list of loaded skeletons
  73978. */
  73979. loadedSkeletons: Array<Skeleton>;
  73980. /**
  73981. * Gets the list of loaded animation groups
  73982. */
  73983. loadedAnimationGroups: Array<AnimationGroup>;
  73984. /**
  73985. * Callback called when the task is successful
  73986. */
  73987. onSuccess: (task: ContainerAssetTask) => void;
  73988. /**
  73989. * Callback called when the task is successful
  73990. */
  73991. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73992. /**
  73993. * Creates a new ContainerAssetTask
  73994. * @param name defines the name of the task
  73995. * @param meshesNames defines the list of mesh's names you want to load
  73996. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73997. * @param sceneFilename defines the filename or File of the scene to load from
  73998. */
  73999. constructor(
  74000. /**
  74001. * Defines the name of the task
  74002. */
  74003. name: string,
  74004. /**
  74005. * Defines the list of mesh's names you want to load
  74006. */
  74007. meshesNames: any,
  74008. /**
  74009. * Defines the root url to use as a base to load your meshes and associated resources
  74010. */
  74011. rootUrl: string,
  74012. /**
  74013. * Defines the filename or File of the scene to load from
  74014. */
  74015. sceneFilename: string | File);
  74016. /**
  74017. * Execute the current task
  74018. * @param scene defines the scene where you want your assets to be loaded
  74019. * @param onSuccess is a callback called when the task is successfully executed
  74020. * @param onError is a callback called if an error occurs
  74021. */
  74022. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74023. }
  74024. /**
  74025. * Define a task used by AssetsManager to load meshes
  74026. */
  74027. export class MeshAssetTask extends AbstractAssetTask {
  74028. /**
  74029. * Defines the name of the task
  74030. */
  74031. name: string;
  74032. /**
  74033. * Defines the list of mesh's names you want to load
  74034. */
  74035. meshesNames: any;
  74036. /**
  74037. * Defines the root url to use as a base to load your meshes and associated resources
  74038. */
  74039. rootUrl: string;
  74040. /**
  74041. * Defines the filename or File of the scene to load from
  74042. */
  74043. sceneFilename: string | File;
  74044. /**
  74045. * Gets the list of loaded meshes
  74046. */
  74047. loadedMeshes: Array<AbstractMesh>;
  74048. /**
  74049. * Gets the list of loaded particle systems
  74050. */
  74051. loadedParticleSystems: Array<IParticleSystem>;
  74052. /**
  74053. * Gets the list of loaded skeletons
  74054. */
  74055. loadedSkeletons: Array<Skeleton>;
  74056. /**
  74057. * Gets the list of loaded animation groups
  74058. */
  74059. loadedAnimationGroups: Array<AnimationGroup>;
  74060. /**
  74061. * Callback called when the task is successful
  74062. */
  74063. onSuccess: (task: MeshAssetTask) => void;
  74064. /**
  74065. * Callback called when the task is successful
  74066. */
  74067. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74068. /**
  74069. * Creates a new MeshAssetTask
  74070. * @param name defines the name of the task
  74071. * @param meshesNames defines the list of mesh's names you want to load
  74072. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74073. * @param sceneFilename defines the filename or File of the scene to load from
  74074. */
  74075. constructor(
  74076. /**
  74077. * Defines the name of the task
  74078. */
  74079. name: string,
  74080. /**
  74081. * Defines the list of mesh's names you want to load
  74082. */
  74083. meshesNames: any,
  74084. /**
  74085. * Defines the root url to use as a base to load your meshes and associated resources
  74086. */
  74087. rootUrl: string,
  74088. /**
  74089. * Defines the filename or File of the scene to load from
  74090. */
  74091. sceneFilename: string | File);
  74092. /**
  74093. * Execute the current task
  74094. * @param scene defines the scene where you want your assets to be loaded
  74095. * @param onSuccess is a callback called when the task is successfully executed
  74096. * @param onError is a callback called if an error occurs
  74097. */
  74098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74099. }
  74100. /**
  74101. * Define a task used by AssetsManager to load text content
  74102. */
  74103. export class TextFileAssetTask extends AbstractAssetTask {
  74104. /**
  74105. * Defines the name of the task
  74106. */
  74107. name: string;
  74108. /**
  74109. * Defines the location of the file to load
  74110. */
  74111. url: string;
  74112. /**
  74113. * Gets the loaded text string
  74114. */
  74115. text: string;
  74116. /**
  74117. * Callback called when the task is successful
  74118. */
  74119. onSuccess: (task: TextFileAssetTask) => void;
  74120. /**
  74121. * Callback called when the task is successful
  74122. */
  74123. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74124. /**
  74125. * Creates a new TextFileAssetTask object
  74126. * @param name defines the name of the task
  74127. * @param url defines the location of the file to load
  74128. */
  74129. constructor(
  74130. /**
  74131. * Defines the name of the task
  74132. */
  74133. name: string,
  74134. /**
  74135. * Defines the location of the file to load
  74136. */
  74137. url: string);
  74138. /**
  74139. * Execute the current task
  74140. * @param scene defines the scene where you want your assets to be loaded
  74141. * @param onSuccess is a callback called when the task is successfully executed
  74142. * @param onError is a callback called if an error occurs
  74143. */
  74144. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74145. }
  74146. /**
  74147. * Define a task used by AssetsManager to load binary data
  74148. */
  74149. export class BinaryFileAssetTask extends AbstractAssetTask {
  74150. /**
  74151. * Defines the name of the task
  74152. */
  74153. name: string;
  74154. /**
  74155. * Defines the location of the file to load
  74156. */
  74157. url: string;
  74158. /**
  74159. * Gets the lodaded data (as an array buffer)
  74160. */
  74161. data: ArrayBuffer;
  74162. /**
  74163. * Callback called when the task is successful
  74164. */
  74165. onSuccess: (task: BinaryFileAssetTask) => void;
  74166. /**
  74167. * Callback called when the task is successful
  74168. */
  74169. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74170. /**
  74171. * Creates a new BinaryFileAssetTask object
  74172. * @param name defines the name of the new task
  74173. * @param url defines the location of the file to load
  74174. */
  74175. constructor(
  74176. /**
  74177. * Defines the name of the task
  74178. */
  74179. name: string,
  74180. /**
  74181. * Defines the location of the file to load
  74182. */
  74183. url: string);
  74184. /**
  74185. * Execute the current task
  74186. * @param scene defines the scene where you want your assets to be loaded
  74187. * @param onSuccess is a callback called when the task is successfully executed
  74188. * @param onError is a callback called if an error occurs
  74189. */
  74190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74191. }
  74192. /**
  74193. * Define a task used by AssetsManager to load images
  74194. */
  74195. export class ImageAssetTask extends AbstractAssetTask {
  74196. /**
  74197. * Defines the name of the task
  74198. */
  74199. name: string;
  74200. /**
  74201. * Defines the location of the image to load
  74202. */
  74203. url: string;
  74204. /**
  74205. * Gets the loaded images
  74206. */
  74207. image: HTMLImageElement;
  74208. /**
  74209. * Callback called when the task is successful
  74210. */
  74211. onSuccess: (task: ImageAssetTask) => void;
  74212. /**
  74213. * Callback called when the task is successful
  74214. */
  74215. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74216. /**
  74217. * Creates a new ImageAssetTask
  74218. * @param name defines the name of the task
  74219. * @param url defines the location of the image to load
  74220. */
  74221. constructor(
  74222. /**
  74223. * Defines the name of the task
  74224. */
  74225. name: string,
  74226. /**
  74227. * Defines the location of the image to load
  74228. */
  74229. url: string);
  74230. /**
  74231. * Execute the current task
  74232. * @param scene defines the scene where you want your assets to be loaded
  74233. * @param onSuccess is a callback called when the task is successfully executed
  74234. * @param onError is a callback called if an error occurs
  74235. */
  74236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74237. }
  74238. /**
  74239. * Defines the interface used by texture loading tasks
  74240. */
  74241. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74242. /**
  74243. * Gets the loaded texture
  74244. */
  74245. texture: TEX;
  74246. }
  74247. /**
  74248. * Define a task used by AssetsManager to load 2D textures
  74249. */
  74250. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74251. /**
  74252. * Defines the name of the task
  74253. */
  74254. name: string;
  74255. /**
  74256. * Defines the location of the file to load
  74257. */
  74258. url: string;
  74259. /**
  74260. * Defines if mipmap should not be generated (default is false)
  74261. */
  74262. noMipmap?: boolean | undefined;
  74263. /**
  74264. * Defines if texture must be inverted on Y axis (default is true)
  74265. */
  74266. invertY: boolean;
  74267. /**
  74268. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74269. */
  74270. samplingMode: number;
  74271. /**
  74272. * Gets the loaded texture
  74273. */
  74274. texture: Texture;
  74275. /**
  74276. * Callback called when the task is successful
  74277. */
  74278. onSuccess: (task: TextureAssetTask) => void;
  74279. /**
  74280. * Callback called when the task is successful
  74281. */
  74282. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74283. /**
  74284. * Creates a new TextureAssetTask object
  74285. * @param name defines the name of the task
  74286. * @param url defines the location of the file to load
  74287. * @param noMipmap defines if mipmap should not be generated (default is false)
  74288. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74289. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74290. */
  74291. constructor(
  74292. /**
  74293. * Defines the name of the task
  74294. */
  74295. name: string,
  74296. /**
  74297. * Defines the location of the file to load
  74298. */
  74299. url: string,
  74300. /**
  74301. * Defines if mipmap should not be generated (default is false)
  74302. */
  74303. noMipmap?: boolean | undefined,
  74304. /**
  74305. * Defines if texture must be inverted on Y axis (default is true)
  74306. */
  74307. invertY?: boolean,
  74308. /**
  74309. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74310. */
  74311. samplingMode?: number);
  74312. /**
  74313. * Execute the current task
  74314. * @param scene defines the scene where you want your assets to be loaded
  74315. * @param onSuccess is a callback called when the task is successfully executed
  74316. * @param onError is a callback called if an error occurs
  74317. */
  74318. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74319. }
  74320. /**
  74321. * Define a task used by AssetsManager to load cube textures
  74322. */
  74323. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74324. /**
  74325. * Defines the name of the task
  74326. */
  74327. name: string;
  74328. /**
  74329. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74330. */
  74331. url: string;
  74332. /**
  74333. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74334. */
  74335. extensions?: string[] | undefined;
  74336. /**
  74337. * Defines if mipmaps should not be generated (default is false)
  74338. */
  74339. noMipmap?: boolean | undefined;
  74340. /**
  74341. * Defines the explicit list of files (undefined by default)
  74342. */
  74343. files?: string[] | undefined;
  74344. /**
  74345. * Gets the loaded texture
  74346. */
  74347. texture: CubeTexture;
  74348. /**
  74349. * Callback called when the task is successful
  74350. */
  74351. onSuccess: (task: CubeTextureAssetTask) => void;
  74352. /**
  74353. * Callback called when the task is successful
  74354. */
  74355. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74356. /**
  74357. * Creates a new CubeTextureAssetTask
  74358. * @param name defines the name of the task
  74359. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74360. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74361. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74362. * @param files defines the explicit list of files (undefined by default)
  74363. */
  74364. constructor(
  74365. /**
  74366. * Defines the name of the task
  74367. */
  74368. name: string,
  74369. /**
  74370. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74371. */
  74372. url: string,
  74373. /**
  74374. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74375. */
  74376. extensions?: string[] | undefined,
  74377. /**
  74378. * Defines if mipmaps should not be generated (default is false)
  74379. */
  74380. noMipmap?: boolean | undefined,
  74381. /**
  74382. * Defines the explicit list of files (undefined by default)
  74383. */
  74384. files?: string[] | undefined);
  74385. /**
  74386. * Execute the current task
  74387. * @param scene defines the scene where you want your assets to be loaded
  74388. * @param onSuccess is a callback called when the task is successfully executed
  74389. * @param onError is a callback called if an error occurs
  74390. */
  74391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74392. }
  74393. /**
  74394. * Define a task used by AssetsManager to load HDR cube textures
  74395. */
  74396. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74397. /**
  74398. * Defines the name of the task
  74399. */
  74400. name: string;
  74401. /**
  74402. * Defines the location of the file to load
  74403. */
  74404. url: string;
  74405. /**
  74406. * Defines the desired size (the more it increases the longer the generation will be)
  74407. */
  74408. size: number;
  74409. /**
  74410. * Defines if mipmaps should not be generated (default is false)
  74411. */
  74412. noMipmap: boolean;
  74413. /**
  74414. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74415. */
  74416. generateHarmonics: boolean;
  74417. /**
  74418. * 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)
  74419. */
  74420. gammaSpace: boolean;
  74421. /**
  74422. * Internal Use Only
  74423. */
  74424. reserved: boolean;
  74425. /**
  74426. * Gets the loaded texture
  74427. */
  74428. texture: HDRCubeTexture;
  74429. /**
  74430. * Callback called when the task is successful
  74431. */
  74432. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74433. /**
  74434. * Callback called when the task is successful
  74435. */
  74436. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74437. /**
  74438. * Creates a new HDRCubeTextureAssetTask object
  74439. * @param name defines the name of the task
  74440. * @param url defines the location of the file to load
  74441. * @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.
  74442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74443. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74444. * @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)
  74445. * @param reserved Internal use only
  74446. */
  74447. constructor(
  74448. /**
  74449. * Defines the name of the task
  74450. */
  74451. name: string,
  74452. /**
  74453. * Defines the location of the file to load
  74454. */
  74455. url: string,
  74456. /**
  74457. * Defines the desired size (the more it increases the longer the generation will be)
  74458. */
  74459. size: number,
  74460. /**
  74461. * Defines if mipmaps should not be generated (default is false)
  74462. */
  74463. noMipmap?: boolean,
  74464. /**
  74465. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74466. */
  74467. generateHarmonics?: boolean,
  74468. /**
  74469. * 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)
  74470. */
  74471. gammaSpace?: boolean,
  74472. /**
  74473. * Internal Use Only
  74474. */
  74475. reserved?: boolean);
  74476. /**
  74477. * Execute the current task
  74478. * @param scene defines the scene where you want your assets to be loaded
  74479. * @param onSuccess is a callback called when the task is successfully executed
  74480. * @param onError is a callback called if an error occurs
  74481. */
  74482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74483. }
  74484. /**
  74485. * Define a task used by AssetsManager to load Equirectangular cube textures
  74486. */
  74487. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74488. /**
  74489. * Defines the name of the task
  74490. */
  74491. name: string;
  74492. /**
  74493. * Defines the location of the file to load
  74494. */
  74495. url: string;
  74496. /**
  74497. * Defines the desired size (the more it increases the longer the generation will be)
  74498. */
  74499. size: number;
  74500. /**
  74501. * Defines if mipmaps should not be generated (default is false)
  74502. */
  74503. noMipmap: boolean;
  74504. /**
  74505. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74506. * but the standard material would require them in Gamma space) (default is true)
  74507. */
  74508. gammaSpace: boolean;
  74509. /**
  74510. * Gets the loaded texture
  74511. */
  74512. texture: EquiRectangularCubeTexture;
  74513. /**
  74514. * Callback called when the task is successful
  74515. */
  74516. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74517. /**
  74518. * Callback called when the task is successful
  74519. */
  74520. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74521. /**
  74522. * Creates a new EquiRectangularCubeTextureAssetTask object
  74523. * @param name defines the name of the task
  74524. * @param url defines the location of the file to load
  74525. * @param size defines the desired size (the more it increases the longer the generation will be)
  74526. * If the size is omitted this implies you are using a preprocessed cubemap.
  74527. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74528. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74529. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74530. * (default is true)
  74531. */
  74532. constructor(
  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. * Execute the current task
  74556. * @param scene defines the scene where you want your assets to be loaded
  74557. * @param onSuccess is a callback called when the task is successfully executed
  74558. * @param onError is a callback called if an error occurs
  74559. */
  74560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74561. }
  74562. /**
  74563. * This class can be used to easily import assets into a scene
  74564. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74565. */
  74566. export class AssetsManager {
  74567. private _scene;
  74568. private _isLoading;
  74569. protected _tasks: AbstractAssetTask[];
  74570. protected _waitingTasksCount: number;
  74571. protected _totalTasksCount: number;
  74572. /**
  74573. * Callback called when all tasks are processed
  74574. */
  74575. onFinish: (tasks: AbstractAssetTask[]) => void;
  74576. /**
  74577. * Callback called when a task is successful
  74578. */
  74579. onTaskSuccess: (task: AbstractAssetTask) => void;
  74580. /**
  74581. * Callback called when a task had an error
  74582. */
  74583. onTaskError: (task: AbstractAssetTask) => void;
  74584. /**
  74585. * Callback called when a task is done (whatever the result is)
  74586. */
  74587. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74588. /**
  74589. * Observable called when all tasks are processed
  74590. */
  74591. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74592. /**
  74593. * Observable called when a task had an error
  74594. */
  74595. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74596. /**
  74597. * Observable called when all tasks were executed
  74598. */
  74599. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74600. /**
  74601. * Observable called when a task is done (whatever the result is)
  74602. */
  74603. onProgressObservable: Observable<IAssetsProgressEvent>;
  74604. /**
  74605. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74606. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74607. */
  74608. useDefaultLoadingScreen: boolean;
  74609. /**
  74610. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74611. * when all assets have been downloaded.
  74612. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74613. */
  74614. autoHideLoadingUI: boolean;
  74615. /**
  74616. * Creates a new AssetsManager
  74617. * @param scene defines the scene to work on
  74618. */
  74619. constructor(scene: Scene);
  74620. /**
  74621. * Add a ContainerAssetTask to the list of active tasks
  74622. * @param taskName defines the name of the new task
  74623. * @param meshesNames defines the name of meshes to load
  74624. * @param rootUrl defines the root url to use to locate files
  74625. * @param sceneFilename defines the filename of the scene file
  74626. * @returns a new ContainerAssetTask object
  74627. */
  74628. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74629. /**
  74630. * Add a MeshAssetTask to the list of active tasks
  74631. * @param taskName defines the name of the new task
  74632. * @param meshesNames defines the name of meshes to load
  74633. * @param rootUrl defines the root url to use to locate files
  74634. * @param sceneFilename defines the filename of the scene file
  74635. * @returns a new MeshAssetTask object
  74636. */
  74637. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74638. /**
  74639. * Add a TextFileAssetTask to the list of active tasks
  74640. * @param taskName defines the name of the new task
  74641. * @param url defines the url of the file to load
  74642. * @returns a new TextFileAssetTask object
  74643. */
  74644. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74645. /**
  74646. * Add a BinaryFileAssetTask to the list of active tasks
  74647. * @param taskName defines the name of the new task
  74648. * @param url defines the url of the file to load
  74649. * @returns a new BinaryFileAssetTask object
  74650. */
  74651. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74652. /**
  74653. * Add a ImageAssetTask to the list of active tasks
  74654. * @param taskName defines the name of the new task
  74655. * @param url defines the url of the file to load
  74656. * @returns a new ImageAssetTask object
  74657. */
  74658. addImageTask(taskName: string, url: string): ImageAssetTask;
  74659. /**
  74660. * Add a TextureAssetTask to the list of active tasks
  74661. * @param taskName defines the name of the new task
  74662. * @param url defines the url of the file to load
  74663. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74664. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74665. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74666. * @returns a new TextureAssetTask object
  74667. */
  74668. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74669. /**
  74670. * Add a CubeTextureAssetTask to the list of active tasks
  74671. * @param taskName defines the name of the new task
  74672. * @param url defines the url of the file to load
  74673. * @param extensions defines the extension to use to load the cube map (can be null)
  74674. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74675. * @param files defines the list of files to load (can be null)
  74676. * @returns a new CubeTextureAssetTask object
  74677. */
  74678. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74679. /**
  74680. *
  74681. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74682. * @param taskName defines the name of the new task
  74683. * @param url defines the url of the file to load
  74684. * @param size defines the size you want for the cubemap (can be null)
  74685. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74686. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74687. * @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)
  74688. * @param reserved Internal use only
  74689. * @returns a new HDRCubeTextureAssetTask object
  74690. */
  74691. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74692. /**
  74693. *
  74694. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74695. * @param taskName defines the name of the new task
  74696. * @param url defines the url of the file to load
  74697. * @param size defines the size you want for the cubemap (can be null)
  74698. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74699. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74700. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74701. * @returns a new EquiRectangularCubeTextureAssetTask object
  74702. */
  74703. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74704. /**
  74705. * Remove a task from the assets manager.
  74706. * @param task the task to remove
  74707. */
  74708. removeTask(task: AbstractAssetTask): void;
  74709. private _decreaseWaitingTasksCount;
  74710. private _runTask;
  74711. /**
  74712. * Reset the AssetsManager and remove all tasks
  74713. * @return the current instance of the AssetsManager
  74714. */
  74715. reset(): AssetsManager;
  74716. /**
  74717. * Start the loading process
  74718. * @return the current instance of the AssetsManager
  74719. */
  74720. load(): AssetsManager;
  74721. /**
  74722. * Start the loading process as an async operation
  74723. * @return a promise returning the list of failed tasks
  74724. */
  74725. loadAsync(): Promise<void>;
  74726. }
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * Wrapper class for promise with external resolve and reject.
  74731. */
  74732. export class Deferred<T> {
  74733. /**
  74734. * The promise associated with this deferred object.
  74735. */
  74736. readonly promise: Promise<T>;
  74737. private _resolve;
  74738. private _reject;
  74739. /**
  74740. * The resolve method of the promise associated with this deferred object.
  74741. */
  74742. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74743. /**
  74744. * The reject method of the promise associated with this deferred object.
  74745. */
  74746. get reject(): (reason?: any) => void;
  74747. /**
  74748. * Constructor for this deferred object.
  74749. */
  74750. constructor();
  74751. }
  74752. }
  74753. declare module BABYLON {
  74754. /**
  74755. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74756. */
  74757. export class MeshExploder {
  74758. private _centerMesh;
  74759. private _meshes;
  74760. private _meshesOrigins;
  74761. private _toCenterVectors;
  74762. private _scaledDirection;
  74763. private _newPosition;
  74764. private _centerPosition;
  74765. /**
  74766. * Explodes meshes from a center mesh.
  74767. * @param meshes The meshes to explode.
  74768. * @param centerMesh The mesh to be center of explosion.
  74769. */
  74770. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74771. private _setCenterMesh;
  74772. /**
  74773. * Get class name
  74774. * @returns "MeshExploder"
  74775. */
  74776. getClassName(): string;
  74777. /**
  74778. * "Exploded meshes"
  74779. * @returns Array of meshes with the centerMesh at index 0.
  74780. */
  74781. getMeshes(): Array<Mesh>;
  74782. /**
  74783. * Explodes meshes giving a specific direction
  74784. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74785. */
  74786. explode(direction?: number): void;
  74787. }
  74788. }
  74789. declare module BABYLON {
  74790. /**
  74791. * Class used to help managing file picking and drag'n'drop
  74792. */
  74793. export class FilesInput {
  74794. /**
  74795. * List of files ready to be loaded
  74796. */
  74797. static get FilesToLoad(): {
  74798. [key: string]: File;
  74799. };
  74800. /**
  74801. * Callback called when a file is processed
  74802. */
  74803. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74804. private _engine;
  74805. private _currentScene;
  74806. private _sceneLoadedCallback;
  74807. private _progressCallback;
  74808. private _additionalRenderLoopLogicCallback;
  74809. private _textureLoadingCallback;
  74810. private _startingProcessingFilesCallback;
  74811. private _onReloadCallback;
  74812. private _errorCallback;
  74813. private _elementToMonitor;
  74814. private _sceneFileToLoad;
  74815. private _filesToLoad;
  74816. /**
  74817. * Creates a new FilesInput
  74818. * @param engine defines the rendering engine
  74819. * @param scene defines the hosting scene
  74820. * @param sceneLoadedCallback callback called when scene is loaded
  74821. * @param progressCallback callback called to track progress
  74822. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74823. * @param textureLoadingCallback callback called when a texture is loading
  74824. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74825. * @param onReloadCallback callback called when a reload is requested
  74826. * @param errorCallback callback call if an error occurs
  74827. */
  74828. 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>);
  74829. private _dragEnterHandler;
  74830. private _dragOverHandler;
  74831. private _dropHandler;
  74832. /**
  74833. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74834. * @param elementToMonitor defines the DOM element to track
  74835. */
  74836. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74837. /** Gets the current list of files to load */
  74838. get filesToLoad(): File[];
  74839. /**
  74840. * Release all associated resources
  74841. */
  74842. dispose(): void;
  74843. private renderFunction;
  74844. private drag;
  74845. private drop;
  74846. private _traverseFolder;
  74847. private _processFiles;
  74848. /**
  74849. * Load files from a drop event
  74850. * @param event defines the drop event to use as source
  74851. */
  74852. loadFiles(event: any): void;
  74853. private _processReload;
  74854. /**
  74855. * Reload the current scene from the loaded files
  74856. */
  74857. reload(): void;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74863. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74864. */
  74865. export class SceneOptimization {
  74866. /**
  74867. * Defines the priority of this optimization (0 by default which means first in the list)
  74868. */
  74869. priority: number;
  74870. /**
  74871. * Gets a string describing the action executed by the current optimization
  74872. * @returns description string
  74873. */
  74874. getDescription(): string;
  74875. /**
  74876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74877. * @param scene defines the current scene where to apply this optimization
  74878. * @param optimizer defines the current optimizer
  74879. * @returns true if everything that can be done was applied
  74880. */
  74881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74882. /**
  74883. * Creates the SceneOptimization object
  74884. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74885. * @param desc defines the description associated with the optimization
  74886. */
  74887. constructor(
  74888. /**
  74889. * Defines the priority of this optimization (0 by default which means first in the list)
  74890. */
  74891. priority?: number);
  74892. }
  74893. /**
  74894. * Defines an optimization used to reduce the size of render target textures
  74895. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74896. */
  74897. export class TextureOptimization extends SceneOptimization {
  74898. /**
  74899. * Defines the priority of this optimization (0 by default which means first in the list)
  74900. */
  74901. priority: number;
  74902. /**
  74903. * 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
  74904. */
  74905. maximumSize: number;
  74906. /**
  74907. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74908. */
  74909. step: number;
  74910. /**
  74911. * Gets a string describing the action executed by the current optimization
  74912. * @returns description string
  74913. */
  74914. getDescription(): string;
  74915. /**
  74916. * Creates the TextureOptimization object
  74917. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74918. * @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
  74919. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74920. */
  74921. constructor(
  74922. /**
  74923. * Defines the priority of this optimization (0 by default which means first in the list)
  74924. */
  74925. priority?: number,
  74926. /**
  74927. * 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
  74928. */
  74929. maximumSize?: number,
  74930. /**
  74931. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74932. */
  74933. step?: number);
  74934. /**
  74935. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74936. * @param scene defines the current scene where to apply this optimization
  74937. * @param optimizer defines the current optimizer
  74938. * @returns true if everything that can be done was applied
  74939. */
  74940. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74941. }
  74942. /**
  74943. * Defines an optimization used to increase or decrease the rendering resolution
  74944. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74945. */
  74946. export class HardwareScalingOptimization extends SceneOptimization {
  74947. /**
  74948. * Defines the priority of this optimization (0 by default which means first in the list)
  74949. */
  74950. priority: number;
  74951. /**
  74952. * Defines the maximum scale to use (2 by default)
  74953. */
  74954. maximumScale: number;
  74955. /**
  74956. * Defines the step to use between two passes (0.5 by default)
  74957. */
  74958. step: number;
  74959. private _currentScale;
  74960. private _directionOffset;
  74961. /**
  74962. * Gets a string describing the action executed by the current optimization
  74963. * @return description string
  74964. */
  74965. getDescription(): string;
  74966. /**
  74967. * Creates the HardwareScalingOptimization object
  74968. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74969. * @param maximumScale defines the maximum scale to use (2 by default)
  74970. * @param step defines the step to use between two passes (0.5 by default)
  74971. */
  74972. constructor(
  74973. /**
  74974. * Defines the priority of this optimization (0 by default which means first in the list)
  74975. */
  74976. priority?: number,
  74977. /**
  74978. * Defines the maximum scale to use (2 by default)
  74979. */
  74980. maximumScale?: number,
  74981. /**
  74982. * Defines the step to use between two passes (0.5 by default)
  74983. */
  74984. step?: number);
  74985. /**
  74986. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74987. * @param scene defines the current scene where to apply this optimization
  74988. * @param optimizer defines the current optimizer
  74989. * @returns true if everything that can be done was applied
  74990. */
  74991. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74992. }
  74993. /**
  74994. * Defines an optimization used to remove shadows
  74995. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74996. */
  74997. export class ShadowsOptimization extends SceneOptimization {
  74998. /**
  74999. * Gets a string describing the action executed by the current optimization
  75000. * @return description string
  75001. */
  75002. getDescription(): string;
  75003. /**
  75004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75005. * @param scene defines the current scene where to apply this optimization
  75006. * @param optimizer defines the current optimizer
  75007. * @returns true if everything that can be done was applied
  75008. */
  75009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75010. }
  75011. /**
  75012. * Defines an optimization used to turn post-processes off
  75013. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75014. */
  75015. export class PostProcessesOptimization extends SceneOptimization {
  75016. /**
  75017. * Gets a string describing the action executed by the current optimization
  75018. * @return description string
  75019. */
  75020. getDescription(): string;
  75021. /**
  75022. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75023. * @param scene defines the current scene where to apply this optimization
  75024. * @param optimizer defines the current optimizer
  75025. * @returns true if everything that can be done was applied
  75026. */
  75027. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75028. }
  75029. /**
  75030. * Defines an optimization used to turn lens flares off
  75031. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75032. */
  75033. export class LensFlaresOptimization extends SceneOptimization {
  75034. /**
  75035. * Gets a string describing the action executed by the current optimization
  75036. * @return description string
  75037. */
  75038. getDescription(): string;
  75039. /**
  75040. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75041. * @param scene defines the current scene where to apply this optimization
  75042. * @param optimizer defines the current optimizer
  75043. * @returns true if everything that can be done was applied
  75044. */
  75045. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75046. }
  75047. /**
  75048. * Defines an optimization based on user defined callback.
  75049. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75050. */
  75051. export class CustomOptimization extends SceneOptimization {
  75052. /**
  75053. * Callback called to apply the custom optimization.
  75054. */
  75055. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75056. /**
  75057. * Callback called to get custom description
  75058. */
  75059. onGetDescription: () => string;
  75060. /**
  75061. * Gets a string describing the action executed by the current optimization
  75062. * @returns description string
  75063. */
  75064. getDescription(): string;
  75065. /**
  75066. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75067. * @param scene defines the current scene where to apply this optimization
  75068. * @param optimizer defines the current optimizer
  75069. * @returns true if everything that can be done was applied
  75070. */
  75071. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75072. }
  75073. /**
  75074. * Defines an optimization used to turn particles off
  75075. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75076. */
  75077. export class ParticlesOptimization extends SceneOptimization {
  75078. /**
  75079. * Gets a string describing the action executed by the current optimization
  75080. * @return description string
  75081. */
  75082. getDescription(): string;
  75083. /**
  75084. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75085. * @param scene defines the current scene where to apply this optimization
  75086. * @param optimizer defines the current optimizer
  75087. * @returns true if everything that can be done was applied
  75088. */
  75089. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75090. }
  75091. /**
  75092. * Defines an optimization used to turn render targets off
  75093. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75094. */
  75095. export class RenderTargetsOptimization extends SceneOptimization {
  75096. /**
  75097. * Gets a string describing the action executed by the current optimization
  75098. * @return description string
  75099. */
  75100. getDescription(): string;
  75101. /**
  75102. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75103. * @param scene defines the current scene where to apply this optimization
  75104. * @param optimizer defines the current optimizer
  75105. * @returns true if everything that can be done was applied
  75106. */
  75107. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75108. }
  75109. /**
  75110. * Defines an optimization used to merge meshes with compatible materials
  75111. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75112. */
  75113. export class MergeMeshesOptimization extends SceneOptimization {
  75114. private static _UpdateSelectionTree;
  75115. /**
  75116. * Gets or sets a boolean which defines if optimization octree has to be updated
  75117. */
  75118. static get UpdateSelectionTree(): boolean;
  75119. /**
  75120. * Gets or sets a boolean which defines if optimization octree has to be updated
  75121. */
  75122. static set UpdateSelectionTree(value: boolean);
  75123. /**
  75124. * Gets a string describing the action executed by the current optimization
  75125. * @return description string
  75126. */
  75127. getDescription(): string;
  75128. private _canBeMerged;
  75129. /**
  75130. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75131. * @param scene defines the current scene where to apply this optimization
  75132. * @param optimizer defines the current optimizer
  75133. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75134. * @returns true if everything that can be done was applied
  75135. */
  75136. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75137. }
  75138. /**
  75139. * Defines a list of options used by SceneOptimizer
  75140. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75141. */
  75142. export class SceneOptimizerOptions {
  75143. /**
  75144. * Defines the target frame rate to reach (60 by default)
  75145. */
  75146. targetFrameRate: number;
  75147. /**
  75148. * Defines the interval between two checkes (2000ms by default)
  75149. */
  75150. trackerDuration: number;
  75151. /**
  75152. * Gets the list of optimizations to apply
  75153. */
  75154. optimizations: SceneOptimization[];
  75155. /**
  75156. * Creates a new list of options used by SceneOptimizer
  75157. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75158. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75159. */
  75160. constructor(
  75161. /**
  75162. * Defines the target frame rate to reach (60 by default)
  75163. */
  75164. targetFrameRate?: number,
  75165. /**
  75166. * Defines the interval between two checkes (2000ms by default)
  75167. */
  75168. trackerDuration?: number);
  75169. /**
  75170. * Add a new optimization
  75171. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75172. * @returns the current SceneOptimizerOptions
  75173. */
  75174. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75175. /**
  75176. * Add a new custom optimization
  75177. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75178. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75179. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75180. * @returns the current SceneOptimizerOptions
  75181. */
  75182. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75183. /**
  75184. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75185. * @param targetFrameRate defines the target frame rate (60 by default)
  75186. * @returns a SceneOptimizerOptions object
  75187. */
  75188. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75189. /**
  75190. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75191. * @param targetFrameRate defines the target frame rate (60 by default)
  75192. * @returns a SceneOptimizerOptions object
  75193. */
  75194. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75195. /**
  75196. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75197. * @param targetFrameRate defines the target frame rate (60 by default)
  75198. * @returns a SceneOptimizerOptions object
  75199. */
  75200. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75201. }
  75202. /**
  75203. * Class used to run optimizations in order to reach a target frame rate
  75204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75205. */
  75206. export class SceneOptimizer implements IDisposable {
  75207. private _isRunning;
  75208. private _options;
  75209. private _scene;
  75210. private _currentPriorityLevel;
  75211. private _targetFrameRate;
  75212. private _trackerDuration;
  75213. private _currentFrameRate;
  75214. private _sceneDisposeObserver;
  75215. private _improvementMode;
  75216. /**
  75217. * Defines an observable called when the optimizer reaches the target frame rate
  75218. */
  75219. onSuccessObservable: Observable<SceneOptimizer>;
  75220. /**
  75221. * Defines an observable called when the optimizer enables an optimization
  75222. */
  75223. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75224. /**
  75225. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75226. */
  75227. onFailureObservable: Observable<SceneOptimizer>;
  75228. /**
  75229. * Gets a boolean indicating if the optimizer is in improvement mode
  75230. */
  75231. get isInImprovementMode(): boolean;
  75232. /**
  75233. * Gets the current priority level (0 at start)
  75234. */
  75235. get currentPriorityLevel(): number;
  75236. /**
  75237. * Gets the current frame rate checked by the SceneOptimizer
  75238. */
  75239. get currentFrameRate(): number;
  75240. /**
  75241. * Gets or sets the current target frame rate (60 by default)
  75242. */
  75243. get targetFrameRate(): number;
  75244. /**
  75245. * Gets or sets the current target frame rate (60 by default)
  75246. */
  75247. set targetFrameRate(value: number);
  75248. /**
  75249. * Gets or sets the current interval between two checks (every 2000ms by default)
  75250. */
  75251. get trackerDuration(): number;
  75252. /**
  75253. * Gets or sets the current interval between two checks (every 2000ms by default)
  75254. */
  75255. set trackerDuration(value: number);
  75256. /**
  75257. * Gets the list of active optimizations
  75258. */
  75259. get optimizations(): SceneOptimization[];
  75260. /**
  75261. * Creates a new SceneOptimizer
  75262. * @param scene defines the scene to work on
  75263. * @param options defines the options to use with the SceneOptimizer
  75264. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75265. * @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)
  75266. */
  75267. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75268. /**
  75269. * Stops the current optimizer
  75270. */
  75271. stop(): void;
  75272. /**
  75273. * Reset the optimizer to initial step (current priority level = 0)
  75274. */
  75275. reset(): void;
  75276. /**
  75277. * Start the optimizer. By default it will try to reach a specific framerate
  75278. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75279. */
  75280. start(): void;
  75281. private _checkCurrentState;
  75282. /**
  75283. * Release all resources
  75284. */
  75285. dispose(): void;
  75286. /**
  75287. * Helper function to create a SceneOptimizer with one single line of code
  75288. * @param scene defines the scene to work on
  75289. * @param options defines the options to use with the SceneOptimizer
  75290. * @param onSuccess defines a callback to call on success
  75291. * @param onFailure defines a callback to call on failure
  75292. * @returns the new SceneOptimizer object
  75293. */
  75294. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75295. }
  75296. }
  75297. declare module BABYLON {
  75298. /**
  75299. * Class used to serialize a scene into a string
  75300. */
  75301. export class SceneSerializer {
  75302. /**
  75303. * Clear cache used by a previous serialization
  75304. */
  75305. static ClearCache(): void;
  75306. /**
  75307. * Serialize a scene into a JSON compatible object
  75308. * @param scene defines the scene to serialize
  75309. * @returns a JSON compatible object
  75310. */
  75311. static Serialize(scene: Scene): any;
  75312. /**
  75313. * Serialize a mesh into a JSON compatible object
  75314. * @param toSerialize defines the mesh to serialize
  75315. * @param withParents defines if parents must be serialized as well
  75316. * @param withChildren defines if children must be serialized as well
  75317. * @returns a JSON compatible object
  75318. */
  75319. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75320. }
  75321. }
  75322. declare module BABYLON {
  75323. /**
  75324. * Class used to host texture specific utilities
  75325. */
  75326. export class TextureTools {
  75327. /**
  75328. * Uses the GPU to create a copy texture rescaled at a given size
  75329. * @param texture Texture to copy from
  75330. * @param width defines the desired width
  75331. * @param height defines the desired height
  75332. * @param useBilinearMode defines if bilinear mode has to be used
  75333. * @return the generated texture
  75334. */
  75335. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75336. }
  75337. }
  75338. declare module BABYLON {
  75339. /**
  75340. * This represents the different options available for the video capture.
  75341. */
  75342. export interface VideoRecorderOptions {
  75343. /** Defines the mime type of the video. */
  75344. mimeType: string;
  75345. /** Defines the FPS the video should be recorded at. */
  75346. fps: number;
  75347. /** Defines the chunk size for the recording data. */
  75348. recordChunckSize: number;
  75349. /** The audio tracks to attach to the recording. */
  75350. audioTracks?: MediaStreamTrack[];
  75351. }
  75352. /**
  75353. * This can help with recording videos from BabylonJS.
  75354. * This is based on the available WebRTC functionalities of the browser.
  75355. *
  75356. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75357. */
  75358. export class VideoRecorder {
  75359. private static readonly _defaultOptions;
  75360. /**
  75361. * Returns whether or not the VideoRecorder is available in your browser.
  75362. * @param engine Defines the Babylon Engine.
  75363. * @returns true if supported otherwise false.
  75364. */
  75365. static IsSupported(engine: Engine): boolean;
  75366. private readonly _options;
  75367. private _canvas;
  75368. private _mediaRecorder;
  75369. private _recordedChunks;
  75370. private _fileName;
  75371. private _resolve;
  75372. private _reject;
  75373. /**
  75374. * True when a recording is already in progress.
  75375. */
  75376. get isRecording(): boolean;
  75377. /**
  75378. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75379. * @param engine Defines the BabylonJS Engine you wish to record.
  75380. * @param options Defines options that can be used to customize the capture.
  75381. */
  75382. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75383. /**
  75384. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75385. */
  75386. stopRecording(): void;
  75387. /**
  75388. * Starts recording the canvas for a max duration specified in parameters.
  75389. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75390. * If null no automatic download will start and you can rely on the promise to get the data back.
  75391. * @param maxDuration Defines the maximum recording time in seconds.
  75392. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75393. * @return A promise callback at the end of the recording with the video data in Blob.
  75394. */
  75395. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75396. /**
  75397. * Releases internal resources used during the recording.
  75398. */
  75399. dispose(): void;
  75400. private _handleDataAvailable;
  75401. private _handleError;
  75402. private _handleStop;
  75403. }
  75404. }
  75405. declare module BABYLON {
  75406. /**
  75407. * Class containing a set of static utilities functions for screenshots
  75408. */
  75409. export class ScreenshotTools {
  75410. /**
  75411. * Captures a screenshot of the current rendering
  75412. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75413. * @param engine defines the rendering engine
  75414. * @param camera defines the source camera
  75415. * @param size This parameter can be set to a single number or to an object with the
  75416. * following (optional) properties: precision, width, height. If a single number is passed,
  75417. * it will be used for both width and height. If an object is passed, the screenshot size
  75418. * will be derived from the parameters. The precision property is a multiplier allowing
  75419. * rendering at a higher or lower resolution
  75420. * @param successCallback defines the callback receives a single parameter which contains the
  75421. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75422. * src parameter of an <img> to display it
  75423. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75424. * Check your browser for supported MIME types
  75425. */
  75426. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75427. /**
  75428. * Captures a screenshot of the current rendering
  75429. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75430. * @param engine defines the rendering engine
  75431. * @param camera defines the source camera
  75432. * @param size This parameter can be set to a single number or to an object with the
  75433. * following (optional) properties: precision, width, height. If a single number is passed,
  75434. * it will be used for both width and height. If an object is passed, the screenshot size
  75435. * will be derived from the parameters. The precision property is a multiplier allowing
  75436. * rendering at a higher or lower resolution
  75437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75438. * Check your browser for supported MIME types
  75439. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75440. * to the src parameter of an <img> to display it
  75441. */
  75442. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75443. /**
  75444. * Generates an image screenshot from the specified camera.
  75445. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75446. * @param engine The engine to use for rendering
  75447. * @param camera The camera to use for rendering
  75448. * @param size This parameter can be set to a single number or to an object with the
  75449. * following (optional) properties: precision, width, height. If a single number is passed,
  75450. * it will be used for both width and height. If an object is passed, the screenshot size
  75451. * will be derived from the parameters. The precision property is a multiplier allowing
  75452. * rendering at a higher or lower resolution
  75453. * @param successCallback The callback receives a single parameter which contains the
  75454. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75455. * src parameter of an <img> to display it
  75456. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75457. * Check your browser for supported MIME types
  75458. * @param samples Texture samples (default: 1)
  75459. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75460. * @param fileName A name for for the downloaded file.
  75461. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75462. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75463. */
  75464. 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;
  75465. /**
  75466. * Generates an image screenshot from the specified camera.
  75467. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75468. * @param engine The engine to use for rendering
  75469. * @param camera The camera to use for rendering
  75470. * @param size This parameter can be set to a single number or to an object with the
  75471. * following (optional) properties: precision, width, height. If a single number is passed,
  75472. * it will be used for both width and height. If an object is passed, the screenshot size
  75473. * will be derived from the parameters. The precision property is a multiplier allowing
  75474. * rendering at a higher or lower resolution
  75475. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75476. * Check your browser for supported MIME types
  75477. * @param samples Texture samples (default: 1)
  75478. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75479. * @param fileName A name for for the downloaded file.
  75480. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75481. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75482. * to the src parameter of an <img> to display it
  75483. */
  75484. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75485. /**
  75486. * Gets height and width for screenshot size
  75487. * @private
  75488. */
  75489. private static _getScreenshotSize;
  75490. }
  75491. }
  75492. declare module BABYLON {
  75493. /**
  75494. * Interface for a data buffer
  75495. */
  75496. export interface IDataBuffer {
  75497. /**
  75498. * Reads bytes from the data buffer.
  75499. * @param byteOffset The byte offset to read
  75500. * @param byteLength The byte length to read
  75501. * @returns A promise that resolves when the bytes are read
  75502. */
  75503. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75504. /**
  75505. * The byte length of the buffer.
  75506. */
  75507. readonly byteLength: number;
  75508. }
  75509. /**
  75510. * Utility class for reading from a data buffer
  75511. */
  75512. export class DataReader {
  75513. /**
  75514. * The data buffer associated with this data reader.
  75515. */
  75516. readonly buffer: IDataBuffer;
  75517. /**
  75518. * The current byte offset from the beginning of the data buffer.
  75519. */
  75520. byteOffset: number;
  75521. private _dataView;
  75522. private _dataByteOffset;
  75523. /**
  75524. * Constructor
  75525. * @param buffer The buffer to read
  75526. */
  75527. constructor(buffer: IDataBuffer);
  75528. /**
  75529. * Loads the given byte length.
  75530. * @param byteLength The byte length to load
  75531. * @returns A promise that resolves when the load is complete
  75532. */
  75533. loadAsync(byteLength: number): Promise<void>;
  75534. /**
  75535. * Read a unsigned 32-bit integer from the currently loaded data range.
  75536. * @returns The 32-bit integer read
  75537. */
  75538. readUint32(): number;
  75539. /**
  75540. * Read a byte array from the currently loaded data range.
  75541. * @param byteLength The byte length to read
  75542. * @returns The byte array read
  75543. */
  75544. readUint8Array(byteLength: number): Uint8Array;
  75545. /**
  75546. * Read a string from the currently loaded data range.
  75547. * @param byteLength The byte length to read
  75548. * @returns The string read
  75549. */
  75550. readString(byteLength: number): string;
  75551. /**
  75552. * Skips the given byte length the currently loaded data range.
  75553. * @param byteLength The byte length to skip
  75554. */
  75555. skipBytes(byteLength: number): void;
  75556. }
  75557. }
  75558. declare module BABYLON {
  75559. /**
  75560. * Class for storing data to local storage if available or in-memory storage otherwise
  75561. */
  75562. export class DataStorage {
  75563. private static _Storage;
  75564. private static _GetStorage;
  75565. /**
  75566. * Reads a string from the data storage
  75567. * @param key The key to read
  75568. * @param defaultValue The value if the key doesn't exist
  75569. * @returns The string value
  75570. */
  75571. static ReadString(key: string, defaultValue: string): string;
  75572. /**
  75573. * Writes a string to the data storage
  75574. * @param key The key to write
  75575. * @param value The value to write
  75576. */
  75577. static WriteString(key: string, value: string): void;
  75578. /**
  75579. * Reads a boolean from the data storage
  75580. * @param key The key to read
  75581. * @param defaultValue The value if the key doesn't exist
  75582. * @returns The boolean value
  75583. */
  75584. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75585. /**
  75586. * Writes a boolean to the data storage
  75587. * @param key The key to write
  75588. * @param value The value to write
  75589. */
  75590. static WriteBoolean(key: string, value: boolean): void;
  75591. /**
  75592. * Reads a number from the data storage
  75593. * @param key The key to read
  75594. * @param defaultValue The value if the key doesn't exist
  75595. * @returns The number value
  75596. */
  75597. static ReadNumber(key: string, defaultValue: number): number;
  75598. /**
  75599. * Writes a number to the data storage
  75600. * @param key The key to write
  75601. * @param value The value to write
  75602. */
  75603. static WriteNumber(key: string, value: number): void;
  75604. }
  75605. }
  75606. declare module BABYLON {
  75607. /**
  75608. * Class used to record delta files between 2 scene states
  75609. */
  75610. export class SceneRecorder {
  75611. private _trackedScene;
  75612. private _savedJSON;
  75613. /**
  75614. * Track a given scene. This means the current scene state will be considered the original state
  75615. * @param scene defines the scene to track
  75616. */
  75617. track(scene: Scene): void;
  75618. /**
  75619. * Get the delta between current state and original state
  75620. * @returns a string containing the delta
  75621. */
  75622. getDelta(): any;
  75623. private _compareArray;
  75624. private _compareObjects;
  75625. private _compareCollections;
  75626. private static GetShadowGeneratorById;
  75627. /**
  75628. * Apply a given delta to a given scene
  75629. * @param deltaJSON defines the JSON containing the delta
  75630. * @param scene defines the scene to apply the delta to
  75631. */
  75632. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75633. private static _ApplyPropertiesToEntity;
  75634. private static _ApplyDeltaForEntity;
  75635. }
  75636. }
  75637. declare module BABYLON {
  75638. /**
  75639. * A 3D trajectory consisting of an order list of vectors describing a
  75640. * path of motion through 3D space.
  75641. */
  75642. export class Trajectory {
  75643. private _points;
  75644. private readonly _segmentLength;
  75645. /**
  75646. * Serialize to JSON.
  75647. * @returns serialized JSON string
  75648. */
  75649. serialize(): string;
  75650. /**
  75651. * Deserialize from JSON.
  75652. * @param json serialized JSON string
  75653. * @returns deserialized Trajectory
  75654. */
  75655. static Deserialize(json: string): Trajectory;
  75656. /**
  75657. * Create a new empty Trajectory.
  75658. * @param segmentLength radius of discretization for Trajectory points
  75659. */
  75660. constructor(segmentLength?: number);
  75661. /**
  75662. * Get the length of the Trajectory.
  75663. * @returns length of the Trajectory
  75664. */
  75665. getLength(): number;
  75666. /**
  75667. * Append a new point to the Trajectory.
  75668. * NOTE: This implementation has many allocations.
  75669. * @param point point to append to the Trajectory
  75670. */
  75671. add(point: DeepImmutable<Vector3>): void;
  75672. /**
  75673. * Create a new Trajectory with a segment length chosen to make it
  75674. * probable that the new Trajectory will have a specified number of
  75675. * segments. This operation is imprecise.
  75676. * @param targetResolution number of segments desired
  75677. * @returns new Trajectory with approximately the requested number of segments
  75678. */
  75679. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75680. /**
  75681. * Convert Trajectory segments into tokenized representation. This
  75682. * representation is an array of numbers where each nth number is the
  75683. * index of the token which is most similar to the nth segment of the
  75684. * Trajectory.
  75685. * @param tokens list of vectors which serve as discrete tokens
  75686. * @returns list of indices of most similar token per segment
  75687. */
  75688. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75689. private static _forwardDir;
  75690. private static _inverseFromVec;
  75691. private static _upDir;
  75692. private static _fromToVec;
  75693. private static _lookMatrix;
  75694. /**
  75695. * Transform the rotation (i.e., direction) of a segment to isolate
  75696. * the relative transformation represented by the segment. This operation
  75697. * may or may not succeed due to singularities in the equations that define
  75698. * motion relativity in this context.
  75699. * @param priorVec the origin of the prior segment
  75700. * @param fromVec the origin of the current segment
  75701. * @param toVec the destination of the current segment
  75702. * @param result reference to output variable
  75703. * @returns whether or not transformation was successful
  75704. */
  75705. private static _transformSegmentDirToRef;
  75706. private static _bestMatch;
  75707. private static _score;
  75708. private static _bestScore;
  75709. /**
  75710. * Determine which token vector is most similar to the
  75711. * segment vector.
  75712. * @param segment segment vector
  75713. * @param tokens token vector list
  75714. * @returns index of the most similar token to the segment
  75715. */
  75716. private static _tokenizeSegment;
  75717. }
  75718. /**
  75719. * Class representing a set of known, named trajectories to which Trajectories can be
  75720. * added and using which Trajectories can be recognized.
  75721. */
  75722. export class TrajectoryClassifier {
  75723. private _maximumAllowableMatchCost;
  75724. private _vector3Alphabet;
  75725. private _levenshteinAlphabet;
  75726. private _nameToDescribedTrajectory;
  75727. /**
  75728. * Serialize to JSON.
  75729. * @returns JSON serialization
  75730. */
  75731. serialize(): string;
  75732. /**
  75733. * Deserialize from JSON.
  75734. * @param json JSON serialization
  75735. * @returns deserialized TrajectorySet
  75736. */
  75737. static Deserialize(json: string): TrajectoryClassifier;
  75738. /**
  75739. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75740. * VERY naive, need to be generating these things from known
  75741. * sets. Better version later, probably eliminating this one.
  75742. * @returns auto-generated TrajectorySet
  75743. */
  75744. static Generate(): TrajectoryClassifier;
  75745. private constructor();
  75746. /**
  75747. * Add a new Trajectory to the set with a given name.
  75748. * @param trajectory new Trajectory to be added
  75749. * @param classification name to which to add the Trajectory
  75750. */
  75751. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75752. /**
  75753. * Remove a known named trajectory and all Trajectories associated with it.
  75754. * @param classification name to remove
  75755. * @returns whether anything was removed
  75756. */
  75757. deleteClassification(classification: string): boolean;
  75758. /**
  75759. * Attempt to recognize a Trajectory from among all the classifications
  75760. * already known to the classifier.
  75761. * @param trajectory Trajectory to be recognized
  75762. * @returns classification of Trajectory if recognized, null otherwise
  75763. */
  75764. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75765. }
  75766. }
  75767. declare module BABYLON {
  75768. /**
  75769. * An interface for all Hit test features
  75770. */
  75771. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75772. /**
  75773. * Triggered when new babylon (transformed) hit test results are available
  75774. */
  75775. onHitTestResultObservable: Observable<T[]>;
  75776. }
  75777. /**
  75778. * Options used for hit testing
  75779. */
  75780. export interface IWebXRLegacyHitTestOptions {
  75781. /**
  75782. * Only test when user interacted with the scene. Default - hit test every frame
  75783. */
  75784. testOnPointerDownOnly?: boolean;
  75785. /**
  75786. * The node to use to transform the local results to world coordinates
  75787. */
  75788. worldParentNode?: TransformNode;
  75789. }
  75790. /**
  75791. * Interface defining the babylon result of raycasting/hit-test
  75792. */
  75793. export interface IWebXRLegacyHitResult {
  75794. /**
  75795. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75796. */
  75797. transformationMatrix: Matrix;
  75798. /**
  75799. * The native hit test result
  75800. */
  75801. xrHitResult: XRHitResult | XRHitTestResult;
  75802. }
  75803. /**
  75804. * The currently-working hit-test module.
  75805. * Hit test (or Ray-casting) is used to interact with the real world.
  75806. * For further information read here - https://github.com/immersive-web/hit-test
  75807. */
  75808. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75809. /**
  75810. * options to use when constructing this feature
  75811. */
  75812. readonly options: IWebXRLegacyHitTestOptions;
  75813. private _direction;
  75814. private _mat;
  75815. private _onSelectEnabled;
  75816. private _origin;
  75817. /**
  75818. * The module's name
  75819. */
  75820. static readonly Name: string;
  75821. /**
  75822. * The (Babylon) version of this module.
  75823. * This is an integer representing the implementation version.
  75824. * This number does not correspond to the WebXR specs version
  75825. */
  75826. static readonly Version: number;
  75827. /**
  75828. * Populated with the last native XR Hit Results
  75829. */
  75830. lastNativeXRHitResults: XRHitResult[];
  75831. /**
  75832. * Triggered when new babylon (transformed) hit test results are available
  75833. */
  75834. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75835. /**
  75836. * Creates a new instance of the (legacy version) hit test feature
  75837. * @param _xrSessionManager an instance of WebXRSessionManager
  75838. * @param options options to use when constructing this feature
  75839. */
  75840. constructor(_xrSessionManager: WebXRSessionManager,
  75841. /**
  75842. * options to use when constructing this feature
  75843. */
  75844. options?: IWebXRLegacyHitTestOptions);
  75845. /**
  75846. * execute a hit test with an XR Ray
  75847. *
  75848. * @param xrSession a native xrSession that will execute this hit test
  75849. * @param xrRay the ray (position and direction) to use for ray-casting
  75850. * @param referenceSpace native XR reference space to use for the hit-test
  75851. * @param filter filter function that will filter the results
  75852. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75853. */
  75854. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75855. /**
  75856. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75857. * @param event the (select) event to use to select with
  75858. * @param referenceSpace the reference space to use for this hit test
  75859. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75860. */
  75861. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75862. /**
  75863. * attach this feature
  75864. * Will usually be called by the features manager
  75865. *
  75866. * @returns true if successful.
  75867. */
  75868. attach(): boolean;
  75869. /**
  75870. * detach this feature.
  75871. * Will usually be called by the features manager
  75872. *
  75873. * @returns true if successful.
  75874. */
  75875. detach(): boolean;
  75876. /**
  75877. * Dispose this feature and all of the resources attached
  75878. */
  75879. dispose(): void;
  75880. protected _onXRFrame(frame: XRFrame): void;
  75881. private _onHitTestResults;
  75882. private _onSelect;
  75883. }
  75884. }
  75885. declare module BABYLON {
  75886. /**
  75887. * Options used for hit testing (version 2)
  75888. */
  75889. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75890. /**
  75891. * Do not create a permanent hit test. Will usually be used when only
  75892. * transient inputs are needed.
  75893. */
  75894. disablePermanentHitTest?: boolean;
  75895. /**
  75896. * Enable transient (for example touch-based) hit test inspections
  75897. */
  75898. enableTransientHitTest?: boolean;
  75899. /**
  75900. * Offset ray for the permanent hit test
  75901. */
  75902. offsetRay?: Vector3;
  75903. /**
  75904. * Offset ray for the transient hit test
  75905. */
  75906. transientOffsetRay?: Vector3;
  75907. /**
  75908. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75909. */
  75910. useReferenceSpace?: boolean;
  75911. /**
  75912. * Override the default entity type(s) of the hit-test result
  75913. */
  75914. entityTypes?: XRHitTestTrackableType[];
  75915. }
  75916. /**
  75917. * Interface defining the babylon result of hit-test
  75918. */
  75919. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75920. /**
  75921. * The input source that generated this hit test (if transient)
  75922. */
  75923. inputSource?: XRInputSource;
  75924. /**
  75925. * Is this a transient hit test
  75926. */
  75927. isTransient?: boolean;
  75928. /**
  75929. * Position of the hit test result
  75930. */
  75931. position: Vector3;
  75932. /**
  75933. * Rotation of the hit test result
  75934. */
  75935. rotationQuaternion: Quaternion;
  75936. /**
  75937. * The native hit test result
  75938. */
  75939. xrHitResult: XRHitTestResult;
  75940. }
  75941. /**
  75942. * The currently-working hit-test module.
  75943. * Hit test (or Ray-casting) is used to interact with the real world.
  75944. * For further information read here - https://github.com/immersive-web/hit-test
  75945. *
  75946. * Tested on chrome (mobile) 80.
  75947. */
  75948. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75949. /**
  75950. * options to use when constructing this feature
  75951. */
  75952. readonly options: IWebXRHitTestOptions;
  75953. private _tmpMat;
  75954. private _tmpPos;
  75955. private _tmpQuat;
  75956. private _transientXrHitTestSource;
  75957. private _xrHitTestSource;
  75958. private initHitTestSource;
  75959. /**
  75960. * The module's name
  75961. */
  75962. static readonly Name: string;
  75963. /**
  75964. * The (Babylon) version of this module.
  75965. * This is an integer representing the implementation version.
  75966. * This number does not correspond to the WebXR specs version
  75967. */
  75968. static readonly Version: number;
  75969. /**
  75970. * When set to true, each hit test will have its own position/rotation objects
  75971. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75972. * the developers will clone them or copy them as they see fit.
  75973. */
  75974. autoCloneTransformation: boolean;
  75975. /**
  75976. * Triggered when new babylon (transformed) hit test results are available
  75977. * Note - this will be called when results come back from the device. It can be an empty array!!
  75978. */
  75979. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75980. /**
  75981. * Use this to temporarily pause hit test checks.
  75982. */
  75983. paused: boolean;
  75984. /**
  75985. * Creates a new instance of the hit test feature
  75986. * @param _xrSessionManager an instance of WebXRSessionManager
  75987. * @param options options to use when constructing this feature
  75988. */
  75989. constructor(_xrSessionManager: WebXRSessionManager,
  75990. /**
  75991. * options to use when constructing this feature
  75992. */
  75993. options?: IWebXRHitTestOptions);
  75994. /**
  75995. * attach this feature
  75996. * Will usually be called by the features manager
  75997. *
  75998. * @returns true if successful.
  75999. */
  76000. attach(): boolean;
  76001. /**
  76002. * detach this feature.
  76003. * Will usually be called by the features manager
  76004. *
  76005. * @returns true if successful.
  76006. */
  76007. detach(): boolean;
  76008. /**
  76009. * Dispose this feature and all of the resources attached
  76010. */
  76011. dispose(): void;
  76012. protected _onXRFrame(frame: XRFrame): void;
  76013. private _processWebXRHitTestResult;
  76014. }
  76015. }
  76016. declare module BABYLON {
  76017. /**
  76018. * Configuration options of the anchor system
  76019. */
  76020. export interface IWebXRAnchorSystemOptions {
  76021. /**
  76022. * a node that will be used to convert local to world coordinates
  76023. */
  76024. worldParentNode?: TransformNode;
  76025. /**
  76026. * If set to true a reference of the created anchors will be kept until the next session starts
  76027. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76028. */
  76029. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76030. }
  76031. /**
  76032. * A babylon container for an XR Anchor
  76033. */
  76034. export interface IWebXRAnchor {
  76035. /**
  76036. * A babylon-assigned ID for this anchor
  76037. */
  76038. id: number;
  76039. /**
  76040. * Transformation matrix to apply to an object attached to this anchor
  76041. */
  76042. transformationMatrix: Matrix;
  76043. /**
  76044. * The native anchor object
  76045. */
  76046. xrAnchor: XRAnchor;
  76047. /**
  76048. * if defined, this object will be constantly updated by the anchor's position and rotation
  76049. */
  76050. attachedNode?: TransformNode;
  76051. }
  76052. /**
  76053. * An implementation of the anchor system for WebXR.
  76054. * For further information see https://github.com/immersive-web/anchors/
  76055. */
  76056. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76057. private _options;
  76058. private _lastFrameDetected;
  76059. private _trackedAnchors;
  76060. private _referenceSpaceForFrameAnchors;
  76061. private _futureAnchors;
  76062. /**
  76063. * The module's name
  76064. */
  76065. static readonly Name: string;
  76066. /**
  76067. * The (Babylon) version of this module.
  76068. * This is an integer representing the implementation version.
  76069. * This number does not correspond to the WebXR specs version
  76070. */
  76071. static readonly Version: number;
  76072. /**
  76073. * Observers registered here will be executed when a new anchor was added to the session
  76074. */
  76075. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76076. /**
  76077. * Observers registered here will be executed when an anchor was removed from the session
  76078. */
  76079. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76080. /**
  76081. * Observers registered here will be executed when an existing anchor updates
  76082. * This can execute N times every frame
  76083. */
  76084. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76085. /**
  76086. * Set the reference space to use for anchor creation, when not using a hit test.
  76087. * Will default to the session's reference space if not defined
  76088. */
  76089. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76090. /**
  76091. * constructs a new anchor system
  76092. * @param _xrSessionManager an instance of WebXRSessionManager
  76093. * @param _options configuration object for this feature
  76094. */
  76095. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76096. private _tmpVector;
  76097. private _tmpQuaternion;
  76098. private _populateTmpTransformation;
  76099. /**
  76100. * Create a new anchor point using a hit test result at a specific point in the scene
  76101. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76102. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76103. *
  76104. * @param hitTestResult The hit test result to use for this anchor creation
  76105. * @param position an optional position offset for this anchor
  76106. * @param rotationQuaternion an optional rotation offset for this anchor
  76107. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76108. */
  76109. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  76110. /**
  76111. * Add a new anchor at a specific position and rotation
  76112. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76113. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76114. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76115. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76116. *
  76117. * @param position the position in which to add an anchor
  76118. * @param rotationQuaternion an optional rotation for the anchor transformation
  76119. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76120. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  76121. */
  76122. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  76123. /**
  76124. * detach this feature.
  76125. * Will usually be called by the features manager
  76126. *
  76127. * @returns true if successful.
  76128. */
  76129. detach(): boolean;
  76130. /**
  76131. * Dispose this feature and all of the resources attached
  76132. */
  76133. dispose(): void;
  76134. protected _onXRFrame(frame: XRFrame): void;
  76135. /**
  76136. * avoiding using Array.find for global support.
  76137. * @param xrAnchor the plane to find in the array
  76138. */
  76139. private _findIndexInAnchorArray;
  76140. private _updateAnchorWithXRFrame;
  76141. private _createAnchorAtTransformation;
  76142. }
  76143. }
  76144. declare module BABYLON {
  76145. /**
  76146. * Options used in the plane detector module
  76147. */
  76148. export interface IWebXRPlaneDetectorOptions {
  76149. /**
  76150. * The node to use to transform the local results to world coordinates
  76151. */
  76152. worldParentNode?: TransformNode;
  76153. /**
  76154. * If set to true a reference of the created planes will be kept until the next session starts
  76155. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76156. */
  76157. doNotRemovePlanesOnSessionEnded?: boolean;
  76158. }
  76159. /**
  76160. * A babylon interface for a WebXR plane.
  76161. * A Plane is actually a polygon, built from N points in space
  76162. *
  76163. * Supported in chrome 79, not supported in canary 81 ATM
  76164. */
  76165. export interface IWebXRPlane {
  76166. /**
  76167. * a babylon-assigned ID for this polygon
  76168. */
  76169. id: number;
  76170. /**
  76171. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76172. */
  76173. polygonDefinition: Array<Vector3>;
  76174. /**
  76175. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76176. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76177. */
  76178. transformationMatrix: Matrix;
  76179. /**
  76180. * the native xr-plane object
  76181. */
  76182. xrPlane: XRPlane;
  76183. }
  76184. /**
  76185. * The plane detector is used to detect planes in the real world when in AR
  76186. * For more information see https://github.com/immersive-web/real-world-geometry/
  76187. */
  76188. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76189. private _options;
  76190. private _detectedPlanes;
  76191. private _enabled;
  76192. private _lastFrameDetected;
  76193. /**
  76194. * The module's name
  76195. */
  76196. static readonly Name: string;
  76197. /**
  76198. * The (Babylon) version of this module.
  76199. * This is an integer representing the implementation version.
  76200. * This number does not correspond to the WebXR specs version
  76201. */
  76202. static readonly Version: number;
  76203. /**
  76204. * Observers registered here will be executed when a new plane was added to the session
  76205. */
  76206. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76207. /**
  76208. * Observers registered here will be executed when a plane is no longer detected in the session
  76209. */
  76210. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76211. /**
  76212. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76213. * This can execute N times every frame
  76214. */
  76215. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76216. /**
  76217. * construct a new Plane Detector
  76218. * @param _xrSessionManager an instance of xr Session manager
  76219. * @param _options configuration to use when constructing this feature
  76220. */
  76221. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76222. /**
  76223. * detach this feature.
  76224. * Will usually be called by the features manager
  76225. *
  76226. * @returns true if successful.
  76227. */
  76228. detach(): boolean;
  76229. /**
  76230. * Dispose this feature and all of the resources attached
  76231. */
  76232. dispose(): void;
  76233. /**
  76234. * Check if the needed objects are defined.
  76235. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76236. */
  76237. isCompatible(): boolean;
  76238. protected _onXRFrame(frame: XRFrame): void;
  76239. private _init;
  76240. private _updatePlaneWithXRPlane;
  76241. /**
  76242. * avoiding using Array.find for global support.
  76243. * @param xrPlane the plane to find in the array
  76244. */
  76245. private findIndexInPlaneArray;
  76246. }
  76247. }
  76248. declare module BABYLON {
  76249. /**
  76250. * Options interface for the background remover plugin
  76251. */
  76252. export interface IWebXRBackgroundRemoverOptions {
  76253. /**
  76254. * Further background meshes to disable when entering AR
  76255. */
  76256. backgroundMeshes?: AbstractMesh[];
  76257. /**
  76258. * flags to configure the removal of the environment helper.
  76259. * If not set, the entire background will be removed. If set, flags should be set as well.
  76260. */
  76261. environmentHelperRemovalFlags?: {
  76262. /**
  76263. * Should the skybox be removed (default false)
  76264. */
  76265. skyBox?: boolean;
  76266. /**
  76267. * Should the ground be removed (default false)
  76268. */
  76269. ground?: boolean;
  76270. };
  76271. /**
  76272. * don't disable the environment helper
  76273. */
  76274. ignoreEnvironmentHelper?: boolean;
  76275. }
  76276. /**
  76277. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76278. */
  76279. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76280. /**
  76281. * read-only options to be used in this module
  76282. */
  76283. readonly options: IWebXRBackgroundRemoverOptions;
  76284. /**
  76285. * The module's name
  76286. */
  76287. static readonly Name: string;
  76288. /**
  76289. * The (Babylon) version of this module.
  76290. * This is an integer representing the implementation version.
  76291. * This number does not correspond to the WebXR specs version
  76292. */
  76293. static readonly Version: number;
  76294. /**
  76295. * registered observers will be triggered when the background state changes
  76296. */
  76297. onBackgroundStateChangedObservable: Observable<boolean>;
  76298. /**
  76299. * constructs a new background remover module
  76300. * @param _xrSessionManager the session manager for this module
  76301. * @param options read-only options to be used in this module
  76302. */
  76303. constructor(_xrSessionManager: WebXRSessionManager,
  76304. /**
  76305. * read-only options to be used in this module
  76306. */
  76307. options?: IWebXRBackgroundRemoverOptions);
  76308. /**
  76309. * attach this feature
  76310. * Will usually be called by the features manager
  76311. *
  76312. * @returns true if successful.
  76313. */
  76314. attach(): boolean;
  76315. /**
  76316. * detach this feature.
  76317. * Will usually be called by the features manager
  76318. *
  76319. * @returns true if successful.
  76320. */
  76321. detach(): boolean;
  76322. /**
  76323. * Dispose this feature and all of the resources attached
  76324. */
  76325. dispose(): void;
  76326. protected _onXRFrame(_xrFrame: XRFrame): void;
  76327. private _setBackgroundState;
  76328. }
  76329. }
  76330. declare module BABYLON {
  76331. /**
  76332. * Options for the controller physics feature
  76333. */
  76334. export class IWebXRControllerPhysicsOptions {
  76335. /**
  76336. * Should the headset get its own impostor
  76337. */
  76338. enableHeadsetImpostor?: boolean;
  76339. /**
  76340. * Optional parameters for the headset impostor
  76341. */
  76342. headsetImpostorParams?: {
  76343. /**
  76344. * The type of impostor to create. Default is sphere
  76345. */
  76346. impostorType: number;
  76347. /**
  76348. * the size of the impostor. Defaults to 10cm
  76349. */
  76350. impostorSize?: number | {
  76351. width: number;
  76352. height: number;
  76353. depth: number;
  76354. };
  76355. /**
  76356. * Friction definitions
  76357. */
  76358. friction?: number;
  76359. /**
  76360. * Restitution
  76361. */
  76362. restitution?: number;
  76363. };
  76364. /**
  76365. * The physics properties of the future impostors
  76366. */
  76367. physicsProperties?: {
  76368. /**
  76369. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76370. * Note that this requires a physics engine that supports mesh impostors!
  76371. */
  76372. useControllerMesh?: boolean;
  76373. /**
  76374. * The type of impostor to create. Default is sphere
  76375. */
  76376. impostorType?: number;
  76377. /**
  76378. * the size of the impostor. Defaults to 10cm
  76379. */
  76380. impostorSize?: number | {
  76381. width: number;
  76382. height: number;
  76383. depth: number;
  76384. };
  76385. /**
  76386. * Friction definitions
  76387. */
  76388. friction?: number;
  76389. /**
  76390. * Restitution
  76391. */
  76392. restitution?: number;
  76393. };
  76394. /**
  76395. * the xr input to use with this pointer selection
  76396. */
  76397. xrInput: WebXRInput;
  76398. }
  76399. /**
  76400. * Add physics impostor to your webxr controllers,
  76401. * including naive calculation of their linear and angular velocity
  76402. */
  76403. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76404. private readonly _options;
  76405. private _attachController;
  76406. private _controllers;
  76407. private _debugMode;
  76408. private _delta;
  76409. private _headsetImpostor?;
  76410. private _headsetMesh?;
  76411. private _lastTimestamp;
  76412. private _tmpQuaternion;
  76413. private _tmpVector;
  76414. /**
  76415. * The module's name
  76416. */
  76417. static readonly Name: string;
  76418. /**
  76419. * The (Babylon) version of this module.
  76420. * This is an integer representing the implementation version.
  76421. * This number does not correspond to the webxr specs version
  76422. */
  76423. static readonly Version: number;
  76424. /**
  76425. * Construct a new Controller Physics Feature
  76426. * @param _xrSessionManager the corresponding xr session manager
  76427. * @param _options options to create this feature with
  76428. */
  76429. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76430. /**
  76431. * @hidden
  76432. * enable debugging - will show console outputs and the impostor mesh
  76433. */
  76434. _enablePhysicsDebug(): void;
  76435. /**
  76436. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76437. * @param xrController the controller to add
  76438. */
  76439. addController(xrController: WebXRInputSource): void;
  76440. /**
  76441. * attach this feature
  76442. * Will usually be called by the features manager
  76443. *
  76444. * @returns true if successful.
  76445. */
  76446. attach(): boolean;
  76447. /**
  76448. * detach this feature.
  76449. * Will usually be called by the features manager
  76450. *
  76451. * @returns true if successful.
  76452. */
  76453. detach(): boolean;
  76454. /**
  76455. * Get the headset impostor, if enabled
  76456. * @returns the impostor
  76457. */
  76458. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76459. /**
  76460. * Get the physics impostor of a specific controller.
  76461. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76462. * @param controller the controller or the controller id of which to get the impostor
  76463. * @returns the impostor or null
  76464. */
  76465. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76466. /**
  76467. * Update the physics properties provided in the constructor
  76468. * @param newProperties the new properties object
  76469. */
  76470. setPhysicsProperties(newProperties: {
  76471. impostorType?: number;
  76472. impostorSize?: number | {
  76473. width: number;
  76474. height: number;
  76475. depth: number;
  76476. };
  76477. friction?: number;
  76478. restitution?: number;
  76479. }): void;
  76480. protected _onXRFrame(_xrFrame: any): void;
  76481. private _detachController;
  76482. }
  76483. }
  76484. declare module BABYLON {
  76485. /**
  76486. * A babylon interface for a "WebXR" feature point.
  76487. * Represents the position and confidence value of a given feature point.
  76488. */
  76489. export interface IWebXRFeaturePoint {
  76490. /**
  76491. * Represents the position of the feature point in world space.
  76492. */
  76493. position: Vector3;
  76494. /**
  76495. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76496. */
  76497. confidenceValue: number;
  76498. }
  76499. /**
  76500. * The feature point system is used to detect feature points from real world geometry.
  76501. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76502. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76503. */
  76504. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76505. private _enabled;
  76506. private _featurePointCloud;
  76507. /**
  76508. * The module's name
  76509. */
  76510. static readonly Name: string;
  76511. /**
  76512. * The (Babylon) version of this module.
  76513. * This is an integer representing the implementation version.
  76514. * This number does not correspond to the WebXR specs version
  76515. */
  76516. static readonly Version: number;
  76517. /**
  76518. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76519. * Will notify the observers about which feature points have been added.
  76520. */
  76521. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76522. /**
  76523. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76524. * Will notify the observers about which feature points have been updated.
  76525. */
  76526. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76527. /**
  76528. * The current feature point cloud maintained across frames.
  76529. */
  76530. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76531. /**
  76532. * construct the feature point system
  76533. * @param _xrSessionManager an instance of xr Session manager
  76534. */
  76535. constructor(_xrSessionManager: WebXRSessionManager);
  76536. /**
  76537. * Detach this feature.
  76538. * Will usually be called by the features manager
  76539. *
  76540. * @returns true if successful.
  76541. */
  76542. detach(): boolean;
  76543. /**
  76544. * Dispose this feature and all of the resources attached
  76545. */
  76546. dispose(): void;
  76547. /**
  76548. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76549. */
  76550. protected _onXRFrame(frame: XRFrame): void;
  76551. /**
  76552. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76553. */
  76554. private _init;
  76555. }
  76556. }
  76557. declare module BABYLON {
  76558. /**
  76559. * Configuration interface for the hand tracking feature
  76560. */
  76561. export interface IWebXRHandTrackingOptions {
  76562. /**
  76563. * The xrInput that will be used as source for new hands
  76564. */
  76565. xrInput: WebXRInput;
  76566. /**
  76567. * Configuration object for the joint meshes
  76568. */
  76569. jointMeshes?: {
  76570. /**
  76571. * Should the meshes created be invisible (defaults to false)
  76572. */
  76573. invisible?: boolean;
  76574. /**
  76575. * A source mesh to be used to create instances. Defaults to a sphere.
  76576. * This mesh will be the source for all other (25) meshes.
  76577. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76578. */
  76579. sourceMesh?: Mesh;
  76580. /**
  76581. * This function will be called after a mesh was created for a specific joint.
  76582. * Using this function you can either manipulate the instance or return a new mesh.
  76583. * When returning a new mesh the instance created before will be disposed
  76584. */
  76585. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76586. /**
  76587. * Should the source mesh stay visible. Defaults to false
  76588. */
  76589. keepOriginalVisible?: boolean;
  76590. /**
  76591. * Scale factor for all instances (defaults to 2)
  76592. */
  76593. scaleFactor?: number;
  76594. /**
  76595. * Should each instance have its own physics impostor
  76596. */
  76597. enablePhysics?: boolean;
  76598. /**
  76599. * If enabled, override default physics properties
  76600. */
  76601. physicsProps?: {
  76602. friction?: number;
  76603. restitution?: number;
  76604. impostorType?: number;
  76605. };
  76606. /**
  76607. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76608. */
  76609. handMesh?: AbstractMesh;
  76610. };
  76611. }
  76612. /**
  76613. * Parts of the hands divided to writs and finger names
  76614. */
  76615. export const enum HandPart {
  76616. /**
  76617. * HandPart - Wrist
  76618. */
  76619. WRIST = "wrist",
  76620. /**
  76621. * HandPart - The THumb
  76622. */
  76623. THUMB = "thumb",
  76624. /**
  76625. * HandPart - Index finger
  76626. */
  76627. INDEX = "index",
  76628. /**
  76629. * HandPart - Middle finger
  76630. */
  76631. MIDDLE = "middle",
  76632. /**
  76633. * HandPart - Ring finger
  76634. */
  76635. RING = "ring",
  76636. /**
  76637. * HandPart - Little finger
  76638. */
  76639. LITTLE = "little"
  76640. }
  76641. /**
  76642. * Representing a single hand (with its corresponding native XRHand object)
  76643. */
  76644. export class WebXRHand implements IDisposable {
  76645. /** the controller to which the hand correlates */
  76646. readonly xrController: WebXRInputSource;
  76647. /** the meshes to be used to track the hand joints */
  76648. readonly trackedMeshes: AbstractMesh[];
  76649. /**
  76650. * Hand-parts definition (key is HandPart)
  76651. */
  76652. handPartsDefinition: {
  76653. [key: string]: number[];
  76654. };
  76655. /**
  76656. * Populate the HandPartsDefinition object.
  76657. * This is called as a side effect since certain browsers don't have XRHand defined.
  76658. */
  76659. private generateHandPartsDefinition;
  76660. /**
  76661. * Construct a new hand object
  76662. * @param xrController the controller to which the hand correlates
  76663. * @param trackedMeshes the meshes to be used to track the hand joints
  76664. */
  76665. constructor(
  76666. /** the controller to which the hand correlates */
  76667. xrController: WebXRInputSource,
  76668. /** the meshes to be used to track the hand joints */
  76669. trackedMeshes: AbstractMesh[]);
  76670. /**
  76671. * Update this hand from the latest xr frame
  76672. * @param xrFrame xrFrame to update from
  76673. * @param referenceSpace The current viewer reference space
  76674. * @param scaleFactor optional scale factor for the meshes
  76675. */
  76676. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76677. /**
  76678. * Get meshes of part of the hand
  76679. * @param part the part of hand to get
  76680. * @returns An array of meshes that correlate to the hand part requested
  76681. */
  76682. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76683. /**
  76684. * Dispose this Hand object
  76685. */
  76686. dispose(): void;
  76687. }
  76688. /**
  76689. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76690. */
  76691. export class WebXRHandTracking extends WebXRAbstractFeature {
  76692. /**
  76693. * options to use when constructing this feature
  76694. */
  76695. readonly options: IWebXRHandTrackingOptions;
  76696. private static _idCounter;
  76697. /**
  76698. * The module's name
  76699. */
  76700. static readonly Name: string;
  76701. /**
  76702. * The (Babylon) version of this module.
  76703. * This is an integer representing the implementation version.
  76704. * This number does not correspond to the WebXR specs version
  76705. */
  76706. static readonly Version: number;
  76707. /**
  76708. * This observable will notify registered observers when a new hand object was added and initialized
  76709. */
  76710. onHandAddedObservable: Observable<WebXRHand>;
  76711. /**
  76712. * This observable will notify its observers right before the hand object is disposed
  76713. */
  76714. onHandRemovedObservable: Observable<WebXRHand>;
  76715. private _hands;
  76716. /**
  76717. * Creates a new instance of the hit test feature
  76718. * @param _xrSessionManager an instance of WebXRSessionManager
  76719. * @param options options to use when constructing this feature
  76720. */
  76721. constructor(_xrSessionManager: WebXRSessionManager,
  76722. /**
  76723. * options to use when constructing this feature
  76724. */
  76725. options: IWebXRHandTrackingOptions);
  76726. /**
  76727. * Check if the needed objects are defined.
  76728. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76729. */
  76730. isCompatible(): boolean;
  76731. /**
  76732. * attach this feature
  76733. * Will usually be called by the features manager
  76734. *
  76735. * @returns true if successful.
  76736. */
  76737. attach(): boolean;
  76738. /**
  76739. * detach this feature.
  76740. * Will usually be called by the features manager
  76741. *
  76742. * @returns true if successful.
  76743. */
  76744. detach(): boolean;
  76745. /**
  76746. * Dispose this feature and all of the resources attached
  76747. */
  76748. dispose(): void;
  76749. /**
  76750. * Get the hand object according to the controller id
  76751. * @param controllerId the controller id to which we want to get the hand
  76752. * @returns null if not found or the WebXRHand object if found
  76753. */
  76754. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76755. /**
  76756. * Get a hand object according to the requested handedness
  76757. * @param handedness the handedness to request
  76758. * @returns null if not found or the WebXRHand object if found
  76759. */
  76760. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76761. protected _onXRFrame(_xrFrame: XRFrame): void;
  76762. private _attachHand;
  76763. private _detachHand;
  76764. }
  76765. }
  76766. declare module BABYLON {
  76767. /**
  76768. * The motion controller class for all microsoft mixed reality controllers
  76769. */
  76770. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76771. protected readonly _mapping: {
  76772. defaultButton: {
  76773. valueNodeName: string;
  76774. unpressedNodeName: string;
  76775. pressedNodeName: string;
  76776. };
  76777. defaultAxis: {
  76778. valueNodeName: string;
  76779. minNodeName: string;
  76780. maxNodeName: string;
  76781. };
  76782. buttons: {
  76783. "xr-standard-trigger": {
  76784. rootNodeName: string;
  76785. componentProperty: string;
  76786. states: string[];
  76787. };
  76788. "xr-standard-squeeze": {
  76789. rootNodeName: string;
  76790. componentProperty: string;
  76791. states: string[];
  76792. };
  76793. "xr-standard-touchpad": {
  76794. rootNodeName: string;
  76795. labelAnchorNodeName: string;
  76796. touchPointNodeName: string;
  76797. };
  76798. "xr-standard-thumbstick": {
  76799. rootNodeName: string;
  76800. componentProperty: string;
  76801. states: string[];
  76802. };
  76803. };
  76804. axes: {
  76805. "xr-standard-touchpad": {
  76806. "x-axis": {
  76807. rootNodeName: string;
  76808. };
  76809. "y-axis": {
  76810. rootNodeName: string;
  76811. };
  76812. };
  76813. "xr-standard-thumbstick": {
  76814. "x-axis": {
  76815. rootNodeName: string;
  76816. };
  76817. "y-axis": {
  76818. rootNodeName: string;
  76819. };
  76820. };
  76821. };
  76822. };
  76823. /**
  76824. * The base url used to load the left and right controller models
  76825. */
  76826. static MODEL_BASE_URL: string;
  76827. /**
  76828. * The name of the left controller model file
  76829. */
  76830. static MODEL_LEFT_FILENAME: string;
  76831. /**
  76832. * The name of the right controller model file
  76833. */
  76834. static MODEL_RIGHT_FILENAME: string;
  76835. profileId: string;
  76836. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76837. protected _getFilenameAndPath(): {
  76838. filename: string;
  76839. path: string;
  76840. };
  76841. protected _getModelLoadingConstraints(): boolean;
  76842. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76843. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76844. protected _updateModel(): void;
  76845. }
  76846. }
  76847. declare module BABYLON {
  76848. /**
  76849. * The motion controller class for oculus touch (quest, rift).
  76850. * This class supports legacy mapping as well the standard xr mapping
  76851. */
  76852. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76853. private _forceLegacyControllers;
  76854. private _modelRootNode;
  76855. /**
  76856. * The base url used to load the left and right controller models
  76857. */
  76858. static MODEL_BASE_URL: string;
  76859. /**
  76860. * The name of the left controller model file
  76861. */
  76862. static MODEL_LEFT_FILENAME: string;
  76863. /**
  76864. * The name of the right controller model file
  76865. */
  76866. static MODEL_RIGHT_FILENAME: string;
  76867. /**
  76868. * Base Url for the Quest controller model.
  76869. */
  76870. static QUEST_MODEL_BASE_URL: string;
  76871. profileId: string;
  76872. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76873. protected _getFilenameAndPath(): {
  76874. filename: string;
  76875. path: string;
  76876. };
  76877. protected _getModelLoadingConstraints(): boolean;
  76878. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76879. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76880. protected _updateModel(): void;
  76881. /**
  76882. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76883. * between the touch and touch 2.
  76884. */
  76885. private _isQuest;
  76886. }
  76887. }
  76888. declare module BABYLON {
  76889. /**
  76890. * The motion controller class for the standard HTC-Vive controllers
  76891. */
  76892. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76893. private _modelRootNode;
  76894. /**
  76895. * The base url used to load the left and right controller models
  76896. */
  76897. static MODEL_BASE_URL: string;
  76898. /**
  76899. * File name for the controller model.
  76900. */
  76901. static MODEL_FILENAME: string;
  76902. profileId: string;
  76903. /**
  76904. * Create a new Vive motion controller object
  76905. * @param scene the scene to use to create this controller
  76906. * @param gamepadObject the corresponding gamepad object
  76907. * @param handedness the handedness of the controller
  76908. */
  76909. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76910. protected _getFilenameAndPath(): {
  76911. filename: string;
  76912. path: string;
  76913. };
  76914. protected _getModelLoadingConstraints(): boolean;
  76915. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76916. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76917. protected _updateModel(): void;
  76918. }
  76919. }
  76920. declare module BABYLON {
  76921. /**
  76922. * A cursor which tracks a point on a path
  76923. */
  76924. export class PathCursor {
  76925. private path;
  76926. /**
  76927. * Stores path cursor callbacks for when an onchange event is triggered
  76928. */
  76929. private _onchange;
  76930. /**
  76931. * The value of the path cursor
  76932. */
  76933. value: number;
  76934. /**
  76935. * The animation array of the path cursor
  76936. */
  76937. animations: Animation[];
  76938. /**
  76939. * Initializes the path cursor
  76940. * @param path The path to track
  76941. */
  76942. constructor(path: Path2);
  76943. /**
  76944. * Gets the cursor point on the path
  76945. * @returns A point on the path cursor at the cursor location
  76946. */
  76947. getPoint(): Vector3;
  76948. /**
  76949. * Moves the cursor ahead by the step amount
  76950. * @param step The amount to move the cursor forward
  76951. * @returns This path cursor
  76952. */
  76953. moveAhead(step?: number): PathCursor;
  76954. /**
  76955. * Moves the cursor behind by the step amount
  76956. * @param step The amount to move the cursor back
  76957. * @returns This path cursor
  76958. */
  76959. moveBack(step?: number): PathCursor;
  76960. /**
  76961. * Moves the cursor by the step amount
  76962. * If the step amount is greater than one, an exception is thrown
  76963. * @param step The amount to move the cursor
  76964. * @returns This path cursor
  76965. */
  76966. move(step: number): PathCursor;
  76967. /**
  76968. * Ensures that the value is limited between zero and one
  76969. * @returns This path cursor
  76970. */
  76971. private ensureLimits;
  76972. /**
  76973. * Runs onchange callbacks on change (used by the animation engine)
  76974. * @returns This path cursor
  76975. */
  76976. private raiseOnChange;
  76977. /**
  76978. * Executes a function on change
  76979. * @param f A path cursor onchange callback
  76980. * @returns This path cursor
  76981. */
  76982. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76983. }
  76984. }
  76985. declare module BABYLON {
  76986. /** @hidden */
  76987. export var blurPixelShader: {
  76988. name: string;
  76989. shader: string;
  76990. };
  76991. }
  76992. declare module BABYLON {
  76993. /** @hidden */
  76994. export var pointCloudVertexDeclaration: {
  76995. name: string;
  76996. shader: string;
  76997. };
  76998. }
  76999. // Mixins
  77000. interface Window {
  77001. mozIndexedDB: IDBFactory;
  77002. webkitIndexedDB: IDBFactory;
  77003. msIndexedDB: IDBFactory;
  77004. webkitURL: typeof URL;
  77005. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77006. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77007. WebGLRenderingContext: WebGLRenderingContext;
  77008. MSGesture: MSGesture;
  77009. CANNON: any;
  77010. AudioContext: AudioContext;
  77011. webkitAudioContext: AudioContext;
  77012. PointerEvent: any;
  77013. Math: Math;
  77014. Uint8Array: Uint8ArrayConstructor;
  77015. Float32Array: Float32ArrayConstructor;
  77016. mozURL: typeof URL;
  77017. msURL: typeof URL;
  77018. VRFrameData: any; // WebVR, from specs 1.1
  77019. DracoDecoderModule: any;
  77020. setImmediate(handler: (...args: any[]) => void): number;
  77021. }
  77022. interface HTMLCanvasElement {
  77023. requestPointerLock(): void;
  77024. msRequestPointerLock?(): void;
  77025. mozRequestPointerLock?(): void;
  77026. webkitRequestPointerLock?(): void;
  77027. /** Track wether a record is in progress */
  77028. isRecording: boolean;
  77029. /** Capture Stream method defined by some browsers */
  77030. captureStream(fps?: number): MediaStream;
  77031. }
  77032. interface CanvasRenderingContext2D {
  77033. msImageSmoothingEnabled: boolean;
  77034. }
  77035. interface MouseEvent {
  77036. mozMovementX: number;
  77037. mozMovementY: number;
  77038. webkitMovementX: number;
  77039. webkitMovementY: number;
  77040. msMovementX: number;
  77041. msMovementY: number;
  77042. }
  77043. interface Navigator {
  77044. mozGetVRDevices: (any: any) => any;
  77045. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77046. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77047. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77048. webkitGetGamepads(): Gamepad[];
  77049. msGetGamepads(): Gamepad[];
  77050. webkitGamepads(): Gamepad[];
  77051. }
  77052. interface HTMLVideoElement {
  77053. mozSrcObject: any;
  77054. }
  77055. interface Math {
  77056. fround(x: number): number;
  77057. imul(a: number, b: number): number;
  77058. }
  77059. interface WebGLRenderingContext {
  77060. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77061. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77062. vertexAttribDivisor(index: number, divisor: number): void;
  77063. createVertexArray(): any;
  77064. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77065. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77066. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77067. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77068. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77069. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77070. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77071. // Queries
  77072. createQuery(): WebGLQuery;
  77073. deleteQuery(query: WebGLQuery): void;
  77074. beginQuery(target: number, query: WebGLQuery): void;
  77075. endQuery(target: number): void;
  77076. getQueryParameter(query: WebGLQuery, pname: number): any;
  77077. getQuery(target: number, pname: number): any;
  77078. MAX_SAMPLES: number;
  77079. RGBA8: number;
  77080. READ_FRAMEBUFFER: number;
  77081. DRAW_FRAMEBUFFER: number;
  77082. UNIFORM_BUFFER: number;
  77083. HALF_FLOAT_OES: number;
  77084. RGBA16F: number;
  77085. RGBA32F: number;
  77086. R32F: number;
  77087. RG32F: number;
  77088. RGB32F: number;
  77089. R16F: number;
  77090. RG16F: number;
  77091. RGB16F: number;
  77092. RED: number;
  77093. RG: number;
  77094. R8: number;
  77095. RG8: number;
  77096. UNSIGNED_INT_24_8: number;
  77097. DEPTH24_STENCIL8: number;
  77098. MIN: number;
  77099. MAX: number;
  77100. /* Multiple Render Targets */
  77101. drawBuffers(buffers: number[]): void;
  77102. readBuffer(src: number): void;
  77103. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77104. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77105. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77106. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77107. // Occlusion Query
  77108. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77109. ANY_SAMPLES_PASSED: number;
  77110. QUERY_RESULT_AVAILABLE: number;
  77111. QUERY_RESULT: number;
  77112. }
  77113. interface WebGLProgram {
  77114. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77115. }
  77116. interface EXT_disjoint_timer_query {
  77117. QUERY_COUNTER_BITS_EXT: number;
  77118. TIME_ELAPSED_EXT: number;
  77119. TIMESTAMP_EXT: number;
  77120. GPU_DISJOINT_EXT: number;
  77121. QUERY_RESULT_EXT: number;
  77122. QUERY_RESULT_AVAILABLE_EXT: number;
  77123. queryCounterEXT(query: WebGLQuery, target: number): void;
  77124. createQueryEXT(): WebGLQuery;
  77125. beginQueryEXT(target: number, query: WebGLQuery): void;
  77126. endQueryEXT(target: number): void;
  77127. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77128. deleteQueryEXT(query: WebGLQuery): void;
  77129. }
  77130. interface WebGLUniformLocation {
  77131. _currentState: any;
  77132. }
  77133. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77134. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77135. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77136. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77137. interface WebGLRenderingContext {
  77138. readonly RASTERIZER_DISCARD: number;
  77139. readonly DEPTH_COMPONENT24: number;
  77140. readonly TEXTURE_3D: number;
  77141. readonly TEXTURE_2D_ARRAY: number;
  77142. readonly TEXTURE_COMPARE_FUNC: number;
  77143. readonly TEXTURE_COMPARE_MODE: number;
  77144. readonly COMPARE_REF_TO_TEXTURE: number;
  77145. readonly TEXTURE_WRAP_R: number;
  77146. readonly HALF_FLOAT: number;
  77147. readonly RGB8: number;
  77148. readonly RED_INTEGER: number;
  77149. readonly RG_INTEGER: number;
  77150. readonly RGB_INTEGER: number;
  77151. readonly RGBA_INTEGER: number;
  77152. readonly R8_SNORM: number;
  77153. readonly RG8_SNORM: number;
  77154. readonly RGB8_SNORM: number;
  77155. readonly RGBA8_SNORM: number;
  77156. readonly R8I: number;
  77157. readonly RG8I: number;
  77158. readonly RGB8I: number;
  77159. readonly RGBA8I: number;
  77160. readonly R8UI: number;
  77161. readonly RG8UI: number;
  77162. readonly RGB8UI: number;
  77163. readonly RGBA8UI: number;
  77164. readonly R16I: number;
  77165. readonly RG16I: number;
  77166. readonly RGB16I: number;
  77167. readonly RGBA16I: number;
  77168. readonly R16UI: number;
  77169. readonly RG16UI: number;
  77170. readonly RGB16UI: number;
  77171. readonly RGBA16UI: number;
  77172. readonly R32I: number;
  77173. readonly RG32I: number;
  77174. readonly RGB32I: number;
  77175. readonly RGBA32I: number;
  77176. readonly R32UI: number;
  77177. readonly RG32UI: number;
  77178. readonly RGB32UI: number;
  77179. readonly RGBA32UI: number;
  77180. readonly RGB10_A2UI: number;
  77181. readonly R11F_G11F_B10F: number;
  77182. readonly RGB9_E5: number;
  77183. readonly RGB10_A2: number;
  77184. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77185. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77186. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77187. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77188. readonly DEPTH_COMPONENT32F: number;
  77189. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77190. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77191. 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;
  77192. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77193. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77194. readonly TRANSFORM_FEEDBACK: number;
  77195. readonly INTERLEAVED_ATTRIBS: number;
  77196. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77197. createTransformFeedback(): WebGLTransformFeedback;
  77198. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77199. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77200. beginTransformFeedback(primitiveMode: number): void;
  77201. endTransformFeedback(): void;
  77202. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77203. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77204. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77205. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77206. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77207. }
  77208. interface ImageBitmap {
  77209. readonly width: number;
  77210. readonly height: number;
  77211. close(): void;
  77212. }
  77213. interface WebGLQuery extends WebGLObject {
  77214. }
  77215. declare var WebGLQuery: {
  77216. prototype: WebGLQuery;
  77217. new(): WebGLQuery;
  77218. };
  77219. interface WebGLSampler extends WebGLObject {
  77220. }
  77221. declare var WebGLSampler: {
  77222. prototype: WebGLSampler;
  77223. new(): WebGLSampler;
  77224. };
  77225. interface WebGLSync extends WebGLObject {
  77226. }
  77227. declare var WebGLSync: {
  77228. prototype: WebGLSync;
  77229. new(): WebGLSync;
  77230. };
  77231. interface WebGLTransformFeedback extends WebGLObject {
  77232. }
  77233. declare var WebGLTransformFeedback: {
  77234. prototype: WebGLTransformFeedback;
  77235. new(): WebGLTransformFeedback;
  77236. };
  77237. interface WebGLVertexArrayObject extends WebGLObject {
  77238. }
  77239. declare var WebGLVertexArrayObject: {
  77240. prototype: WebGLVertexArrayObject;
  77241. new(): WebGLVertexArrayObject;
  77242. };
  77243. // Type definitions for WebVR API
  77244. // Project: https://w3c.github.io/webvr/
  77245. // Definitions by: six a <https://github.com/lostfictions>
  77246. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77247. interface VRDisplay extends EventTarget {
  77248. /**
  77249. * Dictionary of capabilities describing the VRDisplay.
  77250. */
  77251. readonly capabilities: VRDisplayCapabilities;
  77252. /**
  77253. * z-depth defining the far plane of the eye view frustum
  77254. * enables mapping of values in the render target depth
  77255. * attachment to scene coordinates. Initially set to 10000.0.
  77256. */
  77257. depthFar: number;
  77258. /**
  77259. * z-depth defining the near plane of the eye view frustum
  77260. * enables mapping of values in the render target depth
  77261. * attachment to scene coordinates. Initially set to 0.01.
  77262. */
  77263. depthNear: number;
  77264. /**
  77265. * An identifier for this distinct VRDisplay. Used as an
  77266. * association point in the Gamepad API.
  77267. */
  77268. readonly displayId: number;
  77269. /**
  77270. * A display name, a user-readable name identifying it.
  77271. */
  77272. readonly displayName: string;
  77273. readonly isConnected: boolean;
  77274. readonly isPresenting: boolean;
  77275. /**
  77276. * If this VRDisplay supports room-scale experiences, the optional
  77277. * stage attribute contains details on the room-scale parameters.
  77278. */
  77279. readonly stageParameters: VRStageParameters | null;
  77280. /**
  77281. * Passing the value returned by `requestAnimationFrame` to
  77282. * `cancelAnimationFrame` will unregister the callback.
  77283. * @param handle Define the hanle of the request to cancel
  77284. */
  77285. cancelAnimationFrame(handle: number): void;
  77286. /**
  77287. * Stops presenting to the VRDisplay.
  77288. * @returns a promise to know when it stopped
  77289. */
  77290. exitPresent(): Promise<void>;
  77291. /**
  77292. * Return the current VREyeParameters for the given eye.
  77293. * @param whichEye Define the eye we want the parameter for
  77294. * @returns the eye parameters
  77295. */
  77296. getEyeParameters(whichEye: string): VREyeParameters;
  77297. /**
  77298. * Populates the passed VRFrameData with the information required to render
  77299. * the current frame.
  77300. * @param frameData Define the data structure to populate
  77301. * @returns true if ok otherwise false
  77302. */
  77303. getFrameData(frameData: VRFrameData): boolean;
  77304. /**
  77305. * Get the layers currently being presented.
  77306. * @returns the list of VR layers
  77307. */
  77308. getLayers(): VRLayer[];
  77309. /**
  77310. * Return a VRPose containing the future predicted pose of the VRDisplay
  77311. * when the current frame will be presented. The value returned will not
  77312. * change until JavaScript has returned control to the browser.
  77313. *
  77314. * The VRPose will contain the position, orientation, velocity,
  77315. * and acceleration of each of these properties.
  77316. * @returns the pose object
  77317. */
  77318. getPose(): VRPose;
  77319. /**
  77320. * Return the current instantaneous pose of the VRDisplay, with no
  77321. * prediction applied.
  77322. * @returns the current instantaneous pose
  77323. */
  77324. getImmediatePose(): VRPose;
  77325. /**
  77326. * The callback passed to `requestAnimationFrame` will be called
  77327. * any time a new frame should be rendered. When the VRDisplay is
  77328. * presenting the callback will be called at the native refresh
  77329. * rate of the HMD. When not presenting this function acts
  77330. * identically to how window.requestAnimationFrame acts. Content should
  77331. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77332. * asynchronously from other displays and at differing refresh rates.
  77333. * @param callback Define the eaction to run next frame
  77334. * @returns the request handle it
  77335. */
  77336. requestAnimationFrame(callback: FrameRequestCallback): number;
  77337. /**
  77338. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77339. * Repeat calls while already presenting will update the VRLayers being displayed.
  77340. * @param layers Define the list of layer to present
  77341. * @returns a promise to know when the request has been fulfilled
  77342. */
  77343. requestPresent(layers: VRLayer[]): Promise<void>;
  77344. /**
  77345. * Reset the pose for this display, treating its current position and
  77346. * orientation as the "origin/zero" values. VRPose.position,
  77347. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77348. * updated when calling resetPose(). This should be called in only
  77349. * sitting-space experiences.
  77350. */
  77351. resetPose(): void;
  77352. /**
  77353. * The VRLayer provided to the VRDisplay will be captured and presented
  77354. * in the HMD. Calling this function has the same effect on the source
  77355. * canvas as any other operation that uses its source image, and canvases
  77356. * created without preserveDrawingBuffer set to true will be cleared.
  77357. * @param pose Define the pose to submit
  77358. */
  77359. submitFrame(pose?: VRPose): void;
  77360. }
  77361. declare var VRDisplay: {
  77362. prototype: VRDisplay;
  77363. new(): VRDisplay;
  77364. };
  77365. interface VRLayer {
  77366. leftBounds?: number[] | Float32Array | null;
  77367. rightBounds?: number[] | Float32Array | null;
  77368. source?: HTMLCanvasElement | null;
  77369. }
  77370. interface VRDisplayCapabilities {
  77371. readonly canPresent: boolean;
  77372. readonly hasExternalDisplay: boolean;
  77373. readonly hasOrientation: boolean;
  77374. readonly hasPosition: boolean;
  77375. readonly maxLayers: number;
  77376. }
  77377. interface VREyeParameters {
  77378. /** @deprecated */
  77379. readonly fieldOfView: VRFieldOfView;
  77380. readonly offset: Float32Array;
  77381. readonly renderHeight: number;
  77382. readonly renderWidth: number;
  77383. }
  77384. interface VRFieldOfView {
  77385. readonly downDegrees: number;
  77386. readonly leftDegrees: number;
  77387. readonly rightDegrees: number;
  77388. readonly upDegrees: number;
  77389. }
  77390. interface VRFrameData {
  77391. readonly leftProjectionMatrix: Float32Array;
  77392. readonly leftViewMatrix: Float32Array;
  77393. readonly pose: VRPose;
  77394. readonly rightProjectionMatrix: Float32Array;
  77395. readonly rightViewMatrix: Float32Array;
  77396. readonly timestamp: number;
  77397. }
  77398. interface VRPose {
  77399. readonly angularAcceleration: Float32Array | null;
  77400. readonly angularVelocity: Float32Array | null;
  77401. readonly linearAcceleration: Float32Array | null;
  77402. readonly linearVelocity: Float32Array | null;
  77403. readonly orientation: Float32Array | null;
  77404. readonly position: Float32Array | null;
  77405. readonly timestamp: number;
  77406. }
  77407. interface VRStageParameters {
  77408. sittingToStandingTransform?: Float32Array;
  77409. sizeX?: number;
  77410. sizeY?: number;
  77411. }
  77412. interface Navigator {
  77413. getVRDisplays(): Promise<VRDisplay[]>;
  77414. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77415. }
  77416. interface Window {
  77417. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77418. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77419. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77420. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77421. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77422. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77423. }
  77424. interface Gamepad {
  77425. readonly displayId: number;
  77426. }
  77427. /**
  77428. * Available session modes
  77429. */
  77430. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77431. /**
  77432. * Reference space types
  77433. */
  77434. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77435. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77436. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77437. /**
  77438. * Handedness types
  77439. */
  77440. type XRHandedness = "none" | "left" | "right";
  77441. /**
  77442. * InputSource target ray modes
  77443. */
  77444. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77445. /**
  77446. * Eye types
  77447. */
  77448. type XREye = "none" | "left" | "right";
  77449. /**
  77450. * Type of XR events available
  77451. */
  77452. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77453. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77454. type XRPlaneSet = Set<XRPlane>;
  77455. type XRAnchorSet = Set<XRAnchor>;
  77456. type XREventHandler = (callback: any) => void;
  77457. interface XRLayer extends EventTarget {}
  77458. interface XRSessionInit {
  77459. optionalFeatures?: string[];
  77460. requiredFeatures?: string[];
  77461. }
  77462. interface XRSessionEvent extends Event {
  77463. readonly session: XRSession;
  77464. }
  77465. interface XRSystem {
  77466. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77467. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77468. }
  77469. interface XRViewport {
  77470. readonly x: number;
  77471. readonly y: number;
  77472. readonly width: number;
  77473. readonly height: number;
  77474. }
  77475. interface XRWebGLLayerInit {
  77476. antialias?: boolean;
  77477. depth?: boolean;
  77478. stencil?: boolean;
  77479. alpha?: boolean;
  77480. multiview?: boolean;
  77481. framebufferScaleFactor?: number;
  77482. }
  77483. declare class XRWebGLLayer {
  77484. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77485. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77486. readonly antialias: boolean;
  77487. readonly framebuffer: WebGLFramebuffer;
  77488. readonly framebufferWidth: number;
  77489. readonly framebufferHeight: number;
  77490. readonly ignoreDepthValues: boolean;
  77491. getViewport: (view: XRView) => XRViewport;
  77492. }
  77493. // tslint:disable-next-line no-empty-interface
  77494. interface XRSpace extends EventTarget {}
  77495. interface XRRenderState {
  77496. readonly baseLayer?: XRWebGLLayer;
  77497. readonly depthFar: number;
  77498. readonly depthNear: number;
  77499. readonly inlineVerticalFieldOfView?: number;
  77500. }
  77501. interface XRRenderStateInit extends XRRenderState {
  77502. baseLayer: XRWebGLLayer;
  77503. depthFar: number;
  77504. depthNear: number;
  77505. inlineVerticalFieldOfView?: number;
  77506. layers?: XRLayer[];
  77507. }
  77508. interface XRReferenceSpace extends XRSpace {
  77509. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77510. onreset: XREventHandler;
  77511. }
  77512. interface XRBoundedReferenceSpace extends XRSpace {
  77513. readonly boundsGeometry: DOMPointReadOnly[];
  77514. }
  77515. interface XRInputSource {
  77516. readonly handedness: XRHandedness;
  77517. readonly targetRayMode: XRTargetRayMode;
  77518. readonly targetRaySpace: XRSpace;
  77519. readonly gripSpace?: XRSpace;
  77520. readonly gamepad?: Gamepad;
  77521. readonly profiles: Array<string>;
  77522. readonly hand?: XRHand;
  77523. }
  77524. interface XRPose {
  77525. readonly transform: XRRigidTransform;
  77526. readonly emulatedPosition: boolean;
  77527. }
  77528. interface XRFrame {
  77529. readonly session: XRSession;
  77530. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77531. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77532. // AR
  77533. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77534. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77535. // Anchors
  77536. trackedAnchors?: XRAnchorSet;
  77537. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77538. // Planes
  77539. worldInformation?: {
  77540. detectedPlanes?: XRPlaneSet;
  77541. };
  77542. // Hand tracking
  77543. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77544. }
  77545. interface XRInputSourceEvent extends Event {
  77546. readonly frame: XRFrame;
  77547. readonly inputSource: XRInputSource;
  77548. }
  77549. type XRInputSourceArray = XRInputSource[];
  77550. interface XRSession {
  77551. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77552. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77553. /**
  77554. * Returns a list of this session's XRInputSources, each representing an input device
  77555. * used to control the camera and/or scene.
  77556. */
  77557. readonly inputSources: Array<XRInputSource>;
  77558. /**
  77559. * object which contains options affecting how the imagery is rendered.
  77560. * This includes things such as the near and far clipping planes
  77561. */
  77562. readonly renderState: XRRenderState;
  77563. readonly visibilityState: XRVisibilityState;
  77564. /**
  77565. * Removes a callback from the animation frame painting callback from
  77566. * XRSession's set of animation frame rendering callbacks, given the
  77567. * identifying handle returned by a previous call to requestAnimationFrame().
  77568. */
  77569. cancelAnimationFrame: (handle: number) => void;
  77570. /**
  77571. * Ends the WebXR session. Returns a promise which resolves when the
  77572. * session has been shut down.
  77573. */
  77574. end(): Promise<void>;
  77575. /**
  77576. * Schedules the specified method to be called the next time the user agent
  77577. * is working on rendering an animation frame for the WebXR device. Returns an
  77578. * integer value which can be used to identify the request for the purposes of
  77579. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77580. * to the Window.requestAnimationFrame() method.
  77581. */
  77582. requestAnimationFrame: XRFrameRequestCallback;
  77583. /**
  77584. * Requests that a new XRReferenceSpace of the specified type be created.
  77585. * Returns a promise which resolves with the XRReferenceSpace or
  77586. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77587. * the requested space type isn't supported by the device.
  77588. */
  77589. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77590. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77591. onend: XREventHandler;
  77592. oninputsourceschange: XREventHandler;
  77593. onselect: XREventHandler;
  77594. onselectstart: XREventHandler;
  77595. onselectend: XREventHandler;
  77596. onsqueeze: XREventHandler;
  77597. onsqueezestart: XREventHandler;
  77598. onsqueezeend: XREventHandler;
  77599. onvisibilitychange: XREventHandler;
  77600. // hit test
  77601. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77602. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77603. // legacy AR hit test
  77604. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77605. // legacy plane detection
  77606. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77607. }
  77608. interface XRViewerPose extends XRPose {
  77609. readonly views: Array<XRView>;
  77610. }
  77611. declare class XRRigidTransform {
  77612. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77613. position: DOMPointReadOnly;
  77614. orientation: DOMPointReadOnly;
  77615. matrix: Float32Array;
  77616. inverse: XRRigidTransform;
  77617. }
  77618. interface XRView {
  77619. readonly eye: XREye;
  77620. readonly projectionMatrix: Float32Array;
  77621. readonly transform: XRRigidTransform;
  77622. readonly recommendedViewportScale?: number;
  77623. requestViewportScale(scale: number): void;
  77624. }
  77625. interface XRInputSourceChangeEvent extends Event {
  77626. session: XRSession;
  77627. removed: Array<XRInputSource>;
  77628. added: Array<XRInputSource>;
  77629. }
  77630. // Experimental/Draft features
  77631. declare class XRRay {
  77632. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77633. origin: DOMPointReadOnly;
  77634. direction: DOMPointReadOnly;
  77635. matrix: Float32Array;
  77636. }
  77637. declare enum XRHitTestTrackableType {
  77638. "point",
  77639. "plane",
  77640. "mesh",
  77641. }
  77642. interface XRHitResult {
  77643. hitMatrix: Float32Array;
  77644. }
  77645. interface XRTransientInputHitTestResult {
  77646. readonly inputSource: XRInputSource;
  77647. readonly results: Array<XRHitTestResult>;
  77648. }
  77649. interface XRHitTestResult {
  77650. getPose(baseSpace: XRSpace): XRPose | undefined;
  77651. // When anchor system is enabled
  77652. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77653. }
  77654. interface XRHitTestSource {
  77655. cancel(): void;
  77656. }
  77657. interface XRTransientInputHitTestSource {
  77658. cancel(): void;
  77659. }
  77660. interface XRHitTestOptionsInit {
  77661. space: XRSpace;
  77662. entityTypes?: Array<XRHitTestTrackableType>;
  77663. offsetRay?: XRRay;
  77664. }
  77665. interface XRTransientInputHitTestOptionsInit {
  77666. profile: string;
  77667. entityTypes?: Array<XRHitTestTrackableType>;
  77668. offsetRay?: XRRay;
  77669. }
  77670. interface XRAnchor {
  77671. anchorSpace: XRSpace;
  77672. delete(): void;
  77673. }
  77674. interface XRPlane {
  77675. orientation: "Horizontal" | "Vertical";
  77676. planeSpace: XRSpace;
  77677. polygon: Array<DOMPointReadOnly>;
  77678. lastChangedTime: number;
  77679. }
  77680. interface XRJointSpace extends XRSpace {}
  77681. interface XRJointPose extends XRPose {
  77682. radius: number | undefined;
  77683. }
  77684. interface XRHand extends Iterable<XRJointSpace> {
  77685. readonly length: number;
  77686. [index: number]: XRJointSpace;
  77687. readonly WRIST: number;
  77688. readonly THUMB_METACARPAL: number;
  77689. readonly THUMB_PHALANX_PROXIMAL: number;
  77690. readonly THUMB_PHALANX_DISTAL: number;
  77691. readonly THUMB_PHALANX_TIP: number;
  77692. readonly INDEX_METACARPAL: number;
  77693. readonly INDEX_PHALANX_PROXIMAL: number;
  77694. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77695. readonly INDEX_PHALANX_DISTAL: number;
  77696. readonly INDEX_PHALANX_TIP: number;
  77697. readonly MIDDLE_METACARPAL: number;
  77698. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77699. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77700. readonly MIDDLE_PHALANX_DISTAL: number;
  77701. readonly MIDDLE_PHALANX_TIP: number;
  77702. readonly RING_METACARPAL: number;
  77703. readonly RING_PHALANX_PROXIMAL: number;
  77704. readonly RING_PHALANX_INTERMEDIATE: number;
  77705. readonly RING_PHALANX_DISTAL: number;
  77706. readonly RING_PHALANX_TIP: number;
  77707. readonly LITTLE_METACARPAL: number;
  77708. readonly LITTLE_PHALANX_PROXIMAL: number;
  77709. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77710. readonly LITTLE_PHALANX_DISTAL: number;
  77711. readonly LITTLE_PHALANX_TIP: number;
  77712. }
  77713. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77714. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77715. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77716. interface XRSession {
  77717. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77718. }
  77719. interface XRFrame {
  77720. featurePointCloud? : Array<number>;
  77721. }
  77722. /**
  77723. * @ignore
  77724. */
  77725. declare module BABYLON.GLTF2.Exporter {
  77726. }
  77727. /**
  77728. * @ignore
  77729. */
  77730. declare module BABYLON.GLTF1 {
  77731. }
  77732. declare module BABYLON.GUI {
  77733. /**
  77734. * Class used to specific a value and its associated unit
  77735. */
  77736. export class ValueAndUnit {
  77737. /** defines the unit to store */
  77738. unit: number;
  77739. /** defines a boolean indicating if the value can be negative */
  77740. negativeValueAllowed: boolean;
  77741. private _value;
  77742. private _originalUnit;
  77743. /**
  77744. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77745. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77746. */
  77747. ignoreAdaptiveScaling: boolean;
  77748. /**
  77749. * Creates a new ValueAndUnit
  77750. * @param value defines the value to store
  77751. * @param unit defines the unit to store
  77752. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77753. */
  77754. constructor(value: number,
  77755. /** defines the unit to store */
  77756. unit?: number,
  77757. /** defines a boolean indicating if the value can be negative */
  77758. negativeValueAllowed?: boolean);
  77759. /** Gets a boolean indicating if the value is a percentage */
  77760. get isPercentage(): boolean;
  77761. /** Gets a boolean indicating if the value is store as pixel */
  77762. get isPixel(): boolean;
  77763. /** Gets direct internal value */
  77764. get internalValue(): number;
  77765. /**
  77766. * Gets value as pixel
  77767. * @param host defines the root host
  77768. * @param refValue defines the reference value for percentages
  77769. * @returns the value as pixel
  77770. */
  77771. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77772. /**
  77773. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77774. * @param value defines the value to store
  77775. * @param unit defines the unit to store
  77776. * @returns the current ValueAndUnit
  77777. */
  77778. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77779. /**
  77780. * Gets the value accordingly to its unit
  77781. * @param host defines the root host
  77782. * @returns the value
  77783. */
  77784. getValue(host: AdvancedDynamicTexture): number;
  77785. /**
  77786. * Gets a string representation of the value
  77787. * @param host defines the root host
  77788. * @param decimals defines an optional number of decimals to display
  77789. * @returns a string
  77790. */
  77791. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77792. /**
  77793. * Store a value parsed from a string
  77794. * @param source defines the source string
  77795. * @returns true if the value was successfully parsed
  77796. */
  77797. fromString(source: string | number): boolean;
  77798. private static _Regex;
  77799. private static _UNITMODE_PERCENTAGE;
  77800. private static _UNITMODE_PIXEL;
  77801. /** UNITMODE_PERCENTAGE */
  77802. static get UNITMODE_PERCENTAGE(): number;
  77803. /** UNITMODE_PIXEL */
  77804. static get UNITMODE_PIXEL(): number;
  77805. }
  77806. }
  77807. declare module BABYLON.GUI {
  77808. /**
  77809. * Define a style used by control to automatically setup properties based on a template.
  77810. * Only support font related properties so far
  77811. */
  77812. export class Style implements BABYLON.IDisposable {
  77813. private _fontFamily;
  77814. private _fontStyle;
  77815. private _fontWeight;
  77816. /** @hidden */
  77817. _host: AdvancedDynamicTexture;
  77818. /** @hidden */
  77819. _fontSize: ValueAndUnit;
  77820. /**
  77821. * BABYLON.Observable raised when the style values are changed
  77822. */
  77823. onChangedObservable: BABYLON.Observable<Style>;
  77824. /**
  77825. * Creates a new style object
  77826. * @param host defines the AdvancedDynamicTexture which hosts this style
  77827. */
  77828. constructor(host: AdvancedDynamicTexture);
  77829. /**
  77830. * Gets or sets the font size
  77831. */
  77832. get fontSize(): string | number;
  77833. set fontSize(value: string | number);
  77834. /**
  77835. * Gets or sets the font family
  77836. */
  77837. get fontFamily(): string;
  77838. set fontFamily(value: string);
  77839. /**
  77840. * Gets or sets the font style
  77841. */
  77842. get fontStyle(): string;
  77843. set fontStyle(value: string);
  77844. /** Gets or sets font weight */
  77845. get fontWeight(): string;
  77846. set fontWeight(value: string);
  77847. /** Dispose all associated resources */
  77848. dispose(): void;
  77849. }
  77850. }
  77851. declare module BABYLON.GUI {
  77852. /**
  77853. * Class used to transport BABYLON.Vector2 information for pointer events
  77854. */
  77855. export class Vector2WithInfo extends BABYLON.Vector2 {
  77856. /** defines the current mouse button index */
  77857. buttonIndex: number;
  77858. /**
  77859. * Creates a new Vector2WithInfo
  77860. * @param source defines the vector2 data to transport
  77861. * @param buttonIndex defines the current mouse button index
  77862. */
  77863. constructor(source: BABYLON.Vector2,
  77864. /** defines the current mouse button index */
  77865. buttonIndex?: number);
  77866. }
  77867. /** Class used to provide 2D matrix features */
  77868. export class Matrix2D {
  77869. /** Gets the internal array of 6 floats used to store matrix data */
  77870. m: Float32Array;
  77871. /**
  77872. * Creates a new matrix
  77873. * @param m00 defines value for (0, 0)
  77874. * @param m01 defines value for (0, 1)
  77875. * @param m10 defines value for (1, 0)
  77876. * @param m11 defines value for (1, 1)
  77877. * @param m20 defines value for (2, 0)
  77878. * @param m21 defines value for (2, 1)
  77879. */
  77880. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77881. /**
  77882. * Fills the matrix from direct values
  77883. * @param m00 defines value for (0, 0)
  77884. * @param m01 defines value for (0, 1)
  77885. * @param m10 defines value for (1, 0)
  77886. * @param m11 defines value for (1, 1)
  77887. * @param m20 defines value for (2, 0)
  77888. * @param m21 defines value for (2, 1)
  77889. * @returns the current modified matrix
  77890. */
  77891. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77892. /**
  77893. * Gets matrix determinant
  77894. * @returns the determinant
  77895. */
  77896. determinant(): number;
  77897. /**
  77898. * Inverses the matrix and stores it in a target matrix
  77899. * @param result defines the target matrix
  77900. * @returns the current matrix
  77901. */
  77902. invertToRef(result: Matrix2D): Matrix2D;
  77903. /**
  77904. * Multiplies the current matrix with another one
  77905. * @param other defines the second operand
  77906. * @param result defines the target matrix
  77907. * @returns the current matrix
  77908. */
  77909. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77910. /**
  77911. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77912. * @param x defines the x coordinate to transform
  77913. * @param y defines the x coordinate to transform
  77914. * @param result defines the target vector2
  77915. * @returns the current matrix
  77916. */
  77917. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77918. /**
  77919. * Creates an identity matrix
  77920. * @returns a new matrix
  77921. */
  77922. static Identity(): Matrix2D;
  77923. /**
  77924. * Creates a translation matrix and stores it in a target matrix
  77925. * @param x defines the x coordinate of the translation
  77926. * @param y defines the y coordinate of the translation
  77927. * @param result defines the target matrix
  77928. */
  77929. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77930. /**
  77931. * Creates a scaling matrix and stores it in a target matrix
  77932. * @param x defines the x coordinate of the scaling
  77933. * @param y defines the y coordinate of the scaling
  77934. * @param result defines the target matrix
  77935. */
  77936. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77937. /**
  77938. * Creates a rotation matrix and stores it in a target matrix
  77939. * @param angle defines the rotation angle
  77940. * @param result defines the target matrix
  77941. */
  77942. static RotationToRef(angle: number, result: Matrix2D): void;
  77943. private static _TempPreTranslationMatrix;
  77944. private static _TempPostTranslationMatrix;
  77945. private static _TempRotationMatrix;
  77946. private static _TempScalingMatrix;
  77947. private static _TempCompose0;
  77948. private static _TempCompose1;
  77949. private static _TempCompose2;
  77950. /**
  77951. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77952. * @param tx defines the x coordinate of the translation
  77953. * @param ty defines the y coordinate of the translation
  77954. * @param angle defines the rotation angle
  77955. * @param scaleX defines the x coordinate of the scaling
  77956. * @param scaleY defines the y coordinate of the scaling
  77957. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77958. * @param result defines the target matrix
  77959. */
  77960. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77961. }
  77962. }
  77963. declare module BABYLON.GUI {
  77964. /**
  77965. * Class used to store 2D control sizes
  77966. */
  77967. export class Measure {
  77968. /** defines left coordinate */
  77969. left: number;
  77970. /** defines top coordinate */
  77971. top: number;
  77972. /** defines width dimension */
  77973. width: number;
  77974. /** defines height dimension */
  77975. height: number;
  77976. /**
  77977. * Creates a new measure
  77978. * @param left defines left coordinate
  77979. * @param top defines top coordinate
  77980. * @param width defines width dimension
  77981. * @param height defines height dimension
  77982. */
  77983. constructor(
  77984. /** defines left coordinate */
  77985. left: number,
  77986. /** defines top coordinate */
  77987. top: number,
  77988. /** defines width dimension */
  77989. width: number,
  77990. /** defines height dimension */
  77991. height: number);
  77992. /**
  77993. * Copy from another measure
  77994. * @param other defines the other measure to copy from
  77995. */
  77996. copyFrom(other: Measure): void;
  77997. /**
  77998. * Copy from a group of 4 floats
  77999. * @param left defines left coordinate
  78000. * @param top defines top coordinate
  78001. * @param width defines width dimension
  78002. * @param height defines height dimension
  78003. */
  78004. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78005. /**
  78006. * Computes the axis aligned bounding box measure for two given measures
  78007. * @param a Input measure
  78008. * @param b Input measure
  78009. * @param result the resulting bounding measure
  78010. */
  78011. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78012. /**
  78013. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78014. * @param transform the matrix to transform the measure before computing the AABB
  78015. * @param addX number to add to left
  78016. * @param addY number to add to top
  78017. * @param addWidth number to add to width
  78018. * @param addHeight number to add to height
  78019. * @param result the resulting AABB
  78020. */
  78021. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78022. /**
  78023. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78024. * @param transform the matrix to transform the measure before computing the AABB
  78025. * @param result the resulting AABB
  78026. */
  78027. transformToRef(transform: Matrix2D, result: Measure): void;
  78028. /**
  78029. * Check equality between this measure and another one
  78030. * @param other defines the other measures
  78031. * @returns true if both measures are equals
  78032. */
  78033. isEqualsTo(other: Measure): boolean;
  78034. /**
  78035. * Creates an empty measure
  78036. * @returns a new measure
  78037. */
  78038. static Empty(): Measure;
  78039. }
  78040. }
  78041. declare module BABYLON.GUI {
  78042. /**
  78043. * Interface used to define a control that can receive focus
  78044. */
  78045. export interface IFocusableControl {
  78046. /**
  78047. * Function called when the control receives the focus
  78048. */
  78049. onFocus(): void;
  78050. /**
  78051. * Function called when the control loses the focus
  78052. */
  78053. onBlur(): void;
  78054. /**
  78055. * Function called to let the control handle keyboard events
  78056. * @param evt defines the current keyboard event
  78057. */
  78058. processKeyboard(evt: KeyboardEvent): void;
  78059. /**
  78060. * Function called to get the list of controls that should not steal the focus from this control
  78061. * @returns an array of controls
  78062. */
  78063. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78064. }
  78065. /**
  78066. * Class used to create texture to support 2D GUI elements
  78067. * @see https://doc.babylonjs.com/how_to/gui
  78068. */
  78069. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78070. private _isDirty;
  78071. private _renderObserver;
  78072. private _resizeObserver;
  78073. private _preKeyboardObserver;
  78074. private _pointerMoveObserver;
  78075. private _pointerObserver;
  78076. private _canvasPointerOutObserver;
  78077. private _canvasBlurObserver;
  78078. private _background;
  78079. /** @hidden */
  78080. _rootContainer: Container;
  78081. /** @hidden */
  78082. _lastPickedControl: Control;
  78083. /** @hidden */
  78084. _lastControlOver: {
  78085. [pointerId: number]: Control;
  78086. };
  78087. /** @hidden */
  78088. _lastControlDown: {
  78089. [pointerId: number]: Control;
  78090. };
  78091. /** @hidden */
  78092. _capturingControl: {
  78093. [pointerId: number]: Control;
  78094. };
  78095. /** @hidden */
  78096. _shouldBlockPointer: boolean;
  78097. /** @hidden */
  78098. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78099. /** @hidden */
  78100. _linkedControls: Control[];
  78101. private _isFullscreen;
  78102. private _fullscreenViewport;
  78103. private _idealWidth;
  78104. private _idealHeight;
  78105. private _useSmallestIdeal;
  78106. private _renderAtIdealSize;
  78107. private _focusedControl;
  78108. private _blockNextFocusCheck;
  78109. private _renderScale;
  78110. private _rootElement;
  78111. private _cursorChanged;
  78112. private _defaultMousePointerId;
  78113. /** @hidden */
  78114. _numLayoutCalls: number;
  78115. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78116. get numLayoutCalls(): number;
  78117. /** @hidden */
  78118. _numRenderCalls: number;
  78119. /** Gets the number of render calls made the last time the ADT has been rendered */
  78120. get numRenderCalls(): number;
  78121. /**
  78122. * Define type to string to ensure compatibility across browsers
  78123. * Safari doesn't support DataTransfer constructor
  78124. */
  78125. private _clipboardData;
  78126. /**
  78127. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78128. */
  78129. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78130. /**
  78131. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78132. */
  78133. onControlPickedObservable: BABYLON.Observable<Control>;
  78134. /**
  78135. * BABYLON.Observable event triggered before layout is evaluated
  78136. */
  78137. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78138. /**
  78139. * BABYLON.Observable event triggered after the layout was evaluated
  78140. */
  78141. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78142. /**
  78143. * BABYLON.Observable event triggered before the texture is rendered
  78144. */
  78145. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78146. /**
  78147. * BABYLON.Observable event triggered after the texture was rendered
  78148. */
  78149. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78150. /**
  78151. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78152. */
  78153. premulAlpha: boolean;
  78154. /**
  78155. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78156. * Useful when you want more antialiasing
  78157. */
  78158. get renderScale(): number;
  78159. set renderScale(value: number);
  78160. /** Gets or sets the background color */
  78161. get background(): string;
  78162. set background(value: string);
  78163. /**
  78164. * Gets or sets the ideal width used to design controls.
  78165. * The GUI will then rescale everything accordingly
  78166. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78167. */
  78168. get idealWidth(): number;
  78169. set idealWidth(value: number);
  78170. /**
  78171. * Gets or sets the ideal height used to design controls.
  78172. * The GUI will then rescale everything accordingly
  78173. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78174. */
  78175. get idealHeight(): number;
  78176. set idealHeight(value: number);
  78177. /**
  78178. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78179. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78180. */
  78181. get useSmallestIdeal(): boolean;
  78182. set useSmallestIdeal(value: boolean);
  78183. /**
  78184. * Gets or sets a boolean indicating if adaptive scaling must be used
  78185. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78186. */
  78187. get renderAtIdealSize(): boolean;
  78188. set renderAtIdealSize(value: boolean);
  78189. /**
  78190. * Gets the ratio used when in "ideal mode"
  78191. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78192. * */
  78193. get idealRatio(): number;
  78194. /**
  78195. * Gets the underlying layer used to render the texture when in fullscreen mode
  78196. */
  78197. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78198. /**
  78199. * Gets the root container control
  78200. */
  78201. get rootContainer(): Container;
  78202. /**
  78203. * Returns an array containing the root container.
  78204. * This is mostly used to let the Inspector introspects the ADT
  78205. * @returns an array containing the rootContainer
  78206. */
  78207. getChildren(): Array<Container>;
  78208. /**
  78209. * Will return all controls that are inside this texture
  78210. * @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
  78211. * @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
  78212. * @return all child controls
  78213. */
  78214. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78215. /**
  78216. * Gets or sets the current focused control
  78217. */
  78218. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78219. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78220. /**
  78221. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78222. */
  78223. get isForeground(): boolean;
  78224. set isForeground(value: boolean);
  78225. /**
  78226. * Gets or set information about clipboardData
  78227. */
  78228. get clipboardData(): string;
  78229. set clipboardData(value: string);
  78230. /**
  78231. * Creates a new AdvancedDynamicTexture
  78232. * @param name defines the name of the texture
  78233. * @param width defines the width of the texture
  78234. * @param height defines the height of the texture
  78235. * @param scene defines the hosting scene
  78236. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78237. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78238. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78239. */
  78240. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78241. /**
  78242. * Get the current class name of the texture useful for serialization or dynamic coding.
  78243. * @returns "AdvancedDynamicTexture"
  78244. */
  78245. getClassName(): string;
  78246. /**
  78247. * Function used to execute a function on all controls
  78248. * @param func defines the function to execute
  78249. * @param container defines the container where controls belong. If null the root container will be used
  78250. */
  78251. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78252. private _useInvalidateRectOptimization;
  78253. /**
  78254. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78255. */
  78256. get useInvalidateRectOptimization(): boolean;
  78257. set useInvalidateRectOptimization(value: boolean);
  78258. private _invalidatedRectangle;
  78259. /**
  78260. * Invalidates a rectangle area on the gui texture
  78261. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78262. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78263. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78264. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78265. */
  78266. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78267. /**
  78268. * Marks the texture as dirty forcing a complete update
  78269. */
  78270. markAsDirty(): void;
  78271. /**
  78272. * Helper function used to create a new style
  78273. * @returns a new style
  78274. * @see https://doc.babylonjs.com/how_to/gui#styles
  78275. */
  78276. createStyle(): Style;
  78277. /**
  78278. * Adds a new control to the root container
  78279. * @param control defines the control to add
  78280. * @returns the current texture
  78281. */
  78282. addControl(control: Control): AdvancedDynamicTexture;
  78283. /**
  78284. * Removes a control from the root container
  78285. * @param control defines the control to remove
  78286. * @returns the current texture
  78287. */
  78288. removeControl(control: Control): AdvancedDynamicTexture;
  78289. /**
  78290. * Release all resources
  78291. */
  78292. dispose(): void;
  78293. private _onResize;
  78294. /** @hidden */
  78295. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78296. /**
  78297. * Get screen coordinates for a vector3
  78298. * @param position defines the position to project
  78299. * @param worldMatrix defines the world matrix to use
  78300. * @returns the projected position
  78301. */
  78302. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78303. private _checkUpdate;
  78304. private _clearMeasure;
  78305. private _render;
  78306. /** @hidden */
  78307. _changeCursor(cursor: string): void;
  78308. /** @hidden */
  78309. _registerLastControlDown(control: Control, pointerId: number): void;
  78310. private _doPicking;
  78311. /** @hidden */
  78312. _cleanControlAfterRemovalFromList(list: {
  78313. [pointerId: number]: Control;
  78314. }, control: Control): void;
  78315. /** @hidden */
  78316. _cleanControlAfterRemoval(control: Control): void;
  78317. /** Attach to all scene events required to support pointer events */
  78318. attach(): void;
  78319. /** @hidden */
  78320. private onClipboardCopy;
  78321. /** @hidden */
  78322. private onClipboardCut;
  78323. /** @hidden */
  78324. private onClipboardPaste;
  78325. /**
  78326. * Register the clipboard Events onto the canvas
  78327. */
  78328. registerClipboardEvents(): void;
  78329. /**
  78330. * Unregister the clipboard Events from the canvas
  78331. */
  78332. unRegisterClipboardEvents(): void;
  78333. /**
  78334. * Connect the texture to a hosting mesh to enable interactions
  78335. * @param mesh defines the mesh to attach to
  78336. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78337. */
  78338. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78339. /**
  78340. * Move the focus to a specific control
  78341. * @param control defines the control which will receive the focus
  78342. */
  78343. moveFocusToControl(control: IFocusableControl): void;
  78344. private _manageFocus;
  78345. private _attachToOnPointerOut;
  78346. private _attachToOnBlur;
  78347. /**
  78348. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78349. * @param mesh defines the mesh which will receive the texture
  78350. * @param width defines the texture width (1024 by default)
  78351. * @param height defines the texture height (1024 by default)
  78352. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78353. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78354. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78355. * @returns a new AdvancedDynamicTexture
  78356. */
  78357. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78358. /**
  78359. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78360. * In this mode the texture will rely on a layer for its rendering.
  78361. * This allows it to be treated like any other layer.
  78362. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78363. * LayerMask is set through advancedTexture.layer.layerMask
  78364. * @param name defines name for the texture
  78365. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78366. * @param scene defines the hsoting scene
  78367. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78368. * @returns a new AdvancedDynamicTexture
  78369. */
  78370. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78371. }
  78372. }
  78373. declare module BABYLON.GUI {
  78374. /**
  78375. * Root class used for all 2D controls
  78376. * @see https://doc.babylonjs.com/how_to/gui#controls
  78377. */
  78378. export class Control {
  78379. /** defines the name of the control */
  78380. name?: string | undefined;
  78381. /**
  78382. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78383. */
  78384. static AllowAlphaInheritance: boolean;
  78385. private _alpha;
  78386. private _alphaSet;
  78387. private _zIndex;
  78388. /** @hidden */
  78389. _host: AdvancedDynamicTexture;
  78390. /** Gets or sets the control parent */
  78391. parent: BABYLON.Nullable<Container>;
  78392. /** @hidden */
  78393. _currentMeasure: Measure;
  78394. private _fontFamily;
  78395. private _fontStyle;
  78396. private _fontWeight;
  78397. private _fontSize;
  78398. private _font;
  78399. /** @hidden */
  78400. _width: ValueAndUnit;
  78401. /** @hidden */
  78402. _height: ValueAndUnit;
  78403. /** @hidden */
  78404. protected _fontOffset: {
  78405. ascent: number;
  78406. height: number;
  78407. descent: number;
  78408. };
  78409. private _color;
  78410. private _style;
  78411. private _styleObserver;
  78412. /** @hidden */
  78413. protected _horizontalAlignment: number;
  78414. /** @hidden */
  78415. protected _verticalAlignment: number;
  78416. /** @hidden */
  78417. protected _isDirty: boolean;
  78418. /** @hidden */
  78419. protected _wasDirty: boolean;
  78420. /** @hidden */
  78421. _tempParentMeasure: Measure;
  78422. /** @hidden */
  78423. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78424. /** @hidden */
  78425. protected _cachedParentMeasure: Measure;
  78426. private _paddingLeft;
  78427. private _paddingRight;
  78428. private _paddingTop;
  78429. private _paddingBottom;
  78430. /** @hidden */
  78431. _left: ValueAndUnit;
  78432. /** @hidden */
  78433. _top: ValueAndUnit;
  78434. private _scaleX;
  78435. private _scaleY;
  78436. private _rotation;
  78437. private _transformCenterX;
  78438. private _transformCenterY;
  78439. /** @hidden */
  78440. _transformMatrix: Matrix2D;
  78441. /** @hidden */
  78442. protected _invertTransformMatrix: Matrix2D;
  78443. /** @hidden */
  78444. protected _transformedPosition: BABYLON.Vector2;
  78445. private _isMatrixDirty;
  78446. private _cachedOffsetX;
  78447. private _cachedOffsetY;
  78448. private _isVisible;
  78449. private _isHighlighted;
  78450. /** @hidden */
  78451. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78452. private _fontSet;
  78453. private _dummyVector2;
  78454. private _downCount;
  78455. private _enterCount;
  78456. private _doNotRender;
  78457. private _downPointerIds;
  78458. protected _isEnabled: boolean;
  78459. protected _disabledColor: string;
  78460. protected _disabledColorItem: string;
  78461. /** @hidden */
  78462. protected _rebuildLayout: boolean;
  78463. /** @hidden */
  78464. _customData: any;
  78465. /** @hidden */
  78466. _isClipped: boolean;
  78467. /** @hidden */
  78468. _automaticSize: boolean;
  78469. /** @hidden */
  78470. _tag: any;
  78471. /**
  78472. * 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
  78473. */
  78474. uniqueId: number;
  78475. /**
  78476. * Gets or sets an object used to store user defined information for the node
  78477. */
  78478. metadata: any;
  78479. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78480. isHitTestVisible: boolean;
  78481. /** Gets or sets a boolean indicating if the control can block pointer events */
  78482. isPointerBlocker: boolean;
  78483. /** Gets or sets a boolean indicating if the control can be focusable */
  78484. isFocusInvisible: boolean;
  78485. /**
  78486. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78487. * 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
  78488. */
  78489. clipChildren: boolean;
  78490. /**
  78491. * Gets or sets a boolean indicating that control content must be clipped
  78492. * 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
  78493. */
  78494. clipContent: boolean;
  78495. /**
  78496. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78497. */
  78498. useBitmapCache: boolean;
  78499. private _cacheData;
  78500. private _shadowOffsetX;
  78501. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78502. get shadowOffsetX(): number;
  78503. set shadowOffsetX(value: number);
  78504. private _shadowOffsetY;
  78505. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78506. get shadowOffsetY(): number;
  78507. set shadowOffsetY(value: number);
  78508. private _shadowBlur;
  78509. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78510. get shadowBlur(): number;
  78511. set shadowBlur(value: number);
  78512. private _shadowColor;
  78513. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78514. get shadowColor(): string;
  78515. set shadowColor(value: string);
  78516. /** Gets or sets the cursor to use when the control is hovered */
  78517. hoverCursor: string;
  78518. /** @hidden */
  78519. protected _linkOffsetX: ValueAndUnit;
  78520. /** @hidden */
  78521. protected _linkOffsetY: ValueAndUnit;
  78522. /** Gets the control type name */
  78523. get typeName(): string;
  78524. /**
  78525. * Get the current class name of the control.
  78526. * @returns current class name
  78527. */
  78528. getClassName(): string;
  78529. /**
  78530. * An event triggered when pointer wheel is scrolled
  78531. */
  78532. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78533. /**
  78534. * An event triggered when the pointer move over the control.
  78535. */
  78536. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78537. /**
  78538. * An event triggered when the pointer move out of the control.
  78539. */
  78540. onPointerOutObservable: BABYLON.Observable<Control>;
  78541. /**
  78542. * An event triggered when the pointer taps the control
  78543. */
  78544. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78545. /**
  78546. * An event triggered when pointer up
  78547. */
  78548. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78549. /**
  78550. * An event triggered when a control is clicked on
  78551. */
  78552. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78553. /**
  78554. * An event triggered when pointer enters the control
  78555. */
  78556. onPointerEnterObservable: BABYLON.Observable<Control>;
  78557. /**
  78558. * An event triggered when the control is marked as dirty
  78559. */
  78560. onDirtyObservable: BABYLON.Observable<Control>;
  78561. /**
  78562. * An event triggered before drawing the control
  78563. */
  78564. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78565. /**
  78566. * An event triggered after the control was drawn
  78567. */
  78568. onAfterDrawObservable: BABYLON.Observable<Control>;
  78569. /**
  78570. * An event triggered when the control has been disposed
  78571. */
  78572. onDisposeObservable: BABYLON.Observable<Control>;
  78573. /**
  78574. * Get the hosting AdvancedDynamicTexture
  78575. */
  78576. get host(): AdvancedDynamicTexture;
  78577. /** Gets or set information about font offsets (used to render and align text) */
  78578. get fontOffset(): {
  78579. ascent: number;
  78580. height: number;
  78581. descent: number;
  78582. };
  78583. set fontOffset(offset: {
  78584. ascent: number;
  78585. height: number;
  78586. descent: number;
  78587. });
  78588. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78589. get alpha(): number;
  78590. set alpha(value: number);
  78591. /**
  78592. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78593. */
  78594. get isHighlighted(): boolean;
  78595. set isHighlighted(value: boolean);
  78596. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78597. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78598. */
  78599. get scaleX(): number;
  78600. set scaleX(value: number);
  78601. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78602. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78603. */
  78604. get scaleY(): number;
  78605. set scaleY(value: number);
  78606. /** Gets or sets the rotation angle (0 by default)
  78607. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78608. */
  78609. get rotation(): number;
  78610. set rotation(value: number);
  78611. /** Gets or sets the transformation center on Y axis (0 by default)
  78612. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78613. */
  78614. get transformCenterY(): number;
  78615. set transformCenterY(value: number);
  78616. /** Gets or sets the transformation center on X axis (0 by default)
  78617. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78618. */
  78619. get transformCenterX(): number;
  78620. set transformCenterX(value: number);
  78621. /**
  78622. * Gets or sets the horizontal alignment
  78623. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78624. */
  78625. get horizontalAlignment(): number;
  78626. set horizontalAlignment(value: number);
  78627. /**
  78628. * Gets or sets the vertical alignment
  78629. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78630. */
  78631. get verticalAlignment(): number;
  78632. set verticalAlignment(value: number);
  78633. /**
  78634. * Gets or sets a fixed ratio for this control.
  78635. * When different from 0, the ratio is used to compute the "second" dimension.
  78636. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78637. * second dimension is computed as first dimension * fixedRatio
  78638. */
  78639. fixedRatio: number;
  78640. private _fixedRatioMasterIsWidth;
  78641. /**
  78642. * Gets or sets control width
  78643. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78644. */
  78645. get width(): string | number;
  78646. set width(value: string | number);
  78647. /**
  78648. * Gets or sets the control width in pixel
  78649. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78650. */
  78651. get widthInPixels(): number;
  78652. set widthInPixels(value: number);
  78653. /**
  78654. * Gets or sets control height
  78655. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78656. */
  78657. get height(): string | number;
  78658. set height(value: string | number);
  78659. /**
  78660. * Gets or sets control height in pixel
  78661. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78662. */
  78663. get heightInPixels(): number;
  78664. set heightInPixels(value: number);
  78665. /** Gets or set font family */
  78666. get fontFamily(): string;
  78667. set fontFamily(value: string);
  78668. /** Gets or sets font style */
  78669. get fontStyle(): string;
  78670. set fontStyle(value: string);
  78671. /** Gets or sets font weight */
  78672. get fontWeight(): string;
  78673. set fontWeight(value: string);
  78674. /**
  78675. * Gets or sets style
  78676. * @see https://doc.babylonjs.com/how_to/gui#styles
  78677. */
  78678. get style(): BABYLON.Nullable<Style>;
  78679. set style(value: BABYLON.Nullable<Style>);
  78680. /** @hidden */
  78681. get _isFontSizeInPercentage(): boolean;
  78682. /** Gets or sets font size in pixels */
  78683. get fontSizeInPixels(): number;
  78684. set fontSizeInPixels(value: number);
  78685. /** Gets or sets font size */
  78686. get fontSize(): string | number;
  78687. set fontSize(value: string | number);
  78688. /** Gets or sets foreground color */
  78689. get color(): string;
  78690. set color(value: string);
  78691. /** Gets or sets z index which is used to reorder controls on the z axis */
  78692. get zIndex(): number;
  78693. set zIndex(value: number);
  78694. /** Gets or sets a boolean indicating if the control can be rendered */
  78695. get notRenderable(): boolean;
  78696. set notRenderable(value: boolean);
  78697. /** Gets or sets a boolean indicating if the control is visible */
  78698. get isVisible(): boolean;
  78699. set isVisible(value: boolean);
  78700. /** Gets a boolean indicating that the control needs to update its rendering */
  78701. get isDirty(): boolean;
  78702. /**
  78703. * Gets the current linked mesh (or null if none)
  78704. */
  78705. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78706. /**
  78707. * Gets or sets a value indicating the padding to use on the left of the control
  78708. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78709. */
  78710. get paddingLeft(): string | number;
  78711. set paddingLeft(value: string | number);
  78712. /**
  78713. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78714. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78715. */
  78716. get paddingLeftInPixels(): number;
  78717. set paddingLeftInPixels(value: number);
  78718. /**
  78719. * Gets or sets a value indicating the padding to use on the right of the control
  78720. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78721. */
  78722. get paddingRight(): string | number;
  78723. set paddingRight(value: string | number);
  78724. /**
  78725. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78726. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78727. */
  78728. get paddingRightInPixels(): number;
  78729. set paddingRightInPixels(value: number);
  78730. /**
  78731. * Gets or sets a value indicating the padding to use on the top of the control
  78732. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78733. */
  78734. get paddingTop(): string | number;
  78735. set paddingTop(value: string | number);
  78736. /**
  78737. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78738. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78739. */
  78740. get paddingTopInPixels(): number;
  78741. set paddingTopInPixels(value: number);
  78742. /**
  78743. * Gets or sets a value indicating the padding to use on the bottom of the control
  78744. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78745. */
  78746. get paddingBottom(): string | number;
  78747. set paddingBottom(value: string | number);
  78748. /**
  78749. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78750. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78751. */
  78752. get paddingBottomInPixels(): number;
  78753. set paddingBottomInPixels(value: number);
  78754. /**
  78755. * Gets or sets a value indicating the left coordinate of the control
  78756. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78757. */
  78758. get left(): string | number;
  78759. set left(value: string | number);
  78760. /**
  78761. * Gets or sets a value indicating the left coordinate in pixels of the control
  78762. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78763. */
  78764. get leftInPixels(): number;
  78765. set leftInPixels(value: number);
  78766. /**
  78767. * Gets or sets a value indicating the top coordinate of the control
  78768. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78769. */
  78770. get top(): string | number;
  78771. set top(value: string | number);
  78772. /**
  78773. * Gets or sets a value indicating the top coordinate in pixels of the control
  78774. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78775. */
  78776. get topInPixels(): number;
  78777. set topInPixels(value: number);
  78778. /**
  78779. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78780. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78781. */
  78782. get linkOffsetX(): string | number;
  78783. set linkOffsetX(value: string | number);
  78784. /**
  78785. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78786. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78787. */
  78788. get linkOffsetXInPixels(): number;
  78789. set linkOffsetXInPixels(value: number);
  78790. /**
  78791. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78792. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78793. */
  78794. get linkOffsetY(): string | number;
  78795. set linkOffsetY(value: string | number);
  78796. /**
  78797. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78798. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78799. */
  78800. get linkOffsetYInPixels(): number;
  78801. set linkOffsetYInPixels(value: number);
  78802. /** Gets the center coordinate on X axis */
  78803. get centerX(): number;
  78804. /** Gets the center coordinate on Y axis */
  78805. get centerY(): number;
  78806. /** Gets or sets if control is Enabled*/
  78807. get isEnabled(): boolean;
  78808. set isEnabled(value: boolean);
  78809. /** Gets or sets background color of control if it's disabled*/
  78810. get disabledColor(): string;
  78811. set disabledColor(value: string);
  78812. /** Gets or sets front color of control if it's disabled*/
  78813. get disabledColorItem(): string;
  78814. set disabledColorItem(value: string);
  78815. /**
  78816. * Creates a new control
  78817. * @param name defines the name of the control
  78818. */
  78819. constructor(
  78820. /** defines the name of the control */
  78821. name?: string | undefined);
  78822. /** @hidden */
  78823. protected _getTypeName(): string;
  78824. /**
  78825. * Gets the first ascendant in the hierarchy of the given type
  78826. * @param className defines the required type
  78827. * @returns the ascendant or null if not found
  78828. */
  78829. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78830. /** @hidden */
  78831. _resetFontCache(): void;
  78832. /**
  78833. * Determines if a container is an ascendant of the current control
  78834. * @param container defines the container to look for
  78835. * @returns true if the container is one of the ascendant of the control
  78836. */
  78837. isAscendant(container: Control): boolean;
  78838. /**
  78839. * Gets coordinates in local control space
  78840. * @param globalCoordinates defines the coordinates to transform
  78841. * @returns the new coordinates in local space
  78842. */
  78843. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78844. /**
  78845. * Gets coordinates in local control space
  78846. * @param globalCoordinates defines the coordinates to transform
  78847. * @param result defines the target vector2 where to store the result
  78848. * @returns the current control
  78849. */
  78850. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78851. /**
  78852. * Gets coordinates in parent local control space
  78853. * @param globalCoordinates defines the coordinates to transform
  78854. * @returns the new coordinates in parent local space
  78855. */
  78856. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78857. /**
  78858. * Move the current control to a vector3 position projected onto the screen.
  78859. * @param position defines the target position
  78860. * @param scene defines the hosting scene
  78861. */
  78862. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78863. /**
  78864. * Will store all controls that have this control as ascendant in a given array
  78865. * @param results defines the array where to store the descendants
  78866. * @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
  78867. * @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
  78868. */
  78869. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78870. /**
  78871. * Will return all controls that have this control as ascendant
  78872. * @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
  78873. * @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
  78874. * @return all child controls
  78875. */
  78876. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78877. /**
  78878. * Link current control with a target mesh
  78879. * @param mesh defines the mesh to link with
  78880. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78881. */
  78882. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78883. /** @hidden */
  78884. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78885. /** @hidden */
  78886. _offsetLeft(offset: number): void;
  78887. /** @hidden */
  78888. _offsetTop(offset: number): void;
  78889. /** @hidden */
  78890. _markMatrixAsDirty(): void;
  78891. /** @hidden */
  78892. _flagDescendantsAsMatrixDirty(): void;
  78893. /** @hidden */
  78894. _intersectsRect(rect: Measure): boolean;
  78895. /** @hidden */
  78896. protected invalidateRect(): void;
  78897. /** @hidden */
  78898. _markAsDirty(force?: boolean): void;
  78899. /** @hidden */
  78900. _markAllAsDirty(): void;
  78901. /** @hidden */
  78902. _link(host: AdvancedDynamicTexture): void;
  78903. /** @hidden */
  78904. protected _transform(context?: CanvasRenderingContext2D): void;
  78905. /** @hidden */
  78906. _renderHighlight(context: CanvasRenderingContext2D): void;
  78907. /** @hidden */
  78908. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78909. /** @hidden */
  78910. protected _applyStates(context: CanvasRenderingContext2D): void;
  78911. /** @hidden */
  78912. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78913. /** @hidden */
  78914. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78915. protected _evaluateClippingState(parentMeasure: Measure): void;
  78916. /** @hidden */
  78917. _measure(): void;
  78918. /** @hidden */
  78919. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78920. /** @hidden */
  78921. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78922. /** @hidden */
  78923. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78924. /** @hidden */
  78925. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78926. private static _ClipMeasure;
  78927. private _tmpMeasureA;
  78928. private _clip;
  78929. /** @hidden */
  78930. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78931. /** @hidden */
  78932. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78933. /**
  78934. * Tests if a given coordinates belong to the current control
  78935. * @param x defines x coordinate to test
  78936. * @param y defines y coordinate to test
  78937. * @returns true if the coordinates are inside the control
  78938. */
  78939. contains(x: number, y: number): boolean;
  78940. /** @hidden */
  78941. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78942. /** @hidden */
  78943. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78944. /** @hidden */
  78945. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78946. /** @hidden */
  78947. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78948. /** @hidden */
  78949. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78950. /** @hidden */
  78951. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78952. /** @hidden */
  78953. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78954. /** @hidden */
  78955. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78956. /** @hidden */
  78957. _onCanvasBlur(): void;
  78958. /** @hidden */
  78959. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78960. private _prepareFont;
  78961. /** Releases associated resources */
  78962. dispose(): void;
  78963. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78964. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78965. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78966. private static _VERTICAL_ALIGNMENT_TOP;
  78967. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78968. private static _VERTICAL_ALIGNMENT_CENTER;
  78969. /** HORIZONTAL_ALIGNMENT_LEFT */
  78970. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78971. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78972. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78973. /** HORIZONTAL_ALIGNMENT_CENTER */
  78974. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78975. /** VERTICAL_ALIGNMENT_TOP */
  78976. static get VERTICAL_ALIGNMENT_TOP(): number;
  78977. /** VERTICAL_ALIGNMENT_BOTTOM */
  78978. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78979. /** VERTICAL_ALIGNMENT_CENTER */
  78980. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78981. private static _FontHeightSizes;
  78982. /** @hidden */
  78983. static _GetFontOffset(font: string): {
  78984. ascent: number;
  78985. height: number;
  78986. descent: number;
  78987. };
  78988. /**
  78989. * Creates a stack panel that can be used to render headers
  78990. * @param control defines the control to associate with the header
  78991. * @param text defines the text of the header
  78992. * @param size defines the size of the header
  78993. * @param options defines options used to configure the header
  78994. * @returns a new StackPanel
  78995. * @ignore
  78996. * @hidden
  78997. */
  78998. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78999. isHorizontal: boolean;
  79000. controlFirst: boolean;
  79001. }) => any;
  79002. /** @hidden */
  79003. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79004. }
  79005. }
  79006. declare module BABYLON.GUI {
  79007. /**
  79008. * Root class for 2D containers
  79009. * @see https://doc.babylonjs.com/how_to/gui#containers
  79010. */
  79011. export class Container extends Control {
  79012. name?: string | undefined;
  79013. /** @hidden */
  79014. _children: Control[];
  79015. /** @hidden */
  79016. protected _measureForChildren: Measure;
  79017. /** @hidden */
  79018. protected _background: string;
  79019. /** @hidden */
  79020. protected _adaptWidthToChildren: boolean;
  79021. /** @hidden */
  79022. protected _adaptHeightToChildren: boolean;
  79023. /**
  79024. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79025. */
  79026. logLayoutCycleErrors: boolean;
  79027. /**
  79028. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79029. */
  79030. maxLayoutCycle: number;
  79031. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79032. get adaptHeightToChildren(): boolean;
  79033. set adaptHeightToChildren(value: boolean);
  79034. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79035. get adaptWidthToChildren(): boolean;
  79036. set adaptWidthToChildren(value: boolean);
  79037. /** Gets or sets background color */
  79038. get background(): string;
  79039. set background(value: string);
  79040. /** Gets the list of children */
  79041. get children(): Control[];
  79042. /**
  79043. * Creates a new Container
  79044. * @param name defines the name of the container
  79045. */
  79046. constructor(name?: string | undefined);
  79047. protected _getTypeName(): string;
  79048. _flagDescendantsAsMatrixDirty(): void;
  79049. /**
  79050. * Gets a child using its name
  79051. * @param name defines the child name to look for
  79052. * @returns the child control if found
  79053. */
  79054. getChildByName(name: string): BABYLON.Nullable<Control>;
  79055. /**
  79056. * Gets a child using its type and its name
  79057. * @param name defines the child name to look for
  79058. * @param type defines the child type to look for
  79059. * @returns the child control if found
  79060. */
  79061. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79062. /**
  79063. * Search for a specific control in children
  79064. * @param control defines the control to look for
  79065. * @returns true if the control is in child list
  79066. */
  79067. containsControl(control: Control): boolean;
  79068. /**
  79069. * Adds a new control to the current container
  79070. * @param control defines the control to add
  79071. * @returns the current container
  79072. */
  79073. addControl(control: BABYLON.Nullable<Control>): Container;
  79074. /**
  79075. * Removes all controls from the current container
  79076. * @returns the current container
  79077. */
  79078. clearControls(): Container;
  79079. /**
  79080. * Removes a control from the current container
  79081. * @param control defines the control to remove
  79082. * @returns the current container
  79083. */
  79084. removeControl(control: Control): Container;
  79085. /** @hidden */
  79086. _reOrderControl(control: Control): void;
  79087. /** @hidden */
  79088. _offsetLeft(offset: number): void;
  79089. /** @hidden */
  79090. _offsetTop(offset: number): void;
  79091. /** @hidden */
  79092. _markAllAsDirty(): void;
  79093. /** @hidden */
  79094. protected _localDraw(context: CanvasRenderingContext2D): void;
  79095. /** @hidden */
  79096. _link(host: AdvancedDynamicTexture): void;
  79097. /** @hidden */
  79098. protected _beforeLayout(): void;
  79099. /** @hidden */
  79100. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79101. /** @hidden */
  79102. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79103. protected _postMeasure(): void;
  79104. /** @hidden */
  79105. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79106. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79107. /** @hidden */
  79108. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79109. /** @hidden */
  79110. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79111. /** Releases associated resources */
  79112. dispose(): void;
  79113. }
  79114. }
  79115. declare module BABYLON.GUI {
  79116. /** Class used to create rectangle container */
  79117. export class Rectangle extends Container {
  79118. name?: string | undefined;
  79119. private _thickness;
  79120. private _cornerRadius;
  79121. /** Gets or sets border thickness */
  79122. get thickness(): number;
  79123. set thickness(value: number);
  79124. /** Gets or sets the corner radius angle */
  79125. get cornerRadius(): number;
  79126. set cornerRadius(value: number);
  79127. /**
  79128. * Creates a new Rectangle
  79129. * @param name defines the control name
  79130. */
  79131. constructor(name?: string | undefined);
  79132. protected _getTypeName(): string;
  79133. protected _localDraw(context: CanvasRenderingContext2D): void;
  79134. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79135. private _drawRoundedRect;
  79136. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79137. }
  79138. }
  79139. declare module BABYLON.GUI {
  79140. /**
  79141. * Enum that determines the text-wrapping mode to use.
  79142. */
  79143. export enum TextWrapping {
  79144. /**
  79145. * Clip the text when it's larger than Control.width; this is the default mode.
  79146. */
  79147. Clip = 0,
  79148. /**
  79149. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79150. */
  79151. WordWrap = 1,
  79152. /**
  79153. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79154. */
  79155. Ellipsis = 2
  79156. }
  79157. /**
  79158. * Class used to create text block control
  79159. */
  79160. export class TextBlock extends Control {
  79161. /**
  79162. * Defines the name of the control
  79163. */
  79164. name?: string | undefined;
  79165. private _text;
  79166. private _textWrapping;
  79167. private _textHorizontalAlignment;
  79168. private _textVerticalAlignment;
  79169. private _lines;
  79170. private _resizeToFit;
  79171. private _lineSpacing;
  79172. private _outlineWidth;
  79173. private _outlineColor;
  79174. private _underline;
  79175. private _lineThrough;
  79176. /**
  79177. * An event triggered after the text is changed
  79178. */
  79179. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79180. /**
  79181. * An event triggered after the text was broken up into lines
  79182. */
  79183. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79184. /**
  79185. * Function used to split a string into words. By default, a string is split at each space character found
  79186. */
  79187. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79188. /**
  79189. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79190. */
  79191. get lines(): any[];
  79192. /**
  79193. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79194. */
  79195. get resizeToFit(): boolean;
  79196. /**
  79197. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79198. */
  79199. set resizeToFit(value: boolean);
  79200. /**
  79201. * Gets or sets a boolean indicating if text must be wrapped
  79202. */
  79203. get textWrapping(): TextWrapping | boolean;
  79204. /**
  79205. * Gets or sets a boolean indicating if text must be wrapped
  79206. */
  79207. set textWrapping(value: TextWrapping | boolean);
  79208. /**
  79209. * Gets or sets text to display
  79210. */
  79211. get text(): string;
  79212. /**
  79213. * Gets or sets text to display
  79214. */
  79215. set text(value: string);
  79216. /**
  79217. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79218. */
  79219. get textHorizontalAlignment(): number;
  79220. /**
  79221. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79222. */
  79223. set textHorizontalAlignment(value: number);
  79224. /**
  79225. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79226. */
  79227. get textVerticalAlignment(): number;
  79228. /**
  79229. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79230. */
  79231. set textVerticalAlignment(value: number);
  79232. /**
  79233. * Gets or sets line spacing value
  79234. */
  79235. set lineSpacing(value: string | number);
  79236. /**
  79237. * Gets or sets line spacing value
  79238. */
  79239. get lineSpacing(): string | number;
  79240. /**
  79241. * Gets or sets outlineWidth of the text to display
  79242. */
  79243. get outlineWidth(): number;
  79244. /**
  79245. * Gets or sets outlineWidth of the text to display
  79246. */
  79247. set outlineWidth(value: number);
  79248. /**
  79249. * Gets or sets a boolean indicating that text must have underline
  79250. */
  79251. get underline(): boolean;
  79252. /**
  79253. * Gets or sets a boolean indicating that text must have underline
  79254. */
  79255. set underline(value: boolean);
  79256. /**
  79257. * Gets or sets an boolean indicating that text must be crossed out
  79258. */
  79259. get lineThrough(): boolean;
  79260. /**
  79261. * Gets or sets an boolean indicating that text must be crossed out
  79262. */
  79263. set lineThrough(value: boolean);
  79264. /**
  79265. * Gets or sets outlineColor of the text to display
  79266. */
  79267. get outlineColor(): string;
  79268. /**
  79269. * Gets or sets outlineColor of the text to display
  79270. */
  79271. set outlineColor(value: string);
  79272. /**
  79273. * Creates a new TextBlock object
  79274. * @param name defines the name of the control
  79275. * @param text defines the text to display (emptry string by default)
  79276. */
  79277. constructor(
  79278. /**
  79279. * Defines the name of the control
  79280. */
  79281. name?: string | undefined, text?: string);
  79282. protected _getTypeName(): string;
  79283. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79284. private _drawText;
  79285. /** @hidden */
  79286. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79287. protected _applyStates(context: CanvasRenderingContext2D): void;
  79288. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79289. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79290. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79291. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79292. protected _renderLines(context: CanvasRenderingContext2D): void;
  79293. /**
  79294. * Given a width constraint applied on the text block, find the expected height
  79295. * @returns expected height
  79296. */
  79297. computeExpectedHeight(): number;
  79298. dispose(): void;
  79299. }
  79300. }
  79301. declare module BABYLON.GUI {
  79302. /**
  79303. * Class used to create 2D images
  79304. */
  79305. export class Image extends Control {
  79306. name?: string | undefined;
  79307. private _workingCanvas;
  79308. private _domImage;
  79309. private _imageWidth;
  79310. private _imageHeight;
  79311. private _loaded;
  79312. private _stretch;
  79313. private _source;
  79314. private _autoScale;
  79315. private _sourceLeft;
  79316. private _sourceTop;
  79317. private _sourceWidth;
  79318. private _sourceHeight;
  79319. private _svgAttributesComputationCompleted;
  79320. private _isSVG;
  79321. private _cellWidth;
  79322. private _cellHeight;
  79323. private _cellId;
  79324. private _populateNinePatchSlicesFromImage;
  79325. private _sliceLeft;
  79326. private _sliceRight;
  79327. private _sliceTop;
  79328. private _sliceBottom;
  79329. private _detectPointerOnOpaqueOnly;
  79330. private _imageDataCache;
  79331. /**
  79332. * BABYLON.Observable notified when the content is loaded
  79333. */
  79334. onImageLoadedObservable: BABYLON.Observable<Image>;
  79335. /**
  79336. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79337. */
  79338. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79339. /**
  79340. * Gets a boolean indicating that the content is loaded
  79341. */
  79342. get isLoaded(): boolean;
  79343. /**
  79344. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79345. */
  79346. get populateNinePatchSlicesFromImage(): boolean;
  79347. set populateNinePatchSlicesFromImage(value: boolean);
  79348. /**
  79349. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79350. * Beware using this as this will comsume more memory as the image has to be stored twice
  79351. */
  79352. get detectPointerOnOpaqueOnly(): boolean;
  79353. set detectPointerOnOpaqueOnly(value: boolean);
  79354. /**
  79355. * Gets or sets the left value for slicing (9-patch)
  79356. */
  79357. get sliceLeft(): number;
  79358. set sliceLeft(value: number);
  79359. /**
  79360. * Gets or sets the right value for slicing (9-patch)
  79361. */
  79362. get sliceRight(): number;
  79363. set sliceRight(value: number);
  79364. /**
  79365. * Gets or sets the top value for slicing (9-patch)
  79366. */
  79367. get sliceTop(): number;
  79368. set sliceTop(value: number);
  79369. /**
  79370. * Gets or sets the bottom value for slicing (9-patch)
  79371. */
  79372. get sliceBottom(): number;
  79373. set sliceBottom(value: number);
  79374. /**
  79375. * Gets or sets the left coordinate in the source image
  79376. */
  79377. get sourceLeft(): number;
  79378. set sourceLeft(value: number);
  79379. /**
  79380. * Gets or sets the top coordinate in the source image
  79381. */
  79382. get sourceTop(): number;
  79383. set sourceTop(value: number);
  79384. /**
  79385. * Gets or sets the width to capture in the source image
  79386. */
  79387. get sourceWidth(): number;
  79388. set sourceWidth(value: number);
  79389. /**
  79390. * Gets or sets the height to capture in the source image
  79391. */
  79392. get sourceHeight(): number;
  79393. set sourceHeight(value: number);
  79394. /** Indicates if the format of the image is SVG */
  79395. get isSVG(): boolean;
  79396. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79397. get svgAttributesComputationCompleted(): boolean;
  79398. /**
  79399. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79400. * @see https://doc.babylonjs.com/how_to/gui#image
  79401. */
  79402. get autoScale(): boolean;
  79403. set autoScale(value: boolean);
  79404. /** Gets or sets the streching mode used by the image */
  79405. get stretch(): number;
  79406. set stretch(value: number);
  79407. /** @hidden */
  79408. _rotate90(n: number, preserveProperties?: boolean): Image;
  79409. private _handleRotationForSVGImage;
  79410. private _rotate90SourceProperties;
  79411. /**
  79412. * Gets or sets the internal DOM image used to render the control
  79413. */
  79414. set domImage(value: HTMLImageElement);
  79415. get domImage(): HTMLImageElement;
  79416. private _onImageLoaded;
  79417. private _extractNinePatchSliceDataFromImage;
  79418. /**
  79419. * Gets or sets image source url
  79420. */
  79421. set source(value: BABYLON.Nullable<string>);
  79422. /**
  79423. * Checks for svg document with icon id present
  79424. */
  79425. private _svgCheck;
  79426. /**
  79427. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79428. * given external svg file and icon id
  79429. */
  79430. private _getSVGAttribs;
  79431. /**
  79432. * Gets or sets the cell width to use when animation sheet is enabled
  79433. * @see https://doc.babylonjs.com/how_to/gui#image
  79434. */
  79435. get cellWidth(): number;
  79436. set cellWidth(value: number);
  79437. /**
  79438. * Gets or sets the cell height to use when animation sheet is enabled
  79439. * @see https://doc.babylonjs.com/how_to/gui#image
  79440. */
  79441. get cellHeight(): number;
  79442. set cellHeight(value: number);
  79443. /**
  79444. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79445. * @see https://doc.babylonjs.com/how_to/gui#image
  79446. */
  79447. get cellId(): number;
  79448. set cellId(value: number);
  79449. /**
  79450. * Creates a new Image
  79451. * @param name defines the control name
  79452. * @param url defines the image url
  79453. */
  79454. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79455. /**
  79456. * Tests if a given coordinates belong to the current control
  79457. * @param x defines x coordinate to test
  79458. * @param y defines y coordinate to test
  79459. * @returns true if the coordinates are inside the control
  79460. */
  79461. contains(x: number, y: number): boolean;
  79462. protected _getTypeName(): string;
  79463. /** Force the control to synchronize with its content */
  79464. synchronizeSizeWithContent(): void;
  79465. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79466. private _prepareWorkingCanvasForOpaqueDetection;
  79467. private _drawImage;
  79468. _draw(context: CanvasRenderingContext2D): void;
  79469. private _renderCornerPatch;
  79470. private _renderNinePatch;
  79471. dispose(): void;
  79472. /** STRETCH_NONE */
  79473. static readonly STRETCH_NONE: number;
  79474. /** STRETCH_FILL */
  79475. static readonly STRETCH_FILL: number;
  79476. /** STRETCH_UNIFORM */
  79477. static readonly STRETCH_UNIFORM: number;
  79478. /** STRETCH_EXTEND */
  79479. static readonly STRETCH_EXTEND: number;
  79480. /** NINE_PATCH */
  79481. static readonly STRETCH_NINE_PATCH: number;
  79482. }
  79483. }
  79484. declare module BABYLON.GUI {
  79485. /**
  79486. * Class used to create 2D buttons
  79487. */
  79488. export class Button extends Rectangle {
  79489. name?: string | undefined;
  79490. /**
  79491. * Function called to generate a pointer enter animation
  79492. */
  79493. pointerEnterAnimation: () => void;
  79494. /**
  79495. * Function called to generate a pointer out animation
  79496. */
  79497. pointerOutAnimation: () => void;
  79498. /**
  79499. * Function called to generate a pointer down animation
  79500. */
  79501. pointerDownAnimation: () => void;
  79502. /**
  79503. * Function called to generate a pointer up animation
  79504. */
  79505. pointerUpAnimation: () => void;
  79506. /**
  79507. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79508. */
  79509. delegatePickingToChildren: boolean;
  79510. private _image;
  79511. /**
  79512. * Returns the image part of the button (if any)
  79513. */
  79514. get image(): BABYLON.Nullable<Image>;
  79515. private _textBlock;
  79516. /**
  79517. * Returns the image part of the button (if any)
  79518. */
  79519. get textBlock(): BABYLON.Nullable<TextBlock>;
  79520. /**
  79521. * Creates a new Button
  79522. * @param name defines the name of the button
  79523. */
  79524. constructor(name?: string | undefined);
  79525. protected _getTypeName(): string;
  79526. /** @hidden */
  79527. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79528. /** @hidden */
  79529. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79530. /** @hidden */
  79531. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79532. /** @hidden */
  79533. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79534. /** @hidden */
  79535. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79536. /**
  79537. * Creates a new button made with an image and a text
  79538. * @param name defines the name of the button
  79539. * @param text defines the text of the button
  79540. * @param imageUrl defines the url of the image
  79541. * @returns a new Button
  79542. */
  79543. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79544. /**
  79545. * Creates a new button made with an image
  79546. * @param name defines the name of the button
  79547. * @param imageUrl defines the url of the image
  79548. * @returns a new Button
  79549. */
  79550. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79551. /**
  79552. * Creates a new button made with a text
  79553. * @param name defines the name of the button
  79554. * @param text defines the text of the button
  79555. * @returns a new Button
  79556. */
  79557. static CreateSimpleButton(name: string, text: string): Button;
  79558. /**
  79559. * Creates a new button made with an image and a centered text
  79560. * @param name defines the name of the button
  79561. * @param text defines the text of the button
  79562. * @param imageUrl defines the url of the image
  79563. * @returns a new Button
  79564. */
  79565. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79566. }
  79567. }
  79568. declare module BABYLON.GUI {
  79569. /**
  79570. * Class used to create a 2D stack panel container
  79571. */
  79572. export class StackPanel extends Container {
  79573. name?: string | undefined;
  79574. private _isVertical;
  79575. private _manualWidth;
  79576. private _manualHeight;
  79577. private _doNotTrackManualChanges;
  79578. /**
  79579. * Gets or sets a boolean indicating that layou warnings should be ignored
  79580. */
  79581. ignoreLayoutWarnings: boolean;
  79582. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79583. get isVertical(): boolean;
  79584. set isVertical(value: boolean);
  79585. /**
  79586. * Gets or sets panel width.
  79587. * This value should not be set when in horizontal mode as it will be computed automatically
  79588. */
  79589. set width(value: string | number);
  79590. get width(): string | number;
  79591. /**
  79592. * Gets or sets panel height.
  79593. * This value should not be set when in vertical mode as it will be computed automatically
  79594. */
  79595. set height(value: string | number);
  79596. get height(): string | number;
  79597. /**
  79598. * Creates a new StackPanel
  79599. * @param name defines control name
  79600. */
  79601. constructor(name?: string | undefined);
  79602. protected _getTypeName(): string;
  79603. /** @hidden */
  79604. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79605. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79606. protected _postMeasure(): void;
  79607. }
  79608. }
  79609. declare module BABYLON.GUI {
  79610. /**
  79611. * Class used to represent a 2D checkbox
  79612. */
  79613. export class Checkbox extends Control {
  79614. name?: string | undefined;
  79615. private _isChecked;
  79616. private _background;
  79617. private _checkSizeRatio;
  79618. private _thickness;
  79619. /** Gets or sets border thickness */
  79620. get thickness(): number;
  79621. set thickness(value: number);
  79622. /**
  79623. * BABYLON.Observable raised when isChecked property changes
  79624. */
  79625. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79626. /** Gets or sets a value indicating the ratio between overall size and check size */
  79627. get checkSizeRatio(): number;
  79628. set checkSizeRatio(value: number);
  79629. /** Gets or sets background color */
  79630. get background(): string;
  79631. set background(value: string);
  79632. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79633. get isChecked(): boolean;
  79634. set isChecked(value: boolean);
  79635. /**
  79636. * Creates a new CheckBox
  79637. * @param name defines the control name
  79638. */
  79639. constructor(name?: string | undefined);
  79640. protected _getTypeName(): string;
  79641. /** @hidden */
  79642. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79643. /** @hidden */
  79644. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79645. /**
  79646. * Utility function to easily create a checkbox with a header
  79647. * @param title defines the label to use for the header
  79648. * @param onValueChanged defines the callback to call when value changes
  79649. * @returns a StackPanel containing the checkbox and a textBlock
  79650. */
  79651. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79652. }
  79653. }
  79654. declare module BABYLON.GUI {
  79655. /**
  79656. * Class used to store key control properties
  79657. */
  79658. export class KeyPropertySet {
  79659. /** Width */
  79660. width?: string;
  79661. /** Height */
  79662. height?: string;
  79663. /** Left padding */
  79664. paddingLeft?: string;
  79665. /** Right padding */
  79666. paddingRight?: string;
  79667. /** Top padding */
  79668. paddingTop?: string;
  79669. /** Bottom padding */
  79670. paddingBottom?: string;
  79671. /** Foreground color */
  79672. color?: string;
  79673. /** Background color */
  79674. background?: string;
  79675. }
  79676. /**
  79677. * Class used to create virtual keyboard
  79678. */
  79679. export class VirtualKeyboard extends StackPanel {
  79680. /** BABYLON.Observable raised when a key is pressed */
  79681. onKeyPressObservable: BABYLON.Observable<string>;
  79682. /** Gets or sets default key button width */
  79683. defaultButtonWidth: string;
  79684. /** Gets or sets default key button height */
  79685. defaultButtonHeight: string;
  79686. /** Gets or sets default key button left padding */
  79687. defaultButtonPaddingLeft: string;
  79688. /** Gets or sets default key button right padding */
  79689. defaultButtonPaddingRight: string;
  79690. /** Gets or sets default key button top padding */
  79691. defaultButtonPaddingTop: string;
  79692. /** Gets or sets default key button bottom padding */
  79693. defaultButtonPaddingBottom: string;
  79694. /** Gets or sets default key button foreground color */
  79695. defaultButtonColor: string;
  79696. /** Gets or sets default key button background color */
  79697. defaultButtonBackground: string;
  79698. /** Gets or sets shift button foreground color */
  79699. shiftButtonColor: string;
  79700. /** Gets or sets shift button thickness*/
  79701. selectedShiftThickness: number;
  79702. /** Gets shift key state */
  79703. shiftState: number;
  79704. protected _getTypeName(): string;
  79705. private _createKey;
  79706. /**
  79707. * Adds a new row of keys
  79708. * @param keys defines the list of keys to add
  79709. * @param propertySets defines the associated property sets
  79710. */
  79711. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79712. /**
  79713. * Set the shift key to a specific state
  79714. * @param shiftState defines the new shift state
  79715. */
  79716. applyShiftState(shiftState: number): void;
  79717. private _currentlyConnectedInputText;
  79718. private _connectedInputTexts;
  79719. private _onKeyPressObserver;
  79720. /** Gets the input text control currently attached to the keyboard */
  79721. get connectedInputText(): BABYLON.Nullable<InputText>;
  79722. /**
  79723. * Connects the keyboard with an input text control
  79724. *
  79725. * @param input defines the target control
  79726. */
  79727. connect(input: InputText): void;
  79728. /**
  79729. * Disconnects the keyboard from connected InputText controls
  79730. *
  79731. * @param input optionally defines a target control, otherwise all are disconnected
  79732. */
  79733. disconnect(input?: InputText): void;
  79734. private _removeConnectedInputObservables;
  79735. /**
  79736. * Release all resources
  79737. */
  79738. dispose(): void;
  79739. /**
  79740. * Creates a new keyboard using a default layout
  79741. *
  79742. * @param name defines control name
  79743. * @returns a new VirtualKeyboard
  79744. */
  79745. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79746. }
  79747. }
  79748. declare module BABYLON.GUI {
  79749. /**
  79750. * Class used to create input text control
  79751. */
  79752. export class InputText extends Control implements IFocusableControl {
  79753. name?: string | undefined;
  79754. private _text;
  79755. private _placeholderText;
  79756. private _background;
  79757. private _focusedBackground;
  79758. private _focusedColor;
  79759. private _placeholderColor;
  79760. private _thickness;
  79761. private _margin;
  79762. private _autoStretchWidth;
  79763. private _maxWidth;
  79764. private _isFocused;
  79765. private _blinkTimeout;
  79766. private _blinkIsEven;
  79767. private _cursorOffset;
  79768. private _scrollLeft;
  79769. private _textWidth;
  79770. private _clickedCoordinate;
  79771. private _deadKey;
  79772. private _addKey;
  79773. private _currentKey;
  79774. private _isTextHighlightOn;
  79775. private _textHighlightColor;
  79776. private _highligherOpacity;
  79777. private _highlightedText;
  79778. private _startHighlightIndex;
  79779. private _endHighlightIndex;
  79780. private _cursorIndex;
  79781. private _onFocusSelectAll;
  79782. private _isPointerDown;
  79783. private _onClipboardObserver;
  79784. private _onPointerDblTapObserver;
  79785. /** @hidden */
  79786. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79787. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79788. promptMessage: string;
  79789. /** Force disable prompt on mobile device */
  79790. disableMobilePrompt: boolean;
  79791. /** BABYLON.Observable raised when the text changes */
  79792. onTextChangedObservable: BABYLON.Observable<InputText>;
  79793. /** BABYLON.Observable raised just before an entered character is to be added */
  79794. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79795. /** BABYLON.Observable raised when the control gets the focus */
  79796. onFocusObservable: BABYLON.Observable<InputText>;
  79797. /** BABYLON.Observable raised when the control loses the focus */
  79798. onBlurObservable: BABYLON.Observable<InputText>;
  79799. /**Observable raised when the text is highlighted */
  79800. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79801. /**Observable raised when copy event is triggered */
  79802. onTextCopyObservable: BABYLON.Observable<InputText>;
  79803. /** BABYLON.Observable raised when cut event is triggered */
  79804. onTextCutObservable: BABYLON.Observable<InputText>;
  79805. /** BABYLON.Observable raised when paste event is triggered */
  79806. onTextPasteObservable: BABYLON.Observable<InputText>;
  79807. /** BABYLON.Observable raised when a key event was processed */
  79808. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79809. /** Gets or sets the maximum width allowed by the control */
  79810. get maxWidth(): string | number;
  79811. /** Gets the maximum width allowed by the control in pixels */
  79812. get maxWidthInPixels(): number;
  79813. set maxWidth(value: string | number);
  79814. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79815. get highligherOpacity(): number;
  79816. set highligherOpacity(value: number);
  79817. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79818. get onFocusSelectAll(): boolean;
  79819. set onFocusSelectAll(value: boolean);
  79820. /** Gets or sets the text hightlight color */
  79821. get textHighlightColor(): string;
  79822. set textHighlightColor(value: string);
  79823. /** Gets or sets control margin */
  79824. get margin(): string;
  79825. /** Gets control margin in pixels */
  79826. get marginInPixels(): number;
  79827. set margin(value: string);
  79828. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79829. get autoStretchWidth(): boolean;
  79830. set autoStretchWidth(value: boolean);
  79831. /** Gets or sets border thickness */
  79832. get thickness(): number;
  79833. set thickness(value: number);
  79834. /** Gets or sets the background color when focused */
  79835. get focusedBackground(): string;
  79836. set focusedBackground(value: string);
  79837. /** Gets or sets the background color when focused */
  79838. get focusedColor(): string;
  79839. set focusedColor(value: string);
  79840. /** Gets or sets the background color */
  79841. get background(): string;
  79842. set background(value: string);
  79843. /** Gets or sets the placeholder color */
  79844. get placeholderColor(): string;
  79845. set placeholderColor(value: string);
  79846. /** Gets or sets the text displayed when the control is empty */
  79847. get placeholderText(): string;
  79848. set placeholderText(value: string);
  79849. /** Gets or sets the dead key flag */
  79850. get deadKey(): boolean;
  79851. set deadKey(flag: boolean);
  79852. /** Gets or sets the highlight text */
  79853. get highlightedText(): string;
  79854. set highlightedText(text: string);
  79855. /** Gets or sets if the current key should be added */
  79856. get addKey(): boolean;
  79857. set addKey(flag: boolean);
  79858. /** Gets or sets the value of the current key being entered */
  79859. get currentKey(): string;
  79860. set currentKey(key: string);
  79861. /** Gets or sets the text displayed in the control */
  79862. get text(): string;
  79863. set text(value: string);
  79864. /** Gets or sets control width */
  79865. get width(): string | number;
  79866. set width(value: string | number);
  79867. /**
  79868. * Creates a new InputText
  79869. * @param name defines the control name
  79870. * @param text defines the text of the control
  79871. */
  79872. constructor(name?: string | undefined, text?: string);
  79873. /** @hidden */
  79874. onBlur(): void;
  79875. /** @hidden */
  79876. onFocus(): void;
  79877. protected _getTypeName(): string;
  79878. /**
  79879. * Function called to get the list of controls that should not steal the focus from this control
  79880. * @returns an array of controls
  79881. */
  79882. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79883. /** @hidden */
  79884. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79885. /** @hidden */
  79886. private _updateValueFromCursorIndex;
  79887. /** @hidden */
  79888. private _processDblClick;
  79889. /** @hidden */
  79890. private _selectAllText;
  79891. /**
  79892. * Handles the keyboard event
  79893. * @param evt Defines the KeyboardEvent
  79894. */
  79895. processKeyboard(evt: KeyboardEvent): void;
  79896. /** @hidden */
  79897. private _onCopyText;
  79898. /** @hidden */
  79899. private _onCutText;
  79900. /** @hidden */
  79901. private _onPasteText;
  79902. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79903. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79904. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79905. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79906. protected _beforeRenderText(text: string): string;
  79907. dispose(): void;
  79908. }
  79909. }
  79910. declare module BABYLON.GUI {
  79911. /**
  79912. * Class used to create a 2D grid container
  79913. */
  79914. export class Grid extends Container {
  79915. name?: string | undefined;
  79916. private _rowDefinitions;
  79917. private _columnDefinitions;
  79918. private _cells;
  79919. private _childControls;
  79920. /**
  79921. * Gets the number of columns
  79922. */
  79923. get columnCount(): number;
  79924. /**
  79925. * Gets the number of rows
  79926. */
  79927. get rowCount(): number;
  79928. /** Gets the list of children */
  79929. get children(): Control[];
  79930. /** Gets the list of cells (e.g. the containers) */
  79931. get cells(): {
  79932. [key: string]: Container;
  79933. };
  79934. /**
  79935. * Gets the definition of a specific row
  79936. * @param index defines the index of the row
  79937. * @returns the row definition
  79938. */
  79939. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79940. /**
  79941. * Gets the definition of a specific column
  79942. * @param index defines the index of the column
  79943. * @returns the column definition
  79944. */
  79945. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79946. /**
  79947. * Adds a new row to the grid
  79948. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79949. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79950. * @returns the current grid
  79951. */
  79952. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79953. /**
  79954. * Adds a new column to the grid
  79955. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79956. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79957. * @returns the current grid
  79958. */
  79959. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79960. /**
  79961. * Update a row definition
  79962. * @param index defines the index of the row to update
  79963. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79964. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79965. * @returns the current grid
  79966. */
  79967. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79968. /**
  79969. * Update a column definition
  79970. * @param index defines the index of the column to update
  79971. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79972. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79973. * @returns the current grid
  79974. */
  79975. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79976. /**
  79977. * Gets the list of children stored in a specific cell
  79978. * @param row defines the row to check
  79979. * @param column defines the column to check
  79980. * @returns the list of controls
  79981. */
  79982. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79983. /**
  79984. * Gets a string representing the child cell info (row x column)
  79985. * @param child defines the control to get info from
  79986. * @returns a string containing the child cell info (row x column)
  79987. */
  79988. getChildCellInfo(child: Control): string;
  79989. private _removeCell;
  79990. private _offsetCell;
  79991. /**
  79992. * Remove a column definition at specified index
  79993. * @param index defines the index of the column to remove
  79994. * @returns the current grid
  79995. */
  79996. removeColumnDefinition(index: number): Grid;
  79997. /**
  79998. * Remove a row definition at specified index
  79999. * @param index defines the index of the row to remove
  80000. * @returns the current grid
  80001. */
  80002. removeRowDefinition(index: number): Grid;
  80003. /**
  80004. * Adds a new control to the current grid
  80005. * @param control defines the control to add
  80006. * @param row defines the row where to add the control (0 by default)
  80007. * @param column defines the column where to add the control (0 by default)
  80008. * @returns the current grid
  80009. */
  80010. addControl(control: Control, row?: number, column?: number): Grid;
  80011. /**
  80012. * Removes a control from the current container
  80013. * @param control defines the control to remove
  80014. * @returns the current container
  80015. */
  80016. removeControl(control: Control): Container;
  80017. /**
  80018. * Creates a new Grid
  80019. * @param name defines control name
  80020. */
  80021. constructor(name?: string | undefined);
  80022. protected _getTypeName(): string;
  80023. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80024. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80025. _flagDescendantsAsMatrixDirty(): void;
  80026. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80027. /** Releases associated resources */
  80028. dispose(): void;
  80029. }
  80030. }
  80031. declare module BABYLON.GUI {
  80032. /** Class used to create color pickers */
  80033. export class ColorPicker extends Control {
  80034. name?: string | undefined;
  80035. private static _Epsilon;
  80036. private _colorWheelCanvas;
  80037. private _value;
  80038. private _tmpColor;
  80039. private _pointerStartedOnSquare;
  80040. private _pointerStartedOnWheel;
  80041. private _squareLeft;
  80042. private _squareTop;
  80043. private _squareSize;
  80044. private _h;
  80045. private _s;
  80046. private _v;
  80047. private _lastPointerDownID;
  80048. /**
  80049. * BABYLON.Observable raised when the value changes
  80050. */
  80051. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80052. /** Gets or sets the color of the color picker */
  80053. get value(): BABYLON.Color3;
  80054. set value(value: BABYLON.Color3);
  80055. /**
  80056. * Gets or sets control width
  80057. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80058. */
  80059. get width(): string | number;
  80060. set width(value: string | number);
  80061. /**
  80062. * Gets or sets control height
  80063. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80064. */
  80065. get height(): string | number;
  80066. /** Gets or sets control height */
  80067. set height(value: string | number);
  80068. /** Gets or sets control size */
  80069. get size(): string | number;
  80070. set size(value: string | number);
  80071. /**
  80072. * Creates a new ColorPicker
  80073. * @param name defines the control name
  80074. */
  80075. constructor(name?: string | undefined);
  80076. protected _getTypeName(): string;
  80077. /** @hidden */
  80078. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80079. private _updateSquareProps;
  80080. private _drawGradientSquare;
  80081. private _drawCircle;
  80082. private _createColorWheelCanvas;
  80083. /** @hidden */
  80084. _draw(context: CanvasRenderingContext2D): void;
  80085. private _pointerIsDown;
  80086. private _updateValueFromPointer;
  80087. private _isPointOnSquare;
  80088. private _isPointOnWheel;
  80089. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80090. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80091. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80092. _onCanvasBlur(): void;
  80093. /**
  80094. * This function expands the color picker by creating a color picker dialog with manual
  80095. * color value input and the ability to save colors into an array to be used later in
  80096. * subsequent launches of the dialogue.
  80097. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80098. * @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.
  80099. * @returns picked color as a hex string and the saved colors array as hex strings.
  80100. */
  80101. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80102. pickerWidth?: string;
  80103. pickerHeight?: string;
  80104. headerHeight?: string;
  80105. lastColor?: string;
  80106. swatchLimit?: number;
  80107. numSwatchesPerLine?: number;
  80108. savedColors?: Array<string>;
  80109. }): Promise<{
  80110. savedColors?: string[];
  80111. pickedColor: string;
  80112. }>;
  80113. }
  80114. }
  80115. declare module BABYLON.GUI {
  80116. /** Class used to create 2D ellipse containers */
  80117. export class Ellipse extends Container {
  80118. name?: string | undefined;
  80119. private _thickness;
  80120. /** Gets or sets border thickness */
  80121. get thickness(): number;
  80122. set thickness(value: number);
  80123. /**
  80124. * Creates a new Ellipse
  80125. * @param name defines the control name
  80126. */
  80127. constructor(name?: string | undefined);
  80128. protected _getTypeName(): string;
  80129. protected _localDraw(context: CanvasRenderingContext2D): void;
  80130. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80131. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80132. }
  80133. }
  80134. declare module BABYLON.GUI {
  80135. /**
  80136. * Class used to create a password control
  80137. */
  80138. export class InputPassword extends InputText {
  80139. protected _beforeRenderText(text: string): string;
  80140. }
  80141. }
  80142. declare module BABYLON.GUI {
  80143. /** Class used to render 2D lines */
  80144. export class Line extends Control {
  80145. name?: string | undefined;
  80146. private _lineWidth;
  80147. private _x1;
  80148. private _y1;
  80149. private _x2;
  80150. private _y2;
  80151. private _dash;
  80152. private _connectedControl;
  80153. private _connectedControlDirtyObserver;
  80154. /** Gets or sets the dash pattern */
  80155. get dash(): Array<number>;
  80156. set dash(value: Array<number>);
  80157. /** Gets or sets the control connected with the line end */
  80158. get connectedControl(): Control;
  80159. set connectedControl(value: Control);
  80160. /** Gets or sets start coordinates on X axis */
  80161. get x1(): string | number;
  80162. set x1(value: string | number);
  80163. /** Gets or sets start coordinates on Y axis */
  80164. get y1(): string | number;
  80165. set y1(value: string | number);
  80166. /** Gets or sets end coordinates on X axis */
  80167. get x2(): string | number;
  80168. set x2(value: string | number);
  80169. /** Gets or sets end coordinates on Y axis */
  80170. get y2(): string | number;
  80171. set y2(value: string | number);
  80172. /** Gets or sets line width */
  80173. get lineWidth(): number;
  80174. set lineWidth(value: number);
  80175. /** Gets or sets horizontal alignment */
  80176. set horizontalAlignment(value: number);
  80177. /** Gets or sets vertical alignment */
  80178. set verticalAlignment(value: number);
  80179. private get _effectiveX2();
  80180. private get _effectiveY2();
  80181. /**
  80182. * Creates a new Line
  80183. * @param name defines the control name
  80184. */
  80185. constructor(name?: string | undefined);
  80186. protected _getTypeName(): string;
  80187. _draw(context: CanvasRenderingContext2D): void;
  80188. _measure(): void;
  80189. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80190. /**
  80191. * Move one end of the line given 3D cartesian coordinates.
  80192. * @param position Targeted world position
  80193. * @param scene BABYLON.Scene
  80194. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80195. */
  80196. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80197. /**
  80198. * Move one end of the line to a position in screen absolute space.
  80199. * @param projectedPosition Position in screen absolute space (X, Y)
  80200. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80201. */
  80202. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80203. }
  80204. }
  80205. declare module BABYLON.GUI {
  80206. /**
  80207. * Class used to store a point for a MultiLine object.
  80208. * The point can be pure 2D coordinates, a mesh or a control
  80209. */
  80210. export class MultiLinePoint {
  80211. private _multiLine;
  80212. private _x;
  80213. private _y;
  80214. private _control;
  80215. private _mesh;
  80216. private _controlObserver;
  80217. private _meshObserver;
  80218. /** @hidden */
  80219. _point: BABYLON.Vector2;
  80220. /**
  80221. * Creates a new MultiLinePoint
  80222. * @param multiLine defines the source MultiLine object
  80223. */
  80224. constructor(multiLine: MultiLine);
  80225. /** Gets or sets x coordinate */
  80226. get x(): string | number;
  80227. set x(value: string | number);
  80228. /** Gets or sets y coordinate */
  80229. get y(): string | number;
  80230. set y(value: string | number);
  80231. /** Gets or sets the control associated with this point */
  80232. get control(): BABYLON.Nullable<Control>;
  80233. set control(value: BABYLON.Nullable<Control>);
  80234. /** Gets or sets the mesh associated with this point */
  80235. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80236. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80237. /** Resets links */
  80238. resetLinks(): void;
  80239. /**
  80240. * Gets a translation vector
  80241. * @returns the translation vector
  80242. */
  80243. translate(): BABYLON.Vector2;
  80244. private _translatePoint;
  80245. /** Release associated resources */
  80246. dispose(): void;
  80247. }
  80248. }
  80249. declare module BABYLON.GUI {
  80250. /**
  80251. * Class used to create multi line control
  80252. */
  80253. export class MultiLine extends Control {
  80254. name?: string | undefined;
  80255. private _lineWidth;
  80256. private _dash;
  80257. private _points;
  80258. private _minX;
  80259. private _minY;
  80260. private _maxX;
  80261. private _maxY;
  80262. /**
  80263. * Creates a new MultiLine
  80264. * @param name defines the control name
  80265. */
  80266. constructor(name?: string | undefined);
  80267. /** Gets or sets dash pattern */
  80268. get dash(): Array<number>;
  80269. set dash(value: Array<number>);
  80270. /**
  80271. * Gets point stored at specified index
  80272. * @param index defines the index to look for
  80273. * @returns the requested point if found
  80274. */
  80275. getAt(index: number): MultiLinePoint;
  80276. /** Function called when a point is updated */
  80277. onPointUpdate: () => void;
  80278. /**
  80279. * Adds new points to the point collection
  80280. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80281. * @returns the list of created MultiLinePoint
  80282. */
  80283. add(...items: (AbstractMesh | Control | {
  80284. x: string | number;
  80285. y: string | number;
  80286. })[]): MultiLinePoint[];
  80287. /**
  80288. * Adds a new point to the point collection
  80289. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80290. * @returns the created MultiLinePoint
  80291. */
  80292. push(item?: (AbstractMesh | Control | {
  80293. x: string | number;
  80294. y: string | number;
  80295. })): MultiLinePoint;
  80296. /**
  80297. * Remove a specific value or point from the active point collection
  80298. * @param value defines the value or point to remove
  80299. */
  80300. remove(value: number | MultiLinePoint): void;
  80301. /**
  80302. * Resets this object to initial state (no point)
  80303. */
  80304. reset(): void;
  80305. /**
  80306. * Resets all links
  80307. */
  80308. resetLinks(): void;
  80309. /** Gets or sets line width */
  80310. get lineWidth(): number;
  80311. set lineWidth(value: number);
  80312. set horizontalAlignment(value: number);
  80313. set verticalAlignment(value: number);
  80314. protected _getTypeName(): string;
  80315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80316. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80317. _measure(): void;
  80318. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80319. dispose(): void;
  80320. }
  80321. }
  80322. declare module BABYLON.GUI {
  80323. /**
  80324. * Class used to create radio button controls
  80325. */
  80326. export class RadioButton extends Control {
  80327. name?: string | undefined;
  80328. private _isChecked;
  80329. private _background;
  80330. private _checkSizeRatio;
  80331. private _thickness;
  80332. /** Gets or sets border thickness */
  80333. get thickness(): number;
  80334. set thickness(value: number);
  80335. /** Gets or sets group name */
  80336. group: string;
  80337. /** BABYLON.Observable raised when isChecked is changed */
  80338. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80339. /** Gets or sets a value indicating the ratio between overall size and check size */
  80340. get checkSizeRatio(): number;
  80341. set checkSizeRatio(value: number);
  80342. /** Gets or sets background color */
  80343. get background(): string;
  80344. set background(value: string);
  80345. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80346. get isChecked(): boolean;
  80347. set isChecked(value: boolean);
  80348. /**
  80349. * Creates a new RadioButton
  80350. * @param name defines the control name
  80351. */
  80352. constructor(name?: string | undefined);
  80353. protected _getTypeName(): string;
  80354. _draw(context: CanvasRenderingContext2D): void;
  80355. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80356. /**
  80357. * Utility function to easily create a radio button with a header
  80358. * @param title defines the label to use for the header
  80359. * @param group defines the group to use for the radio button
  80360. * @param isChecked defines the initial state of the radio button
  80361. * @param onValueChanged defines the callback to call when value changes
  80362. * @returns a StackPanel containing the radio button and a textBlock
  80363. */
  80364. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80365. }
  80366. }
  80367. declare module BABYLON.GUI {
  80368. /**
  80369. * Class used to create slider controls
  80370. */
  80371. export class BaseSlider extends Control {
  80372. name?: string | undefined;
  80373. protected _thumbWidth: ValueAndUnit;
  80374. private _minimum;
  80375. private _maximum;
  80376. private _value;
  80377. private _isVertical;
  80378. protected _barOffset: ValueAndUnit;
  80379. private _isThumbClamped;
  80380. protected _displayThumb: boolean;
  80381. private _step;
  80382. private _lastPointerDownID;
  80383. protected _effectiveBarOffset: number;
  80384. protected _renderLeft: number;
  80385. protected _renderTop: number;
  80386. protected _renderWidth: number;
  80387. protected _renderHeight: number;
  80388. protected _backgroundBoxLength: number;
  80389. protected _backgroundBoxThickness: number;
  80390. protected _effectiveThumbThickness: number;
  80391. /** BABYLON.Observable raised when the sldier value changes */
  80392. onValueChangedObservable: BABYLON.Observable<number>;
  80393. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80394. get displayThumb(): boolean;
  80395. set displayThumb(value: boolean);
  80396. /** Gets or sets a step to apply to values (0 by default) */
  80397. get step(): number;
  80398. set step(value: number);
  80399. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80400. get barOffset(): string | number;
  80401. /** Gets main bar offset in pixels*/
  80402. get barOffsetInPixels(): number;
  80403. set barOffset(value: string | number);
  80404. /** Gets or sets thumb width */
  80405. get thumbWidth(): string | number;
  80406. /** Gets thumb width in pixels */
  80407. get thumbWidthInPixels(): number;
  80408. set thumbWidth(value: string | number);
  80409. /** Gets or sets minimum value */
  80410. get minimum(): number;
  80411. set minimum(value: number);
  80412. /** Gets or sets maximum value */
  80413. get maximum(): number;
  80414. set maximum(value: number);
  80415. /** Gets or sets current value */
  80416. get value(): number;
  80417. set value(value: number);
  80418. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80419. get isVertical(): boolean;
  80420. set isVertical(value: boolean);
  80421. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80422. get isThumbClamped(): boolean;
  80423. set isThumbClamped(value: boolean);
  80424. /**
  80425. * Creates a new BaseSlider
  80426. * @param name defines the control name
  80427. */
  80428. constructor(name?: string | undefined);
  80429. protected _getTypeName(): string;
  80430. protected _getThumbPosition(): number;
  80431. protected _getThumbThickness(type: string): number;
  80432. protected _prepareRenderingData(type: string): void;
  80433. private _pointerIsDown;
  80434. /** @hidden */
  80435. protected _updateValueFromPointer(x: number, y: number): void;
  80436. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80437. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80438. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80439. _onCanvasBlur(): void;
  80440. }
  80441. }
  80442. declare module BABYLON.GUI {
  80443. /**
  80444. * Class used to create slider controls
  80445. */
  80446. export class Slider extends BaseSlider {
  80447. name?: string | undefined;
  80448. private _background;
  80449. private _borderColor;
  80450. private _thumbColor;
  80451. private _isThumbCircle;
  80452. protected _displayValueBar: boolean;
  80453. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80454. get displayValueBar(): boolean;
  80455. set displayValueBar(value: boolean);
  80456. /** Gets or sets border color */
  80457. get borderColor(): string;
  80458. set borderColor(value: string);
  80459. /** Gets or sets background color */
  80460. get background(): string;
  80461. set background(value: string);
  80462. /** Gets or sets thumb's color */
  80463. get thumbColor(): string;
  80464. set thumbColor(value: string);
  80465. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80466. get isThumbCircle(): boolean;
  80467. set isThumbCircle(value: boolean);
  80468. /**
  80469. * Creates a new Slider
  80470. * @param name defines the control name
  80471. */
  80472. constructor(name?: string | undefined);
  80473. protected _getTypeName(): string;
  80474. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80475. }
  80476. }
  80477. declare module BABYLON.GUI {
  80478. /** Class used to create a RadioGroup
  80479. * which contains groups of radio buttons
  80480. */
  80481. export class SelectorGroup {
  80482. /** name of SelectorGroup */
  80483. name: string;
  80484. private _groupPanel;
  80485. private _selectors;
  80486. private _groupHeader;
  80487. /**
  80488. * Creates a new SelectorGroup
  80489. * @param name of group, used as a group heading
  80490. */
  80491. constructor(
  80492. /** name of SelectorGroup */
  80493. name: string);
  80494. /** Gets the groupPanel of the SelectorGroup */
  80495. get groupPanel(): StackPanel;
  80496. /** Gets the selectors array */
  80497. get selectors(): StackPanel[];
  80498. /** Gets and sets the group header */
  80499. get header(): string;
  80500. set header(label: string);
  80501. /** @hidden */
  80502. private _addGroupHeader;
  80503. /** @hidden*/
  80504. _getSelector(selectorNb: number): StackPanel | undefined;
  80505. /** Removes the selector at the given position
  80506. * @param selectorNb the position of the selector within the group
  80507. */
  80508. removeSelector(selectorNb: number): void;
  80509. }
  80510. /** Class used to create a CheckboxGroup
  80511. * which contains groups of checkbox buttons
  80512. */
  80513. export class CheckboxGroup extends SelectorGroup {
  80514. /** Adds a checkbox as a control
  80515. * @param text is the label for the selector
  80516. * @param func is the function called when the Selector is checked
  80517. * @param checked is true when Selector is checked
  80518. */
  80519. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80520. /** @hidden */
  80521. _setSelectorLabel(selectorNb: number, label: string): void;
  80522. /** @hidden */
  80523. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80524. /** @hidden */
  80525. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80526. /** @hidden */
  80527. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80528. }
  80529. /** Class used to create a RadioGroup
  80530. * which contains groups of radio buttons
  80531. */
  80532. export class RadioGroup extends SelectorGroup {
  80533. private _selectNb;
  80534. /** Adds a radio button as a control
  80535. * @param label is the label for the selector
  80536. * @param func is the function called when the Selector is checked
  80537. * @param checked is true when Selector is checked
  80538. */
  80539. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80540. /** @hidden */
  80541. _setSelectorLabel(selectorNb: number, label: string): void;
  80542. /** @hidden */
  80543. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80544. /** @hidden */
  80545. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80546. /** @hidden */
  80547. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80548. }
  80549. /** Class used to create a SliderGroup
  80550. * which contains groups of slider buttons
  80551. */
  80552. export class SliderGroup extends SelectorGroup {
  80553. /**
  80554. * Adds a slider to the SelectorGroup
  80555. * @param label is the label for the SliderBar
  80556. * @param func is the function called when the Slider moves
  80557. * @param unit is a string describing the units used, eg degrees or metres
  80558. * @param min is the minimum value for the Slider
  80559. * @param max is the maximum value for the Slider
  80560. * @param value is the start value for the Slider between min and max
  80561. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80562. */
  80563. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80564. /** @hidden */
  80565. _setSelectorLabel(selectorNb: number, label: string): void;
  80566. /** @hidden */
  80567. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80568. /** @hidden */
  80569. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80570. /** @hidden */
  80571. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80572. }
  80573. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80574. * @see https://doc.babylonjs.com/how_to/selector
  80575. */
  80576. export class SelectionPanel extends Rectangle {
  80577. /** name of SelectionPanel */
  80578. name: string;
  80579. /** an array of SelectionGroups */
  80580. groups: SelectorGroup[];
  80581. private _panel;
  80582. private _buttonColor;
  80583. private _buttonBackground;
  80584. private _headerColor;
  80585. private _barColor;
  80586. private _barHeight;
  80587. private _spacerHeight;
  80588. private _labelColor;
  80589. private _groups;
  80590. private _bars;
  80591. /**
  80592. * Creates a new SelectionPanel
  80593. * @param name of SelectionPanel
  80594. * @param groups is an array of SelectionGroups
  80595. */
  80596. constructor(
  80597. /** name of SelectionPanel */
  80598. name: string,
  80599. /** an array of SelectionGroups */
  80600. groups?: SelectorGroup[]);
  80601. protected _getTypeName(): string;
  80602. /** Gets the (stack) panel of the SelectionPanel */
  80603. get panel(): StackPanel;
  80604. /** Gets or sets the headerColor */
  80605. get headerColor(): string;
  80606. set headerColor(color: string);
  80607. private _setHeaderColor;
  80608. /** Gets or sets the button color */
  80609. get buttonColor(): string;
  80610. set buttonColor(color: string);
  80611. private _setbuttonColor;
  80612. /** Gets or sets the label color */
  80613. get labelColor(): string;
  80614. set labelColor(color: string);
  80615. private _setLabelColor;
  80616. /** Gets or sets the button background */
  80617. get buttonBackground(): string;
  80618. set buttonBackground(color: string);
  80619. private _setButtonBackground;
  80620. /** Gets or sets the color of separator bar */
  80621. get barColor(): string;
  80622. set barColor(color: string);
  80623. private _setBarColor;
  80624. /** Gets or sets the height of separator bar */
  80625. get barHeight(): string;
  80626. set barHeight(value: string);
  80627. private _setBarHeight;
  80628. /** Gets or sets the height of spacers*/
  80629. get spacerHeight(): string;
  80630. set spacerHeight(value: string);
  80631. private _setSpacerHeight;
  80632. /** Adds a bar between groups */
  80633. private _addSpacer;
  80634. /** Add a group to the selection panel
  80635. * @param group is the selector group to add
  80636. */
  80637. addGroup(group: SelectorGroup): void;
  80638. /** Remove the group from the given position
  80639. * @param groupNb is the position of the group in the list
  80640. */
  80641. removeGroup(groupNb: number): void;
  80642. /** Change a group header label
  80643. * @param label is the new group header label
  80644. * @param groupNb is the number of the group to relabel
  80645. * */
  80646. setHeaderName(label: string, groupNb: number): void;
  80647. /** Change selector label to the one given
  80648. * @param label is the new selector label
  80649. * @param groupNb is the number of the groupcontaining the selector
  80650. * @param selectorNb is the number of the selector within a group to relabel
  80651. * */
  80652. relabel(label: string, groupNb: number, selectorNb: number): void;
  80653. /** For a given group position remove the selector at the given position
  80654. * @param groupNb is the number of the group to remove the selector from
  80655. * @param selectorNb is the number of the selector within the group
  80656. */
  80657. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80658. /** For a given group position of correct type add a checkbox button
  80659. * @param groupNb is the number of the group to remove the selector from
  80660. * @param label is the label for the selector
  80661. * @param func is the function called when the Selector is checked
  80662. * @param checked is true when Selector is checked
  80663. */
  80664. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80665. /** For a given group position of correct type add a radio button
  80666. * @param groupNb is the number of the group to remove the selector from
  80667. * @param label is the label for the selector
  80668. * @param func is the function called when the Selector is checked
  80669. * @param checked is true when Selector is checked
  80670. */
  80671. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80672. /**
  80673. * For a given slider group add a slider
  80674. * @param groupNb is the number of the group to add the slider to
  80675. * @param label is the label for the Slider
  80676. * @param func is the function called when the Slider moves
  80677. * @param unit is a string describing the units used, eg degrees or metres
  80678. * @param min is the minimum value for the Slider
  80679. * @param max is the maximum value for the Slider
  80680. * @param value is the start value for the Slider between min and max
  80681. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80682. */
  80683. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80684. }
  80685. }
  80686. declare module BABYLON.GUI {
  80687. /**
  80688. * Class used to hold a the container for ScrollViewer
  80689. * @hidden
  80690. */
  80691. export class _ScrollViewerWindow extends Container {
  80692. parentClientWidth: number;
  80693. parentClientHeight: number;
  80694. private _freezeControls;
  80695. private _parentMeasure;
  80696. private _oldLeft;
  80697. private _oldTop;
  80698. get freezeControls(): boolean;
  80699. set freezeControls(value: boolean);
  80700. private _bucketWidth;
  80701. private _bucketHeight;
  80702. private _buckets;
  80703. private _bucketLen;
  80704. get bucketWidth(): number;
  80705. get bucketHeight(): number;
  80706. setBucketSizes(width: number, height: number): void;
  80707. private _useBuckets;
  80708. private _makeBuckets;
  80709. private _dispatchInBuckets;
  80710. private _updateMeasures;
  80711. private _updateChildrenMeasures;
  80712. private _restoreMeasures;
  80713. /**
  80714. * Creates a new ScrollViewerWindow
  80715. * @param name of ScrollViewerWindow
  80716. */
  80717. constructor(name?: string);
  80718. protected _getTypeName(): string;
  80719. /** @hidden */
  80720. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80721. /** @hidden */
  80722. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80723. private _scrollChildren;
  80724. private _scrollChildrenWithBuckets;
  80725. /** @hidden */
  80726. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80727. protected _postMeasure(): void;
  80728. }
  80729. }
  80730. declare module BABYLON.GUI {
  80731. /**
  80732. * Class used to create slider controls
  80733. */
  80734. export class ScrollBar extends BaseSlider {
  80735. name?: string | undefined;
  80736. private _background;
  80737. private _borderColor;
  80738. private _tempMeasure;
  80739. /** Gets or sets border color */
  80740. get borderColor(): string;
  80741. set borderColor(value: string);
  80742. /** Gets or sets background color */
  80743. get background(): string;
  80744. set background(value: string);
  80745. /**
  80746. * Creates a new Slider
  80747. * @param name defines the control name
  80748. */
  80749. constructor(name?: string | undefined);
  80750. protected _getTypeName(): string;
  80751. protected _getThumbThickness(): number;
  80752. _draw(context: CanvasRenderingContext2D): void;
  80753. private _first;
  80754. private _originX;
  80755. private _originY;
  80756. /** @hidden */
  80757. protected _updateValueFromPointer(x: number, y: number): void;
  80758. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80759. }
  80760. }
  80761. declare module BABYLON.GUI {
  80762. /**
  80763. * Class used to create slider controls
  80764. */
  80765. export class ImageScrollBar extends BaseSlider {
  80766. name?: string | undefined;
  80767. private _backgroundBaseImage;
  80768. private _backgroundImage;
  80769. private _thumbImage;
  80770. private _thumbBaseImage;
  80771. private _thumbLength;
  80772. private _thumbHeight;
  80773. private _barImageHeight;
  80774. private _tempMeasure;
  80775. /** Number of 90° rotation to apply on the images when in vertical mode */
  80776. num90RotationInVerticalMode: number;
  80777. /**
  80778. * Gets or sets the image used to render the background for horizontal bar
  80779. */
  80780. get backgroundImage(): Image;
  80781. set backgroundImage(value: Image);
  80782. /**
  80783. * Gets or sets the image used to render the thumb
  80784. */
  80785. get thumbImage(): Image;
  80786. set thumbImage(value: Image);
  80787. /**
  80788. * Gets or sets the length of the thumb
  80789. */
  80790. get thumbLength(): number;
  80791. set thumbLength(value: number);
  80792. /**
  80793. * Gets or sets the height of the thumb
  80794. */
  80795. get thumbHeight(): number;
  80796. set thumbHeight(value: number);
  80797. /**
  80798. * Gets or sets the height of the bar image
  80799. */
  80800. get barImageHeight(): number;
  80801. set barImageHeight(value: number);
  80802. /**
  80803. * Creates a new ImageScrollBar
  80804. * @param name defines the control name
  80805. */
  80806. constructor(name?: string | undefined);
  80807. protected _getTypeName(): string;
  80808. protected _getThumbThickness(): number;
  80809. _draw(context: CanvasRenderingContext2D): void;
  80810. private _first;
  80811. private _originX;
  80812. private _originY;
  80813. /** @hidden */
  80814. protected _updateValueFromPointer(x: number, y: number): void;
  80815. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80816. }
  80817. }
  80818. declare module BABYLON.GUI {
  80819. /**
  80820. * Class used to hold a viewer window and sliders in a grid
  80821. */
  80822. export class ScrollViewer extends Rectangle {
  80823. private _grid;
  80824. private _horizontalBarSpace;
  80825. private _verticalBarSpace;
  80826. private _dragSpace;
  80827. private _horizontalBar;
  80828. private _verticalBar;
  80829. private _barColor;
  80830. private _barBackground;
  80831. private _barImage;
  80832. private _horizontalBarImage;
  80833. private _verticalBarImage;
  80834. private _barBackgroundImage;
  80835. private _horizontalBarBackgroundImage;
  80836. private _verticalBarBackgroundImage;
  80837. private _barSize;
  80838. private _window;
  80839. private _pointerIsOver;
  80840. private _wheelPrecision;
  80841. private _onWheelObserver;
  80842. private _clientWidth;
  80843. private _clientHeight;
  80844. private _useImageBar;
  80845. private _thumbLength;
  80846. private _thumbHeight;
  80847. private _barImageHeight;
  80848. private _horizontalBarImageHeight;
  80849. private _verticalBarImageHeight;
  80850. private _oldWindowContentsWidth;
  80851. private _oldWindowContentsHeight;
  80852. /**
  80853. * Gets the horizontal scrollbar
  80854. */
  80855. get horizontalBar(): ScrollBar | ImageScrollBar;
  80856. /**
  80857. * Gets the vertical scrollbar
  80858. */
  80859. get verticalBar(): ScrollBar | ImageScrollBar;
  80860. /**
  80861. * Adds a new control to the current container
  80862. * @param control defines the control to add
  80863. * @returns the current container
  80864. */
  80865. addControl(control: BABYLON.Nullable<Control>): Container;
  80866. /**
  80867. * Removes a control from the current container
  80868. * @param control defines the control to remove
  80869. * @returns the current container
  80870. */
  80871. removeControl(control: Control): Container;
  80872. /** Gets the list of children */
  80873. get children(): Control[];
  80874. _flagDescendantsAsMatrixDirty(): void;
  80875. /**
  80876. * Freezes or unfreezes the controls in the window.
  80877. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80878. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80879. */
  80880. get freezeControls(): boolean;
  80881. set freezeControls(value: boolean);
  80882. /** Gets the bucket width */
  80883. get bucketWidth(): number;
  80884. /** Gets the bucket height */
  80885. get bucketHeight(): number;
  80886. /**
  80887. * Sets the bucket sizes.
  80888. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80889. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80890. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80891. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80892. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80893. * used), that's why it is not enabled by default.
  80894. * @param width width of the bucket
  80895. * @param height height of the bucket
  80896. */
  80897. setBucketSizes(width: number, height: number): void;
  80898. private _forceHorizontalBar;
  80899. private _forceVerticalBar;
  80900. /**
  80901. * Forces the horizontal scroll bar to be displayed
  80902. */
  80903. get forceHorizontalBar(): boolean;
  80904. set forceHorizontalBar(value: boolean);
  80905. /**
  80906. * Forces the vertical scroll bar to be displayed
  80907. */
  80908. get forceVerticalBar(): boolean;
  80909. set forceVerticalBar(value: boolean);
  80910. /**
  80911. * Creates a new ScrollViewer
  80912. * @param name of ScrollViewer
  80913. */
  80914. constructor(name?: string, isImageBased?: boolean);
  80915. /** Reset the scroll viewer window to initial size */
  80916. resetWindow(): void;
  80917. protected _getTypeName(): string;
  80918. private _buildClientSizes;
  80919. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80920. protected _postMeasure(): void;
  80921. /**
  80922. * Gets or sets the mouse wheel precision
  80923. * from 0 to 1 with a default value of 0.05
  80924. * */
  80925. get wheelPrecision(): number;
  80926. set wheelPrecision(value: number);
  80927. /** Gets or sets the scroll bar container background color */
  80928. get scrollBackground(): string;
  80929. set scrollBackground(color: string);
  80930. /** Gets or sets the bar color */
  80931. get barColor(): string;
  80932. set barColor(color: string);
  80933. /** Gets or sets the bar image */
  80934. get thumbImage(): Image;
  80935. set thumbImage(value: Image);
  80936. /** Gets or sets the horizontal bar image */
  80937. get horizontalThumbImage(): Image;
  80938. set horizontalThumbImage(value: Image);
  80939. /** Gets or sets the vertical bar image */
  80940. get verticalThumbImage(): Image;
  80941. set verticalThumbImage(value: Image);
  80942. /** Gets or sets the size of the bar */
  80943. get barSize(): number;
  80944. set barSize(value: number);
  80945. /** Gets or sets the length of the thumb */
  80946. get thumbLength(): number;
  80947. set thumbLength(value: number);
  80948. /** Gets or sets the height of the thumb */
  80949. get thumbHeight(): number;
  80950. set thumbHeight(value: number);
  80951. /** Gets or sets the height of the bar image */
  80952. get barImageHeight(): number;
  80953. set barImageHeight(value: number);
  80954. /** Gets or sets the height of the horizontal bar image */
  80955. get horizontalBarImageHeight(): number;
  80956. set horizontalBarImageHeight(value: number);
  80957. /** Gets or sets the height of the vertical bar image */
  80958. get verticalBarImageHeight(): number;
  80959. set verticalBarImageHeight(value: number);
  80960. /** Gets or sets the bar background */
  80961. get barBackground(): string;
  80962. set barBackground(color: string);
  80963. /** Gets or sets the bar background image */
  80964. get barImage(): Image;
  80965. set barImage(value: Image);
  80966. /** Gets or sets the horizontal bar background image */
  80967. get horizontalBarImage(): Image;
  80968. set horizontalBarImage(value: Image);
  80969. /** Gets or sets the vertical bar background image */
  80970. get verticalBarImage(): Image;
  80971. set verticalBarImage(value: Image);
  80972. private _setWindowPosition;
  80973. /** @hidden */
  80974. private _updateScroller;
  80975. _link(host: AdvancedDynamicTexture): void;
  80976. /** @hidden */
  80977. private _addBar;
  80978. /** @hidden */
  80979. private _attachWheel;
  80980. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80981. /** Releases associated resources */
  80982. dispose(): void;
  80983. }
  80984. }
  80985. declare module BABYLON.GUI {
  80986. /** Class used to render a grid */
  80987. export class DisplayGrid extends Control {
  80988. name?: string | undefined;
  80989. private _cellWidth;
  80990. private _cellHeight;
  80991. private _minorLineTickness;
  80992. private _minorLineColor;
  80993. private _majorLineTickness;
  80994. private _majorLineColor;
  80995. private _majorLineFrequency;
  80996. private _background;
  80997. private _displayMajorLines;
  80998. private _displayMinorLines;
  80999. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81000. get displayMinorLines(): boolean;
  81001. set displayMinorLines(value: boolean);
  81002. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81003. get displayMajorLines(): boolean;
  81004. set displayMajorLines(value: boolean);
  81005. /** Gets or sets background color (Black by default) */
  81006. get background(): string;
  81007. set background(value: string);
  81008. /** Gets or sets the width of each cell (20 by default) */
  81009. get cellWidth(): number;
  81010. set cellWidth(value: number);
  81011. /** Gets or sets the height of each cell (20 by default) */
  81012. get cellHeight(): number;
  81013. set cellHeight(value: number);
  81014. /** Gets or sets the tickness of minor lines (1 by default) */
  81015. get minorLineTickness(): number;
  81016. set minorLineTickness(value: number);
  81017. /** Gets or sets the color of minor lines (DarkGray by default) */
  81018. get minorLineColor(): string;
  81019. set minorLineColor(value: string);
  81020. /** Gets or sets the tickness of major lines (2 by default) */
  81021. get majorLineTickness(): number;
  81022. set majorLineTickness(value: number);
  81023. /** Gets or sets the color of major lines (White by default) */
  81024. get majorLineColor(): string;
  81025. set majorLineColor(value: string);
  81026. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81027. get majorLineFrequency(): number;
  81028. set majorLineFrequency(value: number);
  81029. /**
  81030. * Creates a new GridDisplayRectangle
  81031. * @param name defines the control name
  81032. */
  81033. constructor(name?: string | undefined);
  81034. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81035. protected _getTypeName(): string;
  81036. }
  81037. }
  81038. declare module BABYLON.GUI {
  81039. /**
  81040. * Class used to create slider controls based on images
  81041. */
  81042. export class ImageBasedSlider extends BaseSlider {
  81043. name?: string | undefined;
  81044. private _backgroundImage;
  81045. private _thumbImage;
  81046. private _valueBarImage;
  81047. private _tempMeasure;
  81048. get displayThumb(): boolean;
  81049. set displayThumb(value: boolean);
  81050. /**
  81051. * Gets or sets the image used to render the background
  81052. */
  81053. get backgroundImage(): Image;
  81054. set backgroundImage(value: Image);
  81055. /**
  81056. * Gets or sets the image used to render the value bar
  81057. */
  81058. get valueBarImage(): Image;
  81059. set valueBarImage(value: Image);
  81060. /**
  81061. * Gets or sets the image used to render the thumb
  81062. */
  81063. get thumbImage(): Image;
  81064. set thumbImage(value: Image);
  81065. /**
  81066. * Creates a new ImageBasedSlider
  81067. * @param name defines the control name
  81068. */
  81069. constructor(name?: string | undefined);
  81070. protected _getTypeName(): string;
  81071. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81072. }
  81073. }
  81074. declare module BABYLON.GUI {
  81075. /**
  81076. * Forcing an export so that this code will execute
  81077. * @hidden
  81078. */
  81079. const name = "Statics";
  81080. }
  81081. declare module BABYLON.GUI {
  81082. /**
  81083. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81084. */
  81085. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81086. /**
  81087. * Define the instrumented AdvancedDynamicTexture.
  81088. */
  81089. texture: AdvancedDynamicTexture;
  81090. private _captureRenderTime;
  81091. private _renderTime;
  81092. private _captureLayoutTime;
  81093. private _layoutTime;
  81094. private _onBeginRenderObserver;
  81095. private _onEndRenderObserver;
  81096. private _onBeginLayoutObserver;
  81097. private _onEndLayoutObserver;
  81098. /**
  81099. * Gets the perf counter used to capture render time
  81100. */
  81101. get renderTimeCounter(): BABYLON.PerfCounter;
  81102. /**
  81103. * Gets the perf counter used to capture layout time
  81104. */
  81105. get layoutTimeCounter(): BABYLON.PerfCounter;
  81106. /**
  81107. * Enable or disable the render time capture
  81108. */
  81109. get captureRenderTime(): boolean;
  81110. set captureRenderTime(value: boolean);
  81111. /**
  81112. * Enable or disable the layout time capture
  81113. */
  81114. get captureLayoutTime(): boolean;
  81115. set captureLayoutTime(value: boolean);
  81116. /**
  81117. * Instantiates a new advanced dynamic texture instrumentation.
  81118. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81119. * @param texture Defines the AdvancedDynamicTexture to instrument
  81120. */
  81121. constructor(
  81122. /**
  81123. * Define the instrumented AdvancedDynamicTexture.
  81124. */
  81125. texture: AdvancedDynamicTexture);
  81126. /**
  81127. * Dispose and release associated resources.
  81128. */
  81129. dispose(): void;
  81130. }
  81131. }
  81132. declare module BABYLON.GUI {
  81133. /**
  81134. * Class used to load GUI via XML.
  81135. */
  81136. export class XmlLoader {
  81137. private _nodes;
  81138. private _nodeTypes;
  81139. private _isLoaded;
  81140. private _objectAttributes;
  81141. private _parentClass;
  81142. /**
  81143. * Create a new xml loader
  81144. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81145. */
  81146. constructor(parentClass?: null);
  81147. private _getChainElement;
  81148. private _getClassAttribute;
  81149. private _createGuiElement;
  81150. private _parseGrid;
  81151. private _parseElement;
  81152. private _prepareSourceElement;
  81153. private _parseElementsFromSource;
  81154. private _parseXml;
  81155. /**
  81156. * Gets if the loading has finished.
  81157. * @returns whether the loading has finished or not
  81158. */
  81159. isLoaded(): boolean;
  81160. /**
  81161. * Gets a loaded node / control by id.
  81162. * @param id the Controls id set in the xml
  81163. * @returns element of type Control
  81164. */
  81165. getNodeById(id: string): any;
  81166. /**
  81167. * Gets all loaded nodes / controls
  81168. * @returns Array of controls
  81169. */
  81170. getNodes(): any;
  81171. /**
  81172. * Initiates the xml layout loading
  81173. * @param xmlFile defines the xml layout to load
  81174. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81175. * @param callback defines the callback called on layout load.
  81176. */
  81177. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81178. }
  81179. }
  81180. declare module BABYLON.GUI {
  81181. /**
  81182. * Class used to create containers for controls
  81183. */
  81184. export class Container3D extends Control3D {
  81185. private _blockLayout;
  81186. /**
  81187. * Gets the list of child controls
  81188. */
  81189. protected _children: Control3D[];
  81190. /**
  81191. * Gets the list of child controls
  81192. */
  81193. get children(): Array<Control3D>;
  81194. /**
  81195. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81196. * This is helpful to optimize layout operation when adding multiple children in a row
  81197. */
  81198. get blockLayout(): boolean;
  81199. set blockLayout(value: boolean);
  81200. /**
  81201. * Creates a new container
  81202. * @param name defines the container name
  81203. */
  81204. constructor(name?: string);
  81205. /**
  81206. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81207. * @returns the current container
  81208. */
  81209. updateLayout(): Container3D;
  81210. /**
  81211. * Gets a boolean indicating if the given control is in the children of this control
  81212. * @param control defines the control to check
  81213. * @returns true if the control is in the child list
  81214. */
  81215. containsControl(control: Control3D): boolean;
  81216. /**
  81217. * Adds a control to the children of this control
  81218. * @param control defines the control to add
  81219. * @returns the current container
  81220. */
  81221. addControl(control: Control3D): Container3D;
  81222. /**
  81223. * This function will be called everytime a new control is added
  81224. */
  81225. protected _arrangeChildren(): void;
  81226. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81227. /**
  81228. * Removes a control from the children of this control
  81229. * @param control defines the control to remove
  81230. * @returns the current container
  81231. */
  81232. removeControl(control: Control3D): Container3D;
  81233. protected _getTypeName(): string;
  81234. /**
  81235. * Releases all associated resources
  81236. */
  81237. dispose(): void;
  81238. /** Control rotation will remain unchanged */
  81239. static readonly UNSET_ORIENTATION: number;
  81240. /** Control will rotate to make it look at sphere central axis */
  81241. static readonly FACEORIGIN_ORIENTATION: number;
  81242. /** Control will rotate to make it look back at sphere central axis */
  81243. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81244. /** Control will rotate to look at z axis (0, 0, 1) */
  81245. static readonly FACEFORWARD_ORIENTATION: number;
  81246. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81247. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81248. }
  81249. }
  81250. declare module BABYLON.GUI {
  81251. /**
  81252. * Class used to manage 3D user interface
  81253. * @see https://doc.babylonjs.com/how_to/gui3d
  81254. */
  81255. export class GUI3DManager implements BABYLON.IDisposable {
  81256. private _scene;
  81257. private _sceneDisposeObserver;
  81258. private _utilityLayer;
  81259. private _rootContainer;
  81260. private _pointerObserver;
  81261. private _pointerOutObserver;
  81262. /** @hidden */
  81263. _lastPickedControl: Control3D;
  81264. /** @hidden */
  81265. _lastControlOver: {
  81266. [pointerId: number]: Control3D;
  81267. };
  81268. /** @hidden */
  81269. _lastControlDown: {
  81270. [pointerId: number]: Control3D;
  81271. };
  81272. /**
  81273. * BABYLON.Observable raised when the point picked by the pointer events changed
  81274. */
  81275. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81276. /** @hidden */
  81277. _sharedMaterials: {
  81278. [key: string]: BABYLON.Material;
  81279. };
  81280. /** Gets the hosting scene */
  81281. get scene(): BABYLON.Scene;
  81282. /** Gets associated utility layer */
  81283. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81284. /**
  81285. * Creates a new GUI3DManager
  81286. * @param scene
  81287. */
  81288. constructor(scene?: BABYLON.Scene);
  81289. private _handlePointerOut;
  81290. private _doPicking;
  81291. /**
  81292. * Gets the root container
  81293. */
  81294. get rootContainer(): Container3D;
  81295. /**
  81296. * Gets a boolean indicating if the given control is in the root child list
  81297. * @param control defines the control to check
  81298. * @returns true if the control is in the root child list
  81299. */
  81300. containsControl(control: Control3D): boolean;
  81301. /**
  81302. * Adds a control to the root child list
  81303. * @param control defines the control to add
  81304. * @returns the current manager
  81305. */
  81306. addControl(control: Control3D): GUI3DManager;
  81307. /**
  81308. * Removes a control from the root child list
  81309. * @param control defines the control to remove
  81310. * @returns the current container
  81311. */
  81312. removeControl(control: Control3D): GUI3DManager;
  81313. /**
  81314. * Releases all associated resources
  81315. */
  81316. dispose(): void;
  81317. }
  81318. }
  81319. declare module BABYLON.GUI {
  81320. /**
  81321. * Class used to transport BABYLON.Vector3 information for pointer events
  81322. */
  81323. export class Vector3WithInfo extends BABYLON.Vector3 {
  81324. /** defines the current mouse button index */
  81325. buttonIndex: number;
  81326. /**
  81327. * Creates a new Vector3WithInfo
  81328. * @param source defines the vector3 data to transport
  81329. * @param buttonIndex defines the current mouse button index
  81330. */
  81331. constructor(source: BABYLON.Vector3,
  81332. /** defines the current mouse button index */
  81333. buttonIndex?: number);
  81334. }
  81335. }
  81336. declare module BABYLON.GUI {
  81337. /**
  81338. * Class used as base class for controls
  81339. */
  81340. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81341. /** Defines the control name */
  81342. name?: string | undefined;
  81343. /** @hidden */
  81344. _host: GUI3DManager;
  81345. private _node;
  81346. private _downCount;
  81347. private _enterCount;
  81348. private _downPointerIds;
  81349. private _isVisible;
  81350. /** Gets or sets the control position in world space */
  81351. get position(): BABYLON.Vector3;
  81352. set position(value: BABYLON.Vector3);
  81353. /** Gets or sets the control scaling in world space */
  81354. get scaling(): BABYLON.Vector3;
  81355. set scaling(value: BABYLON.Vector3);
  81356. /** Callback used to start pointer enter animation */
  81357. pointerEnterAnimation: () => void;
  81358. /** Callback used to start pointer out animation */
  81359. pointerOutAnimation: () => void;
  81360. /** Callback used to start pointer down animation */
  81361. pointerDownAnimation: () => void;
  81362. /** Callback used to start pointer up animation */
  81363. pointerUpAnimation: () => void;
  81364. /**
  81365. * An event triggered when the pointer move over the control
  81366. */
  81367. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81368. /**
  81369. * An event triggered when the pointer move out of the control
  81370. */
  81371. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81372. /**
  81373. * An event triggered when the pointer taps the control
  81374. */
  81375. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81376. /**
  81377. * An event triggered when pointer is up
  81378. */
  81379. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81380. /**
  81381. * An event triggered when a control is clicked on (with a mouse)
  81382. */
  81383. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81384. /**
  81385. * An event triggered when pointer enters the control
  81386. */
  81387. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81388. /**
  81389. * Gets or sets the parent container
  81390. */
  81391. parent: BABYLON.Nullable<Container3D>;
  81392. private _behaviors;
  81393. /**
  81394. * Gets the list of attached behaviors
  81395. * @see https://doc.babylonjs.com/features/behaviour
  81396. */
  81397. get behaviors(): BABYLON.Behavior<Control3D>[];
  81398. /**
  81399. * Attach a behavior to the control
  81400. * @see https://doc.babylonjs.com/features/behaviour
  81401. * @param behavior defines the behavior to attach
  81402. * @returns the current control
  81403. */
  81404. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81405. /**
  81406. * Remove an attached behavior
  81407. * @see https://doc.babylonjs.com/features/behaviour
  81408. * @param behavior defines the behavior to attach
  81409. * @returns the current control
  81410. */
  81411. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81412. /**
  81413. * Gets an attached behavior by name
  81414. * @param name defines the name of the behavior to look for
  81415. * @see https://doc.babylonjs.com/features/behaviour
  81416. * @returns null if behavior was not found else the requested behavior
  81417. */
  81418. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81419. /** Gets or sets a boolean indicating if the control is visible */
  81420. get isVisible(): boolean;
  81421. set isVisible(value: boolean);
  81422. /**
  81423. * Creates a new control
  81424. * @param name defines the control name
  81425. */
  81426. constructor(
  81427. /** Defines the control name */
  81428. name?: string | undefined);
  81429. /**
  81430. * Gets a string representing the class name
  81431. */
  81432. get typeName(): string;
  81433. /**
  81434. * Get the current class name of the control.
  81435. * @returns current class name
  81436. */
  81437. getClassName(): string;
  81438. protected _getTypeName(): string;
  81439. /**
  81440. * Gets the transform node used by this control
  81441. */
  81442. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81443. /**
  81444. * Gets the mesh used to render this control
  81445. */
  81446. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81447. /**
  81448. * Link the control as child of the given node
  81449. * @param node defines the node to link to. Use null to unlink the control
  81450. * @returns the current control
  81451. */
  81452. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81453. /** @hidden **/
  81454. _prepareNode(scene: BABYLON.Scene): void;
  81455. /**
  81456. * Node creation.
  81457. * Can be overriden by children
  81458. * @param scene defines the scene where the node must be attached
  81459. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81460. */
  81461. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81462. /**
  81463. * Affect a material to the given mesh
  81464. * @param mesh defines the mesh which will represent the control
  81465. */
  81466. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81467. /** @hidden */
  81468. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81469. /** @hidden */
  81470. _onPointerEnter(target: Control3D): boolean;
  81471. /** @hidden */
  81472. _onPointerOut(target: Control3D): void;
  81473. /** @hidden */
  81474. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81475. /** @hidden */
  81476. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81477. /** @hidden */
  81478. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81479. /** @hidden */
  81480. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81481. /** @hidden */
  81482. _disposeNode(): void;
  81483. /**
  81484. * Releases all associated resources
  81485. */
  81486. dispose(): void;
  81487. }
  81488. }
  81489. declare module BABYLON.GUI {
  81490. /**
  81491. * Class used as a root to all buttons
  81492. */
  81493. export class AbstractButton3D extends Control3D {
  81494. /**
  81495. * Creates a new button
  81496. * @param name defines the control name
  81497. */
  81498. constructor(name?: string);
  81499. protected _getTypeName(): string;
  81500. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81501. }
  81502. }
  81503. declare module BABYLON.GUI {
  81504. /**
  81505. * Class used to create a button in 3D
  81506. */
  81507. export class Button3D extends AbstractButton3D {
  81508. /** @hidden */
  81509. protected _currentMaterial: BABYLON.Material;
  81510. private _facadeTexture;
  81511. private _content;
  81512. private _contentResolution;
  81513. private _contentScaleRatio;
  81514. /**
  81515. * Gets or sets the texture resolution used to render content (512 by default)
  81516. */
  81517. get contentResolution(): BABYLON.int;
  81518. set contentResolution(value: BABYLON.int);
  81519. /**
  81520. * Gets or sets the texture scale ratio used to render content (2 by default)
  81521. */
  81522. get contentScaleRatio(): number;
  81523. set contentScaleRatio(value: number);
  81524. protected _disposeFacadeTexture(): void;
  81525. protected _resetContent(): void;
  81526. /**
  81527. * Creates a new button
  81528. * @param name defines the control name
  81529. */
  81530. constructor(name?: string);
  81531. /**
  81532. * Gets or sets the GUI 2D content used to display the button's facade
  81533. */
  81534. get content(): Control;
  81535. set content(value: Control);
  81536. /**
  81537. * Apply the facade texture (created from the content property).
  81538. * This function can be overloaded by child classes
  81539. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81540. */
  81541. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81542. protected _getTypeName(): string;
  81543. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81544. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81545. /**
  81546. * Releases all associated resources
  81547. */
  81548. dispose(): void;
  81549. }
  81550. }
  81551. declare module BABYLON.GUI {
  81552. /**
  81553. * Abstract class used to create a container panel deployed on the surface of a volume
  81554. */
  81555. export abstract class VolumeBasedPanel extends Container3D {
  81556. private _columns;
  81557. private _rows;
  81558. private _rowThenColum;
  81559. private _orientation;
  81560. protected _cellWidth: number;
  81561. protected _cellHeight: number;
  81562. /**
  81563. * Gets or sets the distance between elements
  81564. */
  81565. margin: number;
  81566. /**
  81567. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81568. * | Value | Type | Description |
  81569. * | ----- | ----------------------------------- | ----------- |
  81570. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81571. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81572. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81573. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81574. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81575. */
  81576. get orientation(): number;
  81577. set orientation(value: number);
  81578. /**
  81579. * Gets or sets the number of columns requested (10 by default).
  81580. * The panel will automatically compute the number of rows based on number of child controls.
  81581. */
  81582. get columns(): BABYLON.int;
  81583. set columns(value: BABYLON.int);
  81584. /**
  81585. * Gets or sets a the number of rows requested.
  81586. * The panel will automatically compute the number of columns based on number of child controls.
  81587. */
  81588. get rows(): BABYLON.int;
  81589. set rows(value: BABYLON.int);
  81590. /**
  81591. * Creates new VolumeBasedPanel
  81592. */
  81593. constructor();
  81594. protected _arrangeChildren(): void;
  81595. /** Child classes must implement this function to provide correct control positioning */
  81596. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81597. /** Child classes can implement this function to provide additional processing */
  81598. protected _finalProcessing(): void;
  81599. }
  81600. }
  81601. declare module BABYLON.GUI {
  81602. /**
  81603. * Class used to create a container panel deployed on the surface of a cylinder
  81604. */
  81605. export class CylinderPanel extends VolumeBasedPanel {
  81606. private _radius;
  81607. /**
  81608. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81609. */
  81610. get radius(): BABYLON.float;
  81611. set radius(value: BABYLON.float);
  81612. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81613. private _cylindricalMapping;
  81614. }
  81615. }
  81616. declare module BABYLON.GUI {
  81617. /** @hidden */
  81618. export var fluentVertexShader: {
  81619. name: string;
  81620. shader: string;
  81621. };
  81622. }
  81623. declare module BABYLON.GUI {
  81624. /** @hidden */
  81625. export var fluentPixelShader: {
  81626. name: string;
  81627. shader: string;
  81628. };
  81629. }
  81630. declare module BABYLON.GUI {
  81631. /** @hidden */
  81632. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81633. INNERGLOW: boolean;
  81634. BORDER: boolean;
  81635. HOVERLIGHT: boolean;
  81636. TEXTURE: boolean;
  81637. constructor();
  81638. }
  81639. /**
  81640. * Class used to render controls with fluent desgin
  81641. */
  81642. export class FluentMaterial extends BABYLON.PushMaterial {
  81643. /**
  81644. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81645. */
  81646. innerGlowColorIntensity: number;
  81647. /**
  81648. * Gets or sets the inner glow color (white by default)
  81649. */
  81650. innerGlowColor: BABYLON.Color3;
  81651. /**
  81652. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81653. */
  81654. albedoColor: BABYLON.Color3;
  81655. /**
  81656. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81657. */
  81658. renderBorders: boolean;
  81659. /**
  81660. * Gets or sets border width (default is 0.5)
  81661. */
  81662. borderWidth: number;
  81663. /**
  81664. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81665. */
  81666. edgeSmoothingValue: number;
  81667. /**
  81668. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81669. */
  81670. borderMinValue: number;
  81671. /**
  81672. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81673. */
  81674. renderHoverLight: boolean;
  81675. /**
  81676. * Gets or sets the radius used to render the hover light (default is 1.0)
  81677. */
  81678. hoverRadius: number;
  81679. /**
  81680. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81681. */
  81682. hoverColor: BABYLON.Color4;
  81683. /**
  81684. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81685. */
  81686. hoverPosition: BABYLON.Vector3;
  81687. private _albedoTexture;
  81688. /** Gets or sets the texture to use for albedo color */
  81689. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81690. /**
  81691. * Creates a new Fluent material
  81692. * @param name defines the name of the material
  81693. * @param scene defines the hosting scene
  81694. */
  81695. constructor(name: string, scene: BABYLON.Scene);
  81696. needAlphaBlending(): boolean;
  81697. needAlphaTesting(): boolean;
  81698. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81699. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81700. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81701. getActiveTextures(): BABYLON.BaseTexture[];
  81702. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81703. dispose(forceDisposeEffect?: boolean): void;
  81704. clone(name: string): FluentMaterial;
  81705. serialize(): any;
  81706. getClassName(): string;
  81707. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81708. }
  81709. }
  81710. declare module BABYLON.GUI {
  81711. /**
  81712. * Class used to create a holographic button in 3D
  81713. */
  81714. export class HolographicButton extends Button3D {
  81715. private _backPlate;
  81716. private _textPlate;
  81717. private _frontPlate;
  81718. private _text;
  81719. private _imageUrl;
  81720. private _shareMaterials;
  81721. private _frontMaterial;
  81722. private _backMaterial;
  81723. private _plateMaterial;
  81724. private _pickedPointObserver;
  81725. private _tooltipFade;
  81726. private _tooltipTextBlock;
  81727. private _tooltipTexture;
  81728. private _tooltipMesh;
  81729. private _tooltipHoverObserver;
  81730. private _tooltipOutObserver;
  81731. private _disposeTooltip;
  81732. /**
  81733. * Rendering ground id of all the mesh in the button
  81734. */
  81735. set renderingGroupId(id: number);
  81736. get renderingGroupId(): number;
  81737. /**
  81738. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81739. */
  81740. set tooltipText(text: BABYLON.Nullable<string>);
  81741. get tooltipText(): BABYLON.Nullable<string>;
  81742. /**
  81743. * Gets or sets text for the button
  81744. */
  81745. get text(): string;
  81746. set text(value: string);
  81747. /**
  81748. * Gets or sets the image url for the button
  81749. */
  81750. get imageUrl(): string;
  81751. set imageUrl(value: string);
  81752. /**
  81753. * Gets the back material used by this button
  81754. */
  81755. get backMaterial(): FluentMaterial;
  81756. /**
  81757. * Gets the front material used by this button
  81758. */
  81759. get frontMaterial(): FluentMaterial;
  81760. /**
  81761. * Gets the plate material used by this button
  81762. */
  81763. get plateMaterial(): BABYLON.StandardMaterial;
  81764. /**
  81765. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81766. */
  81767. get shareMaterials(): boolean;
  81768. /**
  81769. * Creates a new button
  81770. * @param name defines the control name
  81771. */
  81772. constructor(name?: string, shareMaterials?: boolean);
  81773. protected _getTypeName(): string;
  81774. private _rebuildContent;
  81775. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81776. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81777. private _createBackMaterial;
  81778. private _createFrontMaterial;
  81779. private _createPlateMaterial;
  81780. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81781. /**
  81782. * Releases all associated resources
  81783. */
  81784. dispose(): void;
  81785. }
  81786. }
  81787. declare module BABYLON.GUI {
  81788. /**
  81789. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81790. */
  81791. export class MeshButton3D extends Button3D {
  81792. /** @hidden */
  81793. protected _currentMesh: BABYLON.Mesh;
  81794. /**
  81795. * Creates a new 3D button based on a mesh
  81796. * @param mesh mesh to become a 3D button
  81797. * @param name defines the control name
  81798. */
  81799. constructor(mesh: BABYLON.Mesh, name?: string);
  81800. protected _getTypeName(): string;
  81801. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81802. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81803. }
  81804. }
  81805. declare module BABYLON.GUI {
  81806. /**
  81807. * Class used to create a container panel deployed on the surface of a plane
  81808. */
  81809. export class PlanePanel extends VolumeBasedPanel {
  81810. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81811. }
  81812. }
  81813. declare module BABYLON.GUI {
  81814. /**
  81815. * Class used to create a container panel where items get randomized planar mapping
  81816. */
  81817. export class ScatterPanel extends VolumeBasedPanel {
  81818. private _iteration;
  81819. /**
  81820. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81821. */
  81822. get iteration(): BABYLON.float;
  81823. set iteration(value: BABYLON.float);
  81824. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81825. private _scatterMapping;
  81826. protected _finalProcessing(): void;
  81827. }
  81828. }
  81829. declare module BABYLON.GUI {
  81830. /**
  81831. * Class used to create a container panel deployed on the surface of a sphere
  81832. */
  81833. export class SpherePanel extends VolumeBasedPanel {
  81834. private _radius;
  81835. /**
  81836. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81837. */
  81838. get radius(): BABYLON.float;
  81839. set radius(value: BABYLON.float);
  81840. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81841. private _sphericalMapping;
  81842. }
  81843. }
  81844. declare module BABYLON.GUI {
  81845. /**
  81846. * Class used to create a stack panel in 3D on XY plane
  81847. */
  81848. export class StackPanel3D extends Container3D {
  81849. private _isVertical;
  81850. /**
  81851. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81852. */
  81853. get isVertical(): boolean;
  81854. set isVertical(value: boolean);
  81855. /**
  81856. * Gets or sets the distance between elements
  81857. */
  81858. margin: number;
  81859. /**
  81860. * Creates new StackPanel
  81861. * @param isVertical
  81862. */
  81863. constructor(isVertical?: boolean);
  81864. protected _arrangeChildren(): void;
  81865. }
  81866. }
  81867. declare module BABYLON {
  81868. /**
  81869. * Configuration for glTF validation
  81870. */
  81871. export interface IGLTFValidationConfiguration {
  81872. /**
  81873. * The url of the glTF validator.
  81874. */
  81875. url: string;
  81876. }
  81877. /**
  81878. * glTF validation
  81879. */
  81880. export class GLTFValidation {
  81881. /**
  81882. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81883. */
  81884. static Configuration: IGLTFValidationConfiguration;
  81885. private static _LoadScriptPromise;
  81886. /**
  81887. * Validate a glTF asset using the glTF-Validator.
  81888. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81889. * @param rootUrl The root url for the glTF
  81890. * @param fileName The file name for the glTF
  81891. * @param getExternalResource The callback to get external resources for the glTF validator
  81892. * @returns A promise that resolves with the glTF validation results once complete
  81893. */
  81894. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81895. }
  81896. }
  81897. declare module BABYLON {
  81898. /**
  81899. * Mode that determines the coordinate system to use.
  81900. */
  81901. export enum GLTFLoaderCoordinateSystemMode {
  81902. /**
  81903. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81904. */
  81905. AUTO = 0,
  81906. /**
  81907. * Sets the useRightHandedSystem flag on the scene.
  81908. */
  81909. FORCE_RIGHT_HANDED = 1
  81910. }
  81911. /**
  81912. * Mode that determines what animations will start.
  81913. */
  81914. export enum GLTFLoaderAnimationStartMode {
  81915. /**
  81916. * No animation will start.
  81917. */
  81918. NONE = 0,
  81919. /**
  81920. * The first animation will start.
  81921. */
  81922. FIRST = 1,
  81923. /**
  81924. * All animations will start.
  81925. */
  81926. ALL = 2
  81927. }
  81928. /**
  81929. * Interface that contains the data for the glTF asset.
  81930. */
  81931. export interface IGLTFLoaderData {
  81932. /**
  81933. * The object that represents the glTF JSON.
  81934. */
  81935. json: Object;
  81936. /**
  81937. * The BIN chunk of a binary glTF.
  81938. */
  81939. bin: Nullable<IDataBuffer>;
  81940. }
  81941. /**
  81942. * Interface for extending the loader.
  81943. */
  81944. export interface IGLTFLoaderExtension {
  81945. /**
  81946. * The name of this extension.
  81947. */
  81948. readonly name: string;
  81949. /**
  81950. * Defines whether this extension is enabled.
  81951. */
  81952. enabled: boolean;
  81953. /**
  81954. * Defines the order of this extension.
  81955. * The loader sorts the extensions using these values when loading.
  81956. */
  81957. order?: number;
  81958. }
  81959. /**
  81960. * Loader state.
  81961. */
  81962. export enum GLTFLoaderState {
  81963. /**
  81964. * The asset is loading.
  81965. */
  81966. LOADING = 0,
  81967. /**
  81968. * The asset is ready for rendering.
  81969. */
  81970. READY = 1,
  81971. /**
  81972. * The asset is completely loaded.
  81973. */
  81974. COMPLETE = 2
  81975. }
  81976. /** @hidden */
  81977. export interface IImportMeshAsyncOutput {
  81978. meshes: AbstractMesh[];
  81979. geometries: Geometry[];
  81980. particleSystems: IParticleSystem[];
  81981. skeletons: Skeleton[];
  81982. animationGroups: AnimationGroup[];
  81983. lights: Light[];
  81984. transformNodes: TransformNode[];
  81985. }
  81986. /** @hidden */
  81987. export interface IGLTFLoader extends IDisposable {
  81988. readonly state: Nullable<GLTFLoaderState>;
  81989. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81990. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81991. }
  81992. /**
  81993. * File loader for loading glTF files into a scene.
  81994. */
  81995. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81996. /** @hidden */
  81997. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81998. /** @hidden */
  81999. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82000. /**
  82001. * Raised when the asset has been parsed
  82002. */
  82003. onParsedObservable: Observable<IGLTFLoaderData>;
  82004. private _onParsedObserver;
  82005. /**
  82006. * Raised when the asset has been parsed
  82007. */
  82008. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82009. /**
  82010. * 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.
  82011. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82012. * Defaults to true.
  82013. * @hidden
  82014. */
  82015. static IncrementalLoading: boolean;
  82016. /**
  82017. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82018. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82019. * @hidden
  82020. */
  82021. static HomogeneousCoordinates: boolean;
  82022. /**
  82023. * The coordinate system mode. Defaults to AUTO.
  82024. */
  82025. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82026. /**
  82027. * The animation start mode. Defaults to FIRST.
  82028. */
  82029. animationStartMode: GLTFLoaderAnimationStartMode;
  82030. /**
  82031. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82032. */
  82033. compileMaterials: boolean;
  82034. /**
  82035. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82036. */
  82037. useClipPlane: boolean;
  82038. /**
  82039. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82040. */
  82041. compileShadowGenerators: boolean;
  82042. /**
  82043. * Defines if the Alpha blended materials are only applied as coverage.
  82044. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82045. * If true, no extra effects are applied to transparent pixels.
  82046. */
  82047. transparencyAsCoverage: boolean;
  82048. /**
  82049. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82050. * Enabling will disable offline support and glTF validator.
  82051. * Defaults to false.
  82052. */
  82053. useRangeRequests: boolean;
  82054. /**
  82055. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82056. */
  82057. createInstances: boolean;
  82058. /**
  82059. * 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.
  82060. */
  82061. alwaysComputeBoundingBox: boolean;
  82062. /**
  82063. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82064. */
  82065. loadAllMaterials: boolean;
  82066. /**
  82067. * Function called before loading a url referenced by the asset.
  82068. */
  82069. preprocessUrlAsync: (url: string) => Promise<string>;
  82070. /**
  82071. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82072. * 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, ...)
  82073. */
  82074. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82075. private _onMeshLoadedObserver;
  82076. /**
  82077. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82078. * 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, ...)
  82079. */
  82080. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82081. /**
  82082. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82083. */
  82084. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82085. private _onTextureLoadedObserver;
  82086. /**
  82087. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82088. */
  82089. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82090. /**
  82091. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82092. */
  82093. readonly onMaterialLoadedObservable: Observable<Material>;
  82094. private _onMaterialLoadedObserver;
  82095. /**
  82096. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82097. */
  82098. set onMaterialLoaded(callback: (material: Material) => void);
  82099. /**
  82100. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82101. */
  82102. readonly onCameraLoadedObservable: Observable<Camera>;
  82103. private _onCameraLoadedObserver;
  82104. /**
  82105. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82106. */
  82107. set onCameraLoaded(callback: (camera: Camera) => void);
  82108. /**
  82109. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82110. * For assets with LODs, raised when all of the LODs are complete.
  82111. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82112. */
  82113. readonly onCompleteObservable: Observable<void>;
  82114. private _onCompleteObserver;
  82115. /**
  82116. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82117. * For assets with LODs, raised when all of the LODs are complete.
  82118. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82119. */
  82120. set onComplete(callback: () => void);
  82121. /**
  82122. * Observable raised when an error occurs.
  82123. */
  82124. readonly onErrorObservable: Observable<any>;
  82125. private _onErrorObserver;
  82126. /**
  82127. * Callback raised when an error occurs.
  82128. */
  82129. set onError(callback: (reason: any) => void);
  82130. /**
  82131. * Observable raised after the loader is disposed.
  82132. */
  82133. readonly onDisposeObservable: Observable<void>;
  82134. private _onDisposeObserver;
  82135. /**
  82136. * Callback raised after the loader is disposed.
  82137. */
  82138. set onDispose(callback: () => void);
  82139. /**
  82140. * Observable raised after a loader extension is created.
  82141. * Set additional options for a loader extension in this event.
  82142. */
  82143. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82144. private _onExtensionLoadedObserver;
  82145. /**
  82146. * Callback raised after a loader extension is created.
  82147. */
  82148. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82149. /**
  82150. * Defines if the loader logging is enabled.
  82151. */
  82152. get loggingEnabled(): boolean;
  82153. set loggingEnabled(value: boolean);
  82154. /**
  82155. * Defines if the loader should capture performance counters.
  82156. */
  82157. get capturePerformanceCounters(): boolean;
  82158. set capturePerformanceCounters(value: boolean);
  82159. /**
  82160. * Defines if the loader should validate the asset.
  82161. */
  82162. validate: boolean;
  82163. /**
  82164. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82165. */
  82166. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82167. private _onValidatedObserver;
  82168. /**
  82169. * Callback raised after a loader extension is created.
  82170. */
  82171. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82172. private _loader;
  82173. private _progressCallback?;
  82174. private _requests;
  82175. private static magicBase64Encoded;
  82176. /**
  82177. * Name of the loader ("gltf")
  82178. */
  82179. name: string;
  82180. /** @hidden */
  82181. extensions: ISceneLoaderPluginExtensions;
  82182. /**
  82183. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82184. */
  82185. dispose(): void;
  82186. /** @hidden */
  82187. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82188. /** @hidden */
  82189. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82190. /** @hidden */
  82191. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82192. meshes: AbstractMesh[];
  82193. particleSystems: IParticleSystem[];
  82194. skeletons: Skeleton[];
  82195. animationGroups: AnimationGroup[];
  82196. }>;
  82197. /** @hidden */
  82198. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82199. /** @hidden */
  82200. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82201. /** @hidden */
  82202. canDirectLoad(data: string): boolean;
  82203. /** @hidden */
  82204. directLoad(scene: Scene, data: string): Promise<any>;
  82205. /**
  82206. * The callback that allows custom handling of the root url based on the response url.
  82207. * @param rootUrl the original root url
  82208. * @param responseURL the response url if available
  82209. * @returns the new root url
  82210. */
  82211. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82212. /** @hidden */
  82213. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82214. /**
  82215. * The loader state or null if the loader is not active.
  82216. */
  82217. get loaderState(): Nullable<GLTFLoaderState>;
  82218. /**
  82219. * Returns a promise that resolves when the asset is completely loaded.
  82220. * @returns a promise that resolves when the asset is completely loaded.
  82221. */
  82222. whenCompleteAsync(): Promise<void>;
  82223. /** @hidden */
  82224. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82225. /** @hidden */
  82226. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82227. private _onProgress;
  82228. private _validate;
  82229. private _getLoader;
  82230. private _parseJson;
  82231. private _unpackBinaryAsync;
  82232. private _unpackBinaryV1Async;
  82233. private _unpackBinaryV2Async;
  82234. private static _parseVersion;
  82235. private static _compareVersion;
  82236. private static readonly _logSpaces;
  82237. private _logIndentLevel;
  82238. private _loggingEnabled;
  82239. /** @hidden */
  82240. _log: (message: string) => void;
  82241. /** @hidden */
  82242. _logOpen(message: string): void;
  82243. /** @hidden */
  82244. _logClose(): void;
  82245. private _logEnabled;
  82246. private _logDisabled;
  82247. private _capturePerformanceCounters;
  82248. /** @hidden */
  82249. _startPerformanceCounter: (counterName: string) => void;
  82250. /** @hidden */
  82251. _endPerformanceCounter: (counterName: string) => void;
  82252. private _startPerformanceCounterEnabled;
  82253. private _startPerformanceCounterDisabled;
  82254. private _endPerformanceCounterEnabled;
  82255. private _endPerformanceCounterDisabled;
  82256. }
  82257. }
  82258. declare module BABYLON.GLTF1 {
  82259. /**
  82260. * Enums
  82261. * @hidden
  82262. */
  82263. export enum EComponentType {
  82264. BYTE = 5120,
  82265. UNSIGNED_BYTE = 5121,
  82266. SHORT = 5122,
  82267. UNSIGNED_SHORT = 5123,
  82268. FLOAT = 5126
  82269. }
  82270. /** @hidden */
  82271. export enum EShaderType {
  82272. FRAGMENT = 35632,
  82273. VERTEX = 35633
  82274. }
  82275. /** @hidden */
  82276. export enum EParameterType {
  82277. BYTE = 5120,
  82278. UNSIGNED_BYTE = 5121,
  82279. SHORT = 5122,
  82280. UNSIGNED_SHORT = 5123,
  82281. INT = 5124,
  82282. UNSIGNED_INT = 5125,
  82283. FLOAT = 5126,
  82284. FLOAT_VEC2 = 35664,
  82285. FLOAT_VEC3 = 35665,
  82286. FLOAT_VEC4 = 35666,
  82287. INT_VEC2 = 35667,
  82288. INT_VEC3 = 35668,
  82289. INT_VEC4 = 35669,
  82290. BOOL = 35670,
  82291. BOOL_VEC2 = 35671,
  82292. BOOL_VEC3 = 35672,
  82293. BOOL_VEC4 = 35673,
  82294. FLOAT_MAT2 = 35674,
  82295. FLOAT_MAT3 = 35675,
  82296. FLOAT_MAT4 = 35676,
  82297. SAMPLER_2D = 35678
  82298. }
  82299. /** @hidden */
  82300. export enum ETextureWrapMode {
  82301. CLAMP_TO_EDGE = 33071,
  82302. MIRRORED_REPEAT = 33648,
  82303. REPEAT = 10497
  82304. }
  82305. /** @hidden */
  82306. export enum ETextureFilterType {
  82307. NEAREST = 9728,
  82308. LINEAR = 9728,
  82309. NEAREST_MIPMAP_NEAREST = 9984,
  82310. LINEAR_MIPMAP_NEAREST = 9985,
  82311. NEAREST_MIPMAP_LINEAR = 9986,
  82312. LINEAR_MIPMAP_LINEAR = 9987
  82313. }
  82314. /** @hidden */
  82315. export enum ETextureFormat {
  82316. ALPHA = 6406,
  82317. RGB = 6407,
  82318. RGBA = 6408,
  82319. LUMINANCE = 6409,
  82320. LUMINANCE_ALPHA = 6410
  82321. }
  82322. /** @hidden */
  82323. export enum ECullingType {
  82324. FRONT = 1028,
  82325. BACK = 1029,
  82326. FRONT_AND_BACK = 1032
  82327. }
  82328. /** @hidden */
  82329. export enum EBlendingFunction {
  82330. ZERO = 0,
  82331. ONE = 1,
  82332. SRC_COLOR = 768,
  82333. ONE_MINUS_SRC_COLOR = 769,
  82334. DST_COLOR = 774,
  82335. ONE_MINUS_DST_COLOR = 775,
  82336. SRC_ALPHA = 770,
  82337. ONE_MINUS_SRC_ALPHA = 771,
  82338. DST_ALPHA = 772,
  82339. ONE_MINUS_DST_ALPHA = 773,
  82340. CONSTANT_COLOR = 32769,
  82341. ONE_MINUS_CONSTANT_COLOR = 32770,
  82342. CONSTANT_ALPHA = 32771,
  82343. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82344. SRC_ALPHA_SATURATE = 776
  82345. }
  82346. /** @hidden */
  82347. export interface IGLTFProperty {
  82348. extensions?: {
  82349. [key: string]: any;
  82350. };
  82351. extras?: Object;
  82352. }
  82353. /** @hidden */
  82354. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82355. name?: string;
  82356. }
  82357. /** @hidden */
  82358. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82359. bufferView: string;
  82360. byteOffset: number;
  82361. byteStride: number;
  82362. count: number;
  82363. type: string;
  82364. componentType: EComponentType;
  82365. max?: number[];
  82366. min?: number[];
  82367. name?: string;
  82368. }
  82369. /** @hidden */
  82370. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82371. buffer: string;
  82372. byteOffset: number;
  82373. byteLength: number;
  82374. byteStride: number;
  82375. target?: number;
  82376. }
  82377. /** @hidden */
  82378. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82379. uri: string;
  82380. byteLength?: number;
  82381. type?: string;
  82382. }
  82383. /** @hidden */
  82384. export interface IGLTFShader extends IGLTFChildRootProperty {
  82385. uri: string;
  82386. type: EShaderType;
  82387. }
  82388. /** @hidden */
  82389. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82390. attributes: string[];
  82391. fragmentShader: string;
  82392. vertexShader: string;
  82393. }
  82394. /** @hidden */
  82395. export interface IGLTFTechniqueParameter {
  82396. type: number;
  82397. count?: number;
  82398. semantic?: string;
  82399. node?: string;
  82400. value?: number | boolean | string | Array<any>;
  82401. source?: string;
  82402. babylonValue?: any;
  82403. }
  82404. /** @hidden */
  82405. export interface IGLTFTechniqueCommonProfile {
  82406. lightingModel: string;
  82407. texcoordBindings: Object;
  82408. parameters?: Array<any>;
  82409. }
  82410. /** @hidden */
  82411. export interface IGLTFTechniqueStatesFunctions {
  82412. blendColor?: number[];
  82413. blendEquationSeparate?: number[];
  82414. blendFuncSeparate?: number[];
  82415. colorMask: boolean[];
  82416. cullFace: number[];
  82417. }
  82418. /** @hidden */
  82419. export interface IGLTFTechniqueStates {
  82420. enable: number[];
  82421. functions: IGLTFTechniqueStatesFunctions;
  82422. }
  82423. /** @hidden */
  82424. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82425. parameters: {
  82426. [key: string]: IGLTFTechniqueParameter;
  82427. };
  82428. program: string;
  82429. attributes: {
  82430. [key: string]: string;
  82431. };
  82432. uniforms: {
  82433. [key: string]: string;
  82434. };
  82435. states: IGLTFTechniqueStates;
  82436. }
  82437. /** @hidden */
  82438. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82439. technique?: string;
  82440. values: string[];
  82441. }
  82442. /** @hidden */
  82443. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82444. attributes: {
  82445. [key: string]: string;
  82446. };
  82447. indices: string;
  82448. material: string;
  82449. mode?: number;
  82450. }
  82451. /** @hidden */
  82452. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82453. primitives: IGLTFMeshPrimitive[];
  82454. }
  82455. /** @hidden */
  82456. export interface IGLTFImage extends IGLTFChildRootProperty {
  82457. uri: string;
  82458. }
  82459. /** @hidden */
  82460. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82461. magFilter?: number;
  82462. minFilter?: number;
  82463. wrapS?: number;
  82464. wrapT?: number;
  82465. }
  82466. /** @hidden */
  82467. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82468. sampler: string;
  82469. source: string;
  82470. format?: ETextureFormat;
  82471. internalFormat?: ETextureFormat;
  82472. target?: number;
  82473. type?: number;
  82474. babylonTexture?: Texture;
  82475. }
  82476. /** @hidden */
  82477. export interface IGLTFAmbienLight {
  82478. color?: number[];
  82479. }
  82480. /** @hidden */
  82481. export interface IGLTFDirectionalLight {
  82482. color?: number[];
  82483. }
  82484. /** @hidden */
  82485. export interface IGLTFPointLight {
  82486. color?: number[];
  82487. constantAttenuation?: number;
  82488. linearAttenuation?: number;
  82489. quadraticAttenuation?: number;
  82490. }
  82491. /** @hidden */
  82492. export interface IGLTFSpotLight {
  82493. color?: number[];
  82494. constantAttenuation?: number;
  82495. fallOfAngle?: number;
  82496. fallOffExponent?: number;
  82497. linearAttenuation?: number;
  82498. quadraticAttenuation?: number;
  82499. }
  82500. /** @hidden */
  82501. export interface IGLTFLight extends IGLTFChildRootProperty {
  82502. type: string;
  82503. }
  82504. /** @hidden */
  82505. export interface IGLTFCameraOrthographic {
  82506. xmag: number;
  82507. ymag: number;
  82508. zfar: number;
  82509. znear: number;
  82510. }
  82511. /** @hidden */
  82512. export interface IGLTFCameraPerspective {
  82513. aspectRatio: number;
  82514. yfov: number;
  82515. zfar: number;
  82516. znear: number;
  82517. }
  82518. /** @hidden */
  82519. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82520. type: string;
  82521. }
  82522. /** @hidden */
  82523. export interface IGLTFAnimationChannelTarget {
  82524. id: string;
  82525. path: string;
  82526. }
  82527. /** @hidden */
  82528. export interface IGLTFAnimationChannel {
  82529. sampler: string;
  82530. target: IGLTFAnimationChannelTarget;
  82531. }
  82532. /** @hidden */
  82533. export interface IGLTFAnimationSampler {
  82534. input: string;
  82535. output: string;
  82536. interpolation?: string;
  82537. }
  82538. /** @hidden */
  82539. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82540. channels?: IGLTFAnimationChannel[];
  82541. parameters?: {
  82542. [key: string]: string;
  82543. };
  82544. samplers?: {
  82545. [key: string]: IGLTFAnimationSampler;
  82546. };
  82547. }
  82548. /** @hidden */
  82549. export interface IGLTFNodeInstanceSkin {
  82550. skeletons: string[];
  82551. skin: string;
  82552. meshes: string[];
  82553. }
  82554. /** @hidden */
  82555. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82556. bindShapeMatrix: number[];
  82557. inverseBindMatrices: string;
  82558. jointNames: string[];
  82559. babylonSkeleton?: Skeleton;
  82560. }
  82561. /** @hidden */
  82562. export interface IGLTFNode extends IGLTFChildRootProperty {
  82563. camera?: string;
  82564. children: string[];
  82565. skin?: string;
  82566. jointName?: string;
  82567. light?: string;
  82568. matrix: number[];
  82569. mesh?: string;
  82570. meshes?: string[];
  82571. rotation?: number[];
  82572. scale?: number[];
  82573. translation?: number[];
  82574. babylonNode?: Node;
  82575. }
  82576. /** @hidden */
  82577. export interface IGLTFScene extends IGLTFChildRootProperty {
  82578. nodes: string[];
  82579. }
  82580. /** @hidden */
  82581. export interface IGLTFRuntime {
  82582. extensions: {
  82583. [key: string]: any;
  82584. };
  82585. accessors: {
  82586. [key: string]: IGLTFAccessor;
  82587. };
  82588. buffers: {
  82589. [key: string]: IGLTFBuffer;
  82590. };
  82591. bufferViews: {
  82592. [key: string]: IGLTFBufferView;
  82593. };
  82594. meshes: {
  82595. [key: string]: IGLTFMesh;
  82596. };
  82597. lights: {
  82598. [key: string]: IGLTFLight;
  82599. };
  82600. cameras: {
  82601. [key: string]: IGLTFCamera;
  82602. };
  82603. nodes: {
  82604. [key: string]: IGLTFNode;
  82605. };
  82606. images: {
  82607. [key: string]: IGLTFImage;
  82608. };
  82609. textures: {
  82610. [key: string]: IGLTFTexture;
  82611. };
  82612. shaders: {
  82613. [key: string]: IGLTFShader;
  82614. };
  82615. programs: {
  82616. [key: string]: IGLTFProgram;
  82617. };
  82618. samplers: {
  82619. [key: string]: IGLTFSampler;
  82620. };
  82621. techniques: {
  82622. [key: string]: IGLTFTechnique;
  82623. };
  82624. materials: {
  82625. [key: string]: IGLTFMaterial;
  82626. };
  82627. animations: {
  82628. [key: string]: IGLTFAnimation;
  82629. };
  82630. skins: {
  82631. [key: string]: IGLTFSkins;
  82632. };
  82633. currentScene?: Object;
  82634. scenes: {
  82635. [key: string]: IGLTFScene;
  82636. };
  82637. extensionsUsed: string[];
  82638. extensionsRequired?: string[];
  82639. buffersCount: number;
  82640. shaderscount: number;
  82641. scene: Scene;
  82642. rootUrl: string;
  82643. loadedBufferCount: number;
  82644. loadedBufferViews: {
  82645. [name: string]: ArrayBufferView;
  82646. };
  82647. loadedShaderCount: number;
  82648. importOnlyMeshes: boolean;
  82649. importMeshesNames?: string[];
  82650. dummyNodes: Node[];
  82651. forAssetContainer: boolean;
  82652. }
  82653. /** @hidden */
  82654. export interface INodeToRoot {
  82655. bone: Bone;
  82656. node: IGLTFNode;
  82657. id: string;
  82658. }
  82659. /** @hidden */
  82660. export interface IJointNode {
  82661. node: IGLTFNode;
  82662. id: string;
  82663. }
  82664. }
  82665. declare module BABYLON.GLTF1 {
  82666. /**
  82667. * Utils functions for GLTF
  82668. * @hidden
  82669. */
  82670. export class GLTFUtils {
  82671. /**
  82672. * Sets the given "parameter" matrix
  82673. * @param scene: the Scene object
  82674. * @param source: the source node where to pick the matrix
  82675. * @param parameter: the GLTF technique parameter
  82676. * @param uniformName: the name of the shader's uniform
  82677. * @param shaderMaterial: the shader material
  82678. */
  82679. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82680. /**
  82681. * Sets the given "parameter" matrix
  82682. * @param shaderMaterial: the shader material
  82683. * @param uniform: the name of the shader's uniform
  82684. * @param value: the value of the uniform
  82685. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82686. */
  82687. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82688. /**
  82689. * Returns the wrap mode of the texture
  82690. * @param mode: the mode value
  82691. */
  82692. static GetWrapMode(mode: number): number;
  82693. /**
  82694. * Returns the byte stride giving an accessor
  82695. * @param accessor: the GLTF accessor objet
  82696. */
  82697. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82698. /**
  82699. * Returns the texture filter mode giving a mode value
  82700. * @param mode: the filter mode value
  82701. */
  82702. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82703. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82704. /**
  82705. * Returns a buffer from its accessor
  82706. * @param gltfRuntime: the GLTF runtime
  82707. * @param accessor: the GLTF accessor
  82708. */
  82709. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82710. /**
  82711. * Decodes a buffer view into a string
  82712. * @param view: the buffer view
  82713. */
  82714. static DecodeBufferToText(view: ArrayBufferView): string;
  82715. /**
  82716. * Returns the default material of gltf. Related to
  82717. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82718. * @param scene: the Babylon.js scene
  82719. */
  82720. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82721. private static _DefaultMaterial;
  82722. }
  82723. }
  82724. declare module BABYLON.GLTF1 {
  82725. /**
  82726. * Implementation of the base glTF spec
  82727. * @hidden
  82728. */
  82729. export class GLTFLoaderBase {
  82730. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82731. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82732. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82733. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82734. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82735. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82736. }
  82737. /**
  82738. * glTF V1 Loader
  82739. * @hidden
  82740. */
  82741. export class GLTFLoader implements IGLTFLoader {
  82742. static Extensions: {
  82743. [name: string]: GLTFLoaderExtension;
  82744. };
  82745. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82746. state: Nullable<GLTFLoaderState>;
  82747. dispose(): void;
  82748. private _importMeshAsync;
  82749. /**
  82750. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82751. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82752. * @param scene the scene the meshes should be added to
  82753. * @param forAssetContainer defines if the entities must be stored in the scene
  82754. * @param data gltf data containing information of the meshes in a loaded file
  82755. * @param rootUrl root url to load from
  82756. * @param onProgress event that fires when loading progress has occured
  82757. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82758. */
  82759. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82760. private _loadAsync;
  82761. /**
  82762. * Imports all objects from a loaded gltf file and adds them to the scene
  82763. * @param scene the scene the objects should be added to
  82764. * @param data gltf data containing information of the meshes in a loaded file
  82765. * @param rootUrl root url to load from
  82766. * @param onProgress event that fires when loading progress has occured
  82767. * @returns a promise which completes when objects have been loaded to the scene
  82768. */
  82769. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82770. private _loadShadersAsync;
  82771. private _loadBuffersAsync;
  82772. private _createNodes;
  82773. }
  82774. /** @hidden */
  82775. export abstract class GLTFLoaderExtension {
  82776. private _name;
  82777. constructor(name: string);
  82778. get name(): string;
  82779. /**
  82780. * Defines an override for loading the runtime
  82781. * Return true to stop further extensions from loading the runtime
  82782. */
  82783. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82784. /**
  82785. * Defines an onverride for creating gltf runtime
  82786. * Return true to stop further extensions from creating the runtime
  82787. */
  82788. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82789. /**
  82790. * Defines an override for loading buffers
  82791. * Return true to stop further extensions from loading this buffer
  82792. */
  82793. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82794. /**
  82795. * Defines an override for loading texture buffers
  82796. * Return true to stop further extensions from loading this texture data
  82797. */
  82798. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82799. /**
  82800. * Defines an override for creating textures
  82801. * Return true to stop further extensions from loading this texture
  82802. */
  82803. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82804. /**
  82805. * Defines an override for loading shader strings
  82806. * Return true to stop further extensions from loading this shader data
  82807. */
  82808. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82809. /**
  82810. * Defines an override for loading materials
  82811. * Return true to stop further extensions from loading this material
  82812. */
  82813. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82814. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82815. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82816. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82817. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82818. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82819. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82820. private static LoadTextureBufferAsync;
  82821. private static CreateTextureAsync;
  82822. private static ApplyExtensions;
  82823. }
  82824. }
  82825. declare module BABYLON.GLTF1 {
  82826. /** @hidden */
  82827. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82828. private _bin;
  82829. constructor();
  82830. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82831. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82832. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82833. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82834. }
  82835. }
  82836. declare module BABYLON.GLTF1 {
  82837. /** @hidden */
  82838. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82839. constructor();
  82840. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82841. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82842. private _loadTexture;
  82843. }
  82844. }
  82845. declare module BABYLON.GLTF2.Loader {
  82846. /**
  82847. * Loader interface with an index field.
  82848. */
  82849. export interface IArrayItem {
  82850. /**
  82851. * The index of this item in the array.
  82852. */
  82853. index: number;
  82854. }
  82855. /**
  82856. * Loader interface with additional members.
  82857. */
  82858. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82859. /** @hidden */
  82860. _data?: Promise<ArrayBufferView>;
  82861. /** @hidden */
  82862. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82863. }
  82864. /**
  82865. * Loader interface with additional members.
  82866. */
  82867. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82868. }
  82869. /** @hidden */
  82870. export interface _IAnimationSamplerData {
  82871. input: Float32Array;
  82872. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82873. output: Float32Array;
  82874. }
  82875. /**
  82876. * Loader interface with additional members.
  82877. */
  82878. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82879. /** @hidden */
  82880. _data?: Promise<_IAnimationSamplerData>;
  82881. }
  82882. /**
  82883. * Loader interface with additional members.
  82884. */
  82885. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82886. channels: IAnimationChannel[];
  82887. samplers: IAnimationSampler[];
  82888. /** @hidden */
  82889. _babylonAnimationGroup?: AnimationGroup;
  82890. }
  82891. /**
  82892. * Loader interface with additional members.
  82893. */
  82894. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82895. /** @hidden */
  82896. _data?: Promise<ArrayBufferView>;
  82897. }
  82898. /**
  82899. * Loader interface with additional members.
  82900. */
  82901. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82902. /** @hidden */
  82903. _data?: Promise<ArrayBufferView>;
  82904. /** @hidden */
  82905. _babylonBuffer?: Promise<Buffer>;
  82906. }
  82907. /**
  82908. * Loader interface with additional members.
  82909. */
  82910. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82911. }
  82912. /**
  82913. * Loader interface with additional members.
  82914. */
  82915. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82916. /** @hidden */
  82917. _data?: Promise<ArrayBufferView>;
  82918. }
  82919. /**
  82920. * Loader interface with additional members.
  82921. */
  82922. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82923. }
  82924. /**
  82925. * Loader interface with additional members.
  82926. */
  82927. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82928. }
  82929. /**
  82930. * Loader interface with additional members.
  82931. */
  82932. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82933. baseColorTexture?: ITextureInfo;
  82934. metallicRoughnessTexture?: ITextureInfo;
  82935. }
  82936. /**
  82937. * Loader interface with additional members.
  82938. */
  82939. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82940. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82941. normalTexture?: IMaterialNormalTextureInfo;
  82942. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82943. emissiveTexture?: ITextureInfo;
  82944. /** @hidden */
  82945. _data?: {
  82946. [babylonDrawMode: number]: {
  82947. babylonMaterial: Material;
  82948. babylonMeshes: AbstractMesh[];
  82949. promise: Promise<void>;
  82950. };
  82951. };
  82952. }
  82953. /**
  82954. * Loader interface with additional members.
  82955. */
  82956. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82957. primitives: IMeshPrimitive[];
  82958. }
  82959. /**
  82960. * Loader interface with additional members.
  82961. */
  82962. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82963. /** @hidden */
  82964. _instanceData?: {
  82965. babylonSourceMesh: Mesh;
  82966. promise: Promise<any>;
  82967. };
  82968. }
  82969. /**
  82970. * Loader interface with additional members.
  82971. */
  82972. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82973. /**
  82974. * The parent glTF node.
  82975. */
  82976. parent?: INode;
  82977. /** @hidden */
  82978. _babylonTransformNode?: TransformNode;
  82979. /** @hidden */
  82980. _primitiveBabylonMeshes?: AbstractMesh[];
  82981. /** @hidden */
  82982. _babylonBones?: Bone[];
  82983. /** @hidden */
  82984. _numMorphTargets?: number;
  82985. }
  82986. /** @hidden */
  82987. export interface _ISamplerData {
  82988. noMipMaps: boolean;
  82989. samplingMode: number;
  82990. wrapU: number;
  82991. wrapV: number;
  82992. }
  82993. /**
  82994. * Loader interface with additional members.
  82995. */
  82996. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82997. /** @hidden */
  82998. _data?: _ISamplerData;
  82999. }
  83000. /**
  83001. * Loader interface with additional members.
  83002. */
  83003. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83004. }
  83005. /**
  83006. * Loader interface with additional members.
  83007. */
  83008. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83009. /** @hidden */
  83010. _data?: {
  83011. babylonSkeleton: Skeleton;
  83012. promise: Promise<void>;
  83013. };
  83014. }
  83015. /**
  83016. * Loader interface with additional members.
  83017. */
  83018. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83019. /** @hidden */
  83020. _textureInfo: ITextureInfo;
  83021. }
  83022. /**
  83023. * Loader interface with additional members.
  83024. */
  83025. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83026. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83027. nonColorData?: boolean;
  83028. }
  83029. /**
  83030. * Loader interface with additional members.
  83031. */
  83032. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83033. accessors?: IAccessor[];
  83034. animations?: IAnimation[];
  83035. buffers?: IBuffer[];
  83036. bufferViews?: IBufferView[];
  83037. cameras?: ICamera[];
  83038. images?: IImage[];
  83039. materials?: IMaterial[];
  83040. meshes?: IMesh[];
  83041. nodes?: INode[];
  83042. samplers?: ISampler[];
  83043. scenes?: IScene[];
  83044. skins?: ISkin[];
  83045. textures?: ITexture[];
  83046. }
  83047. }
  83048. declare module BABYLON.GLTF2 {
  83049. /**
  83050. * Interface for a glTF loader extension.
  83051. */
  83052. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83053. /**
  83054. * Called after the loader state changes to LOADING.
  83055. */
  83056. onLoading?(): void;
  83057. /**
  83058. * Called after the loader state changes to READY.
  83059. */
  83060. onReady?(): void;
  83061. /**
  83062. * Define this method to modify the default behavior when loading scenes.
  83063. * @param context The context when loading the asset
  83064. * @param scene The glTF scene property
  83065. * @returns A promise that resolves when the load is complete or null if not handled
  83066. */
  83067. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83068. /**
  83069. * Define this method to modify the default behavior when loading nodes.
  83070. * @param context The context when loading the asset
  83071. * @param node The glTF node property
  83072. * @param assign A function called synchronously after parsing the glTF properties
  83073. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83074. */
  83075. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83076. /**
  83077. * Define this method to modify the default behavior when loading cameras.
  83078. * @param context The context when loading the asset
  83079. * @param camera The glTF camera property
  83080. * @param assign A function called synchronously after parsing the glTF properties
  83081. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83082. */
  83083. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83084. /**
  83085. * @hidden
  83086. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83087. * @param context The context when loading the asset
  83088. * @param primitive The glTF mesh primitive property
  83089. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83090. */
  83091. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83092. /**
  83093. * @hidden
  83094. * Define this method to modify the default behavior when loading data for mesh primitives.
  83095. * @param context The context when loading the asset
  83096. * @param name The mesh name when loading the asset
  83097. * @param node The glTF node when loading the asset
  83098. * @param mesh The glTF mesh when loading the asset
  83099. * @param primitive The glTF mesh primitive property
  83100. * @param assign A function called synchronously after parsing the glTF properties
  83101. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83102. */
  83103. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83104. /**
  83105. * @hidden
  83106. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83107. * @param context The context when loading the asset
  83108. * @param material The glTF material property
  83109. * @param assign A function called synchronously after parsing the glTF properties
  83110. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83111. */
  83112. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83113. /**
  83114. * Define this method to modify the default behavior when creating materials.
  83115. * @param context The context when loading the asset
  83116. * @param material The glTF material property
  83117. * @param babylonDrawMode The draw mode for the Babylon material
  83118. * @returns The Babylon material or null if not handled
  83119. */
  83120. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83121. /**
  83122. * Define this method to modify the default behavior when loading material properties.
  83123. * @param context The context when loading the asset
  83124. * @param material The glTF material property
  83125. * @param babylonMaterial The Babylon material
  83126. * @returns A promise that resolves when the load is complete or null if not handled
  83127. */
  83128. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83129. /**
  83130. * Define this method to modify the default behavior when loading texture infos.
  83131. * @param context The context when loading the asset
  83132. * @param textureInfo The glTF texture info property
  83133. * @param assign A function called synchronously after parsing the glTF properties
  83134. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83135. */
  83136. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83137. /**
  83138. * @hidden
  83139. * Define this method to modify the default behavior when loading textures.
  83140. * @param context The context when loading the asset
  83141. * @param texture The glTF texture property
  83142. * @param assign A function called synchronously after parsing the glTF properties
  83143. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83144. */
  83145. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83146. /**
  83147. * Define this method to modify the default behavior when loading animations.
  83148. * @param context The context when loading the asset
  83149. * @param animation The glTF animation property
  83150. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83151. */
  83152. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83153. /**
  83154. * @hidden
  83155. * Define this method to modify the default behavior when loading skins.
  83156. * @param context The context when loading the asset
  83157. * @param node The glTF node property
  83158. * @param skin The glTF skin property
  83159. * @returns A promise that resolves when the load is complete or null if not handled
  83160. */
  83161. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83162. /**
  83163. * @hidden
  83164. * Define this method to modify the default behavior when loading uris.
  83165. * @param context The context when loading the asset
  83166. * @param property The glTF property associated with the uri
  83167. * @param uri The uri to load
  83168. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83169. */
  83170. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83171. /**
  83172. * Define this method to modify the default behavior when loading buffer views.
  83173. * @param context The context when loading the asset
  83174. * @param bufferView The glTF buffer view property
  83175. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83176. */
  83177. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83178. /**
  83179. * Define this method to modify the default behavior when loading buffers.
  83180. * @param context The context when loading the asset
  83181. * @param buffer The glTF buffer property
  83182. * @param byteOffset The byte offset to load
  83183. * @param byteLength The byte length to load
  83184. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83185. */
  83186. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83187. }
  83188. }
  83189. declare module BABYLON.GLTF2 {
  83190. /**
  83191. * Helper class for working with arrays when loading the glTF asset
  83192. */
  83193. export class ArrayItem {
  83194. /**
  83195. * Gets an item from the given array.
  83196. * @param context The context when loading the asset
  83197. * @param array The array to get the item from
  83198. * @param index The index to the array
  83199. * @returns The array item
  83200. */
  83201. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83202. /**
  83203. * Assign an `index` field to each item of the given array.
  83204. * @param array The array of items
  83205. */
  83206. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83207. }
  83208. /**
  83209. * The glTF 2.0 loader
  83210. */
  83211. export class GLTFLoader implements IGLTFLoader {
  83212. /** @hidden */
  83213. _completePromises: Promise<any>[];
  83214. /** @hidden */
  83215. _forAssetContainer: boolean;
  83216. /** Storage */
  83217. _babylonLights: Light[];
  83218. /** @hidden */
  83219. _disableInstancedMesh: number;
  83220. private _disposed;
  83221. private _parent;
  83222. private _state;
  83223. private _extensions;
  83224. private _rootUrl;
  83225. private _fileName;
  83226. private _uniqueRootUrl;
  83227. private _gltf;
  83228. private _bin;
  83229. private _babylonScene;
  83230. private _rootBabylonMesh;
  83231. private _defaultBabylonMaterialData;
  83232. private static _RegisteredExtensions;
  83233. /**
  83234. * The default glTF sampler.
  83235. */
  83236. static readonly DefaultSampler: ISampler;
  83237. /**
  83238. * Registers a loader extension.
  83239. * @param name The name of the loader extension.
  83240. * @param factory The factory function that creates the loader extension.
  83241. */
  83242. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83243. /**
  83244. * Unregisters a loader extension.
  83245. * @param name The name of the loader extension.
  83246. * @returns A boolean indicating whether the extension has been unregistered
  83247. */
  83248. static UnregisterExtension(name: string): boolean;
  83249. /**
  83250. * The loader state.
  83251. */
  83252. get state(): Nullable<GLTFLoaderState>;
  83253. /**
  83254. * The object that represents the glTF JSON.
  83255. */
  83256. get gltf(): IGLTF;
  83257. /**
  83258. * The BIN chunk of a binary glTF.
  83259. */
  83260. get bin(): Nullable<IDataBuffer>;
  83261. /**
  83262. * The parent file loader.
  83263. */
  83264. get parent(): GLTFFileLoader;
  83265. /**
  83266. * The Babylon scene when loading the asset.
  83267. */
  83268. get babylonScene(): Scene;
  83269. /**
  83270. * The root Babylon mesh when loading the asset.
  83271. */
  83272. get rootBabylonMesh(): Mesh;
  83273. /** @hidden */
  83274. constructor(parent: GLTFFileLoader);
  83275. /** @hidden */
  83276. dispose(): void;
  83277. /** @hidden */
  83278. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  83279. /** @hidden */
  83280. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83281. private _loadAsync;
  83282. private _loadData;
  83283. private _setupData;
  83284. private _loadExtensions;
  83285. private _checkExtensions;
  83286. private _setState;
  83287. private _createRootNode;
  83288. /**
  83289. * Loads a glTF scene.
  83290. * @param context The context when loading the asset
  83291. * @param scene The glTF scene property
  83292. * @returns A promise that resolves when the load is complete
  83293. */
  83294. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83295. private _forEachPrimitive;
  83296. private _getGeometries;
  83297. private _getMeshes;
  83298. private _getTransformNodes;
  83299. private _getSkeletons;
  83300. private _getAnimationGroups;
  83301. private _startAnimations;
  83302. /**
  83303. * Loads a glTF node.
  83304. * @param context The context when loading the asset
  83305. * @param node The glTF node property
  83306. * @param assign A function called synchronously after parsing the glTF properties
  83307. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83308. */
  83309. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83310. private _loadMeshAsync;
  83311. /**
  83312. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83313. * @param context The context when loading the asset
  83314. * @param name The mesh name when loading the asset
  83315. * @param node The glTF node when loading the asset
  83316. * @param mesh The glTF mesh when loading the asset
  83317. * @param primitive The glTF mesh primitive property
  83318. * @param assign A function called synchronously after parsing the glTF properties
  83319. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83320. */
  83321. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83322. private _loadVertexDataAsync;
  83323. private _createMorphTargets;
  83324. private _loadMorphTargetsAsync;
  83325. private _loadMorphTargetVertexDataAsync;
  83326. private static _LoadTransform;
  83327. private _loadSkinAsync;
  83328. private _loadBones;
  83329. private _loadBone;
  83330. private _loadSkinInverseBindMatricesDataAsync;
  83331. private _updateBoneMatrices;
  83332. private _getNodeMatrix;
  83333. /**
  83334. * Loads a glTF camera.
  83335. * @param context The context when loading the asset
  83336. * @param camera The glTF camera property
  83337. * @param assign A function called synchronously after parsing the glTF properties
  83338. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83339. */
  83340. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83341. private _loadAnimationsAsync;
  83342. /**
  83343. * Loads a glTF animation.
  83344. * @param context The context when loading the asset
  83345. * @param animation The glTF animation property
  83346. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83347. */
  83348. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83349. /**
  83350. * @hidden Loads a glTF animation channel.
  83351. * @param context The context when loading the asset
  83352. * @param animationContext The context of the animation when loading the asset
  83353. * @param animation The glTF animation property
  83354. * @param channel The glTF animation channel property
  83355. * @param babylonAnimationGroup The babylon animation group property
  83356. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83357. * @returns A void promise when the channel load is complete
  83358. */
  83359. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83360. private _loadAnimationSamplerAsync;
  83361. private _loadBufferAsync;
  83362. /**
  83363. * Loads a glTF buffer view.
  83364. * @param context The context when loading the asset
  83365. * @param bufferView The glTF buffer view property
  83366. * @returns A promise that resolves with the loaded data when the load is complete
  83367. */
  83368. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83369. private _loadAccessorAsync;
  83370. /** @hidden */
  83371. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83372. private _loadIndicesAccessorAsync;
  83373. private _loadVertexBufferViewAsync;
  83374. private _loadVertexAccessorAsync;
  83375. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83376. /** @hidden */
  83377. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83378. private _createDefaultMaterial;
  83379. /**
  83380. * Creates a Babylon material from a glTF material.
  83381. * @param context The context when loading the asset
  83382. * @param material The glTF material property
  83383. * @param babylonDrawMode The draw mode for the Babylon material
  83384. * @returns The Babylon material
  83385. */
  83386. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83387. /**
  83388. * Loads properties from a glTF material into a Babylon material.
  83389. * @param context The context when loading the asset
  83390. * @param material The glTF material property
  83391. * @param babylonMaterial The Babylon material
  83392. * @returns A promise that resolves when the load is complete
  83393. */
  83394. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83395. /**
  83396. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83397. * @param context The context when loading the asset
  83398. * @param material The glTF material property
  83399. * @param babylonMaterial The Babylon material
  83400. * @returns A promise that resolves when the load is complete
  83401. */
  83402. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83403. /**
  83404. * Loads the alpha properties from a glTF material into a Babylon material.
  83405. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83406. * @param context The context when loading the asset
  83407. * @param material The glTF material property
  83408. * @param babylonMaterial The Babylon material
  83409. */
  83410. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83411. /**
  83412. * Loads a glTF texture info.
  83413. * @param context The context when loading the asset
  83414. * @param textureInfo The glTF texture info property
  83415. * @param assign A function called synchronously after parsing the glTF properties
  83416. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83417. */
  83418. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83419. /** @hidden */
  83420. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83421. /** @hidden */
  83422. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83423. private _loadSampler;
  83424. /**
  83425. * Loads a glTF image.
  83426. * @param context The context when loading the asset
  83427. * @param image The glTF image property
  83428. * @returns A promise that resolves with the loaded data when the load is complete
  83429. */
  83430. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83431. /**
  83432. * Loads a glTF uri.
  83433. * @param context The context when loading the asset
  83434. * @param property The glTF property associated with the uri
  83435. * @param uri The base64 or relative uri
  83436. * @returns A promise that resolves with the loaded data when the load is complete
  83437. */
  83438. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83439. /**
  83440. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83441. * @param babylonObject the Babylon object with metadata
  83442. * @param pointer the JSON pointer
  83443. */
  83444. static AddPointerMetadata(babylonObject: {
  83445. metadata: any;
  83446. }, pointer: string): void;
  83447. private static _GetTextureWrapMode;
  83448. private static _GetTextureSamplingMode;
  83449. private static _GetTypedArrayConstructor;
  83450. private static _GetTypedArray;
  83451. private static _GetNumComponents;
  83452. private static _ValidateUri;
  83453. /** @hidden */
  83454. static _GetDrawMode(context: string, mode: number | undefined): number;
  83455. private _compileMaterialsAsync;
  83456. private _compileShadowGeneratorsAsync;
  83457. private _forEachExtensions;
  83458. private _applyExtensions;
  83459. private _extensionsOnLoading;
  83460. private _extensionsOnReady;
  83461. private _extensionsLoadSceneAsync;
  83462. private _extensionsLoadNodeAsync;
  83463. private _extensionsLoadCameraAsync;
  83464. private _extensionsLoadVertexDataAsync;
  83465. private _extensionsLoadMeshPrimitiveAsync;
  83466. private _extensionsLoadMaterialAsync;
  83467. private _extensionsCreateMaterial;
  83468. private _extensionsLoadMaterialPropertiesAsync;
  83469. private _extensionsLoadTextureInfoAsync;
  83470. private _extensionsLoadTextureAsync;
  83471. private _extensionsLoadAnimationAsync;
  83472. private _extensionsLoadSkinAsync;
  83473. private _extensionsLoadUriAsync;
  83474. private _extensionsLoadBufferViewAsync;
  83475. private _extensionsLoadBufferAsync;
  83476. /**
  83477. * Helper method called by a loader extension to load an glTF extension.
  83478. * @param context The context when loading the asset
  83479. * @param property The glTF property to load the extension from
  83480. * @param extensionName The name of the extension to load
  83481. * @param actionAsync The action to run
  83482. * @returns The promise returned by actionAsync or null if the extension does not exist
  83483. */
  83484. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83485. /**
  83486. * Helper method called by a loader extension to load a glTF extra.
  83487. * @param context The context when loading the asset
  83488. * @param property The glTF property to load the extra from
  83489. * @param extensionName The name of the extension to load
  83490. * @param actionAsync The action to run
  83491. * @returns The promise returned by actionAsync or null if the extra does not exist
  83492. */
  83493. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83494. /**
  83495. * Checks for presence of an extension.
  83496. * @param name The name of the extension to check
  83497. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83498. */
  83499. isExtensionUsed(name: string): boolean;
  83500. /**
  83501. * Increments the indentation level and logs a message.
  83502. * @param message The message to log
  83503. */
  83504. logOpen(message: string): void;
  83505. /**
  83506. * Decrements the indentation level.
  83507. */
  83508. logClose(): void;
  83509. /**
  83510. * Logs a message
  83511. * @param message The message to log
  83512. */
  83513. log(message: string): void;
  83514. /**
  83515. * Starts a performance counter.
  83516. * @param counterName The name of the performance counter
  83517. */
  83518. startPerformanceCounter(counterName: string): void;
  83519. /**
  83520. * Ends a performance counter.
  83521. * @param counterName The name of the performance counter
  83522. */
  83523. endPerformanceCounter(counterName: string): void;
  83524. }
  83525. }
  83526. declare module BABYLON.GLTF2.Loader.Extensions {
  83527. /** @hidden */
  83528. interface IEXTLightsImageBased_LightImageBased {
  83529. _babylonTexture?: BaseTexture;
  83530. _loaded?: Promise<void>;
  83531. }
  83532. /**
  83533. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83534. */
  83535. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83536. /**
  83537. * The name of this extension.
  83538. */
  83539. readonly name: string;
  83540. /**
  83541. * Defines whether this extension is enabled.
  83542. */
  83543. enabled: boolean;
  83544. private _loader;
  83545. private _lights?;
  83546. /** @hidden */
  83547. constructor(loader: GLTFLoader);
  83548. /** @hidden */
  83549. dispose(): void;
  83550. /** @hidden */
  83551. onLoading(): void;
  83552. /** @hidden */
  83553. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83554. private _loadLightAsync;
  83555. }
  83556. }
  83557. declare module BABYLON.GLTF2.Loader.Extensions {
  83558. /**
  83559. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83560. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83561. * !!! Experimental Extension Subject to Changes !!!
  83562. */
  83563. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83564. /**
  83565. * The name of this extension.
  83566. */
  83567. readonly name: string;
  83568. /**
  83569. * Defines whether this extension is enabled.
  83570. */
  83571. enabled: boolean;
  83572. private _loader;
  83573. /** @hidden */
  83574. constructor(loader: GLTFLoader);
  83575. /** @hidden */
  83576. dispose(): void;
  83577. /** @hidden */
  83578. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83579. }
  83580. }
  83581. declare module BABYLON.GLTF2.Loader.Extensions {
  83582. /**
  83583. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83584. */
  83585. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83586. /** The name of this extension. */
  83587. readonly name: string;
  83588. /** Defines whether this extension is enabled. */
  83589. enabled: boolean;
  83590. private _loader;
  83591. /** @hidden */
  83592. constructor(loader: GLTFLoader);
  83593. /** @hidden */
  83594. dispose(): void;
  83595. /** @hidden */
  83596. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83597. }
  83598. }
  83599. declare module BABYLON.GLTF2.Loader.Extensions {
  83600. /**
  83601. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83602. */
  83603. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83604. /**
  83605. * The name of this extension.
  83606. */
  83607. readonly name: string;
  83608. /**
  83609. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83610. */
  83611. dracoCompression?: DracoCompression;
  83612. /**
  83613. * Defines whether this extension is enabled.
  83614. */
  83615. enabled: boolean;
  83616. private _loader;
  83617. /** @hidden */
  83618. constructor(loader: GLTFLoader);
  83619. /** @hidden */
  83620. dispose(): void;
  83621. /** @hidden */
  83622. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83623. }
  83624. }
  83625. declare module BABYLON.GLTF2.Loader.Extensions {
  83626. /**
  83627. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83628. */
  83629. export class KHR_lights implements IGLTFLoaderExtension {
  83630. /**
  83631. * The name of this extension.
  83632. */
  83633. readonly name: string;
  83634. /**
  83635. * Defines whether this extension is enabled.
  83636. */
  83637. enabled: boolean;
  83638. private _loader;
  83639. private _lights?;
  83640. /** @hidden */
  83641. constructor(loader: GLTFLoader);
  83642. /** @hidden */
  83643. dispose(): void;
  83644. /** @hidden */
  83645. onLoading(): void;
  83646. /** @hidden */
  83647. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83648. }
  83649. }
  83650. declare module BABYLON.GLTF2.Loader.Extensions {
  83651. /**
  83652. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83653. */
  83654. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83655. /**
  83656. * The name of this extension.
  83657. */
  83658. readonly name: string;
  83659. /**
  83660. * Defines whether this extension is enabled.
  83661. */
  83662. enabled: boolean;
  83663. /**
  83664. * Defines a number that determines the order the extensions are applied.
  83665. */
  83666. order: number;
  83667. private _loader;
  83668. /** @hidden */
  83669. constructor(loader: GLTFLoader);
  83670. /** @hidden */
  83671. dispose(): void;
  83672. /** @hidden */
  83673. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83674. private _loadSpecularGlossinessPropertiesAsync;
  83675. }
  83676. }
  83677. declare module BABYLON.GLTF2.Loader.Extensions {
  83678. /**
  83679. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83680. */
  83681. export class KHR_materials_unlit 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. /**
  83691. * Defines a number that determines the order the extensions are applied.
  83692. */
  83693. order: number;
  83694. private _loader;
  83695. /** @hidden */
  83696. constructor(loader: GLTFLoader);
  83697. /** @hidden */
  83698. dispose(): void;
  83699. /** @hidden */
  83700. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83701. private _loadUnlitPropertiesAsync;
  83702. }
  83703. }
  83704. declare module BABYLON.GLTF2.Loader.Extensions {
  83705. /**
  83706. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83707. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83708. */
  83709. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83710. /**
  83711. * The name of this extension.
  83712. */
  83713. readonly name: string;
  83714. /**
  83715. * Defines whether this extension is enabled.
  83716. */
  83717. enabled: boolean;
  83718. /**
  83719. * Defines a number that determines the order the extensions are applied.
  83720. */
  83721. order: number;
  83722. private _loader;
  83723. /** @hidden */
  83724. constructor(loader: GLTFLoader);
  83725. /** @hidden */
  83726. dispose(): void;
  83727. /** @hidden */
  83728. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83729. private _loadClearCoatPropertiesAsync;
  83730. }
  83731. }
  83732. declare module BABYLON.GLTF2.Loader.Extensions {
  83733. /**
  83734. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83735. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83736. * !!! Experimental Extension Subject to Changes !!!
  83737. */
  83738. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83739. /**
  83740. * The name of this extension.
  83741. */
  83742. readonly name: string;
  83743. /**
  83744. * Defines whether this extension is enabled.
  83745. */
  83746. enabled: boolean;
  83747. /**
  83748. * Defines a number that determines the order the extensions are applied.
  83749. */
  83750. order: number;
  83751. private _loader;
  83752. /** @hidden */
  83753. constructor(loader: GLTFLoader);
  83754. /** @hidden */
  83755. dispose(): void;
  83756. /** @hidden */
  83757. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83758. private _loadSheenPropertiesAsync;
  83759. }
  83760. }
  83761. declare module BABYLON.GLTF2.Loader.Extensions {
  83762. /**
  83763. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83764. * !!! Experimental Extension Subject to Changes !!!
  83765. */
  83766. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83767. /**
  83768. * The name of this extension.
  83769. */
  83770. readonly name: string;
  83771. /**
  83772. * Defines whether this extension is enabled.
  83773. */
  83774. enabled: boolean;
  83775. /**
  83776. * Defines a number that determines the order the extensions are applied.
  83777. */
  83778. order: number;
  83779. private _loader;
  83780. /** @hidden */
  83781. constructor(loader: GLTFLoader);
  83782. /** @hidden */
  83783. dispose(): void;
  83784. /** @hidden */
  83785. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83786. private _loadSpecularPropertiesAsync;
  83787. }
  83788. }
  83789. declare module BABYLON.GLTF2.Loader.Extensions {
  83790. /**
  83791. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83792. * !!! Experimental Extension Subject to Changes !!!
  83793. */
  83794. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83795. /**
  83796. * Default ior Value from the spec.
  83797. */
  83798. private static readonly _DEFAULT_IOR;
  83799. /**
  83800. * The name of this extension.
  83801. */
  83802. readonly name: string;
  83803. /**
  83804. * Defines whether this extension is enabled.
  83805. */
  83806. enabled: boolean;
  83807. /**
  83808. * Defines a number that determines the order the extensions are applied.
  83809. */
  83810. order: number;
  83811. private _loader;
  83812. /** @hidden */
  83813. constructor(loader: GLTFLoader);
  83814. /** @hidden */
  83815. dispose(): void;
  83816. /** @hidden */
  83817. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83818. private _loadIorPropertiesAsync;
  83819. }
  83820. }
  83821. declare module BABYLON.GLTF2.Loader.Extensions {
  83822. /**
  83823. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83824. * !!! Experimental Extension Subject to Changes !!!
  83825. */
  83826. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83827. /**
  83828. * The name of this extension.
  83829. */
  83830. readonly name: string;
  83831. /**
  83832. * Defines whether this extension is enabled.
  83833. */
  83834. enabled: boolean;
  83835. private _loader;
  83836. private _variants?;
  83837. /** @hidden */
  83838. constructor(loader: GLTFLoader);
  83839. /** @hidden */
  83840. dispose(): void;
  83841. /**
  83842. * Gets the list of available variant names for this asset.
  83843. * @param rootMesh The glTF root mesh
  83844. * @returns the list of all the variant names for this model
  83845. */
  83846. static GetAvailableVariants(rootMesh: Mesh): string[];
  83847. /**
  83848. * Gets the list of available variant names for this asset.
  83849. * @param rootMesh The glTF root mesh
  83850. * @returns the list of all the variant names for this model
  83851. */
  83852. getAvailableVariants(rootMesh: Mesh): string[];
  83853. /**
  83854. * Select a variant given a variant name or a list of variant names.
  83855. * @param rootMesh The glTF root mesh
  83856. * @param variantName The variant name(s) to select.
  83857. */
  83858. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83859. /**
  83860. * Select a variant given a variant name or a list of variant names.
  83861. * @param rootMesh The glTF root mesh
  83862. * @param variantName The variant name(s) to select.
  83863. */
  83864. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83865. /**
  83866. * Reset back to the original before selecting a variant.
  83867. * @param rootMesh The glTF root mesh
  83868. */
  83869. static Reset(rootMesh: Mesh): void;
  83870. /**
  83871. * Reset back to the original before selecting a variant.
  83872. * @param rootMesh The glTF root mesh
  83873. */
  83874. reset(rootMesh: Mesh): void;
  83875. /**
  83876. * Gets the last selected variant name(s) or null if original.
  83877. * @param rootMesh The glTF root mesh
  83878. * @returns The selected variant name(s).
  83879. */
  83880. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83881. /**
  83882. * Gets the last selected variant name(s) or null if original.
  83883. * @param rootMesh The glTF root mesh
  83884. * @returns The selected variant name(s).
  83885. */
  83886. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83887. private static _GetExtensionMetadata;
  83888. /** @hidden */
  83889. onLoading(): void;
  83890. /** @hidden */
  83891. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83892. }
  83893. }
  83894. declare module BABYLON.GLTF2.Loader.Extensions {
  83895. /**
  83896. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83897. * !!! Experimental Extension Subject to Changes !!!
  83898. */
  83899. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83900. /**
  83901. * The name of this extension.
  83902. */
  83903. readonly name: string;
  83904. /**
  83905. * Defines whether this extension is enabled.
  83906. */
  83907. enabled: boolean;
  83908. /**
  83909. * Defines a number that determines the order the extensions are applied.
  83910. */
  83911. order: number;
  83912. private _loader;
  83913. /** @hidden */
  83914. constructor(loader: GLTFLoader);
  83915. /** @hidden */
  83916. dispose(): void;
  83917. /** @hidden */
  83918. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83919. private _loadTransparentPropertiesAsync;
  83920. }
  83921. }
  83922. declare module BABYLON.GLTF2.Loader.Extensions {
  83923. /**
  83924. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83925. */
  83926. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83927. /**
  83928. * The name of this extension.
  83929. */
  83930. readonly name: string;
  83931. /**
  83932. * Defines whether this extension is enabled.
  83933. */
  83934. enabled: boolean;
  83935. /** @hidden */
  83936. constructor(loader: GLTFLoader);
  83937. /** @hidden */
  83938. dispose(): void;
  83939. }
  83940. }
  83941. declare module BABYLON.GLTF2.Loader.Extensions {
  83942. /**
  83943. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83944. * !!! Experimental Extension Subject to Changes !!!
  83945. */
  83946. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83947. /** The name of this extension. */
  83948. readonly name: string;
  83949. /** Defines whether this extension is enabled. */
  83950. enabled: boolean;
  83951. private _loader;
  83952. /** @hidden */
  83953. constructor(loader: GLTFLoader);
  83954. /** @hidden */
  83955. dispose(): void;
  83956. /** @hidden */
  83957. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83958. }
  83959. }
  83960. declare module BABYLON.GLTF2.Loader.Extensions {
  83961. /**
  83962. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83963. */
  83964. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83965. /**
  83966. * The name of this extension.
  83967. */
  83968. readonly name: string;
  83969. /**
  83970. * Defines whether this extension is enabled.
  83971. */
  83972. enabled: boolean;
  83973. private _loader;
  83974. /** @hidden */
  83975. constructor(loader: GLTFLoader);
  83976. /** @hidden */
  83977. dispose(): void;
  83978. /** @hidden */
  83979. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83980. }
  83981. }
  83982. declare module BABYLON.GLTF2.Loader.Extensions {
  83983. /**
  83984. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83985. * !!! Experimental Extension Subject to Changes !!!
  83986. */
  83987. export class KHR_xmp implements IGLTFLoaderExtension {
  83988. /**
  83989. * The name of this extension.
  83990. */
  83991. readonly name: string;
  83992. /**
  83993. * Defines whether this extension is enabled.
  83994. */
  83995. enabled: boolean;
  83996. /**
  83997. * Defines a number that determines the order the extensions are applied.
  83998. */
  83999. order: number;
  84000. private _loader;
  84001. /** @hidden */
  84002. constructor(loader: GLTFLoader);
  84003. /** @hidden */
  84004. dispose(): void;
  84005. /**
  84006. * Called after the loader state changes to LOADING.
  84007. */
  84008. onLoading(): void;
  84009. }
  84010. }
  84011. declare module BABYLON.GLTF2.Loader.Extensions {
  84012. /**
  84013. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84014. */
  84015. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84016. /**
  84017. * The name of this extension.
  84018. */
  84019. readonly name: string;
  84020. /**
  84021. * Defines whether this extension is enabled.
  84022. */
  84023. enabled: boolean;
  84024. private _loader;
  84025. private _clips;
  84026. private _emitters;
  84027. /** @hidden */
  84028. constructor(loader: GLTFLoader);
  84029. /** @hidden */
  84030. dispose(): void;
  84031. /** @hidden */
  84032. onLoading(): void;
  84033. /** @hidden */
  84034. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84035. /** @hidden */
  84036. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84037. /** @hidden */
  84038. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84039. private _loadClipAsync;
  84040. private _loadEmitterAsync;
  84041. private _getEventAction;
  84042. private _loadAnimationEventAsync;
  84043. }
  84044. }
  84045. declare module BABYLON.GLTF2.Loader.Extensions {
  84046. /**
  84047. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84048. */
  84049. export class MSFT_lod implements IGLTFLoaderExtension {
  84050. /**
  84051. * The name of this extension.
  84052. */
  84053. readonly name: string;
  84054. /**
  84055. * Defines whether this extension is enabled.
  84056. */
  84057. enabled: boolean;
  84058. /**
  84059. * Defines a number that determines the order the extensions are applied.
  84060. */
  84061. order: number;
  84062. /**
  84063. * Maximum number of LODs to load, starting from the lowest LOD.
  84064. */
  84065. maxLODsToLoad: number;
  84066. /**
  84067. * Observable raised when all node LODs of one level are loaded.
  84068. * The event data is the index of the loaded LOD starting from zero.
  84069. * Dispose the loader to cancel the loading of the next level of LODs.
  84070. */
  84071. onNodeLODsLoadedObservable: Observable<number>;
  84072. /**
  84073. * Observable raised when all material LODs of one level are loaded.
  84074. * The event data is the index of the loaded LOD starting from zero.
  84075. * Dispose the loader to cancel the loading of the next level of LODs.
  84076. */
  84077. onMaterialLODsLoadedObservable: Observable<number>;
  84078. private _loader;
  84079. private _bufferLODs;
  84080. private _nodeIndexLOD;
  84081. private _nodeSignalLODs;
  84082. private _nodePromiseLODs;
  84083. private _nodeBufferLODs;
  84084. private _materialIndexLOD;
  84085. private _materialSignalLODs;
  84086. private _materialPromiseLODs;
  84087. private _materialBufferLODs;
  84088. /** @hidden */
  84089. constructor(loader: GLTFLoader);
  84090. /** @hidden */
  84091. dispose(): void;
  84092. /** @hidden */
  84093. onReady(): void;
  84094. /** @hidden */
  84095. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84096. /** @hidden */
  84097. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84098. /** @hidden */
  84099. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84100. /** @hidden */
  84101. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84102. /** @hidden */
  84103. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84104. private _loadBufferLOD;
  84105. /**
  84106. * Gets an array of LOD properties from lowest to highest.
  84107. */
  84108. private _getLODs;
  84109. private _disposeTransformNode;
  84110. private _disposeMaterials;
  84111. }
  84112. }
  84113. declare module BABYLON.GLTF2.Loader.Extensions {
  84114. /** @hidden */
  84115. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84116. readonly name: string;
  84117. enabled: boolean;
  84118. private _loader;
  84119. constructor(loader: GLTFLoader);
  84120. dispose(): void;
  84121. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84122. }
  84123. }
  84124. declare module BABYLON.GLTF2.Loader.Extensions {
  84125. /** @hidden */
  84126. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84127. readonly name: string;
  84128. enabled: boolean;
  84129. private _loader;
  84130. constructor(loader: GLTFLoader);
  84131. dispose(): void;
  84132. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84133. }
  84134. }
  84135. declare module BABYLON.GLTF2.Loader.Extensions {
  84136. /**
  84137. * Store glTF extras (if present) in BJS objects' metadata
  84138. */
  84139. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84140. /**
  84141. * The name of this extension.
  84142. */
  84143. readonly name: string;
  84144. /**
  84145. * Defines whether this extension is enabled.
  84146. */
  84147. enabled: boolean;
  84148. private _loader;
  84149. private _assignExtras;
  84150. /** @hidden */
  84151. constructor(loader: GLTFLoader);
  84152. /** @hidden */
  84153. dispose(): void;
  84154. /** @hidden */
  84155. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84156. /** @hidden */
  84157. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84158. /** @hidden */
  84159. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84160. }
  84161. }
  84162. declare module BABYLON {
  84163. /**
  84164. * Class reading and parsing the MTL file bundled with the obj file.
  84165. */
  84166. export class MTLFileLoader {
  84167. /**
  84168. * Invert Y-Axis of referenced textures on load
  84169. */
  84170. static INVERT_TEXTURE_Y: boolean;
  84171. /**
  84172. * All material loaded from the mtl will be set here
  84173. */
  84174. materials: StandardMaterial[];
  84175. /**
  84176. * This function will read the mtl file and create each material described inside
  84177. * This function could be improve by adding :
  84178. * -some component missing (Ni, Tf...)
  84179. * -including the specific options available
  84180. *
  84181. * @param scene defines the scene the material will be created in
  84182. * @param data defines the mtl data to parse
  84183. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84184. * @param forAssetContainer defines if the material should be registered in the scene
  84185. */
  84186. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84187. /**
  84188. * Gets the texture for the material.
  84189. *
  84190. * If the material is imported from input file,
  84191. * We sanitize the url to ensure it takes the textre from aside the material.
  84192. *
  84193. * @param rootUrl The root url to load from
  84194. * @param value The value stored in the mtl
  84195. * @return The Texture
  84196. */
  84197. private static _getTexture;
  84198. }
  84199. }
  84200. declare module BABYLON {
  84201. /**
  84202. * Options for loading OBJ/MTL files
  84203. */
  84204. type MeshLoadOptions = {
  84205. /**
  84206. * Defines if UVs are optimized by default during load.
  84207. */
  84208. OptimizeWithUV: boolean;
  84209. /**
  84210. * Defines custom scaling of UV coordinates of loaded meshes.
  84211. */
  84212. UVScaling: Vector2;
  84213. /**
  84214. * Invert model on y-axis (does a model scaling inversion)
  84215. */
  84216. InvertY: boolean;
  84217. /**
  84218. * Invert Y-Axis of referenced textures on load
  84219. */
  84220. InvertTextureY: boolean;
  84221. /**
  84222. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84223. */
  84224. ImportVertexColors: boolean;
  84225. /**
  84226. * Compute the normals for the model, even if normals are present in the file.
  84227. */
  84228. ComputeNormals: boolean;
  84229. /**
  84230. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84231. */
  84232. SkipMaterials: boolean;
  84233. /**
  84234. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84235. */
  84236. MaterialLoadingFailsSilently: boolean;
  84237. };
  84238. /**
  84239. * OBJ file type loader.
  84240. * This is a babylon scene loader plugin.
  84241. */
  84242. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84243. /**
  84244. * Defines if UVs are optimized by default during load.
  84245. */
  84246. static OPTIMIZE_WITH_UV: boolean;
  84247. /**
  84248. * Invert model on y-axis (does a model scaling inversion)
  84249. */
  84250. static INVERT_Y: boolean;
  84251. /**
  84252. * Invert Y-Axis of referenced textures on load
  84253. */
  84254. static get INVERT_TEXTURE_Y(): boolean;
  84255. static set INVERT_TEXTURE_Y(value: boolean);
  84256. /**
  84257. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84258. */
  84259. static IMPORT_VERTEX_COLORS: boolean;
  84260. /**
  84261. * Compute the normals for the model, even if normals are present in the file.
  84262. */
  84263. static COMPUTE_NORMALS: boolean;
  84264. /**
  84265. * Defines custom scaling of UV coordinates of loaded meshes.
  84266. */
  84267. static UV_SCALING: Vector2;
  84268. /**
  84269. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84270. */
  84271. static SKIP_MATERIALS: boolean;
  84272. /**
  84273. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84274. *
  84275. * Defaults to true for backwards compatibility.
  84276. */
  84277. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84278. /**
  84279. * Defines the name of the plugin.
  84280. */
  84281. name: string;
  84282. /**
  84283. * Defines the extension the plugin is able to load.
  84284. */
  84285. extensions: string;
  84286. /** @hidden */
  84287. obj: RegExp;
  84288. /** @hidden */
  84289. group: RegExp;
  84290. /** @hidden */
  84291. mtllib: RegExp;
  84292. /** @hidden */
  84293. usemtl: RegExp;
  84294. /** @hidden */
  84295. smooth: RegExp;
  84296. /** @hidden */
  84297. vertexPattern: RegExp;
  84298. /** @hidden */
  84299. normalPattern: RegExp;
  84300. /** @hidden */
  84301. uvPattern: RegExp;
  84302. /** @hidden */
  84303. facePattern1: RegExp;
  84304. /** @hidden */
  84305. facePattern2: RegExp;
  84306. /** @hidden */
  84307. facePattern3: RegExp;
  84308. /** @hidden */
  84309. facePattern4: RegExp;
  84310. /** @hidden */
  84311. facePattern5: RegExp;
  84312. private _forAssetContainer;
  84313. private _meshLoadOptions;
  84314. /**
  84315. * Creates loader for .OBJ files
  84316. *
  84317. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84318. */
  84319. constructor(meshLoadOptions?: MeshLoadOptions);
  84320. private static get currentMeshLoadOptions();
  84321. /**
  84322. * Calls synchronously the MTL file attached to this obj.
  84323. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84324. * Without this function materials are not displayed in the first frame (but displayed after).
  84325. * In consequence it is impossible to get material information in your HTML file
  84326. *
  84327. * @param url The URL of the MTL file
  84328. * @param rootUrl
  84329. * @param onSuccess Callback function to be called when the MTL file is loaded
  84330. * @private
  84331. */
  84332. private _loadMTL;
  84333. /**
  84334. * Instantiates a OBJ file loader plugin.
  84335. * @returns the created plugin
  84336. */
  84337. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84338. /**
  84339. * If the data string can be loaded directly.
  84340. *
  84341. * @param data string containing the file data
  84342. * @returns if the data can be loaded directly
  84343. */
  84344. canDirectLoad(data: string): boolean;
  84345. /**
  84346. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84347. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84348. * @param scene the scene the meshes should be added to
  84349. * @param data the OBJ data to load
  84350. * @param rootUrl root url to load from
  84351. * @param onProgress event that fires when loading progress has occured
  84352. * @param fileName Defines the name of the file to load
  84353. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84354. */
  84355. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84356. meshes: AbstractMesh[];
  84357. particleSystems: IParticleSystem[];
  84358. skeletons: Skeleton[];
  84359. animationGroups: AnimationGroup[];
  84360. }>;
  84361. /**
  84362. * Imports all objects from the loaded OBJ data and adds them to the scene
  84363. * @param scene the scene the objects should be added to
  84364. * @param data the OBJ data to load
  84365. * @param rootUrl root url to load from
  84366. * @param onProgress event that fires when loading progress has occured
  84367. * @param fileName Defines the name of the file to load
  84368. * @returns a promise which completes when objects have been loaded to the scene
  84369. */
  84370. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84371. /**
  84372. * Load into an asset container.
  84373. * @param scene The scene to load into
  84374. * @param data The data to import
  84375. * @param rootUrl The root url for scene and resources
  84376. * @param onProgress The callback when the load progresses
  84377. * @param fileName Defines the name of the file to load
  84378. * @returns The loaded asset container
  84379. */
  84380. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84381. /**
  84382. * Read the OBJ file and create an Array of meshes.
  84383. * Each mesh contains all information given by the OBJ and the MTL file.
  84384. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84385. *
  84386. * @param meshesNames
  84387. * @param scene Scene The scene where are displayed the data
  84388. * @param data String The content of the obj file
  84389. * @param rootUrl String The path to the folder
  84390. * @returns Array<AbstractMesh>
  84391. * @private
  84392. */
  84393. private _parseSolid;
  84394. }
  84395. }
  84396. declare module BABYLON {
  84397. /**
  84398. * STL file type loader.
  84399. * This is a babylon scene loader plugin.
  84400. */
  84401. export class STLFileLoader implements ISceneLoaderPlugin {
  84402. /** @hidden */
  84403. solidPattern: RegExp;
  84404. /** @hidden */
  84405. facetsPattern: RegExp;
  84406. /** @hidden */
  84407. normalPattern: RegExp;
  84408. /** @hidden */
  84409. vertexPattern: RegExp;
  84410. /**
  84411. * Defines the name of the plugin.
  84412. */
  84413. name: string;
  84414. /**
  84415. * Defines the extensions the stl loader is able to load.
  84416. * force data to come in as an ArrayBuffer
  84417. * we'll convert to string if it looks like it's an ASCII .stl
  84418. */
  84419. extensions: ISceneLoaderPluginExtensions;
  84420. /**
  84421. * Import meshes into a scene.
  84422. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84423. * @param scene The scene to import into
  84424. * @param data The data to import
  84425. * @param rootUrl The root url for scene and resources
  84426. * @param meshes The meshes array to import into
  84427. * @param particleSystems The particle systems array to import into
  84428. * @param skeletons The skeletons array to import into
  84429. * @param onError The callback when import fails
  84430. * @returns True if successful or false otherwise
  84431. */
  84432. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84433. /**
  84434. * Load into a scene.
  84435. * @param scene The scene to load into
  84436. * @param data The data to import
  84437. * @param rootUrl The root url for scene and resources
  84438. * @param onError The callback when import fails
  84439. * @returns true if successful or false otherwise
  84440. */
  84441. load(scene: Scene, data: any, rootUrl: string): boolean;
  84442. /**
  84443. * Load into an asset container.
  84444. * @param scene The scene to load into
  84445. * @param data The data to import
  84446. * @param rootUrl The root url for scene and resources
  84447. * @param onError The callback when import fails
  84448. * @returns The loaded asset container
  84449. */
  84450. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84451. private _isBinary;
  84452. private _parseBinary;
  84453. private _parseASCII;
  84454. }
  84455. }
  84456. declare module BABYLON {
  84457. /**
  84458. * Class for generating OBJ data from a Babylon scene.
  84459. */
  84460. export class OBJExport {
  84461. /**
  84462. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84463. * @param mesh defines the list of meshes to serialize
  84464. * @param materials defines if materials should be exported
  84465. * @param matlibname defines the name of the associated mtl file
  84466. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84467. * @returns the OBJ content
  84468. */
  84469. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84470. /**
  84471. * Exports the material(s) of a mesh in .MTL file format (text)
  84472. * @param mesh defines the mesh to extract the material from
  84473. * @returns the mtl content
  84474. */
  84475. static MTL(mesh: Mesh): string;
  84476. }
  84477. }
  84478. declare module BABYLON {
  84479. /** @hidden */
  84480. export var __IGLTFExporterExtension: number;
  84481. /**
  84482. * Interface for extending the exporter
  84483. * @hidden
  84484. */
  84485. export interface IGLTFExporterExtension {
  84486. /**
  84487. * The name of this extension
  84488. */
  84489. readonly name: string;
  84490. /**
  84491. * Defines whether this extension is enabled
  84492. */
  84493. enabled: boolean;
  84494. /**
  84495. * Defines whether this extension is required
  84496. */
  84497. required: boolean;
  84498. }
  84499. }
  84500. declare module BABYLON.GLTF2.Exporter {
  84501. /** @hidden */
  84502. export var __IGLTFExporterExtensionV2: number;
  84503. /**
  84504. * Interface for a glTF exporter extension
  84505. * @hidden
  84506. */
  84507. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84508. /**
  84509. * Define this method to modify the default behavior before exporting a texture
  84510. * @param context The context when loading the asset
  84511. * @param babylonTexture The Babylon.js texture
  84512. * @param mimeType The mime-type of the generated image
  84513. * @returns A promise that resolves with the exported texture
  84514. */
  84515. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84516. /**
  84517. * Define this method to get notified when a texture info is created
  84518. * @param context The context when loading the asset
  84519. * @param textureInfo The glTF texture info
  84520. * @param babylonTexture The Babylon.js texture
  84521. */
  84522. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84523. /**
  84524. * Define this method to modify the default behavior when exporting texture info
  84525. * @param context The context when loading the asset
  84526. * @param meshPrimitive glTF mesh primitive
  84527. * @param babylonSubMesh Babylon submesh
  84528. * @param binaryWriter glTF serializer binary writer instance
  84529. * @returns nullable IMeshPrimitive promise
  84530. */
  84531. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84532. /**
  84533. * Define this method to modify the default behavior when exporting a node
  84534. * @param context The context when exporting the node
  84535. * @param node glTF node
  84536. * @param babylonNode BabylonJS node
  84537. * @returns nullable INode promise
  84538. */
  84539. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84540. [key: number]: number;
  84541. }): Promise<Nullable<INode>>;
  84542. /**
  84543. * Define this method to modify the default behavior when exporting a material
  84544. * @param material glTF material
  84545. * @param babylonMaterial BabylonJS material
  84546. * @returns nullable IMaterial promise
  84547. */
  84548. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84549. /**
  84550. * Define this method to return additional textures to export from a material
  84551. * @param material glTF material
  84552. * @param babylonMaterial BabylonJS material
  84553. * @returns List of textures
  84554. */
  84555. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84556. /** Gets a boolean indicating that this extension was used */
  84557. wasUsed: boolean;
  84558. /** Gets a boolean indicating that this extension is required for the file to work */
  84559. required: boolean;
  84560. /**
  84561. * Called after the exporter state changes to EXPORTING
  84562. */
  84563. onExporting?(): void;
  84564. }
  84565. }
  84566. declare module BABYLON.GLTF2.Exporter {
  84567. /**
  84568. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84569. * @hidden
  84570. */
  84571. export class _GLTFMaterialExporter {
  84572. /**
  84573. * Represents the dielectric specular values for R, G and B
  84574. */
  84575. private static readonly _DielectricSpecular;
  84576. /**
  84577. * Allows the maximum specular power to be defined for material calculations
  84578. */
  84579. private static readonly _MaxSpecularPower;
  84580. /**
  84581. * Mapping to store textures
  84582. */
  84583. private _textureMap;
  84584. /**
  84585. * Numeric tolerance value
  84586. */
  84587. private static readonly _Epsilon;
  84588. /**
  84589. * Reference to the glTF Exporter
  84590. */
  84591. private _exporter;
  84592. constructor(exporter: _Exporter);
  84593. /**
  84594. * Specifies if two colors are approximately equal in value
  84595. * @param color1 first color to compare to
  84596. * @param color2 second color to compare to
  84597. * @param epsilon threshold value
  84598. */
  84599. private static FuzzyEquals;
  84600. /**
  84601. * Gets the materials from a Babylon scene and converts them to glTF materials
  84602. * @param scene babylonjs scene
  84603. * @param mimeType texture mime type
  84604. * @param images array of images
  84605. * @param textures array of textures
  84606. * @param materials array of materials
  84607. * @param imageData mapping of texture names to base64 textures
  84608. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84609. */
  84610. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84611. /**
  84612. * Makes a copy of the glTF material without the texture parameters
  84613. * @param originalMaterial original glTF material
  84614. * @returns glTF material without texture parameters
  84615. */
  84616. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84617. /**
  84618. * Specifies if the material has any texture parameters present
  84619. * @param material glTF Material
  84620. * @returns boolean specifying if texture parameters are present
  84621. */
  84622. _hasTexturesPresent(material: IMaterial): boolean;
  84623. /**
  84624. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84625. * @param babylonStandardMaterial
  84626. * @returns glTF Metallic Roughness Material representation
  84627. */
  84628. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84629. /**
  84630. * Computes the metallic factor
  84631. * @param diffuse diffused value
  84632. * @param specular specular value
  84633. * @param oneMinusSpecularStrength one minus the specular strength
  84634. * @returns metallic value
  84635. */
  84636. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84637. /**
  84638. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84639. * @param glTFMaterial glTF material
  84640. * @param babylonMaterial Babylon material
  84641. */
  84642. private static _SetAlphaMode;
  84643. /**
  84644. * Converts a Babylon Standard Material to a glTF Material
  84645. * @param babylonStandardMaterial BJS Standard Material
  84646. * @param mimeType mime type to use for the textures
  84647. * @param images array of glTF image interfaces
  84648. * @param textures array of glTF texture interfaces
  84649. * @param materials array of glTF material interfaces
  84650. * @param imageData map of image file name to data
  84651. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84652. */
  84653. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84654. private _finishMaterial;
  84655. /**
  84656. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84657. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84658. * @param mimeType mime type to use for the textures
  84659. * @param images array of glTF image interfaces
  84660. * @param textures array of glTF texture interfaces
  84661. * @param materials array of glTF material interfaces
  84662. * @param imageData map of image file name to data
  84663. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84664. */
  84665. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84666. /**
  84667. * Converts an image typed array buffer to a base64 image
  84668. * @param buffer typed array buffer
  84669. * @param width width of the image
  84670. * @param height height of the image
  84671. * @param mimeType mimetype of the image
  84672. * @returns base64 image string
  84673. */
  84674. private _createBase64FromCanvasAsync;
  84675. /**
  84676. * Generates a white texture based on the specified width and height
  84677. * @param width width of the texture in pixels
  84678. * @param height height of the texture in pixels
  84679. * @param scene babylonjs scene
  84680. * @returns white texture
  84681. */
  84682. private _createWhiteTexture;
  84683. /**
  84684. * 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
  84685. * @param texture1 first texture to resize
  84686. * @param texture2 second texture to resize
  84687. * @param scene babylonjs scene
  84688. * @returns resized textures or null
  84689. */
  84690. private _resizeTexturesToSameDimensions;
  84691. /**
  84692. * Converts an array of pixels to a Float32Array
  84693. * Throws an error if the pixel format is not supported
  84694. * @param pixels - array buffer containing pixel values
  84695. * @returns Float32 of pixels
  84696. */
  84697. private _convertPixelArrayToFloat32;
  84698. /**
  84699. * Convert Specular Glossiness Textures to Metallic Roughness
  84700. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84701. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84702. * @param diffuseTexture texture used to store diffuse information
  84703. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84704. * @param factors specular glossiness material factors
  84705. * @param mimeType the mime type to use for the texture
  84706. * @returns pbr metallic roughness interface or null
  84707. */
  84708. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84709. /**
  84710. * Converts specular glossiness material properties to metallic roughness
  84711. * @param specularGlossiness interface with specular glossiness material properties
  84712. * @returns interface with metallic roughness material properties
  84713. */
  84714. private _convertSpecularGlossinessToMetallicRoughness;
  84715. /**
  84716. * Calculates the surface reflectance, independent of lighting conditions
  84717. * @param color Color source to calculate brightness from
  84718. * @returns number representing the perceived brightness, or zero if color is undefined
  84719. */
  84720. private _getPerceivedBrightness;
  84721. /**
  84722. * Returns the maximum color component value
  84723. * @param color
  84724. * @returns maximum color component value, or zero if color is null or undefined
  84725. */
  84726. private _getMaxComponent;
  84727. /**
  84728. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84729. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84730. * @param mimeType mime type to use for the textures
  84731. * @param images array of glTF image interfaces
  84732. * @param textures array of glTF texture interfaces
  84733. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84734. * @param imageData map of image file name to data
  84735. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84736. * @returns glTF PBR Metallic Roughness factors
  84737. */
  84738. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84739. private _getGLTFTextureSampler;
  84740. private _getGLTFTextureWrapMode;
  84741. private _getGLTFTextureWrapModesSampler;
  84742. /**
  84743. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84744. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84745. * @param mimeType mime type to use for the textures
  84746. * @param images array of glTF image interfaces
  84747. * @param textures array of glTF texture interfaces
  84748. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84749. * @param imageData map of image file name to data
  84750. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84751. * @returns glTF PBR Metallic Roughness factors
  84752. */
  84753. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84754. /**
  84755. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84756. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84757. * @param mimeType mime type to use for the textures
  84758. * @param images array of glTF image interfaces
  84759. * @param textures array of glTF texture interfaces
  84760. * @param materials array of glTF material interfaces
  84761. * @param imageData map of image file name to data
  84762. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84763. */
  84764. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84765. private setMetallicRoughnessPbrMaterial;
  84766. private getPixelsFromTexture;
  84767. /**
  84768. * Extracts a texture from a Babylon texture into file data and glTF data
  84769. * @param babylonTexture Babylon texture to extract
  84770. * @param mimeType Mime Type of the babylonTexture
  84771. * @return glTF texture info, or null if the texture format is not supported
  84772. */
  84773. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84774. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84775. /**
  84776. * Builds a texture from base64 string
  84777. * @param base64Texture base64 texture string
  84778. * @param baseTextureName Name to use for the texture
  84779. * @param mimeType image mime type for the texture
  84780. * @param images array of images
  84781. * @param textures array of textures
  84782. * @param imageData map of image data
  84783. * @returns glTF texture info, or null if the texture format is not supported
  84784. */
  84785. private _getTextureInfoFromBase64;
  84786. }
  84787. }
  84788. declare module BABYLON {
  84789. /**
  84790. * Class for holding and downloading glTF file data
  84791. */
  84792. export class GLTFData {
  84793. /**
  84794. * Object which contains the file name as the key and its data as the value
  84795. */
  84796. glTFFiles: {
  84797. [fileName: string]: string | Blob;
  84798. };
  84799. /**
  84800. * Initializes the glTF file object
  84801. */
  84802. constructor();
  84803. /**
  84804. * Downloads the glTF data as files based on their names and data
  84805. */
  84806. downloadFiles(): void;
  84807. }
  84808. }
  84809. declare module BABYLON {
  84810. /**
  84811. * Holds a collection of exporter options and parameters
  84812. */
  84813. export interface IExportOptions {
  84814. /**
  84815. * Function which indicates whether a babylon node should be exported or not
  84816. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84817. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84818. */
  84819. shouldExportNode?(node: Node): boolean;
  84820. /**
  84821. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84822. * @param metadata source metadata to read from
  84823. * @returns the data to store to glTF node extras
  84824. */
  84825. metadataSelector?(metadata: any): any;
  84826. /**
  84827. * The sample rate to bake animation curves
  84828. */
  84829. animationSampleRate?: number;
  84830. /**
  84831. * Begin serialization without waiting for the scene to be ready
  84832. */
  84833. exportWithoutWaitingForScene?: boolean;
  84834. /**
  84835. * Indicates if coordinate system swapping root nodes should be included in export
  84836. */
  84837. includeCoordinateSystemConversionNodes?: boolean;
  84838. }
  84839. /**
  84840. * Class for generating glTF data from a Babylon scene.
  84841. */
  84842. export class GLTF2Export {
  84843. /**
  84844. * Exports the geometry of the scene to .gltf file format asynchronously
  84845. * @param scene Babylon scene with scene hierarchy information
  84846. * @param filePrefix File prefix to use when generating the glTF file
  84847. * @param options Exporter options
  84848. * @returns Returns an object with a .gltf file and associates texture names
  84849. * as keys and their data and paths as values
  84850. */
  84851. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84852. private static _PreExportAsync;
  84853. private static _PostExportAsync;
  84854. /**
  84855. * Exports the geometry of the scene to .glb file format asychronously
  84856. * @param scene Babylon scene with scene hierarchy information
  84857. * @param filePrefix File prefix to use when generating glb file
  84858. * @param options Exporter options
  84859. * @returns Returns an object with a .glb filename as key and data as value
  84860. */
  84861. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84862. }
  84863. }
  84864. declare module BABYLON.GLTF2.Exporter {
  84865. /**
  84866. * @hidden
  84867. */
  84868. export class _GLTFUtilities {
  84869. /**
  84870. * Creates a buffer view based on the supplied arguments
  84871. * @param bufferIndex index value of the specified buffer
  84872. * @param byteOffset byte offset value
  84873. * @param byteLength byte length of the bufferView
  84874. * @param byteStride byte distance between conequential elements
  84875. * @param name name of the buffer view
  84876. * @returns bufferView for glTF
  84877. */
  84878. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84879. /**
  84880. * Creates an accessor based on the supplied arguments
  84881. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84882. * @param name The name of the accessor
  84883. * @param type The type of the accessor
  84884. * @param componentType The datatype of components in the attribute
  84885. * @param count The number of attributes referenced by this accessor
  84886. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84887. * @param min Minimum value of each component in this attribute
  84888. * @param max Maximum value of each component in this attribute
  84889. * @returns accessor for glTF
  84890. */
  84891. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84892. /**
  84893. * Calculates the minimum and maximum values of an array of position floats
  84894. * @param positions Positions array of a mesh
  84895. * @param vertexStart Starting vertex offset to calculate min and max values
  84896. * @param vertexCount Number of vertices to check for min and max values
  84897. * @returns min number array and max number array
  84898. */
  84899. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84900. min: number[];
  84901. max: number[];
  84902. };
  84903. /**
  84904. * Converts a new right-handed Vector3
  84905. * @param vector vector3 array
  84906. * @returns right-handed Vector3
  84907. */
  84908. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84909. /**
  84910. * Converts a Vector3 to right-handed
  84911. * @param vector Vector3 to convert to right-handed
  84912. */
  84913. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84914. /**
  84915. * Converts a three element number array to right-handed
  84916. * @param vector number array to convert to right-handed
  84917. */
  84918. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84919. /**
  84920. * Converts a new right-handed Vector3
  84921. * @param vector vector3 array
  84922. * @returns right-handed Vector3
  84923. */
  84924. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84925. /**
  84926. * Converts a Vector3 to right-handed
  84927. * @param vector Vector3 to convert to right-handed
  84928. */
  84929. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84930. /**
  84931. * Converts a three element number array to right-handed
  84932. * @param vector number array to convert to right-handed
  84933. */
  84934. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84935. /**
  84936. * Converts a Vector4 to right-handed
  84937. * @param vector Vector4 to convert to right-handed
  84938. */
  84939. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84940. /**
  84941. * Converts a Vector4 to right-handed
  84942. * @param vector Vector4 to convert to right-handed
  84943. */
  84944. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84945. /**
  84946. * Converts a Quaternion to right-handed
  84947. * @param quaternion Source quaternion to convert to right-handed
  84948. */
  84949. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84950. /**
  84951. * Converts a Quaternion to right-handed
  84952. * @param quaternion Source quaternion to convert to right-handed
  84953. */
  84954. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84955. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84956. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84957. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84958. }
  84959. }
  84960. declare module BABYLON.GLTF2.Exporter {
  84961. /**
  84962. * Converts Babylon Scene into glTF 2.0.
  84963. * @hidden
  84964. */
  84965. export class _Exporter {
  84966. /**
  84967. * Stores the glTF to export
  84968. */
  84969. _glTF: IGLTF;
  84970. /**
  84971. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84972. */
  84973. _bufferViews: IBufferView[];
  84974. /**
  84975. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84976. */
  84977. _accessors: IAccessor[];
  84978. /**
  84979. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84980. */
  84981. _nodes: INode[];
  84982. /**
  84983. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84984. */
  84985. private _scenes;
  84986. /**
  84987. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84988. */
  84989. private _meshes;
  84990. /**
  84991. * Stores all the generated material information, which represents the appearance of each primitive
  84992. */
  84993. _materials: IMaterial[];
  84994. _materialMap: {
  84995. [materialID: number]: number;
  84996. };
  84997. /**
  84998. * Stores all the generated texture information, which is referenced by glTF materials
  84999. */
  85000. _textures: ITexture[];
  85001. /**
  85002. * Stores all the generated image information, which is referenced by glTF textures
  85003. */
  85004. _images: IImage[];
  85005. /**
  85006. * Stores all the texture samplers
  85007. */
  85008. _samplers: ISampler[];
  85009. /**
  85010. * Stores all the generated glTF skins
  85011. */
  85012. _skins: ISkin[];
  85013. /**
  85014. * Stores all the generated animation samplers, which is referenced by glTF animations
  85015. */
  85016. /**
  85017. * Stores the animations for glTF models
  85018. */
  85019. private _animations;
  85020. /**
  85021. * Stores the total amount of bytes stored in the glTF buffer
  85022. */
  85023. private _totalByteLength;
  85024. /**
  85025. * Stores a reference to the Babylon scene containing the source geometry and material information
  85026. */
  85027. _babylonScene: Scene;
  85028. /**
  85029. * Stores a map of the image data, where the key is the file name and the value
  85030. * is the image data
  85031. */
  85032. _imageData: {
  85033. [fileName: string]: {
  85034. data: Uint8Array;
  85035. mimeType: ImageMimeType;
  85036. };
  85037. };
  85038. protected _orderedImageData: Array<{
  85039. data: Uint8Array;
  85040. mimeType: ImageMimeType;
  85041. }>;
  85042. /**
  85043. * Stores a map of the unique id of a node to its index in the node array
  85044. */
  85045. _nodeMap: {
  85046. [key: number]: number;
  85047. };
  85048. /**
  85049. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85050. */
  85051. _convertToRightHandedSystem: boolean;
  85052. /**
  85053. * Specifies if a Babylon node should be converted to right-handed on export
  85054. */
  85055. _convertToRightHandedSystemMap: {
  85056. [nodeId: number]: boolean;
  85057. };
  85058. _includeCoordinateSystemConversionNodes: boolean;
  85059. /**
  85060. * Baked animation sample rate
  85061. */
  85062. private _animationSampleRate;
  85063. private _options;
  85064. private _localEngine;
  85065. _glTFMaterialExporter: _GLTFMaterialExporter;
  85066. private _extensions;
  85067. private static _ExtensionNames;
  85068. private static _ExtensionFactories;
  85069. private _applyExtension;
  85070. private _applyExtensions;
  85071. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85072. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85073. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85074. [key: number]: number;
  85075. }): Promise<Nullable<INode>>;
  85076. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85077. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85078. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85079. private _forEachExtensions;
  85080. private _extensionsOnExporting;
  85081. /**
  85082. * Load glTF serializer extensions
  85083. */
  85084. private _loadExtensions;
  85085. /**
  85086. * Creates a glTF Exporter instance, which can accept optional exporter options
  85087. * @param babylonScene Babylon scene object
  85088. * @param options Options to modify the behavior of the exporter
  85089. */
  85090. constructor(babylonScene: Scene, options?: IExportOptions);
  85091. dispose(): void;
  85092. /**
  85093. * Registers a glTF exporter extension
  85094. * @param name Name of the extension to export
  85095. * @param factory The factory function that creates the exporter extension
  85096. */
  85097. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85098. /**
  85099. * Un-registers an exporter extension
  85100. * @param name The name fo the exporter extension
  85101. * @returns A boolean indicating whether the extension has been un-registered
  85102. */
  85103. static UnregisterExtension(name: string): boolean;
  85104. /**
  85105. * Lazy load a local engine
  85106. */
  85107. _getLocalEngine(): Engine;
  85108. private reorderIndicesBasedOnPrimitiveMode;
  85109. /**
  85110. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85111. * clock-wise during export to glTF
  85112. * @param submesh BabylonJS submesh
  85113. * @param primitiveMode Primitive mode of the mesh
  85114. * @param sideOrientation the winding order of the submesh
  85115. * @param vertexBufferKind The type of vertex attribute
  85116. * @param meshAttributeArray The vertex attribute data
  85117. * @param byteOffset The offset to the binary data
  85118. * @param binaryWriter The binary data for the glTF file
  85119. * @param convertToRightHandedSystem Converts the values to right-handed
  85120. */
  85121. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85122. /**
  85123. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85124. * clock-wise during export to glTF
  85125. * @param submesh BabylonJS submesh
  85126. * @param primitiveMode Primitive mode of the mesh
  85127. * @param sideOrientation the winding order of the submesh
  85128. * @param vertexBufferKind The type of vertex attribute
  85129. * @param meshAttributeArray The vertex attribute data
  85130. * @param byteOffset The offset to the binary data
  85131. * @param binaryWriter The binary data for the glTF file
  85132. * @param convertToRightHandedSystem Converts the values to right-handed
  85133. */
  85134. private reorderTriangleFillMode;
  85135. /**
  85136. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85137. * clock-wise during export to glTF
  85138. * @param submesh BabylonJS submesh
  85139. * @param primitiveMode Primitive mode of the mesh
  85140. * @param sideOrientation the winding order of the submesh
  85141. * @param vertexBufferKind The type of vertex attribute
  85142. * @param meshAttributeArray The vertex attribute data
  85143. * @param byteOffset The offset to the binary data
  85144. * @param binaryWriter The binary data for the glTF file
  85145. * @param convertToRightHandedSystem Converts the values to right-handed
  85146. */
  85147. private reorderTriangleStripDrawMode;
  85148. /**
  85149. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85150. * clock-wise during export to glTF
  85151. * @param submesh BabylonJS submesh
  85152. * @param primitiveMode Primitive mode of the mesh
  85153. * @param sideOrientation the winding order of the submesh
  85154. * @param vertexBufferKind The type of vertex attribute
  85155. * @param meshAttributeArray The vertex attribute data
  85156. * @param byteOffset The offset to the binary data
  85157. * @param binaryWriter The binary data for the glTF file
  85158. * @param convertToRightHandedSystem Converts the values to right-handed
  85159. */
  85160. private reorderTriangleFanMode;
  85161. /**
  85162. * Writes the vertex attribute data to binary
  85163. * @param vertices The vertices to write to the binary writer
  85164. * @param byteOffset The offset into the binary writer to overwrite binary data
  85165. * @param vertexAttributeKind The vertex attribute type
  85166. * @param meshAttributeArray The vertex attribute data
  85167. * @param binaryWriter The writer containing the binary data
  85168. * @param convertToRightHandedSystem Converts the values to right-handed
  85169. */
  85170. private writeVertexAttributeData;
  85171. /**
  85172. * Writes mesh attribute data to a data buffer
  85173. * Returns the bytelength of the data
  85174. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85175. * @param meshAttributeArray Array containing the attribute data
  85176. * @param byteStride Specifies the space between data
  85177. * @param binaryWriter The buffer to write the binary data to
  85178. * @param convertToRightHandedSystem Converts the values to right-handed
  85179. */
  85180. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85181. /**
  85182. * Writes mesh attribute data to a data buffer
  85183. * Returns the bytelength of the data
  85184. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85185. * @param meshAttributeArray Array containing the attribute data
  85186. * @param byteStride Specifies the space between data
  85187. * @param binaryWriter The buffer to write the binary data to
  85188. * @param convertToRightHandedSystem Converts the values to right-handed
  85189. */
  85190. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85191. /**
  85192. * Generates glTF json data
  85193. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85194. * @param glTFPrefix Text to use when prefixing a glTF file
  85195. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85196. * @returns json data as string
  85197. */
  85198. private generateJSON;
  85199. /**
  85200. * Generates data for .gltf and .bin files based on the glTF prefix string
  85201. * @param glTFPrefix Text to use when prefixing a glTF file
  85202. * @param dispose Dispose the exporter
  85203. * @returns GLTFData with glTF file data
  85204. */
  85205. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85206. /**
  85207. * Creates a binary buffer for glTF
  85208. * @returns array buffer for binary data
  85209. */
  85210. private _generateBinaryAsync;
  85211. /**
  85212. * Pads the number to a multiple of 4
  85213. * @param num number to pad
  85214. * @returns padded number
  85215. */
  85216. private _getPadding;
  85217. /**
  85218. * @hidden
  85219. */
  85220. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85221. /**
  85222. * Sets the TRS for each node
  85223. * @param node glTF Node for storing the transformation data
  85224. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85225. * @param convertToRightHandedSystem Converts the values to right-handed
  85226. */
  85227. private setNodeTransformation;
  85228. private getVertexBufferFromMesh;
  85229. /**
  85230. * Creates a bufferview based on the vertices type for the Babylon mesh
  85231. * @param kind Indicates the type of vertices data
  85232. * @param componentType Indicates the numerical type used to store the data
  85233. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85234. * @param binaryWriter The buffer to write the bufferview data to
  85235. * @param convertToRightHandedSystem Converts the values to right-handed
  85236. */
  85237. private createBufferViewKind;
  85238. /**
  85239. * Creates a bufferview based on the vertices type for the Babylon mesh
  85240. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85241. * @param babylonMorphTarget the morph target to be exported
  85242. * @param binaryWriter The buffer to write the bufferview data to
  85243. * @param convertToRightHandedSystem Converts the values to right-handed
  85244. */
  85245. private setMorphTargetAttributes;
  85246. /**
  85247. * The primitive mode of the Babylon mesh
  85248. * @param babylonMesh The BabylonJS mesh
  85249. */
  85250. private getMeshPrimitiveMode;
  85251. /**
  85252. * Sets the primitive mode of the glTF mesh primitive
  85253. * @param meshPrimitive glTF mesh primitive
  85254. * @param primitiveMode The primitive mode
  85255. */
  85256. private setPrimitiveMode;
  85257. /**
  85258. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85259. * @param meshPrimitive glTF mesh primitive
  85260. * @param attributeKind vertex attribute
  85261. * @returns boolean specifying if uv coordinates are present
  85262. */
  85263. private setAttributeKind;
  85264. /**
  85265. * Sets data for the primitive attributes of each submesh
  85266. * @param mesh glTF Mesh object to store the primitive attribute information
  85267. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85268. * @param binaryWriter Buffer to write the attribute data to
  85269. * @param convertToRightHandedSystem Converts the values to right-handed
  85270. */
  85271. private setPrimitiveAttributesAsync;
  85272. /**
  85273. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85274. * @param node The node to check
  85275. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85276. */
  85277. private isBabylonCoordinateSystemConvertingNode;
  85278. /**
  85279. * Creates a glTF scene based on the array of meshes
  85280. * Returns the the total byte offset
  85281. * @param babylonScene Babylon scene to get the mesh data from
  85282. * @param binaryWriter Buffer to write binary data to
  85283. */
  85284. private createSceneAsync;
  85285. /**
  85286. * Creates a mapping of Node unique id to node index and handles animations
  85287. * @param babylonScene Babylon Scene
  85288. * @param nodes Babylon transform nodes
  85289. * @param binaryWriter Buffer to write binary data to
  85290. * @returns Node mapping of unique id to index
  85291. */
  85292. private createNodeMapAndAnimationsAsync;
  85293. /**
  85294. * Creates a glTF node from a Babylon mesh
  85295. * @param babylonMesh Source Babylon mesh
  85296. * @param binaryWriter Buffer for storing geometry data
  85297. * @param convertToRightHandedSystem Converts the values to right-handed
  85298. * @param nodeMap Node mapping of unique id to glTF node index
  85299. * @returns glTF node
  85300. */
  85301. private createNodeAsync;
  85302. /**
  85303. * Creates a glTF skin from a Babylon skeleton
  85304. * @param babylonScene Babylon Scene
  85305. * @param nodes Babylon transform nodes
  85306. * @param binaryWriter Buffer to write binary data to
  85307. * @returns Node mapping of unique id to index
  85308. */
  85309. private createSkinsAsync;
  85310. }
  85311. /**
  85312. * @hidden
  85313. *
  85314. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85315. */
  85316. export class _BinaryWriter {
  85317. /**
  85318. * Array buffer which stores all binary data
  85319. */
  85320. private _arrayBuffer;
  85321. /**
  85322. * View of the array buffer
  85323. */
  85324. private _dataView;
  85325. /**
  85326. * byte offset of data in array buffer
  85327. */
  85328. private _byteOffset;
  85329. /**
  85330. * Initialize binary writer with an initial byte length
  85331. * @param byteLength Initial byte length of the array buffer
  85332. */
  85333. constructor(byteLength: number);
  85334. /**
  85335. * Resize the array buffer to the specified byte length
  85336. * @param byteLength
  85337. */
  85338. private resizeBuffer;
  85339. /**
  85340. * Get an array buffer with the length of the byte offset
  85341. * @returns ArrayBuffer resized to the byte offset
  85342. */
  85343. getArrayBuffer(): ArrayBuffer;
  85344. /**
  85345. * Get the byte offset of the array buffer
  85346. * @returns byte offset
  85347. */
  85348. getByteOffset(): number;
  85349. /**
  85350. * Stores an UInt8 in the array buffer
  85351. * @param entry
  85352. * @param byteOffset If defined, specifies where to set the value as an offset.
  85353. */
  85354. setUInt8(entry: number, byteOffset?: number): void;
  85355. /**
  85356. * Stores an UInt16 in the array buffer
  85357. * @param entry
  85358. * @param byteOffset If defined, specifies where to set the value as an offset.
  85359. */
  85360. setUInt16(entry: number, byteOffset?: number): void;
  85361. /**
  85362. * Gets an UInt32 in the array buffer
  85363. * @param entry
  85364. * @param byteOffset If defined, specifies where to set the value as an offset.
  85365. */
  85366. getUInt32(byteOffset: number): number;
  85367. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85368. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85369. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85370. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85371. /**
  85372. * Stores a Float32 in the array buffer
  85373. * @param entry
  85374. */
  85375. setFloat32(entry: number, byteOffset?: number): void;
  85376. /**
  85377. * Stores an UInt32 in the array buffer
  85378. * @param entry
  85379. * @param byteOffset If defined, specifies where to set the value as an offset.
  85380. */
  85381. setUInt32(entry: number, byteOffset?: number): void;
  85382. }
  85383. }
  85384. declare module BABYLON.GLTF2.Exporter {
  85385. /**
  85386. * @hidden
  85387. * Interface to store animation data.
  85388. */
  85389. export interface _IAnimationData {
  85390. /**
  85391. * Keyframe data.
  85392. */
  85393. inputs: number[];
  85394. /**
  85395. * Value data.
  85396. */
  85397. outputs: number[][];
  85398. /**
  85399. * Animation interpolation data.
  85400. */
  85401. samplerInterpolation: AnimationSamplerInterpolation;
  85402. /**
  85403. * Minimum keyframe value.
  85404. */
  85405. inputsMin: number;
  85406. /**
  85407. * Maximum keyframe value.
  85408. */
  85409. inputsMax: number;
  85410. }
  85411. /**
  85412. * @hidden
  85413. */
  85414. export interface _IAnimationInfo {
  85415. /**
  85416. * The target channel for the animation
  85417. */
  85418. animationChannelTargetPath: AnimationChannelTargetPath;
  85419. /**
  85420. * The glTF accessor type for the data.
  85421. */
  85422. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85423. /**
  85424. * Specifies if quaternions should be used.
  85425. */
  85426. useQuaternion: boolean;
  85427. }
  85428. /**
  85429. * @hidden
  85430. * Utility class for generating glTF animation data from BabylonJS.
  85431. */
  85432. export class _GLTFAnimation {
  85433. /**
  85434. * @ignore
  85435. *
  85436. * Creates glTF channel animation from BabylonJS animation.
  85437. * @param babylonTransformNode - BabylonJS mesh.
  85438. * @param animation - animation.
  85439. * @param animationChannelTargetPath - The target animation channel.
  85440. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85441. * @param useQuaternion - Specifies if quaternions are used.
  85442. * @returns nullable IAnimationData
  85443. */
  85444. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85445. private static _DeduceAnimationInfo;
  85446. /**
  85447. * @ignore
  85448. * Create node animations from the transform node animations
  85449. * @param babylonNode
  85450. * @param runtimeGLTFAnimation
  85451. * @param idleGLTFAnimations
  85452. * @param nodeMap
  85453. * @param nodes
  85454. * @param binaryWriter
  85455. * @param bufferViews
  85456. * @param accessors
  85457. * @param convertToRightHandedSystem
  85458. * @param animationSampleRate
  85459. */
  85460. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85461. [key: number]: number;
  85462. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85463. /**
  85464. * @ignore
  85465. * Create individual morph animations from the mesh's morph target animation tracks
  85466. * @param babylonNode
  85467. * @param runtimeGLTFAnimation
  85468. * @param idleGLTFAnimations
  85469. * @param nodeMap
  85470. * @param nodes
  85471. * @param binaryWriter
  85472. * @param bufferViews
  85473. * @param accessors
  85474. * @param convertToRightHandedSystem
  85475. * @param animationSampleRate
  85476. */
  85477. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85478. [key: number]: number;
  85479. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85480. /**
  85481. * @ignore
  85482. * Create node and morph animations from the animation groups
  85483. * @param babylonScene
  85484. * @param glTFAnimations
  85485. * @param nodeMap
  85486. * @param nodes
  85487. * @param binaryWriter
  85488. * @param bufferViews
  85489. * @param accessors
  85490. * @param convertToRightHandedSystemMap
  85491. * @param animationSampleRate
  85492. */
  85493. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85494. [key: number]: number;
  85495. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85496. [nodeId: number]: boolean;
  85497. }, animationSampleRate: number): void;
  85498. private static AddAnimation;
  85499. /**
  85500. * Create a baked animation
  85501. * @param babylonTransformNode BabylonJS mesh
  85502. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85503. * @param animationChannelTargetPath animation target channel
  85504. * @param minFrame minimum animation frame
  85505. * @param maxFrame maximum animation frame
  85506. * @param fps frames per second of the animation
  85507. * @param inputs input key frames of the animation
  85508. * @param outputs output key frame data of the animation
  85509. * @param convertToRightHandedSystem converts the values to right-handed
  85510. * @param useQuaternion specifies if quaternions should be used
  85511. */
  85512. private static _CreateBakedAnimation;
  85513. private static _ConvertFactorToVector3OrQuaternion;
  85514. private static _SetInterpolatedValue;
  85515. /**
  85516. * Creates linear animation from the animation key frames
  85517. * @param babylonTransformNode BabylonJS mesh
  85518. * @param animation BabylonJS animation
  85519. * @param animationChannelTargetPath The target animation channel
  85520. * @param frameDelta The difference between the last and first frame of the animation
  85521. * @param inputs Array to store the key frame times
  85522. * @param outputs Array to store the key frame data
  85523. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85524. * @param useQuaternion Specifies if quaternions are used in the animation
  85525. */
  85526. private static _CreateLinearOrStepAnimation;
  85527. /**
  85528. * Creates cubic spline animation from the animation key frames
  85529. * @param babylonTransformNode BabylonJS mesh
  85530. * @param animation BabylonJS animation
  85531. * @param animationChannelTargetPath The target animation channel
  85532. * @param frameDelta The difference between the last and first frame of the animation
  85533. * @param inputs Array to store the key frame times
  85534. * @param outputs Array to store the key frame data
  85535. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85536. * @param useQuaternion Specifies if quaternions are used in the animation
  85537. */
  85538. private static _CreateCubicSplineAnimation;
  85539. private static _GetBasePositionRotationOrScale;
  85540. /**
  85541. * Adds a key frame value
  85542. * @param keyFrame
  85543. * @param animation
  85544. * @param outputs
  85545. * @param animationChannelTargetPath
  85546. * @param basePositionRotationOrScale
  85547. * @param convertToRightHandedSystem
  85548. * @param useQuaternion
  85549. */
  85550. private static _AddKeyframeValue;
  85551. /**
  85552. * Determine the interpolation based on the key frames
  85553. * @param keyFrames
  85554. * @param animationChannelTargetPath
  85555. * @param useQuaternion
  85556. */
  85557. private static _DeduceInterpolation;
  85558. /**
  85559. * Adds an input tangent or output tangent to the output data
  85560. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85561. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85562. * @param outputs The animation data by keyframe
  85563. * @param animationChannelTargetPath The target animation channel
  85564. * @param interpolation The interpolation type
  85565. * @param keyFrame The key frame with the animation data
  85566. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85567. * @param useQuaternion Specifies if quaternions are used
  85568. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85569. */
  85570. private static AddSplineTangent;
  85571. /**
  85572. * Get the minimum and maximum key frames' frame values
  85573. * @param keyFrames animation key frames
  85574. * @returns the minimum and maximum key frame value
  85575. */
  85576. private static calculateMinMaxKeyFrames;
  85577. }
  85578. }
  85579. declare module BABYLON.GLTF2.Exporter {
  85580. /** @hidden */
  85581. export var textureTransformPixelShader: {
  85582. name: string;
  85583. shader: string;
  85584. };
  85585. }
  85586. declare module BABYLON.GLTF2.Exporter.Extensions {
  85587. /**
  85588. * @hidden
  85589. */
  85590. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85591. private _recordedTextures;
  85592. /** Name of this extension */
  85593. readonly name: string;
  85594. /** Defines whether this extension is enabled */
  85595. enabled: boolean;
  85596. /** Defines whether this extension is required */
  85597. required: boolean;
  85598. /** Reference to the glTF exporter */
  85599. private _wasUsed;
  85600. constructor(exporter: _Exporter);
  85601. dispose(): void;
  85602. /** @hidden */
  85603. get wasUsed(): boolean;
  85604. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85605. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85606. /**
  85607. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85608. * @param babylonTexture
  85609. * @param offset
  85610. * @param rotation
  85611. * @param scale
  85612. * @param scene
  85613. */
  85614. private _textureTransformTextureAsync;
  85615. }
  85616. }
  85617. declare module BABYLON.GLTF2.Exporter.Extensions {
  85618. /**
  85619. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85620. */
  85621. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85622. /** The name of this extension. */
  85623. readonly name: string;
  85624. /** Defines whether this extension is enabled. */
  85625. enabled: boolean;
  85626. /** Defines whether this extension is required */
  85627. required: boolean;
  85628. /** Reference to the glTF exporter */
  85629. private _exporter;
  85630. private _lights;
  85631. /** @hidden */
  85632. constructor(exporter: _Exporter);
  85633. /** @hidden */
  85634. dispose(): void;
  85635. /** @hidden */
  85636. get wasUsed(): boolean;
  85637. /** @hidden */
  85638. onExporting(): void;
  85639. /**
  85640. * Define this method to modify the default behavior when exporting a node
  85641. * @param context The context when exporting the node
  85642. * @param node glTF node
  85643. * @param babylonNode BabylonJS node
  85644. * @param nodeMap Node mapping of unique id to glTF node index
  85645. * @returns nullable INode promise
  85646. */
  85647. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85648. [key: number]: number;
  85649. }): Promise<Nullable<INode>>;
  85650. }
  85651. }
  85652. declare module BABYLON.GLTF2.Exporter.Extensions {
  85653. /**
  85654. * @hidden
  85655. */
  85656. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85657. /** Name of this extension */
  85658. readonly name: string;
  85659. /** Defines whether this extension is enabled */
  85660. enabled: boolean;
  85661. /** Defines whether this extension is required */
  85662. required: boolean;
  85663. /** Reference to the glTF exporter */
  85664. private _textureInfos;
  85665. private _exportedTextures;
  85666. private _wasUsed;
  85667. constructor(exporter: _Exporter);
  85668. dispose(): void;
  85669. /** @hidden */
  85670. get wasUsed(): boolean;
  85671. private _getTextureIndex;
  85672. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85673. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85674. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85675. }
  85676. }
  85677. declare module BABYLON.GLTF2.Exporter.Extensions {
  85678. /**
  85679. * @hidden
  85680. */
  85681. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85682. /** Name of this extension */
  85683. readonly name: string;
  85684. /** Defines whether this extension is enabled */
  85685. enabled: boolean;
  85686. /** Defines whether this extension is required */
  85687. required: boolean;
  85688. private _wasUsed;
  85689. constructor(exporter: _Exporter);
  85690. /** @hidden */
  85691. get wasUsed(): boolean;
  85692. dispose(): void;
  85693. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85694. }
  85695. }
  85696. declare module BABYLON {
  85697. /**
  85698. * Class for generating STL data from a Babylon scene.
  85699. */
  85700. export class STLExport {
  85701. /**
  85702. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85703. * @param meshes list defines the mesh to serialize
  85704. * @param download triggers the automatic download of the file.
  85705. * @param fileName changes the downloads fileName.
  85706. * @param binary changes the STL to a binary type.
  85707. * @param isLittleEndian toggle for binary type exporter.
  85708. * @returns the STL as UTF8 string
  85709. */
  85710. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85711. }
  85712. }
  85713. declare module "babylonjs-gltf2interface" {
  85714. export = BABYLON.GLTF2;
  85715. }
  85716. /**
  85717. * Module for glTF 2.0 Interface
  85718. */
  85719. declare module BABYLON.GLTF2 {
  85720. /**
  85721. * The datatype of the components in the attribute
  85722. */
  85723. const enum AccessorComponentType {
  85724. /**
  85725. * Byte
  85726. */
  85727. BYTE = 5120,
  85728. /**
  85729. * Unsigned Byte
  85730. */
  85731. UNSIGNED_BYTE = 5121,
  85732. /**
  85733. * Short
  85734. */
  85735. SHORT = 5122,
  85736. /**
  85737. * Unsigned Short
  85738. */
  85739. UNSIGNED_SHORT = 5123,
  85740. /**
  85741. * Unsigned Int
  85742. */
  85743. UNSIGNED_INT = 5125,
  85744. /**
  85745. * Float
  85746. */
  85747. FLOAT = 5126,
  85748. }
  85749. /**
  85750. * Specifies if the attirbute is a scalar, vector, or matrix
  85751. */
  85752. const enum AccessorType {
  85753. /**
  85754. * Scalar
  85755. */
  85756. SCALAR = "SCALAR",
  85757. /**
  85758. * Vector2
  85759. */
  85760. VEC2 = "VEC2",
  85761. /**
  85762. * Vector3
  85763. */
  85764. VEC3 = "VEC3",
  85765. /**
  85766. * Vector4
  85767. */
  85768. VEC4 = "VEC4",
  85769. /**
  85770. * Matrix2x2
  85771. */
  85772. MAT2 = "MAT2",
  85773. /**
  85774. * Matrix3x3
  85775. */
  85776. MAT3 = "MAT3",
  85777. /**
  85778. * Matrix4x4
  85779. */
  85780. MAT4 = "MAT4",
  85781. }
  85782. /**
  85783. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85784. */
  85785. const enum AnimationChannelTargetPath {
  85786. /**
  85787. * Translation
  85788. */
  85789. TRANSLATION = "translation",
  85790. /**
  85791. * Rotation
  85792. */
  85793. ROTATION = "rotation",
  85794. /**
  85795. * Scale
  85796. */
  85797. SCALE = "scale",
  85798. /**
  85799. * Weights
  85800. */
  85801. WEIGHTS = "weights",
  85802. }
  85803. /**
  85804. * Interpolation algorithm
  85805. */
  85806. const enum AnimationSamplerInterpolation {
  85807. /**
  85808. * The animated values are linearly interpolated between keyframes
  85809. */
  85810. LINEAR = "LINEAR",
  85811. /**
  85812. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85813. */
  85814. STEP = "STEP",
  85815. /**
  85816. * The animation's interpolation is computed using a cubic spline with specified tangents
  85817. */
  85818. CUBICSPLINE = "CUBICSPLINE",
  85819. }
  85820. /**
  85821. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85822. */
  85823. const enum CameraType {
  85824. /**
  85825. * A perspective camera containing properties to create a perspective projection matrix
  85826. */
  85827. PERSPECTIVE = "perspective",
  85828. /**
  85829. * An orthographic camera containing properties to create an orthographic projection matrix
  85830. */
  85831. ORTHOGRAPHIC = "orthographic",
  85832. }
  85833. /**
  85834. * The mime-type of the image
  85835. */
  85836. const enum ImageMimeType {
  85837. /**
  85838. * JPEG Mime-type
  85839. */
  85840. JPEG = "image/jpeg",
  85841. /**
  85842. * PNG Mime-type
  85843. */
  85844. PNG = "image/png",
  85845. }
  85846. /**
  85847. * The alpha rendering mode of the material
  85848. */
  85849. const enum MaterialAlphaMode {
  85850. /**
  85851. * The alpha value is ignored and the rendered output is fully opaque
  85852. */
  85853. OPAQUE = "OPAQUE",
  85854. /**
  85855. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85856. */
  85857. MASK = "MASK",
  85858. /**
  85859. * 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)
  85860. */
  85861. BLEND = "BLEND",
  85862. }
  85863. /**
  85864. * The type of the primitives to render
  85865. */
  85866. const enum MeshPrimitiveMode {
  85867. /**
  85868. * Points
  85869. */
  85870. POINTS = 0,
  85871. /**
  85872. * Lines
  85873. */
  85874. LINES = 1,
  85875. /**
  85876. * Line Loop
  85877. */
  85878. LINE_LOOP = 2,
  85879. /**
  85880. * Line Strip
  85881. */
  85882. LINE_STRIP = 3,
  85883. /**
  85884. * Triangles
  85885. */
  85886. TRIANGLES = 4,
  85887. /**
  85888. * Triangle Strip
  85889. */
  85890. TRIANGLE_STRIP = 5,
  85891. /**
  85892. * Triangle Fan
  85893. */
  85894. TRIANGLE_FAN = 6,
  85895. }
  85896. /**
  85897. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85898. */
  85899. const enum TextureMagFilter {
  85900. /**
  85901. * Nearest
  85902. */
  85903. NEAREST = 9728,
  85904. /**
  85905. * Linear
  85906. */
  85907. LINEAR = 9729,
  85908. }
  85909. /**
  85910. * Minification filter. All valid values correspond to WebGL enums
  85911. */
  85912. const enum TextureMinFilter {
  85913. /**
  85914. * Nearest
  85915. */
  85916. NEAREST = 9728,
  85917. /**
  85918. * Linear
  85919. */
  85920. LINEAR = 9729,
  85921. /**
  85922. * Nearest Mip-Map Nearest
  85923. */
  85924. NEAREST_MIPMAP_NEAREST = 9984,
  85925. /**
  85926. * Linear Mipmap Nearest
  85927. */
  85928. LINEAR_MIPMAP_NEAREST = 9985,
  85929. /**
  85930. * Nearest Mipmap Linear
  85931. */
  85932. NEAREST_MIPMAP_LINEAR = 9986,
  85933. /**
  85934. * Linear Mipmap Linear
  85935. */
  85936. LINEAR_MIPMAP_LINEAR = 9987,
  85937. }
  85938. /**
  85939. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85940. */
  85941. const enum TextureWrapMode {
  85942. /**
  85943. * Clamp to Edge
  85944. */
  85945. CLAMP_TO_EDGE = 33071,
  85946. /**
  85947. * Mirrored Repeat
  85948. */
  85949. MIRRORED_REPEAT = 33648,
  85950. /**
  85951. * Repeat
  85952. */
  85953. REPEAT = 10497,
  85954. }
  85955. /**
  85956. * glTF Property
  85957. */
  85958. interface IProperty {
  85959. /**
  85960. * Dictionary object with extension-specific objects
  85961. */
  85962. extensions?: {
  85963. [key: string]: any;
  85964. };
  85965. /**
  85966. * Application-Specific data
  85967. */
  85968. extras?: any;
  85969. }
  85970. /**
  85971. * glTF Child of Root Property
  85972. */
  85973. interface IChildRootProperty extends IProperty {
  85974. /**
  85975. * The user-defined name of this object
  85976. */
  85977. name?: string;
  85978. }
  85979. /**
  85980. * Indices of those attributes that deviate from their initialization value
  85981. */
  85982. interface IAccessorSparseIndices extends IProperty {
  85983. /**
  85984. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85985. */
  85986. bufferView: number;
  85987. /**
  85988. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85989. */
  85990. byteOffset?: number;
  85991. /**
  85992. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85993. */
  85994. componentType: AccessorComponentType;
  85995. }
  85996. /**
  85997. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85998. */
  85999. interface IAccessorSparseValues extends IProperty {
  86000. /**
  86001. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86002. */
  86003. bufferView: number;
  86004. /**
  86005. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86006. */
  86007. byteOffset?: number;
  86008. }
  86009. /**
  86010. * Sparse storage of attributes that deviate from their initialization value
  86011. */
  86012. interface IAccessorSparse extends IProperty {
  86013. /**
  86014. * The number of attributes encoded in this sparse accessor
  86015. */
  86016. count: number;
  86017. /**
  86018. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86019. */
  86020. indices: IAccessorSparseIndices;
  86021. /**
  86022. * 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
  86023. */
  86024. values: IAccessorSparseValues;
  86025. }
  86026. /**
  86027. * 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
  86028. */
  86029. interface IAccessor extends IChildRootProperty {
  86030. /**
  86031. * The index of the bufferview
  86032. */
  86033. bufferView?: number;
  86034. /**
  86035. * The offset relative to the start of the bufferView in bytes
  86036. */
  86037. byteOffset?: number;
  86038. /**
  86039. * The datatype of components in the attribute
  86040. */
  86041. componentType: AccessorComponentType;
  86042. /**
  86043. * Specifies whether integer data values should be normalized
  86044. */
  86045. normalized?: boolean;
  86046. /**
  86047. * The number of attributes referenced by this accessor
  86048. */
  86049. count: number;
  86050. /**
  86051. * Specifies if the attribute is a scalar, vector, or matrix
  86052. */
  86053. type: AccessorType;
  86054. /**
  86055. * Maximum value of each component in this attribute
  86056. */
  86057. max?: number[];
  86058. /**
  86059. * Minimum value of each component in this attribute
  86060. */
  86061. min?: number[];
  86062. /**
  86063. * Sparse storage of attributes that deviate from their initialization value
  86064. */
  86065. sparse?: IAccessorSparse;
  86066. }
  86067. /**
  86068. * Targets an animation's sampler at a node's property
  86069. */
  86070. interface IAnimationChannel extends IProperty {
  86071. /**
  86072. * The index of a sampler in this animation used to compute the value for the target
  86073. */
  86074. sampler: number;
  86075. /**
  86076. * The index of the node and TRS property to target
  86077. */
  86078. target: IAnimationChannelTarget;
  86079. }
  86080. /**
  86081. * The index of the node and TRS property that an animation channel targets
  86082. */
  86083. interface IAnimationChannelTarget extends IProperty {
  86084. /**
  86085. * The index of the node to target
  86086. */
  86087. node: number;
  86088. /**
  86089. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86090. */
  86091. path: AnimationChannelTargetPath;
  86092. }
  86093. /**
  86094. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86095. */
  86096. interface IAnimationSampler extends IProperty {
  86097. /**
  86098. * The index of an accessor containing keyframe input values, e.g., time
  86099. */
  86100. input: number;
  86101. /**
  86102. * Interpolation algorithm
  86103. */
  86104. interpolation?: AnimationSamplerInterpolation;
  86105. /**
  86106. * The index of an accessor, containing keyframe output values
  86107. */
  86108. output: number;
  86109. }
  86110. /**
  86111. * A keyframe animation
  86112. */
  86113. interface IAnimation extends IChildRootProperty {
  86114. /**
  86115. * An array of channels, each of which targets an animation's sampler at a node's property
  86116. */
  86117. channels: IAnimationChannel[];
  86118. /**
  86119. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86120. */
  86121. samplers: IAnimationSampler[];
  86122. }
  86123. /**
  86124. * Metadata about the glTF asset
  86125. */
  86126. interface IAsset extends IChildRootProperty {
  86127. /**
  86128. * A copyright message suitable for display to credit the content creator
  86129. */
  86130. copyright?: string;
  86131. /**
  86132. * Tool that generated this glTF model. Useful for debugging
  86133. */
  86134. generator?: string;
  86135. /**
  86136. * The glTF version that this asset targets
  86137. */
  86138. version: string;
  86139. /**
  86140. * The minimum glTF version that this asset targets
  86141. */
  86142. minVersion?: string;
  86143. }
  86144. /**
  86145. * A buffer points to binary geometry, animation, or skins
  86146. */
  86147. interface IBuffer extends IChildRootProperty {
  86148. /**
  86149. * 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
  86150. */
  86151. uri?: string;
  86152. /**
  86153. * The length of the buffer in bytes
  86154. */
  86155. byteLength: number;
  86156. }
  86157. /**
  86158. * A view into a buffer generally representing a subset of the buffer
  86159. */
  86160. interface IBufferView extends IChildRootProperty {
  86161. /**
  86162. * The index of the buffer
  86163. */
  86164. buffer: number;
  86165. /**
  86166. * The offset into the buffer in bytes
  86167. */
  86168. byteOffset?: number;
  86169. /**
  86170. * The lenth of the bufferView in bytes
  86171. */
  86172. byteLength: number;
  86173. /**
  86174. * The stride, in bytes
  86175. */
  86176. byteStride?: number;
  86177. }
  86178. /**
  86179. * An orthographic camera containing properties to create an orthographic projection matrix
  86180. */
  86181. interface ICameraOrthographic extends IProperty {
  86182. /**
  86183. * The floating-point horizontal magnification of the view. Must not be zero
  86184. */
  86185. xmag: number;
  86186. /**
  86187. * The floating-point vertical magnification of the view. Must not be zero
  86188. */
  86189. ymag: number;
  86190. /**
  86191. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86192. */
  86193. zfar: number;
  86194. /**
  86195. * The floating-point distance to the near clipping plane
  86196. */
  86197. znear: number;
  86198. }
  86199. /**
  86200. * A perspective camera containing properties to create a perspective projection matrix
  86201. */
  86202. interface ICameraPerspective extends IProperty {
  86203. /**
  86204. * The floating-point aspect ratio of the field of view
  86205. */
  86206. aspectRatio?: number;
  86207. /**
  86208. * The floating-point vertical field of view in radians
  86209. */
  86210. yfov: number;
  86211. /**
  86212. * The floating-point distance to the far clipping plane
  86213. */
  86214. zfar?: number;
  86215. /**
  86216. * The floating-point distance to the near clipping plane
  86217. */
  86218. znear: number;
  86219. }
  86220. /**
  86221. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86222. */
  86223. interface ICamera extends IChildRootProperty {
  86224. /**
  86225. * An orthographic camera containing properties to create an orthographic projection matrix
  86226. */
  86227. orthographic?: ICameraOrthographic;
  86228. /**
  86229. * A perspective camera containing properties to create a perspective projection matrix
  86230. */
  86231. perspective?: ICameraPerspective;
  86232. /**
  86233. * Specifies if the camera uses a perspective or orthographic projection
  86234. */
  86235. type: CameraType;
  86236. }
  86237. /**
  86238. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86239. */
  86240. interface IImage extends IChildRootProperty {
  86241. /**
  86242. * 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
  86243. */
  86244. uri?: string;
  86245. /**
  86246. * The image's MIME type
  86247. */
  86248. mimeType?: ImageMimeType;
  86249. /**
  86250. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86251. */
  86252. bufferView?: number;
  86253. }
  86254. /**
  86255. * Material Normal Texture Info
  86256. */
  86257. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86258. /**
  86259. * The scalar multiplier applied to each normal vector of the normal texture
  86260. */
  86261. scale?: number;
  86262. }
  86263. /**
  86264. * Material Occlusion Texture Info
  86265. */
  86266. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86267. /**
  86268. * A scalar multiplier controlling the amount of occlusion applied
  86269. */
  86270. strength?: number;
  86271. }
  86272. /**
  86273. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86274. */
  86275. interface IMaterialPbrMetallicRoughness {
  86276. /**
  86277. * The material's base color factor
  86278. */
  86279. baseColorFactor?: number[];
  86280. /**
  86281. * The base color texture
  86282. */
  86283. baseColorTexture?: ITextureInfo;
  86284. /**
  86285. * The metalness of the material
  86286. */
  86287. metallicFactor?: number;
  86288. /**
  86289. * The roughness of the material
  86290. */
  86291. roughnessFactor?: number;
  86292. /**
  86293. * The metallic-roughness texture
  86294. */
  86295. metallicRoughnessTexture?: ITextureInfo;
  86296. }
  86297. /**
  86298. * The material appearance of a primitive
  86299. */
  86300. interface IMaterial extends IChildRootProperty {
  86301. /**
  86302. * 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
  86303. */
  86304. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86305. /**
  86306. * The normal map texture
  86307. */
  86308. normalTexture?: IMaterialNormalTextureInfo;
  86309. /**
  86310. * The occlusion map texture
  86311. */
  86312. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86313. /**
  86314. * The emissive map texture
  86315. */
  86316. emissiveTexture?: ITextureInfo;
  86317. /**
  86318. * 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
  86319. */
  86320. emissiveFactor?: number[];
  86321. /**
  86322. * The alpha rendering mode of the material
  86323. */
  86324. alphaMode?: MaterialAlphaMode;
  86325. /**
  86326. * The alpha cutoff value of the material
  86327. */
  86328. alphaCutoff?: number;
  86329. /**
  86330. * Specifies whether the material is double sided
  86331. */
  86332. doubleSided?: boolean;
  86333. }
  86334. /**
  86335. * Geometry to be rendered with the given material
  86336. */
  86337. interface IMeshPrimitive extends IProperty {
  86338. /**
  86339. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86340. */
  86341. attributes: {
  86342. [name: string]: number;
  86343. };
  86344. /**
  86345. * The index of the accessor that contains the indices
  86346. */
  86347. indices?: number;
  86348. /**
  86349. * The index of the material to apply to this primitive when rendering
  86350. */
  86351. material?: number;
  86352. /**
  86353. * The type of primitives to render. All valid values correspond to WebGL enums
  86354. */
  86355. mode?: MeshPrimitiveMode;
  86356. /**
  86357. * 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
  86358. */
  86359. targets?: {
  86360. [name: string]: number;
  86361. }[];
  86362. }
  86363. /**
  86364. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86365. */
  86366. interface IMesh extends IChildRootProperty {
  86367. /**
  86368. * An array of primitives, each defining geometry to be rendered with a material
  86369. */
  86370. primitives: IMeshPrimitive[];
  86371. /**
  86372. * Array of weights to be applied to the Morph Targets
  86373. */
  86374. weights?: number[];
  86375. }
  86376. /**
  86377. * A node in the node hierarchy
  86378. */
  86379. interface INode extends IChildRootProperty {
  86380. /**
  86381. * The index of the camera referenced by this node
  86382. */
  86383. camera?: number;
  86384. /**
  86385. * The indices of this node's children
  86386. */
  86387. children?: number[];
  86388. /**
  86389. * The index of the skin referenced by this node
  86390. */
  86391. skin?: number;
  86392. /**
  86393. * A floating-point 4x4 transformation matrix stored in column-major order
  86394. */
  86395. matrix?: number[];
  86396. /**
  86397. * The index of the mesh in this node
  86398. */
  86399. mesh?: number;
  86400. /**
  86401. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86402. */
  86403. rotation?: number[];
  86404. /**
  86405. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86406. */
  86407. scale?: number[];
  86408. /**
  86409. * The node's translation along the x, y, and z axes
  86410. */
  86411. translation?: number[];
  86412. /**
  86413. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86414. */
  86415. weights?: number[];
  86416. }
  86417. /**
  86418. * Texture sampler properties for filtering and wrapping modes
  86419. */
  86420. interface ISampler extends IChildRootProperty {
  86421. /**
  86422. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86423. */
  86424. magFilter?: TextureMagFilter;
  86425. /**
  86426. * Minification filter. All valid values correspond to WebGL enums
  86427. */
  86428. minFilter?: TextureMinFilter;
  86429. /**
  86430. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86431. */
  86432. wrapS?: TextureWrapMode;
  86433. /**
  86434. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86435. */
  86436. wrapT?: TextureWrapMode;
  86437. }
  86438. /**
  86439. * The root nodes of a scene
  86440. */
  86441. interface IScene extends IChildRootProperty {
  86442. /**
  86443. * The indices of each root node
  86444. */
  86445. nodes: number[];
  86446. }
  86447. /**
  86448. * Joints and matrices defining a skin
  86449. */
  86450. interface ISkin extends IChildRootProperty {
  86451. /**
  86452. * 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
  86453. */
  86454. inverseBindMatrices?: number;
  86455. /**
  86456. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86457. */
  86458. skeleton?: number;
  86459. /**
  86460. * 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)
  86461. */
  86462. joints: number[];
  86463. }
  86464. /**
  86465. * A texture and its sampler
  86466. */
  86467. interface ITexture extends IChildRootProperty {
  86468. /**
  86469. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86470. */
  86471. sampler?: number;
  86472. /**
  86473. * The index of the image used by this texture
  86474. */
  86475. source: number;
  86476. }
  86477. /**
  86478. * Reference to a texture
  86479. */
  86480. interface ITextureInfo extends IProperty {
  86481. /**
  86482. * The index of the texture
  86483. */
  86484. index: number;
  86485. /**
  86486. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86487. */
  86488. texCoord?: number;
  86489. }
  86490. /**
  86491. * The root object for a glTF asset
  86492. */
  86493. interface IGLTF extends IProperty {
  86494. /**
  86495. * An array of accessors. An accessor is a typed view into a bufferView
  86496. */
  86497. accessors?: IAccessor[];
  86498. /**
  86499. * An array of keyframe animations
  86500. */
  86501. animations?: IAnimation[];
  86502. /**
  86503. * Metadata about the glTF asset
  86504. */
  86505. asset: IAsset;
  86506. /**
  86507. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86508. */
  86509. buffers?: IBuffer[];
  86510. /**
  86511. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86512. */
  86513. bufferViews?: IBufferView[];
  86514. /**
  86515. * An array of cameras
  86516. */
  86517. cameras?: ICamera[];
  86518. /**
  86519. * Names of glTF extensions used somewhere in this asset
  86520. */
  86521. extensionsUsed?: string[];
  86522. /**
  86523. * Names of glTF extensions required to properly load this asset
  86524. */
  86525. extensionsRequired?: string[];
  86526. /**
  86527. * An array of images. An image defines data used to create a texture
  86528. */
  86529. images?: IImage[];
  86530. /**
  86531. * An array of materials. A material defines the appearance of a primitive
  86532. */
  86533. materials?: IMaterial[];
  86534. /**
  86535. * An array of meshes. A mesh is a set of primitives to be rendered
  86536. */
  86537. meshes?: IMesh[];
  86538. /**
  86539. * An array of nodes
  86540. */
  86541. nodes?: INode[];
  86542. /**
  86543. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86544. */
  86545. samplers?: ISampler[];
  86546. /**
  86547. * The index of the default scene
  86548. */
  86549. scene?: number;
  86550. /**
  86551. * An array of scenes
  86552. */
  86553. scenes?: IScene[];
  86554. /**
  86555. * An array of skins. A skin is defined by joints and matrices
  86556. */
  86557. skins?: ISkin[];
  86558. /**
  86559. * An array of textures
  86560. */
  86561. textures?: ITexture[];
  86562. }
  86563. /**
  86564. * The glTF validation results
  86565. * @ignore
  86566. */
  86567. interface IGLTFValidationResults {
  86568. info: {
  86569. generator: string;
  86570. hasAnimations: boolean;
  86571. hasDefaultScene: boolean;
  86572. hasMaterials: boolean;
  86573. hasMorphTargets: boolean;
  86574. hasSkins: boolean;
  86575. hasTextures: boolean;
  86576. maxAttributesUsed: number;
  86577. primitivesCount: number
  86578. };
  86579. issues: {
  86580. messages: Array<string>;
  86581. numErrors: number;
  86582. numHints: number;
  86583. numInfos: number;
  86584. numWarnings: number;
  86585. truncated: boolean
  86586. };
  86587. mimeType: string;
  86588. uri: string;
  86589. validatedAt: string;
  86590. validatorVersion: string;
  86591. }
  86592. /**
  86593. * The glTF validation options
  86594. */
  86595. interface IGLTFValidationOptions {
  86596. /** Uri to use */
  86597. uri?: string;
  86598. /** Function used to load external resources */
  86599. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86600. /** Boolean indicating that we need to validate accessor data */
  86601. validateAccessorData?: boolean;
  86602. /** max number of issues allowed */
  86603. maxIssues?: number;
  86604. /** Ignored issues */
  86605. ignoredIssues?: Array<string>;
  86606. /** Value to override severy settings */
  86607. severityOverrides?: Object;
  86608. }
  86609. /**
  86610. * The glTF validator object
  86611. * @ignore
  86612. */
  86613. interface IGLTFValidator {
  86614. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86615. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86616. }
  86617. /**
  86618. * Interfaces from the EXT_lights_image_based extension
  86619. */
  86620. /** @hidden */
  86621. interface IEXTLightsImageBased_LightReferenceImageBased {
  86622. light: number;
  86623. }
  86624. /** @hidden */
  86625. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86626. intensity: number;
  86627. rotation: number[];
  86628. specularImageSize: number;
  86629. specularImages: number[][];
  86630. irradianceCoefficients: number[][];
  86631. }
  86632. /** @hidden */
  86633. interface IEXTLightsImageBased {
  86634. lights: IEXTLightsImageBased_LightImageBased[];
  86635. }
  86636. /**
  86637. * Interfaces from the EXT_mesh_gpu_instancing extension
  86638. * !!! Experimental Extension Subject to Changes !!!
  86639. */
  86640. /** @hidden */
  86641. interface IEXTMeshGpuInstancing {
  86642. mesh?: number;
  86643. attributes: { [name: string]: number };
  86644. }
  86645. /**
  86646. * Interfaces from the KHR_draco_mesh_compression extension
  86647. */
  86648. /** @hidden */
  86649. interface IKHRDracoMeshCompression {
  86650. bufferView: number;
  86651. attributes: { [name: string]: number };
  86652. }
  86653. /**
  86654. * Interfaces from the KHR_lights_punctual extension
  86655. */
  86656. /** @hidden */
  86657. const enum IKHRLightsPunctual_LightType {
  86658. DIRECTIONAL = "directional",
  86659. POINT = "point",
  86660. SPOT = "spot"
  86661. }
  86662. /** @hidden */
  86663. interface IKHRLightsPunctual_LightReference {
  86664. light: number;
  86665. }
  86666. /** @hidden */
  86667. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86668. type: IKHRLightsPunctual_LightType;
  86669. color?: number[];
  86670. intensity?: number;
  86671. range?: number;
  86672. spot?: {
  86673. innerConeAngle?: number;
  86674. outerConeAngle?: number;
  86675. };
  86676. }
  86677. /** @hidden */
  86678. interface IKHRLightsPunctual {
  86679. lights: IKHRLightsPunctual_Light[];
  86680. }
  86681. /**
  86682. * Interfaces from the KHR_materials_clearcoat extension
  86683. * !!! Experimental Extension Subject to Changes !!!
  86684. */
  86685. /** @hidden */
  86686. interface IKHRMaterialsClearcoat {
  86687. clearcoatFactor: number;
  86688. clearcoatTexture: ITextureInfo;
  86689. clearcoatRoughnessFactor: number;
  86690. clearcoatRoughnessTexture: ITextureInfo;
  86691. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86692. }
  86693. /**
  86694. * Interfaces from the KHR_materials_ior extension
  86695. * !!! Experimental Extension Subject to Changes !!!
  86696. */
  86697. /** @hidden */
  86698. interface IKHRMaterialsIor {
  86699. ior: number;
  86700. }
  86701. /**
  86702. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86703. */
  86704. /** @hidden */
  86705. interface IKHRMaterialsPbrSpecularGlossiness {
  86706. diffuseFactor: number[];
  86707. diffuseTexture: ITextureInfo;
  86708. specularFactor: number[];
  86709. glossinessFactor: number;
  86710. specularGlossinessTexture: ITextureInfo;
  86711. }
  86712. /**
  86713. * Interfaces from the KHR_materials_sheen extension
  86714. * !!! Experimental Extension Subject to Changes !!!
  86715. */
  86716. /** @hidden */
  86717. interface IKHRMaterialsSheen {
  86718. sheenColorFactor?: number[];
  86719. sheenColorTexture?: ITextureInfo;
  86720. sheenRoughnessFactor?: number;
  86721. sheenRoughnessTexture?: ITextureInfo;
  86722. }
  86723. /**
  86724. * Interfaces from the KHR_materials_specular extension
  86725. * !!! Experimental Extension Subject to Changes !!!
  86726. */
  86727. /** @hidden */
  86728. interface IKHRMaterialsSpecular {
  86729. specularFactor: number;
  86730. specularColorFactor: number[];
  86731. specularTexture: ITextureInfo;
  86732. }
  86733. /**
  86734. * Interfaces from the KHR_materials_transmission extension
  86735. * !!! Experimental Extension Subject to Changes !!!
  86736. */
  86737. /** @hidden */
  86738. interface IKHRMaterialsTransmission {
  86739. transmissionFactor?: number;
  86740. transmissionTexture?: ITextureInfo;
  86741. }
  86742. /**
  86743. * Interfaces from the KHR_materials_variants extension
  86744. * !!! Experimental Extension Subject to Changes !!!
  86745. */
  86746. /** @hidden */
  86747. interface IKHRMaterialVariants_Mapping extends IProperty {
  86748. mappings: Array<{
  86749. variants: number[];
  86750. material: number;
  86751. }>;
  86752. }
  86753. /** @hidden */
  86754. interface IKHRMaterialVariants_Variant extends IProperty {
  86755. name: string;
  86756. }
  86757. /** @hidden */
  86758. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86759. variants: Array<IKHRMaterialVariants_Variant>;
  86760. }
  86761. /**
  86762. * Interfaces from the KHR_texture_basisu extension
  86763. * !!! Experimental Extension Subject to Changes !!!
  86764. */
  86765. /** @hidden */
  86766. interface IKHRTextureBasisU {
  86767. source: number;
  86768. }
  86769. /**
  86770. * Interfaces from the EXT_texture_webp extension
  86771. */
  86772. /** @hidden */
  86773. interface IEXTTextureWebP {
  86774. source: number;
  86775. }
  86776. /**
  86777. * Interfaces from the KHR_texture_transform extension
  86778. */
  86779. /** @hidden */
  86780. interface IKHRTextureTransform {
  86781. offset?: number[];
  86782. rotation?: number;
  86783. scale?: number[];
  86784. texCoord?: number;
  86785. }
  86786. /**
  86787. * Interfaces from the KHR_xmp extension
  86788. * !!! Experimental Extension Subject to Changes !!!
  86789. */
  86790. /** @hidden */
  86791. interface IKHRXmp_Data {
  86792. [key: string]: unknown;
  86793. }
  86794. /** @hidden */
  86795. interface IKHRXmp_Gltf {
  86796. packets: IKHRXmp_Data[];
  86797. }
  86798. /** @hidden */
  86799. interface IKHRXmp_Node {
  86800. packet: number;
  86801. }
  86802. /**
  86803. * Interfaces from the MSFT_audio_emitter extension
  86804. */
  86805. /** @hidden */
  86806. interface IMSFTAudioEmitter_ClipReference {
  86807. clip: number;
  86808. weight?: number;
  86809. }
  86810. /** @hidden */
  86811. interface IMSFTAudioEmitter_EmittersReference {
  86812. emitters: number[];
  86813. }
  86814. /** @hidden */
  86815. const enum IMSFTAudioEmitter_DistanceModel {
  86816. linear = "linear",
  86817. inverse = "inverse",
  86818. exponential = "exponential",
  86819. }
  86820. /** @hidden */
  86821. interface IMSFTAudioEmitter_Emitter {
  86822. name?: string;
  86823. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86824. refDistance?: number;
  86825. maxDistance?: number;
  86826. rolloffFactor?: number;
  86827. innerAngle?: number;
  86828. outerAngle?: number;
  86829. loop?: boolean;
  86830. volume?: number;
  86831. clips: IMSFTAudioEmitter_ClipReference[];
  86832. }
  86833. /** @hidden */
  86834. const enum IMSFTAudioEmitter_AudioMimeType {
  86835. WAV = "audio/wav",
  86836. }
  86837. /** @hidden */
  86838. interface IMSFTAudioEmitter_Clip extends IProperty {
  86839. uri?: string;
  86840. bufferView?: number;
  86841. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86842. }
  86843. /** @hidden */
  86844. const enum IMSFTAudioEmitter_AnimationEventAction {
  86845. play = "play",
  86846. pause = "pause",
  86847. stop = "stop",
  86848. }
  86849. /** @hidden */
  86850. interface IMSFTAudioEmitter_AnimationEvent {
  86851. action: IMSFTAudioEmitter_AnimationEventAction;
  86852. emitter: number;
  86853. time: number;
  86854. startOffset?: number;
  86855. }
  86856. /**
  86857. * Interfaces from the MSFT_lod extension
  86858. */
  86859. /** @hidden */
  86860. interface IMSFTLOD {
  86861. ids: number[];
  86862. }
  86863. }
  86864. declare module BABYLON {
  86865. /** @hidden */
  86866. export var cellPixelShader: {
  86867. name: string;
  86868. shader: string;
  86869. };
  86870. }
  86871. declare module BABYLON {
  86872. /** @hidden */
  86873. export var cellVertexShader: {
  86874. name: string;
  86875. shader: string;
  86876. };
  86877. }
  86878. declare module BABYLON {
  86879. export class CellMaterial extends BABYLON.PushMaterial {
  86880. private _diffuseTexture;
  86881. diffuseTexture: BABYLON.BaseTexture;
  86882. diffuseColor: BABYLON.Color3;
  86883. _computeHighLevel: boolean;
  86884. computeHighLevel: boolean;
  86885. private _disableLighting;
  86886. disableLighting: boolean;
  86887. private _maxSimultaneousLights;
  86888. maxSimultaneousLights: number;
  86889. constructor(name: string, scene: BABYLON.Scene);
  86890. needAlphaBlending(): boolean;
  86891. needAlphaTesting(): boolean;
  86892. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86893. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86894. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86895. getAnimatables(): BABYLON.IAnimatable[];
  86896. getActiveTextures(): BABYLON.BaseTexture[];
  86897. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86898. dispose(forceDisposeEffect?: boolean): void;
  86899. getClassName(): string;
  86900. clone(name: string): CellMaterial;
  86901. serialize(): any;
  86902. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86903. }
  86904. }
  86905. declare module BABYLON {
  86906. export class CustomShaderStructure {
  86907. FragmentStore: string;
  86908. VertexStore: string;
  86909. constructor();
  86910. }
  86911. export class ShaderSpecialParts {
  86912. constructor();
  86913. Fragment_Begin: string;
  86914. Fragment_Definitions: string;
  86915. Fragment_MainBegin: string;
  86916. Fragment_Custom_Diffuse: string;
  86917. Fragment_Before_Lights: string;
  86918. Fragment_Before_Fog: string;
  86919. Fragment_Custom_Alpha: string;
  86920. Fragment_Before_FragColor: string;
  86921. Vertex_Begin: string;
  86922. Vertex_Definitions: string;
  86923. Vertex_MainBegin: string;
  86924. Vertex_Before_PositionUpdated: string;
  86925. Vertex_Before_NormalUpdated: string;
  86926. Vertex_After_WorldPosComputed: string;
  86927. Vertex_MainEnd: string;
  86928. }
  86929. export class CustomMaterial extends BABYLON.StandardMaterial {
  86930. static ShaderIndexer: number;
  86931. CustomParts: ShaderSpecialParts;
  86932. _isCreatedShader: boolean;
  86933. _createdShaderName: string;
  86934. _customUniform: string[];
  86935. _newUniforms: string[];
  86936. _newUniformInstances: {
  86937. [name: string]: any;
  86938. };
  86939. _newSamplerInstances: {
  86940. [name: string]: BABYLON.Texture;
  86941. };
  86942. _customAttributes: string[];
  86943. FragmentShader: string;
  86944. VertexShader: string;
  86945. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86946. ReviewUniform(name: string, arr: string[]): string[];
  86947. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86948. constructor(name: string, scene: BABYLON.Scene);
  86949. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86950. AddAttribute(name: string): CustomMaterial;
  86951. Fragment_Begin(shaderPart: string): CustomMaterial;
  86952. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86953. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86954. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86955. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86956. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86957. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86958. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86959. Vertex_Begin(shaderPart: string): CustomMaterial;
  86960. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86961. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86962. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86963. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86964. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86965. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86966. }
  86967. }
  86968. declare module BABYLON {
  86969. export class ShaderAlebdoParts {
  86970. constructor();
  86971. Fragment_Begin: string;
  86972. Fragment_Definitions: string;
  86973. Fragment_MainBegin: string;
  86974. Fragment_Custom_Albedo: string;
  86975. Fragment_Before_Lights: string;
  86976. Fragment_Custom_MetallicRoughness: string;
  86977. Fragment_Custom_MicroSurface: string;
  86978. Fragment_Before_Fog: string;
  86979. Fragment_Custom_Alpha: string;
  86980. Fragment_Before_FragColor: string;
  86981. Vertex_Begin: string;
  86982. Vertex_Definitions: string;
  86983. Vertex_MainBegin: string;
  86984. Vertex_Before_PositionUpdated: string;
  86985. Vertex_Before_NormalUpdated: string;
  86986. Vertex_After_WorldPosComputed: string;
  86987. Vertex_MainEnd: string;
  86988. }
  86989. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86990. static ShaderIndexer: number;
  86991. CustomParts: ShaderAlebdoParts;
  86992. _isCreatedShader: boolean;
  86993. _createdShaderName: string;
  86994. _customUniform: string[];
  86995. _newUniforms: string[];
  86996. _newUniformInstances: {
  86997. [name: string]: any;
  86998. };
  86999. _newSamplerInstances: {
  87000. [name: string]: BABYLON.Texture;
  87001. };
  87002. _customAttributes: string[];
  87003. FragmentShader: string;
  87004. VertexShader: string;
  87005. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87006. ReviewUniform(name: string, arr: string[]): string[];
  87007. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87008. constructor(name: string, scene: BABYLON.Scene);
  87009. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87010. AddAttribute(name: string): PBRCustomMaterial;
  87011. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87012. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87013. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87014. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87015. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87016. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87017. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87018. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87019. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87020. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87021. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87022. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87023. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87024. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87025. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87026. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87027. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87028. }
  87029. }
  87030. declare module BABYLON {
  87031. /** @hidden */
  87032. export var firePixelShader: {
  87033. name: string;
  87034. shader: string;
  87035. };
  87036. }
  87037. declare module BABYLON {
  87038. /** @hidden */
  87039. export var fireVertexShader: {
  87040. name: string;
  87041. shader: string;
  87042. };
  87043. }
  87044. declare module BABYLON {
  87045. export class FireMaterial extends BABYLON.PushMaterial {
  87046. private _diffuseTexture;
  87047. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87048. private _distortionTexture;
  87049. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87050. private _opacityTexture;
  87051. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87052. diffuseColor: BABYLON.Color3;
  87053. speed: number;
  87054. private _scaledDiffuse;
  87055. private _lastTime;
  87056. constructor(name: string, scene: BABYLON.Scene);
  87057. needAlphaBlending(): boolean;
  87058. needAlphaTesting(): boolean;
  87059. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87061. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87062. getAnimatables(): BABYLON.IAnimatable[];
  87063. getActiveTextures(): BABYLON.BaseTexture[];
  87064. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87065. getClassName(): string;
  87066. dispose(forceDisposeEffect?: boolean): void;
  87067. clone(name: string): FireMaterial;
  87068. serialize(): any;
  87069. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87070. }
  87071. }
  87072. declare module BABYLON {
  87073. /** @hidden */
  87074. export var furPixelShader: {
  87075. name: string;
  87076. shader: string;
  87077. };
  87078. }
  87079. declare module BABYLON {
  87080. /** @hidden */
  87081. export var furVertexShader: {
  87082. name: string;
  87083. shader: string;
  87084. };
  87085. }
  87086. declare module BABYLON {
  87087. export class FurMaterial extends BABYLON.PushMaterial {
  87088. private _diffuseTexture;
  87089. diffuseTexture: BABYLON.BaseTexture;
  87090. private _heightTexture;
  87091. heightTexture: BABYLON.BaseTexture;
  87092. diffuseColor: BABYLON.Color3;
  87093. furLength: number;
  87094. furAngle: number;
  87095. furColor: BABYLON.Color3;
  87096. furOffset: number;
  87097. furSpacing: number;
  87098. furGravity: BABYLON.Vector3;
  87099. furSpeed: number;
  87100. furDensity: number;
  87101. furOcclusion: number;
  87102. furTexture: BABYLON.DynamicTexture;
  87103. private _disableLighting;
  87104. disableLighting: boolean;
  87105. private _maxSimultaneousLights;
  87106. maxSimultaneousLights: number;
  87107. highLevelFur: boolean;
  87108. _meshes: BABYLON.AbstractMesh[];
  87109. private _furTime;
  87110. constructor(name: string, scene: BABYLON.Scene);
  87111. get furTime(): number;
  87112. set furTime(furTime: number);
  87113. needAlphaBlending(): boolean;
  87114. needAlphaTesting(): boolean;
  87115. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87116. updateFur(): void;
  87117. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87118. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87119. getAnimatables(): BABYLON.IAnimatable[];
  87120. getActiveTextures(): BABYLON.BaseTexture[];
  87121. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87122. dispose(forceDisposeEffect?: boolean): void;
  87123. clone(name: string): FurMaterial;
  87124. serialize(): any;
  87125. getClassName(): string;
  87126. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87127. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87128. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87129. }
  87130. }
  87131. declare module BABYLON {
  87132. /** @hidden */
  87133. export var gradientPixelShader: {
  87134. name: string;
  87135. shader: string;
  87136. };
  87137. }
  87138. declare module BABYLON {
  87139. /** @hidden */
  87140. export var gradientVertexShader: {
  87141. name: string;
  87142. shader: string;
  87143. };
  87144. }
  87145. declare module BABYLON {
  87146. export class GradientMaterial extends BABYLON.PushMaterial {
  87147. private _maxSimultaneousLights;
  87148. maxSimultaneousLights: number;
  87149. topColor: BABYLON.Color3;
  87150. topColorAlpha: number;
  87151. bottomColor: BABYLON.Color3;
  87152. bottomColorAlpha: number;
  87153. offset: number;
  87154. scale: number;
  87155. smoothness: number;
  87156. private _disableLighting;
  87157. disableLighting: boolean;
  87158. constructor(name: string, scene: BABYLON.Scene);
  87159. needAlphaBlending(): boolean;
  87160. needAlphaTesting(): boolean;
  87161. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87162. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87163. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87164. getAnimatables(): BABYLON.IAnimatable[];
  87165. dispose(forceDisposeEffect?: boolean): void;
  87166. clone(name: string): GradientMaterial;
  87167. serialize(): any;
  87168. getClassName(): string;
  87169. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87170. }
  87171. }
  87172. declare module BABYLON {
  87173. /** @hidden */
  87174. export var gridPixelShader: {
  87175. name: string;
  87176. shader: string;
  87177. };
  87178. }
  87179. declare module BABYLON {
  87180. /** @hidden */
  87181. export var gridVertexShader: {
  87182. name: string;
  87183. shader: string;
  87184. };
  87185. }
  87186. declare module BABYLON {
  87187. /**
  87188. * The grid materials allows you to wrap any shape with a grid.
  87189. * Colors are customizable.
  87190. */
  87191. export class GridMaterial extends BABYLON.PushMaterial {
  87192. /**
  87193. * Main color of the grid (e.g. between lines)
  87194. */
  87195. mainColor: BABYLON.Color3;
  87196. /**
  87197. * Color of the grid lines.
  87198. */
  87199. lineColor: BABYLON.Color3;
  87200. /**
  87201. * The scale of the grid compared to unit.
  87202. */
  87203. gridRatio: number;
  87204. /**
  87205. * Allows setting an offset for the grid lines.
  87206. */
  87207. gridOffset: BABYLON.Vector3;
  87208. /**
  87209. * The frequency of thicker lines.
  87210. */
  87211. majorUnitFrequency: number;
  87212. /**
  87213. * The visibility of minor units in the grid.
  87214. */
  87215. minorUnitVisibility: number;
  87216. /**
  87217. * The grid opacity outside of the lines.
  87218. */
  87219. opacity: number;
  87220. /**
  87221. * Determine RBG output is premultiplied by alpha value.
  87222. */
  87223. preMultiplyAlpha: boolean;
  87224. private _opacityTexture;
  87225. opacityTexture: BABYLON.BaseTexture;
  87226. private _gridControl;
  87227. /**
  87228. * constructor
  87229. * @param name The name given to the material in order to identify it afterwards.
  87230. * @param scene The scene the material is used in.
  87231. */
  87232. constructor(name: string, scene: BABYLON.Scene);
  87233. /**
  87234. * Returns wehter or not the grid requires alpha blending.
  87235. */
  87236. needAlphaBlending(): boolean;
  87237. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87238. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87239. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87240. /**
  87241. * Dispose the material and its associated resources.
  87242. * @param forceDisposeEffect will also dispose the used effect when true
  87243. */
  87244. dispose(forceDisposeEffect?: boolean): void;
  87245. clone(name: string): GridMaterial;
  87246. serialize(): any;
  87247. getClassName(): string;
  87248. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87249. }
  87250. }
  87251. declare module BABYLON {
  87252. /** @hidden */
  87253. export var lavaPixelShader: {
  87254. name: string;
  87255. shader: string;
  87256. };
  87257. }
  87258. declare module BABYLON {
  87259. /** @hidden */
  87260. export var lavaVertexShader: {
  87261. name: string;
  87262. shader: string;
  87263. };
  87264. }
  87265. declare module BABYLON {
  87266. export class LavaMaterial extends BABYLON.PushMaterial {
  87267. private _diffuseTexture;
  87268. diffuseTexture: BABYLON.BaseTexture;
  87269. noiseTexture: BABYLON.BaseTexture;
  87270. fogColor: BABYLON.Color3;
  87271. speed: number;
  87272. movingSpeed: number;
  87273. lowFrequencySpeed: number;
  87274. fogDensity: number;
  87275. private _lastTime;
  87276. diffuseColor: BABYLON.Color3;
  87277. private _disableLighting;
  87278. disableLighting: boolean;
  87279. private _unlit;
  87280. unlit: boolean;
  87281. private _maxSimultaneousLights;
  87282. maxSimultaneousLights: number;
  87283. private _scaledDiffuse;
  87284. constructor(name: string, scene: BABYLON.Scene);
  87285. needAlphaBlending(): boolean;
  87286. needAlphaTesting(): boolean;
  87287. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87288. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87289. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87290. getAnimatables(): BABYLON.IAnimatable[];
  87291. getActiveTextures(): BABYLON.BaseTexture[];
  87292. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87293. dispose(forceDisposeEffect?: boolean): void;
  87294. clone(name: string): LavaMaterial;
  87295. serialize(): any;
  87296. getClassName(): string;
  87297. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87298. }
  87299. }
  87300. declare module BABYLON {
  87301. /** @hidden */
  87302. export var mixPixelShader: {
  87303. name: string;
  87304. shader: string;
  87305. };
  87306. }
  87307. declare module BABYLON {
  87308. /** @hidden */
  87309. export var mixVertexShader: {
  87310. name: string;
  87311. shader: string;
  87312. };
  87313. }
  87314. declare module BABYLON {
  87315. export class MixMaterial extends BABYLON.PushMaterial {
  87316. /**
  87317. * Mix textures
  87318. */
  87319. private _mixTexture1;
  87320. mixTexture1: BABYLON.BaseTexture;
  87321. private _mixTexture2;
  87322. mixTexture2: BABYLON.BaseTexture;
  87323. /**
  87324. * Diffuse textures
  87325. */
  87326. private _diffuseTexture1;
  87327. diffuseTexture1: BABYLON.Texture;
  87328. private _diffuseTexture2;
  87329. diffuseTexture2: BABYLON.Texture;
  87330. private _diffuseTexture3;
  87331. diffuseTexture3: BABYLON.Texture;
  87332. private _diffuseTexture4;
  87333. diffuseTexture4: BABYLON.Texture;
  87334. private _diffuseTexture5;
  87335. diffuseTexture5: BABYLON.Texture;
  87336. private _diffuseTexture6;
  87337. diffuseTexture6: BABYLON.Texture;
  87338. private _diffuseTexture7;
  87339. diffuseTexture7: BABYLON.Texture;
  87340. private _diffuseTexture8;
  87341. diffuseTexture8: BABYLON.Texture;
  87342. /**
  87343. * Uniforms
  87344. */
  87345. diffuseColor: BABYLON.Color3;
  87346. specularColor: BABYLON.Color3;
  87347. specularPower: number;
  87348. private _disableLighting;
  87349. disableLighting: boolean;
  87350. private _maxSimultaneousLights;
  87351. maxSimultaneousLights: number;
  87352. constructor(name: string, scene: BABYLON.Scene);
  87353. needAlphaBlending(): boolean;
  87354. needAlphaTesting(): boolean;
  87355. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87356. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87357. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87358. getAnimatables(): BABYLON.IAnimatable[];
  87359. getActiveTextures(): BABYLON.BaseTexture[];
  87360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87361. dispose(forceDisposeEffect?: boolean): void;
  87362. clone(name: string): MixMaterial;
  87363. serialize(): any;
  87364. getClassName(): string;
  87365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87366. }
  87367. }
  87368. declare module BABYLON {
  87369. /** @hidden */
  87370. export var normalPixelShader: {
  87371. name: string;
  87372. shader: string;
  87373. };
  87374. }
  87375. declare module BABYLON {
  87376. /** @hidden */
  87377. export var normalVertexShader: {
  87378. name: string;
  87379. shader: string;
  87380. };
  87381. }
  87382. declare module BABYLON {
  87383. export class NormalMaterial extends BABYLON.PushMaterial {
  87384. private _diffuseTexture;
  87385. diffuseTexture: BABYLON.BaseTexture;
  87386. diffuseColor: BABYLON.Color3;
  87387. private _disableLighting;
  87388. disableLighting: boolean;
  87389. private _maxSimultaneousLights;
  87390. maxSimultaneousLights: number;
  87391. constructor(name: string, scene: BABYLON.Scene);
  87392. needAlphaBlending(): boolean;
  87393. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87394. needAlphaTesting(): boolean;
  87395. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87396. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87397. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87398. getAnimatables(): BABYLON.IAnimatable[];
  87399. getActiveTextures(): BABYLON.BaseTexture[];
  87400. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87401. dispose(forceDisposeEffect?: boolean): void;
  87402. clone(name: string): NormalMaterial;
  87403. serialize(): any;
  87404. getClassName(): string;
  87405. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87406. }
  87407. }
  87408. declare module BABYLON {
  87409. /** @hidden */
  87410. export var shadowOnlyPixelShader: {
  87411. name: string;
  87412. shader: string;
  87413. };
  87414. }
  87415. declare module BABYLON {
  87416. /** @hidden */
  87417. export var shadowOnlyVertexShader: {
  87418. name: string;
  87419. shader: string;
  87420. };
  87421. }
  87422. declare module BABYLON {
  87423. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87424. private _activeLight;
  87425. private _needAlphaBlending;
  87426. constructor(name: string, scene: BABYLON.Scene);
  87427. shadowColor: BABYLON.Color3;
  87428. needAlphaBlending(): boolean;
  87429. needAlphaTesting(): boolean;
  87430. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87431. get activeLight(): BABYLON.IShadowLight;
  87432. set activeLight(light: BABYLON.IShadowLight);
  87433. private _getFirstShadowLightForMesh;
  87434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87435. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87436. clone(name: string): ShadowOnlyMaterial;
  87437. serialize(): any;
  87438. getClassName(): string;
  87439. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87440. }
  87441. }
  87442. declare module BABYLON {
  87443. /** @hidden */
  87444. export var simplePixelShader: {
  87445. name: string;
  87446. shader: string;
  87447. };
  87448. }
  87449. declare module BABYLON {
  87450. /** @hidden */
  87451. export var simpleVertexShader: {
  87452. name: string;
  87453. shader: string;
  87454. };
  87455. }
  87456. declare module BABYLON {
  87457. export class SimpleMaterial extends BABYLON.PushMaterial {
  87458. private _diffuseTexture;
  87459. diffuseTexture: BABYLON.BaseTexture;
  87460. diffuseColor: BABYLON.Color3;
  87461. private _disableLighting;
  87462. disableLighting: boolean;
  87463. private _maxSimultaneousLights;
  87464. maxSimultaneousLights: number;
  87465. constructor(name: string, scene: BABYLON.Scene);
  87466. needAlphaBlending(): boolean;
  87467. needAlphaTesting(): boolean;
  87468. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87469. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87470. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87471. getAnimatables(): BABYLON.IAnimatable[];
  87472. getActiveTextures(): BABYLON.BaseTexture[];
  87473. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87474. dispose(forceDisposeEffect?: boolean): void;
  87475. clone(name: string): SimpleMaterial;
  87476. serialize(): any;
  87477. getClassName(): string;
  87478. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87479. }
  87480. }
  87481. declare module BABYLON {
  87482. /** @hidden */
  87483. export var skyPixelShader: {
  87484. name: string;
  87485. shader: string;
  87486. };
  87487. }
  87488. declare module BABYLON {
  87489. /** @hidden */
  87490. export var skyVertexShader: {
  87491. name: string;
  87492. shader: string;
  87493. };
  87494. }
  87495. declare module BABYLON {
  87496. /**
  87497. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87498. * @see https://doc.babylonjs.com/extensions/sky
  87499. */
  87500. export class SkyMaterial extends BABYLON.PushMaterial {
  87501. /**
  87502. * Defines the overall luminance of sky in interval ]0, 1[.
  87503. */
  87504. luminance: number;
  87505. /**
  87506. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87507. */
  87508. turbidity: number;
  87509. /**
  87510. * Defines the sky appearance (light intensity).
  87511. */
  87512. rayleigh: number;
  87513. /**
  87514. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87515. */
  87516. mieCoefficient: number;
  87517. /**
  87518. * Defines the amount of haze particles following the Mie scattering theory.
  87519. */
  87520. mieDirectionalG: number;
  87521. /**
  87522. * Defines the distance of the sun according to the active scene camera.
  87523. */
  87524. distance: number;
  87525. /**
  87526. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87527. * "inclined".
  87528. */
  87529. inclination: number;
  87530. /**
  87531. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87532. * an object direction and a reference direction.
  87533. */
  87534. azimuth: number;
  87535. /**
  87536. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87537. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87538. */
  87539. sunPosition: BABYLON.Vector3;
  87540. /**
  87541. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87542. * .sunPosition property.
  87543. */
  87544. useSunPosition: boolean;
  87545. /**
  87546. * Defines an offset vector used to get a horizon offset.
  87547. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87548. */
  87549. cameraOffset: BABYLON.Vector3;
  87550. private _cameraPosition;
  87551. /**
  87552. * Instantiates a new sky material.
  87553. * This material allows to create dynamic and texture free
  87554. * effects for skyboxes by taking care of the atmosphere state.
  87555. * @see https://doc.babylonjs.com/extensions/sky
  87556. * @param name Define the name of the material in the scene
  87557. * @param scene Define the scene the material belong to
  87558. */
  87559. constructor(name: string, scene: BABYLON.Scene);
  87560. /**
  87561. * Specifies if the material will require alpha blending
  87562. * @returns a boolean specifying if alpha blending is needed
  87563. */
  87564. needAlphaBlending(): boolean;
  87565. /**
  87566. * Specifies if this material should be rendered in alpha test mode
  87567. * @returns false as the sky material doesn't need alpha testing.
  87568. */
  87569. needAlphaTesting(): boolean;
  87570. /**
  87571. * Get the texture used for alpha test purpose.
  87572. * @returns null as the sky material has no texture.
  87573. */
  87574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87575. /**
  87576. * Get if the submesh is ready to be used and all its information available.
  87577. * Child classes can use it to update shaders
  87578. * @param mesh defines the mesh to check
  87579. * @param subMesh defines which submesh to check
  87580. * @param useInstances specifies that instances should be used
  87581. * @returns a boolean indicating that the submesh is ready or not
  87582. */
  87583. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87584. /**
  87585. * Binds the submesh to this material by preparing the effect and shader to draw
  87586. * @param world defines the world transformation matrix
  87587. * @param mesh defines the mesh containing the submesh
  87588. * @param subMesh defines the submesh to bind the material to
  87589. */
  87590. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87591. /**
  87592. * Get the list of animatables in the material.
  87593. * @returns the list of animatables object used in the material
  87594. */
  87595. getAnimatables(): BABYLON.IAnimatable[];
  87596. /**
  87597. * Disposes the material
  87598. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87599. */
  87600. dispose(forceDisposeEffect?: boolean): void;
  87601. /**
  87602. * Makes a duplicate of the material, and gives it a new name
  87603. * @param name defines the new name for the duplicated material
  87604. * @returns the cloned material
  87605. */
  87606. clone(name: string): SkyMaterial;
  87607. /**
  87608. * Serializes this material in a JSON representation
  87609. * @returns the serialized material object
  87610. */
  87611. serialize(): any;
  87612. /**
  87613. * Gets the current class name of the material e.g. "SkyMaterial"
  87614. * Mainly use in serialization.
  87615. * @returns the class name
  87616. */
  87617. getClassName(): string;
  87618. /**
  87619. * Creates a sky material from parsed material data
  87620. * @param source defines the JSON representation of the material
  87621. * @param scene defines the hosting scene
  87622. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87623. * @returns a new sky material
  87624. */
  87625. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87626. }
  87627. }
  87628. declare module BABYLON {
  87629. /** @hidden */
  87630. export var terrainPixelShader: {
  87631. name: string;
  87632. shader: string;
  87633. };
  87634. }
  87635. declare module BABYLON {
  87636. /** @hidden */
  87637. export var terrainVertexShader: {
  87638. name: string;
  87639. shader: string;
  87640. };
  87641. }
  87642. declare module BABYLON {
  87643. export class TerrainMaterial extends BABYLON.PushMaterial {
  87644. private _mixTexture;
  87645. mixTexture: BABYLON.BaseTexture;
  87646. private _diffuseTexture1;
  87647. diffuseTexture1: BABYLON.Texture;
  87648. private _diffuseTexture2;
  87649. diffuseTexture2: BABYLON.Texture;
  87650. private _diffuseTexture3;
  87651. diffuseTexture3: BABYLON.Texture;
  87652. private _bumpTexture1;
  87653. bumpTexture1: BABYLON.Texture;
  87654. private _bumpTexture2;
  87655. bumpTexture2: BABYLON.Texture;
  87656. private _bumpTexture3;
  87657. bumpTexture3: BABYLON.Texture;
  87658. diffuseColor: BABYLON.Color3;
  87659. specularColor: BABYLON.Color3;
  87660. specularPower: number;
  87661. private _disableLighting;
  87662. disableLighting: boolean;
  87663. private _maxSimultaneousLights;
  87664. maxSimultaneousLights: number;
  87665. constructor(name: string, scene: BABYLON.Scene);
  87666. needAlphaBlending(): boolean;
  87667. needAlphaTesting(): boolean;
  87668. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87669. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87670. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87671. getAnimatables(): BABYLON.IAnimatable[];
  87672. getActiveTextures(): BABYLON.BaseTexture[];
  87673. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87674. dispose(forceDisposeEffect?: boolean): void;
  87675. clone(name: string): TerrainMaterial;
  87676. serialize(): any;
  87677. getClassName(): string;
  87678. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87679. }
  87680. }
  87681. declare module BABYLON {
  87682. /** @hidden */
  87683. export var triplanarPixelShader: {
  87684. name: string;
  87685. shader: string;
  87686. };
  87687. }
  87688. declare module BABYLON {
  87689. /** @hidden */
  87690. export var triplanarVertexShader: {
  87691. name: string;
  87692. shader: string;
  87693. };
  87694. }
  87695. declare module BABYLON {
  87696. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87697. mixTexture: BABYLON.BaseTexture;
  87698. private _diffuseTextureX;
  87699. diffuseTextureX: BABYLON.BaseTexture;
  87700. private _diffuseTextureY;
  87701. diffuseTextureY: BABYLON.BaseTexture;
  87702. private _diffuseTextureZ;
  87703. diffuseTextureZ: BABYLON.BaseTexture;
  87704. private _normalTextureX;
  87705. normalTextureX: BABYLON.BaseTexture;
  87706. private _normalTextureY;
  87707. normalTextureY: BABYLON.BaseTexture;
  87708. private _normalTextureZ;
  87709. normalTextureZ: BABYLON.BaseTexture;
  87710. tileSize: number;
  87711. diffuseColor: BABYLON.Color3;
  87712. specularColor: BABYLON.Color3;
  87713. specularPower: number;
  87714. private _disableLighting;
  87715. disableLighting: boolean;
  87716. private _maxSimultaneousLights;
  87717. maxSimultaneousLights: number;
  87718. constructor(name: string, scene: BABYLON.Scene);
  87719. needAlphaBlending(): boolean;
  87720. needAlphaTesting(): boolean;
  87721. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87722. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87723. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87724. getAnimatables(): BABYLON.IAnimatable[];
  87725. getActiveTextures(): BABYLON.BaseTexture[];
  87726. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87727. dispose(forceDisposeEffect?: boolean): void;
  87728. clone(name: string): TriPlanarMaterial;
  87729. serialize(): any;
  87730. getClassName(): string;
  87731. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87732. }
  87733. }
  87734. declare module BABYLON {
  87735. /** @hidden */
  87736. export var waterPixelShader: {
  87737. name: string;
  87738. shader: string;
  87739. };
  87740. }
  87741. declare module BABYLON {
  87742. /** @hidden */
  87743. export var waterVertexShader: {
  87744. name: string;
  87745. shader: string;
  87746. };
  87747. }
  87748. declare module BABYLON {
  87749. export class WaterMaterial extends BABYLON.PushMaterial {
  87750. renderTargetSize: BABYLON.Vector2;
  87751. private _bumpTexture;
  87752. bumpTexture: BABYLON.BaseTexture;
  87753. diffuseColor: BABYLON.Color3;
  87754. specularColor: BABYLON.Color3;
  87755. specularPower: number;
  87756. private _disableLighting;
  87757. disableLighting: boolean;
  87758. private _maxSimultaneousLights;
  87759. maxSimultaneousLights: number;
  87760. /**
  87761. * Defines the wind force.
  87762. */
  87763. windForce: number;
  87764. /**
  87765. * Defines the direction of the wind in the plane (X, Z).
  87766. */
  87767. windDirection: BABYLON.Vector2;
  87768. /**
  87769. * Defines the height of the waves.
  87770. */
  87771. waveHeight: number;
  87772. /**
  87773. * Defines the bump height related to the bump map.
  87774. */
  87775. bumpHeight: number;
  87776. /**
  87777. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87778. */
  87779. private _bumpSuperimpose;
  87780. bumpSuperimpose: boolean;
  87781. /**
  87782. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87783. */
  87784. private _fresnelSeparate;
  87785. fresnelSeparate: boolean;
  87786. /**
  87787. * Defines wether or not bump Wwves modify the reflection.
  87788. */
  87789. private _bumpAffectsReflection;
  87790. bumpAffectsReflection: boolean;
  87791. /**
  87792. * Defines the water color blended with the refraction (near).
  87793. */
  87794. waterColor: BABYLON.Color3;
  87795. /**
  87796. * Defines the blend factor related to the water color.
  87797. */
  87798. colorBlendFactor: number;
  87799. /**
  87800. * Defines the water color blended with the reflection (far).
  87801. */
  87802. waterColor2: BABYLON.Color3;
  87803. /**
  87804. * Defines the blend factor related to the water color (reflection, far).
  87805. */
  87806. colorBlendFactor2: number;
  87807. /**
  87808. * Defines the maximum length of a wave.
  87809. */
  87810. waveLength: number;
  87811. /**
  87812. * Defines the waves speed.
  87813. */
  87814. waveSpeed: number;
  87815. /**
  87816. * 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.
  87817. */
  87818. waveCount: number;
  87819. /**
  87820. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87821. * will avoid calculating useless pixels in the pixel shader of the water material.
  87822. */
  87823. disableClipPlane: boolean;
  87824. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87825. private _mesh;
  87826. private _refractionRTT;
  87827. private _reflectionRTT;
  87828. private _reflectionTransform;
  87829. private _lastTime;
  87830. private _lastDeltaTime;
  87831. private _useLogarithmicDepth;
  87832. private _waitingRenderList;
  87833. private _imageProcessingConfiguration;
  87834. private _imageProcessingObserver;
  87835. /**
  87836. * Gets a boolean indicating that current material needs to register RTT
  87837. */
  87838. get hasRenderTargetTextures(): boolean;
  87839. /**
  87840. * Constructor
  87841. */
  87842. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87843. get useLogarithmicDepth(): boolean;
  87844. set useLogarithmicDepth(value: boolean);
  87845. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87846. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87847. addToRenderList(node: any): void;
  87848. enableRenderTargets(enable: boolean): void;
  87849. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87850. get renderTargetsEnabled(): boolean;
  87851. needAlphaBlending(): boolean;
  87852. needAlphaTesting(): boolean;
  87853. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87854. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87855. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87856. private _createRenderTargets;
  87857. getAnimatables(): BABYLON.IAnimatable[];
  87858. getActiveTextures(): BABYLON.BaseTexture[];
  87859. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87860. dispose(forceDisposeEffect?: boolean): void;
  87861. clone(name: string): WaterMaterial;
  87862. serialize(): any;
  87863. getClassName(): string;
  87864. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87865. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87866. }
  87867. }
  87868. declare module BABYLON {
  87869. /** @hidden */
  87870. export var asciiartPixelShader: {
  87871. name: string;
  87872. shader: string;
  87873. };
  87874. }
  87875. declare module BABYLON {
  87876. /**
  87877. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87878. *
  87879. * It basically takes care rendering the font front the given font size to a texture.
  87880. * This is used later on in the postprocess.
  87881. */
  87882. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87883. private _font;
  87884. private _text;
  87885. private _charSize;
  87886. /**
  87887. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87888. */
  87889. get charSize(): number;
  87890. /**
  87891. * Create a new instance of the Ascii Art FontTexture class
  87892. * @param name the name of the texture
  87893. * @param font the font to use, use the W3C CSS notation
  87894. * @param text the caracter set to use in the rendering.
  87895. * @param scene the scene that owns the texture
  87896. */
  87897. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87898. /**
  87899. * Gets the max char width of a font.
  87900. * @param font the font to use, use the W3C CSS notation
  87901. * @return the max char width
  87902. */
  87903. private getFontWidth;
  87904. /**
  87905. * Gets the max char height of a font.
  87906. * @param font the font to use, use the W3C CSS notation
  87907. * @return the max char height
  87908. */
  87909. private getFontHeight;
  87910. /**
  87911. * Clones the current AsciiArtTexture.
  87912. * @return the clone of the texture.
  87913. */
  87914. clone(): AsciiArtFontTexture;
  87915. /**
  87916. * Parses a json object representing the texture and returns an instance of it.
  87917. * @param source the source JSON representation
  87918. * @param scene the scene to create the texture for
  87919. * @return the parsed texture
  87920. */
  87921. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87922. }
  87923. /**
  87924. * Option available in the Ascii Art Post Process.
  87925. */
  87926. export interface IAsciiArtPostProcessOptions {
  87927. /**
  87928. * The font to use following the w3c font definition.
  87929. */
  87930. font?: string;
  87931. /**
  87932. * The character set to use in the postprocess.
  87933. */
  87934. characterSet?: string;
  87935. /**
  87936. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87937. * This number is defined between 0 and 1;
  87938. */
  87939. mixToTile?: number;
  87940. /**
  87941. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87942. * This number is defined between 0 and 1;
  87943. */
  87944. mixToNormal?: number;
  87945. }
  87946. /**
  87947. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87948. *
  87949. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87950. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87951. */
  87952. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87953. /**
  87954. * The font texture used to render the char in the post process.
  87955. */
  87956. private _asciiArtFontTexture;
  87957. /**
  87958. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87959. * This number is defined between 0 and 1;
  87960. */
  87961. mixToTile: number;
  87962. /**
  87963. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87964. * This number is defined between 0 and 1;
  87965. */
  87966. mixToNormal: number;
  87967. /**
  87968. * Instantiates a new Ascii Art Post Process.
  87969. * @param name the name to give to the postprocess
  87970. * @camera the camera to apply the post process to.
  87971. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87972. */
  87973. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87974. }
  87975. }
  87976. declare module BABYLON {
  87977. /** @hidden */
  87978. export var digitalrainPixelShader: {
  87979. name: string;
  87980. shader: string;
  87981. };
  87982. }
  87983. declare module BABYLON {
  87984. /**
  87985. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87986. *
  87987. * It basically takes care rendering the font front the given font size to a texture.
  87988. * This is used later on in the postprocess.
  87989. */
  87990. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87991. private _font;
  87992. private _text;
  87993. private _charSize;
  87994. /**
  87995. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87996. */
  87997. get charSize(): number;
  87998. /**
  87999. * Create a new instance of the Digital Rain FontTexture class
  88000. * @param name the name of the texture
  88001. * @param font the font to use, use the W3C CSS notation
  88002. * @param text the caracter set to use in the rendering.
  88003. * @param scene the scene that owns the texture
  88004. */
  88005. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88006. /**
  88007. * Gets the max char width of a font.
  88008. * @param font the font to use, use the W3C CSS notation
  88009. * @return the max char width
  88010. */
  88011. private getFontWidth;
  88012. /**
  88013. * Gets the max char height of a font.
  88014. * @param font the font to use, use the W3C CSS notation
  88015. * @return the max char height
  88016. */
  88017. private getFontHeight;
  88018. /**
  88019. * Clones the current DigitalRainFontTexture.
  88020. * @return the clone of the texture.
  88021. */
  88022. clone(): DigitalRainFontTexture;
  88023. /**
  88024. * Parses a json object representing the texture and returns an instance of it.
  88025. * @param source the source JSON representation
  88026. * @param scene the scene to create the texture for
  88027. * @return the parsed texture
  88028. */
  88029. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88030. }
  88031. /**
  88032. * Option available in the Digital Rain Post Process.
  88033. */
  88034. export interface IDigitalRainPostProcessOptions {
  88035. /**
  88036. * The font to use following the w3c font definition.
  88037. */
  88038. font?: string;
  88039. /**
  88040. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88041. * This number is defined between 0 and 1;
  88042. */
  88043. mixToTile?: number;
  88044. /**
  88045. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88046. * This number is defined between 0 and 1;
  88047. */
  88048. mixToNormal?: number;
  88049. }
  88050. /**
  88051. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88052. *
  88053. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88054. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88055. */
  88056. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88057. /**
  88058. * The font texture used to render the char in the post process.
  88059. */
  88060. private _digitalRainFontTexture;
  88061. /**
  88062. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88063. * This number is defined between 0 and 1;
  88064. */
  88065. mixToTile: number;
  88066. /**
  88067. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88068. * This number is defined between 0 and 1;
  88069. */
  88070. mixToNormal: number;
  88071. /**
  88072. * Instantiates a new Digital Rain Post Process.
  88073. * @param name the name to give to the postprocess
  88074. * @camera the camera to apply the post process to.
  88075. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88076. */
  88077. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88078. }
  88079. }
  88080. declare module BABYLON {
  88081. /** @hidden */
  88082. export var brickProceduralTexturePixelShader: {
  88083. name: string;
  88084. shader: string;
  88085. };
  88086. }
  88087. declare module BABYLON {
  88088. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88089. private _numberOfBricksHeight;
  88090. private _numberOfBricksWidth;
  88091. private _jointColor;
  88092. private _brickColor;
  88093. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88094. updateShaderUniforms(): void;
  88095. get numberOfBricksHeight(): number;
  88096. set numberOfBricksHeight(value: number);
  88097. get numberOfBricksWidth(): number;
  88098. set numberOfBricksWidth(value: number);
  88099. get jointColor(): BABYLON.Color3;
  88100. set jointColor(value: BABYLON.Color3);
  88101. get brickColor(): BABYLON.Color3;
  88102. set brickColor(value: BABYLON.Color3);
  88103. /**
  88104. * Serializes this brick procedural texture
  88105. * @returns a serialized brick procedural texture object
  88106. */
  88107. serialize(): any;
  88108. /**
  88109. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88110. * @param parsedTexture defines parsed texture data
  88111. * @param scene defines the current scene
  88112. * @param rootUrl defines the root URL containing brick procedural texture information
  88113. * @returns a parsed Brick Procedural BABYLON.Texture
  88114. */
  88115. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88116. }
  88117. }
  88118. declare module BABYLON {
  88119. /** @hidden */
  88120. export var cloudProceduralTexturePixelShader: {
  88121. name: string;
  88122. shader: string;
  88123. };
  88124. }
  88125. declare module BABYLON {
  88126. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88127. private _skyColor;
  88128. private _cloudColor;
  88129. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88130. updateShaderUniforms(): void;
  88131. get skyColor(): BABYLON.Color4;
  88132. set skyColor(value: BABYLON.Color4);
  88133. get cloudColor(): BABYLON.Color4;
  88134. set cloudColor(value: BABYLON.Color4);
  88135. /**
  88136. * Serializes this cloud procedural texture
  88137. * @returns a serialized cloud procedural texture object
  88138. */
  88139. serialize(): any;
  88140. /**
  88141. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88142. * @param parsedTexture defines parsed texture data
  88143. * @param scene defines the current scene
  88144. * @param rootUrl defines the root URL containing cloud procedural texture information
  88145. * @returns a parsed Cloud Procedural BABYLON.Texture
  88146. */
  88147. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88148. }
  88149. }
  88150. declare module BABYLON {
  88151. /** @hidden */
  88152. export var fireProceduralTexturePixelShader: {
  88153. name: string;
  88154. shader: string;
  88155. };
  88156. }
  88157. declare module BABYLON {
  88158. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88159. private _time;
  88160. private _speed;
  88161. private _autoGenerateTime;
  88162. private _fireColors;
  88163. private _alphaThreshold;
  88164. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88165. updateShaderUniforms(): void;
  88166. render(useCameraPostProcess?: boolean): void;
  88167. static get PurpleFireColors(): BABYLON.Color3[];
  88168. static get GreenFireColors(): BABYLON.Color3[];
  88169. static get RedFireColors(): BABYLON.Color3[];
  88170. static get BlueFireColors(): BABYLON.Color3[];
  88171. get autoGenerateTime(): boolean;
  88172. set autoGenerateTime(value: boolean);
  88173. get fireColors(): BABYLON.Color3[];
  88174. set fireColors(value: BABYLON.Color3[]);
  88175. get time(): number;
  88176. set time(value: number);
  88177. get speed(): BABYLON.Vector2;
  88178. set speed(value: BABYLON.Vector2);
  88179. get alphaThreshold(): number;
  88180. set alphaThreshold(value: number);
  88181. /**
  88182. * Serializes this fire procedural texture
  88183. * @returns a serialized fire procedural texture object
  88184. */
  88185. serialize(): any;
  88186. /**
  88187. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88188. * @param parsedTexture defines parsed texture data
  88189. * @param scene defines the current scene
  88190. * @param rootUrl defines the root URL containing fire procedural texture information
  88191. * @returns a parsed Fire Procedural BABYLON.Texture
  88192. */
  88193. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88194. }
  88195. }
  88196. declare module BABYLON {
  88197. /** @hidden */
  88198. export var grassProceduralTexturePixelShader: {
  88199. name: string;
  88200. shader: string;
  88201. };
  88202. }
  88203. declare module BABYLON {
  88204. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88205. private _grassColors;
  88206. private _groundColor;
  88207. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88208. updateShaderUniforms(): void;
  88209. get grassColors(): BABYLON.Color3[];
  88210. set grassColors(value: BABYLON.Color3[]);
  88211. get groundColor(): BABYLON.Color3;
  88212. set groundColor(value: BABYLON.Color3);
  88213. /**
  88214. * Serializes this grass procedural texture
  88215. * @returns a serialized grass procedural texture object
  88216. */
  88217. serialize(): any;
  88218. /**
  88219. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88220. * @param parsedTexture defines parsed texture data
  88221. * @param scene defines the current scene
  88222. * @param rootUrl defines the root URL containing grass procedural texture information
  88223. * @returns a parsed Grass Procedural BABYLON.Texture
  88224. */
  88225. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88226. }
  88227. }
  88228. declare module BABYLON {
  88229. /** @hidden */
  88230. export var marbleProceduralTexturePixelShader: {
  88231. name: string;
  88232. shader: string;
  88233. };
  88234. }
  88235. declare module BABYLON {
  88236. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88237. private _numberOfTilesHeight;
  88238. private _numberOfTilesWidth;
  88239. private _amplitude;
  88240. private _jointColor;
  88241. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88242. updateShaderUniforms(): void;
  88243. get numberOfTilesHeight(): number;
  88244. set numberOfTilesHeight(value: number);
  88245. get amplitude(): number;
  88246. set amplitude(value: number);
  88247. get numberOfTilesWidth(): number;
  88248. set numberOfTilesWidth(value: number);
  88249. get jointColor(): BABYLON.Color3;
  88250. set jointColor(value: BABYLON.Color3);
  88251. /**
  88252. * Serializes this marble procedural texture
  88253. * @returns a serialized marble procedural texture object
  88254. */
  88255. serialize(): any;
  88256. /**
  88257. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88258. * @param parsedTexture defines parsed texture data
  88259. * @param scene defines the current scene
  88260. * @param rootUrl defines the root URL containing marble procedural texture information
  88261. * @returns a parsed Marble Procedural BABYLON.Texture
  88262. */
  88263. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88264. }
  88265. }
  88266. declare module BABYLON {
  88267. /** @hidden */
  88268. export var normalMapProceduralTexturePixelShader: {
  88269. name: string;
  88270. shader: string;
  88271. };
  88272. }
  88273. declare module BABYLON {
  88274. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88275. private _baseTexture;
  88276. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88277. updateShaderUniforms(): void;
  88278. render(useCameraPostProcess?: boolean): void;
  88279. resize(size: any, generateMipMaps: any): void;
  88280. get baseTexture(): BABYLON.Texture;
  88281. set baseTexture(texture: BABYLON.Texture);
  88282. /**
  88283. * Serializes this normal map procedural texture
  88284. * @returns a serialized normal map procedural texture object
  88285. */
  88286. serialize(): any;
  88287. /**
  88288. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88289. * @param parsedTexture defines parsed texture data
  88290. * @param scene defines the current scene
  88291. * @param rootUrl defines the root URL containing normal map procedural texture information
  88292. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88293. */
  88294. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88295. }
  88296. }
  88297. declare module BABYLON {
  88298. /** @hidden */
  88299. export var perlinNoiseProceduralTexturePixelShader: {
  88300. name: string;
  88301. shader: string;
  88302. };
  88303. }
  88304. declare module BABYLON {
  88305. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88306. time: number;
  88307. timeScale: number;
  88308. translationSpeed: number;
  88309. private _currentTranslation;
  88310. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88311. updateShaderUniforms(): void;
  88312. render(useCameraPostProcess?: boolean): void;
  88313. resize(size: any, generateMipMaps: any): void;
  88314. /**
  88315. * Serializes this perlin noise procedural texture
  88316. * @returns a serialized perlin noise procedural texture object
  88317. */
  88318. serialize(): any;
  88319. /**
  88320. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88321. * @param parsedTexture defines parsed texture data
  88322. * @param scene defines the current scene
  88323. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88324. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88325. */
  88326. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88327. }
  88328. }
  88329. declare module BABYLON {
  88330. /** @hidden */
  88331. export var roadProceduralTexturePixelShader: {
  88332. name: string;
  88333. shader: string;
  88334. };
  88335. }
  88336. declare module BABYLON {
  88337. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88338. private _roadColor;
  88339. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88340. updateShaderUniforms(): void;
  88341. get roadColor(): BABYLON.Color3;
  88342. set roadColor(value: BABYLON.Color3);
  88343. /**
  88344. * Serializes this road procedural texture
  88345. * @returns a serialized road procedural texture object
  88346. */
  88347. serialize(): any;
  88348. /**
  88349. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88350. * @param parsedTexture defines parsed texture data
  88351. * @param scene defines the current scene
  88352. * @param rootUrl defines the root URL containing road procedural texture information
  88353. * @returns a parsed Road Procedural BABYLON.Texture
  88354. */
  88355. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88356. }
  88357. }
  88358. declare module BABYLON {
  88359. /** @hidden */
  88360. export var starfieldProceduralTexturePixelShader: {
  88361. name: string;
  88362. shader: string;
  88363. };
  88364. }
  88365. declare module BABYLON {
  88366. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88367. private _time;
  88368. private _alpha;
  88369. private _beta;
  88370. private _zoom;
  88371. private _formuparam;
  88372. private _stepsize;
  88373. private _tile;
  88374. private _brightness;
  88375. private _darkmatter;
  88376. private _distfading;
  88377. private _saturation;
  88378. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88379. updateShaderUniforms(): void;
  88380. get time(): number;
  88381. set time(value: number);
  88382. get alpha(): number;
  88383. set alpha(value: number);
  88384. get beta(): number;
  88385. set beta(value: number);
  88386. get formuparam(): number;
  88387. set formuparam(value: number);
  88388. get stepsize(): number;
  88389. set stepsize(value: number);
  88390. get zoom(): number;
  88391. set zoom(value: number);
  88392. get tile(): number;
  88393. set tile(value: number);
  88394. get brightness(): number;
  88395. set brightness(value: number);
  88396. get darkmatter(): number;
  88397. set darkmatter(value: number);
  88398. get distfading(): number;
  88399. set distfading(value: number);
  88400. get saturation(): number;
  88401. set saturation(value: number);
  88402. /**
  88403. * Serializes this starfield procedural texture
  88404. * @returns a serialized starfield procedural texture object
  88405. */
  88406. serialize(): any;
  88407. /**
  88408. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88409. * @param parsedTexture defines parsed texture data
  88410. * @param scene defines the current scene
  88411. * @param rootUrl defines the root URL containing startfield procedural texture information
  88412. * @returns a parsed Starfield Procedural BABYLON.Texture
  88413. */
  88414. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88415. }
  88416. }
  88417. declare module BABYLON {
  88418. /** @hidden */
  88419. export var woodProceduralTexturePixelShader: {
  88420. name: string;
  88421. shader: string;
  88422. };
  88423. }
  88424. declare module BABYLON {
  88425. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88426. private _ampScale;
  88427. private _woodColor;
  88428. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88429. updateShaderUniforms(): void;
  88430. get ampScale(): number;
  88431. set ampScale(value: number);
  88432. get woodColor(): BABYLON.Color3;
  88433. set woodColor(value: BABYLON.Color3);
  88434. /**
  88435. * Serializes this wood procedural texture
  88436. * @returns a serialized wood procedural texture object
  88437. */
  88438. serialize(): any;
  88439. /**
  88440. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88441. * @param parsedTexture defines parsed texture data
  88442. * @param scene defines the current scene
  88443. * @param rootUrl defines the root URL containing wood procedural texture information
  88444. * @returns a parsed Wood Procedural BABYLON.Texture
  88445. */
  88446. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88447. }
  88448. }