documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * 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.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. 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>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. 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;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. 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;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. 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;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /**
  2041. * Class representing a vector containing 2 coordinates
  2042. */
  2043. export class Vector2 {
  2044. /** defines the first coordinate */
  2045. x: number;
  2046. /** defines the second coordinate */
  2047. y: number;
  2048. /**
  2049. * Creates a new Vector2 from the given x and y coordinates
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. */
  2053. constructor(
  2054. /** defines the first coordinate */
  2055. x?: number,
  2056. /** defines the second coordinate */
  2057. y?: number);
  2058. /**
  2059. * Gets a string with the Vector2 coordinates
  2060. * @returns a string with the Vector2 coordinates
  2061. */
  2062. toString(): string;
  2063. /**
  2064. * Gets class name
  2065. * @returns the string "Vector2"
  2066. */
  2067. getClassName(): string;
  2068. /**
  2069. * Gets current vector hash code
  2070. * @returns the Vector2 hash code as a number
  2071. */
  2072. getHashCode(): number;
  2073. /**
  2074. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2075. * @param array defines the source array
  2076. * @param index defines the offset in source array
  2077. * @returns the current Vector2
  2078. */
  2079. toArray(array: FloatArray, index?: number): Vector2;
  2080. /**
  2081. * Copy the current vector to an array
  2082. * @returns a new array with 2 elements: the Vector2 coordinates.
  2083. */
  2084. asArray(): number[];
  2085. /**
  2086. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2087. * @param source defines the source Vector2
  2088. * @returns the current updated Vector2
  2089. */
  2090. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2091. /**
  2092. * Sets the Vector2 coordinates with the given floats
  2093. * @param x defines the first coordinate
  2094. * @param y defines the second coordinate
  2095. * @returns the current updated Vector2
  2096. */
  2097. copyFromFloats(x: number, y: number): Vector2;
  2098. /**
  2099. * Sets the Vector2 coordinates with the given floats
  2100. * @param x defines the first coordinate
  2101. * @param y defines the second coordinate
  2102. * @returns the current updated Vector2
  2103. */
  2104. set(x: number, y: number): Vector2;
  2105. /**
  2106. * Add another vector with the current one
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2109. */
  2110. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2
  2128. */
  2129. addVector3(otherVector: Vector3): Vector2;
  2130. /**
  2131. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. subtract(otherVector: Vector2): Vector2;
  2136. /**
  2137. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns the current updated Vector2
  2147. */
  2148. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Multiplies in place the current Vector2 coordinates by the given ones
  2151. * @param otherVector defines the other vector
  2152. * @returns the current updated Vector2
  2153. */
  2154. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2155. /**
  2156. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2157. * @param otherVector defines the other vector
  2158. * @returns a new Vector2
  2159. */
  2160. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2163. * @param otherVector defines the other vector
  2164. * @param result defines the target vector
  2165. * @returns the unmodified current Vector2
  2166. */
  2167. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2168. /**
  2169. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns a new Vector2
  2173. */
  2174. multiplyByFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. divide(otherVector: Vector2): Vector2;
  2181. /**
  2182. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Divides the current Vector2 coordinates by the given ones
  2190. * @param otherVector defines the other vector
  2191. * @returns the current updated Vector2
  2192. */
  2193. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2194. /**
  2195. * Gets a new Vector2 with current Vector2 negated coordinates
  2196. * @returns a new Vector2
  2197. */
  2198. negate(): Vector2;
  2199. /**
  2200. * Negate this vector in place
  2201. * @returns this
  2202. */
  2203. negateInPlace(): Vector2;
  2204. /**
  2205. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2206. * @param result defines the Vector3 object where to store the result
  2207. * @returns the current Vector2
  2208. */
  2209. negateToRef(result: Vector2): Vector2;
  2210. /**
  2211. * Multiply the Vector2 coordinates by scale
  2212. * @param scale defines the scaling factor
  2213. * @returns the current updated Vector2
  2214. */
  2215. scaleInPlace(scale: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2218. * @param scale defines the scaling factor
  2219. * @returns a new Vector2
  2220. */
  2221. scale(scale: number): Vector2;
  2222. /**
  2223. * Scale the current Vector2 values by a factor to a given Vector2
  2224. * @param scale defines the scale factor
  2225. * @param result defines the Vector2 object where to store the result
  2226. * @returns the unmodified current Vector2
  2227. */
  2228. scaleToRef(scale: number, result: Vector2): Vector2;
  2229. /**
  2230. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2231. * @param scale defines the scale factor
  2232. * @param result defines the Vector2 object where to store the result
  2233. * @returns the unmodified current Vector2
  2234. */
  2235. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2236. /**
  2237. * Gets a boolean if two vectors are equals
  2238. * @param otherVector defines the other vector
  2239. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2240. */
  2241. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets a boolean if two vectors are equals (using an epsilon value)
  2244. * @param otherVector defines the other vector
  2245. * @param epsilon defines the minimal distance to consider equality
  2246. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2247. */
  2248. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2249. /**
  2250. * Gets a new Vector2 from current Vector2 floored values
  2251. * @returns a new Vector2
  2252. */
  2253. floor(): Vector2;
  2254. /**
  2255. * Gets a new Vector2 from current Vector2 floored values
  2256. * @returns a new Vector2
  2257. */
  2258. fract(): Vector2;
  2259. /**
  2260. * Gets the length of the vector
  2261. * @returns the vector length (float)
  2262. */
  2263. length(): number;
  2264. /**
  2265. * Gets the vector squared length
  2266. * @returns the vector squared length (float)
  2267. */
  2268. lengthSquared(): number;
  2269. /**
  2270. * Normalize the vector
  2271. * @returns the current updated Vector2
  2272. */
  2273. normalize(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 copied from the Vector2
  2276. * @returns a new Vector2
  2277. */
  2278. clone(): Vector2;
  2279. /**
  2280. * Gets a new Vector2(0, 0)
  2281. * @returns a new Vector2
  2282. */
  2283. static Zero(): Vector2;
  2284. /**
  2285. * Gets a new Vector2(1, 1)
  2286. * @returns a new Vector2
  2287. */
  2288. static One(): Vector2;
  2289. /**
  2290. * Gets a new Vector2 set from the given index element of the given array
  2291. * @param array defines the data source
  2292. * @param offset defines the offset in the data source
  2293. * @returns a new Vector2
  2294. */
  2295. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2296. /**
  2297. * Sets "result" from the given index element of the given array
  2298. * @param array defines the data source
  2299. * @param offset defines the offset in the data source
  2300. * @param result defines the target vector
  2301. */
  2302. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2303. /**
  2304. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2305. * @param value1 defines 1st point of control
  2306. * @param value2 defines 2nd point of control
  2307. * @param value3 defines 3rd point of control
  2308. * @param value4 defines 4th point of control
  2309. * @param amount defines the interpolation factor
  2310. * @returns a new Vector2
  2311. */
  2312. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2313. /**
  2314. * 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".
  2315. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2316. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2317. * @param value defines the value to clamp
  2318. * @param min defines the lower limit
  2319. * @param max defines the upper limit
  2320. * @returns a new Vector2
  2321. */
  2322. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2323. /**
  2324. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2325. * @param value1 defines the 1st control point
  2326. * @param tangent1 defines the outgoing tangent
  2327. * @param value2 defines the 2nd control point
  2328. * @param tangent2 defines the incoming tangent
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2335. * @param start defines the start vector
  2336. * @param end defines the end vector
  2337. * @param amount defines the interpolation factor
  2338. * @returns a new Vector2
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2341. /**
  2342. * Gets the dot product of the vector "left" and the vector "right"
  2343. * @param left defines first vector
  2344. * @param right defines second vector
  2345. * @returns the dot product (float)
  2346. */
  2347. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2348. /**
  2349. * Returns a new Vector2 equal to the normalized given vector
  2350. * @param vector defines the vector to normalize
  2351. * @returns a new Vector2
  2352. */
  2353. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2354. /**
  2355. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2356. * @param left defines 1st vector
  2357. * @param right defines 2nd vector
  2358. * @returns a new Vector2
  2359. */
  2360. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2361. /**
  2362. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2363. * @param left defines 1st vector
  2364. * @param right defines 2nd vector
  2365. * @returns a new Vector2
  2366. */
  2367. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2368. /**
  2369. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2370. * @param vector defines the vector to transform
  2371. * @param transformation defines the matrix to apply
  2372. * @returns a new Vector2
  2373. */
  2374. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2375. /**
  2376. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2377. * @param vector defines the vector to transform
  2378. * @param transformation defines the matrix to apply
  2379. * @param result defines the target vector
  2380. */
  2381. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2382. /**
  2383. * Determines if a given vector is included in a triangle
  2384. * @param p defines the vector to test
  2385. * @param p0 defines 1st triangle point
  2386. * @param p1 defines 2nd triangle point
  2387. * @param p2 defines 3rd triangle point
  2388. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2389. */
  2390. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2391. /**
  2392. * Gets the distance between the vectors "value1" and "value2"
  2393. * @param value1 defines first vector
  2394. * @param value2 defines second vector
  2395. * @returns the distance between vectors
  2396. */
  2397. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2398. /**
  2399. * Returns the squared distance between the vectors "value1" and "value2"
  2400. * @param value1 defines first vector
  2401. * @param value2 defines second vector
  2402. * @returns the squared distance between vectors
  2403. */
  2404. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2405. /**
  2406. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2407. * @param value1 defines first vector
  2408. * @param value2 defines second vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2414. * @param p defines the middle point
  2415. * @param segA defines one point of the segment
  2416. * @param segB defines the other point of the segment
  2417. * @returns the shortest distance
  2418. */
  2419. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2420. }
  2421. /**
  2422. * Class used to store (x,y,z) vector representation
  2423. * A Vector3 is the main object used in 3D geometry
  2424. * It can represent etiher the coordinates of a point the space, either a direction
  2425. * Reminder: js uses a left handed forward facing system
  2426. */
  2427. export class Vector3 {
  2428. private static _UpReadOnly;
  2429. private static _ZeroReadOnly;
  2430. /** @hidden */
  2431. _x: number;
  2432. /** @hidden */
  2433. _y: number;
  2434. /** @hidden */
  2435. _z: number;
  2436. /** @hidden */
  2437. _isDirty: boolean;
  2438. /** Gets or sets the x coordinate */
  2439. get x(): number;
  2440. set x(value: number);
  2441. /** Gets or sets the y coordinate */
  2442. get y(): number;
  2443. set y(value: number);
  2444. /** Gets or sets the z coordinate */
  2445. get z(): number;
  2446. set z(value: number);
  2447. /**
  2448. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2449. * @param x defines the first coordinates (on X axis)
  2450. * @param y defines the second coordinates (on Y axis)
  2451. * @param z defines the third coordinates (on Z axis)
  2452. */
  2453. constructor(x?: number, y?: number, z?: number);
  2454. /**
  2455. * Creates a string representation of the Vector3
  2456. * @returns a string with the Vector3 coordinates.
  2457. */
  2458. toString(): string;
  2459. /**
  2460. * Gets the class name
  2461. * @returns the string "Vector3"
  2462. */
  2463. getClassName(): string;
  2464. /**
  2465. * Creates the Vector3 hash code
  2466. * @returns a number which tends to be unique between Vector3 instances
  2467. */
  2468. getHashCode(): number;
  2469. /**
  2470. * Creates an array containing three elements : the coordinates of the Vector3
  2471. * @returns a new array of numbers
  2472. */
  2473. asArray(): number[];
  2474. /**
  2475. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2476. * @param array defines the destination array
  2477. * @param index defines the offset in the destination array
  2478. * @returns the current Vector3
  2479. */
  2480. toArray(array: FloatArray, index?: number): Vector3;
  2481. /**
  2482. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2483. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2484. */
  2485. toQuaternion(): Quaternion;
  2486. /**
  2487. * Adds the given vector to the current Vector3
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Adds the given coordinates to the current Vector3
  2494. * @param x defines the x coordinate of the operand
  2495. * @param y defines the y coordinate of the operand
  2496. * @param z defines the z coordinate of the operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2500. /**
  2501. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2502. * @param otherVector defines the second operand
  2503. * @returns the resulting Vector3
  2504. */
  2505. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2508. * @param otherVector defines the second operand
  2509. * @param result defines the Vector3 object where to store the result
  2510. * @returns the current Vector3
  2511. */
  2512. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2513. /**
  2514. * Subtract the given vector from the current Vector3
  2515. * @param otherVector defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2521. * @param otherVector defines the second operand
  2522. * @returns the resulting Vector3
  2523. */
  2524. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2527. * @param otherVector defines the second operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2532. /**
  2533. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2534. * @param x defines the x coordinate of the operand
  2535. * @param y defines the y coordinate of the operand
  2536. * @param z defines the z coordinate of the operand
  2537. * @returns the resulting Vector3
  2538. */
  2539. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2540. /**
  2541. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2542. * @param x defines the x coordinate of the operand
  2543. * @param y defines the y coordinate of the operand
  2544. * @param z defines the z coordinate of the operand
  2545. * @param result defines the Vector3 object where to store the result
  2546. * @returns the current Vector3
  2547. */
  2548. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2549. /**
  2550. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2551. * @returns a new Vector3
  2552. */
  2553. negate(): Vector3;
  2554. /**
  2555. * Negate this vector in place
  2556. * @returns this
  2557. */
  2558. negateInPlace(): Vector3;
  2559. /**
  2560. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2561. * @param result defines the Vector3 object where to store the result
  2562. * @returns the current Vector3
  2563. */
  2564. negateToRef(result: Vector3): Vector3;
  2565. /**
  2566. * Multiplies the Vector3 coordinates by the float "scale"
  2567. * @param scale defines the multiplier factor
  2568. * @returns the current updated Vector3
  2569. */
  2570. scaleInPlace(scale: number): Vector3;
  2571. /**
  2572. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2573. * @param scale defines the multiplier factor
  2574. * @returns a new Vector3
  2575. */
  2576. scale(scale: number): Vector3;
  2577. /**
  2578. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2579. * @param scale defines the multiplier factor
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. scaleToRef(scale: number, result: Vector3): Vector3;
  2584. /**
  2585. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2586. * @param scale defines the scale factor
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the unmodified current Vector3
  2589. */
  2590. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2591. /**
  2592. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2593. * @param origin defines the origin of the projection ray
  2594. * @param plane defines the plane to project to
  2595. * @returns the projected vector3
  2596. */
  2597. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2598. /**
  2599. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2600. * @param origin defines the origin of the projection ray
  2601. * @param plane defines the plane to project to
  2602. * @param result defines the Vector3 where to store the result
  2603. */
  2604. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2605. /**
  2606. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2607. * @param otherVector defines the second operand
  2608. * @returns true if both vectors are equals
  2609. */
  2610. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2611. /**
  2612. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2613. * @param otherVector defines the second operand
  2614. * @param epsilon defines the minimal distance to define values as equals
  2615. * @returns true if both vectors are distant less than epsilon
  2616. */
  2617. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2618. /**
  2619. * Returns true if the current Vector3 coordinates equals the given floats
  2620. * @param x defines the x coordinate of the operand
  2621. * @param y defines the y coordinate of the operand
  2622. * @param z defines the z coordinate of the operand
  2623. * @returns true if both vectors are equals
  2624. */
  2625. equalsToFloats(x: number, y: number, z: number): boolean;
  2626. /**
  2627. * Multiplies the current Vector3 coordinates by the given ones
  2628. * @param otherVector defines the second operand
  2629. * @returns the current updated Vector3
  2630. */
  2631. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2632. /**
  2633. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2634. * @param otherVector defines the second operand
  2635. * @returns the new Vector3
  2636. */
  2637. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2640. * @param otherVector defines the second operand
  2641. * @param result defines the Vector3 object where to store the result
  2642. * @returns the current Vector3
  2643. */
  2644. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2645. /**
  2646. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the new Vector3
  2651. */
  2652. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2655. * @param otherVector defines the second operand
  2656. * @returns the new Vector3
  2657. */
  2658. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2659. /**
  2660. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2661. * @param otherVector defines the second operand
  2662. * @param result defines the Vector3 object where to store the result
  2663. * @returns the current Vector3
  2664. */
  2665. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2666. /**
  2667. * Divides the current Vector3 coordinates by the given ones.
  2668. * @param otherVector defines the second operand
  2669. * @returns the current updated Vector3
  2670. */
  2671. divideInPlace(otherVector: Vector3): Vector3;
  2672. /**
  2673. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2674. * @param other defines the second operand
  2675. * @returns the current updated Vector3
  2676. */
  2677. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2680. * @param other defines the second operand
  2681. * @returns the current updated Vector3
  2682. */
  2683. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2684. /**
  2685. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2686. * @param x defines the x coordinate of the operand
  2687. * @param y defines the y coordinate of the operand
  2688. * @param z defines the z coordinate of the operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2694. * @param x defines the x coordinate of the operand
  2695. * @param y defines the y coordinate of the operand
  2696. * @param z defines the z coordinate of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2700. /**
  2701. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2702. * Check if is non uniform within a certain amount of decimal places to account for this
  2703. * @param epsilon the amount the values can differ
  2704. * @returns if the the vector is non uniform to a certain number of decimal places
  2705. */
  2706. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2707. /**
  2708. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2709. */
  2710. get isNonUniform(): boolean;
  2711. /**
  2712. * Gets a new Vector3 from current Vector3 floored values
  2713. * @returns a new Vector3
  2714. */
  2715. floor(): Vector3;
  2716. /**
  2717. * Gets a new Vector3 from current Vector3 floored values
  2718. * @returns a new Vector3
  2719. */
  2720. fract(): Vector3;
  2721. /**
  2722. * Gets the length of the Vector3
  2723. * @returns the length of the Vector3
  2724. */
  2725. length(): number;
  2726. /**
  2727. * Gets the squared length of the Vector3
  2728. * @returns squared length of the Vector3
  2729. */
  2730. lengthSquared(): number;
  2731. /**
  2732. * Normalize the current Vector3.
  2733. * Please note that this is an in place operation.
  2734. * @returns the current updated Vector3
  2735. */
  2736. normalize(): Vector3;
  2737. /**
  2738. * Reorders the x y z properties of the vector in place
  2739. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2740. * @returns the current updated vector
  2741. */
  2742. reorderInPlace(order: string): this;
  2743. /**
  2744. * Rotates the vector around 0,0,0 by a quaternion
  2745. * @param quaternion the rotation quaternion
  2746. * @param result vector to store the result
  2747. * @returns the resulting vector
  2748. */
  2749. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2750. /**
  2751. * Rotates a vector around a given point
  2752. * @param quaternion the rotation quaternion
  2753. * @param point the point to rotate around
  2754. * @param result vector to store the result
  2755. * @returns the resulting vector
  2756. */
  2757. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2758. /**
  2759. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2760. * The cross product is then orthogonal to both current and "other"
  2761. * @param other defines the right operand
  2762. * @returns the cross product
  2763. */
  2764. cross(other: Vector3): Vector3;
  2765. /**
  2766. * Normalize the current Vector3 with the given input length.
  2767. * Please note that this is an in place operation.
  2768. * @param len the length of the vector
  2769. * @returns the current updated Vector3
  2770. */
  2771. normalizeFromLength(len: number): Vector3;
  2772. /**
  2773. * Normalize the current Vector3 to a new vector
  2774. * @returns the new Vector3
  2775. */
  2776. normalizeToNew(): Vector3;
  2777. /**
  2778. * Normalize the current Vector3 to the reference
  2779. * @param reference define the Vector3 to update
  2780. * @returns the updated Vector3
  2781. */
  2782. normalizeToRef(reference: Vector3): Vector3;
  2783. /**
  2784. * Creates a new Vector3 copied from the current Vector3
  2785. * @returns the new Vector3
  2786. */
  2787. clone(): Vector3;
  2788. /**
  2789. * Copies the given vector coordinates to the current Vector3 ones
  2790. * @param source defines the source Vector3
  2791. * @returns the current updated Vector3
  2792. */
  2793. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2794. /**
  2795. * Copies the given floats to the current Vector3 coordinates
  2796. * @param x defines the x coordinate of the operand
  2797. * @param y defines the y coordinate of the operand
  2798. * @param z defines the z coordinate of the operand
  2799. * @returns the current updated Vector3
  2800. */
  2801. copyFromFloats(x: number, y: number, z: number): Vector3;
  2802. /**
  2803. * Copies the given floats to the current Vector3 coordinates
  2804. * @param x defines the x coordinate of the operand
  2805. * @param y defines the y coordinate of the operand
  2806. * @param z defines the z coordinate of the operand
  2807. * @returns the current updated Vector3
  2808. */
  2809. set(x: number, y: number, z: number): Vector3;
  2810. /**
  2811. * Copies the given float to the current Vector3 coordinates
  2812. * @param v defines the x, y and z coordinates of the operand
  2813. * @returns the current updated Vector3
  2814. */
  2815. setAll(v: number): Vector3;
  2816. /**
  2817. * Get the clip factor between two vectors
  2818. * @param vector0 defines the first operand
  2819. * @param vector1 defines the second operand
  2820. * @param axis defines the axis to use
  2821. * @param size defines the size along the axis
  2822. * @returns the clip factor
  2823. */
  2824. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2825. /**
  2826. * Get angle between two vectors
  2827. * @param vector0 angle between vector0 and vector1
  2828. * @param vector1 angle between vector0 and vector1
  2829. * @param normal direction of the normal
  2830. * @return the angle between vector0 and vector1
  2831. */
  2832. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2833. /**
  2834. * Returns a new Vector3 set from the index "offset" of the given array
  2835. * @param array defines the source array
  2836. * @param offset defines the offset in the source array
  2837. * @returns the new Vector3
  2838. */
  2839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2840. /**
  2841. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2842. * @param array defines the source array
  2843. * @param offset defines the offset in the source array
  2844. * @returns the new Vector3
  2845. * @deprecated Please use FromArray instead.
  2846. */
  2847. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2848. /**
  2849. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2850. * @param array defines the source array
  2851. * @param offset defines the offset in the source array
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2855. /**
  2856. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2857. * @param array defines the source array
  2858. * @param offset defines the offset in the source array
  2859. * @param result defines the Vector3 where to store the result
  2860. * @deprecated Please use FromArrayToRef instead.
  2861. */
  2862. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2863. /**
  2864. * Sets the given vector "result" with the given floats.
  2865. * @param x defines the x coordinate of the source
  2866. * @param y defines the y coordinate of the source
  2867. * @param z defines the z coordinate of the source
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2873. * @returns a new empty Vector3
  2874. */
  2875. static Zero(): Vector3;
  2876. /**
  2877. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2878. * @returns a new unit Vector3
  2879. */
  2880. static One(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2883. * @returns a new up Vector3
  2884. */
  2885. static Up(): Vector3;
  2886. /**
  2887. * Gets a up Vector3 that must not be updated
  2888. */
  2889. static get UpReadOnly(): DeepImmutable<Vector3>;
  2890. /**
  2891. * Gets a zero Vector3 that must not be updated
  2892. */
  2893. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2894. /**
  2895. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2896. * @returns a new down Vector3
  2897. */
  2898. static Down(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2901. * @param rightHandedSystem is the scene right-handed (negative z)
  2902. * @returns a new forward Vector3
  2903. */
  2904. static Forward(rightHandedSystem?: boolean): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2907. * @param rightHandedSystem is the scene right-handed (negative-z)
  2908. * @returns a new forward Vector3
  2909. */
  2910. static Backward(rightHandedSystem?: boolean): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2913. * @returns a new right Vector3
  2914. */
  2915. static Right(): Vector3;
  2916. /**
  2917. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2918. * @returns a new left Vector3
  2919. */
  2920. static Left(): Vector3;
  2921. /**
  2922. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2923. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2924. * @param vector defines the Vector3 to transform
  2925. * @param transformation defines the transformation matrix
  2926. * @returns the transformed Vector3
  2927. */
  2928. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2931. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2939. * This method computes tranformed coordinates only, not transformed direction vectors
  2940. * @param x define the x coordinate of the source vector
  2941. * @param y define the y coordinate of the source vector
  2942. * @param z define the z coordinate of the source vector
  2943. * @param transformation defines the transformation matrix
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2949. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the new Vector3
  2953. */
  2954. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2957. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2965. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2975. * @param value1 defines the first control point
  2976. * @param value2 defines the second control point
  2977. * @param value3 defines the third control point
  2978. * @param value4 defines the fourth control point
  2979. * @param amount defines the amount on the spline to use
  2980. * @returns the new Vector3
  2981. */
  2982. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @returns the new Vector3
  2991. */
  2992. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2993. /**
  2994. * 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"
  2995. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2996. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2997. * @param value defines the current value
  2998. * @param min defines the lower range value
  2999. * @param max defines the upper range value
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3003. /**
  3004. * Checks if a given vector is inside a specific range
  3005. * @param v defines the vector to test
  3006. * @param min defines the minimum range
  3007. * @param max defines the maximum range
  3008. */
  3009. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3012. * @param value1 defines the first control point
  3013. * @param tangent1 defines the first tangent vector
  3014. * @param value2 defines the second control point
  3015. * @param tangent2 defines the second tangent vector
  3016. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3017. * @returns the new Vector3
  3018. */
  3019. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3020. /**
  3021. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3022. * @param start defines the start value
  3023. * @param end defines the end value
  3024. * @param amount max defines amount between both (between 0 and 1)
  3025. * @returns the new Vector3
  3026. */
  3027. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3028. /**
  3029. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3030. * @param start defines the start value
  3031. * @param end defines the end value
  3032. * @param amount max defines amount between both (between 0 and 1)
  3033. * @param result defines the Vector3 where to store the result
  3034. */
  3035. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3036. /**
  3037. * Returns the dot product (float) between the vectors "left" and "right"
  3038. * @param left defines the left operand
  3039. * @param right defines the right operand
  3040. * @returns the dot product
  3041. */
  3042. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3043. /**
  3044. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3045. * The cross product is then orthogonal to both "left" and "right"
  3046. * @param left defines the left operand
  3047. * @param right defines the right operand
  3048. * @returns the cross product
  3049. */
  3050. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Sets the given vector "result" with the cross product of "left" and "right"
  3053. * The cross product is then orthogonal to both "left" and "right"
  3054. * @param left defines the left operand
  3055. * @param right defines the right operand
  3056. * @param result defines the Vector3 where to store the result
  3057. */
  3058. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3059. /**
  3060. * Returns a new Vector3 as the normalization of the given vector
  3061. * @param vector defines the Vector3 to normalize
  3062. * @returns the new Vector3
  3063. */
  3064. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3065. /**
  3066. * Sets the given vector "result" with the normalization of the given first vector
  3067. * @param vector defines the Vector3 to normalize
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3071. /**
  3072. * Project a Vector3 onto screen space
  3073. * @param vector defines the Vector3 to project
  3074. * @param world defines the world matrix to use
  3075. * @param transform defines the transform (view x projection) matrix to use
  3076. * @param viewport defines the screen viewport to use
  3077. * @returns the new Vector3
  3078. */
  3079. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3080. /** @hidden */
  3081. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param transform defines the transform (view x projection) matrix to use
  3089. * @returns the new Vector3
  3090. */
  3091. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3092. /**
  3093. * Unproject from screen space to object space
  3094. * @param source defines the screen space Vector3 to use
  3095. * @param viewportWidth defines the current width of the viewport
  3096. * @param viewportHeight defines the current height of the viewport
  3097. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3098. * @param view defines the view matrix to use
  3099. * @param projection defines the projection matrix to use
  3100. * @returns the new Vector3
  3101. */
  3102. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3103. /**
  3104. * Unproject from screen space to object space
  3105. * @param source defines the screen space Vector3 to use
  3106. * @param viewportWidth defines the current width of the viewport
  3107. * @param viewportHeight defines the current height of the viewport
  3108. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3109. * @param view defines the view matrix to use
  3110. * @param projection defines the projection matrix to use
  3111. * @param result defines the Vector3 where to store the result
  3112. */
  3113. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3114. /**
  3115. * Unproject from screen space to object space
  3116. * @param sourceX defines the screen space x coordinate to use
  3117. * @param sourceY defines the screen space y coordinate to use
  3118. * @param sourceZ defines the screen space z coordinate to use
  3119. * @param viewportWidth defines the current width of the viewport
  3120. * @param viewportHeight defines the current height of the viewport
  3121. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3122. * @param view defines the view matrix to use
  3123. * @param projection defines the projection matrix to use
  3124. * @param result defines the Vector3 where to store the result
  3125. */
  3126. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3127. /**
  3128. * Gets the minimal coordinate values between two Vector3
  3129. * @param left defines the first operand
  3130. * @param right defines the second operand
  3131. * @returns the new Vector3
  3132. */
  3133. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3134. /**
  3135. * Gets the maximal coordinate values between two Vector3
  3136. * @param left defines the first operand
  3137. * @param right defines the second operand
  3138. * @returns the new Vector3
  3139. */
  3140. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3141. /**
  3142. * Returns the distance between the vectors "value1" and "value2"
  3143. * @param value1 defines the first operand
  3144. * @param value2 defines the second operand
  3145. * @returns the distance
  3146. */
  3147. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3148. /**
  3149. * Returns the squared distance between the vectors "value1" and "value2"
  3150. * @param value1 defines the first operand
  3151. * @param value2 defines the second operand
  3152. * @returns the squared distance
  3153. */
  3154. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3155. /**
  3156. * Returns a new Vector3 located at the center between "value1" and "value2"
  3157. * @param value1 defines the first operand
  3158. * @param value2 defines the second operand
  3159. * @returns the new Vector3
  3160. */
  3161. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3162. /**
  3163. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3164. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3165. * to something in order to rotate it from its local system to the given target system
  3166. * Note: axis1, axis2 and axis3 are normalized during this operation
  3167. * @param axis1 defines the first axis
  3168. * @param axis2 defines the second axis
  3169. * @param axis3 defines the third axis
  3170. * @returns a new Vector3
  3171. */
  3172. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3173. /**
  3174. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3175. * @param axis1 defines the first axis
  3176. * @param axis2 defines the second axis
  3177. * @param axis3 defines the third axis
  3178. * @param ref defines the Vector3 where to store the result
  3179. */
  3180. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3181. }
  3182. /**
  3183. * Vector4 class created for EulerAngle class conversion to Quaternion
  3184. */
  3185. export class Vector4 {
  3186. /** x value of the vector */
  3187. x: number;
  3188. /** y value of the vector */
  3189. y: number;
  3190. /** z value of the vector */
  3191. z: number;
  3192. /** w value of the vector */
  3193. w: number;
  3194. /**
  3195. * Creates a Vector4 object from the given floats.
  3196. * @param x x value of the vector
  3197. * @param y y value of the vector
  3198. * @param z z value of the vector
  3199. * @param w w value of the vector
  3200. */
  3201. constructor(
  3202. /** x value of the vector */
  3203. x: number,
  3204. /** y value of the vector */
  3205. y: number,
  3206. /** z value of the vector */
  3207. z: number,
  3208. /** w value of the vector */
  3209. w: number);
  3210. /**
  3211. * Returns the string with the Vector4 coordinates.
  3212. * @returns a string containing all the vector values
  3213. */
  3214. toString(): string;
  3215. /**
  3216. * Returns the string "Vector4".
  3217. * @returns "Vector4"
  3218. */
  3219. getClassName(): string;
  3220. /**
  3221. * Returns the Vector4 hash code.
  3222. * @returns a unique hash code
  3223. */
  3224. getHashCode(): number;
  3225. /**
  3226. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3227. * @returns the resulting array
  3228. */
  3229. asArray(): number[];
  3230. /**
  3231. * Populates the given array from the given index with the Vector4 coordinates.
  3232. * @param array array to populate
  3233. * @param index index of the array to start at (default: 0)
  3234. * @returns the Vector4.
  3235. */
  3236. toArray(array: FloatArray, index?: number): Vector4;
  3237. /**
  3238. * Adds the given vector to the current Vector4.
  3239. * @param otherVector the vector to add
  3240. * @returns the updated Vector4.
  3241. */
  3242. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3243. /**
  3244. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3245. * @param otherVector the vector to add
  3246. * @returns the resulting vector
  3247. */
  3248. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3249. /**
  3250. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3251. * @param otherVector the vector to add
  3252. * @param result the vector to store the result
  3253. * @returns the current Vector4.
  3254. */
  3255. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3256. /**
  3257. * Subtract in place the given vector from the current Vector4.
  3258. * @param otherVector the vector to subtract
  3259. * @returns the updated Vector4.
  3260. */
  3261. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3264. * @param otherVector the vector to add
  3265. * @returns the new vector with the result
  3266. */
  3267. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3270. * @param otherVector the vector to subtract
  3271. * @param result the vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3277. */
  3278. /**
  3279. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3280. * @param x value to subtract
  3281. * @param y value to subtract
  3282. * @param z value to subtract
  3283. * @param w value to subtract
  3284. * @returns new vector containing the result
  3285. */
  3286. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3287. /**
  3288. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3289. * @param x value to subtract
  3290. * @param y value to subtract
  3291. * @param z value to subtract
  3292. * @param w value to subtract
  3293. * @param result the vector to store the result in
  3294. * @returns the current Vector4.
  3295. */
  3296. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3297. /**
  3298. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3299. * @returns a new vector with the negated values
  3300. */
  3301. negate(): Vector4;
  3302. /**
  3303. * Negate this vector in place
  3304. * @returns this
  3305. */
  3306. negateInPlace(): Vector4;
  3307. /**
  3308. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3309. * @param result defines the Vector3 object where to store the result
  3310. * @returns the current Vector4
  3311. */
  3312. negateToRef(result: Vector4): Vector4;
  3313. /**
  3314. * Multiplies the current Vector4 coordinates by scale (float).
  3315. * @param scale the number to scale with
  3316. * @returns the updated Vector4.
  3317. */
  3318. scaleInPlace(scale: number): Vector4;
  3319. /**
  3320. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3321. * @param scale the number to scale with
  3322. * @returns a new vector with the result
  3323. */
  3324. scale(scale: number): Vector4;
  3325. /**
  3326. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3327. * @param scale the number to scale with
  3328. * @param result a vector to store the result in
  3329. * @returns the current Vector4.
  3330. */
  3331. scaleToRef(scale: number, result: Vector4): Vector4;
  3332. /**
  3333. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3334. * @param scale defines the scale factor
  3335. * @param result defines the Vector4 object where to store the result
  3336. * @returns the unmodified current Vector4
  3337. */
  3338. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3339. /**
  3340. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3341. * @param otherVector the vector to compare against
  3342. * @returns true if they are equal
  3343. */
  3344. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3345. /**
  3346. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3347. * @param otherVector vector to compare against
  3348. * @param epsilon (Default: very small number)
  3349. * @returns true if they are equal
  3350. */
  3351. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3352. /**
  3353. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3354. * @param x x value to compare against
  3355. * @param y y value to compare against
  3356. * @param z z value to compare against
  3357. * @param w w value to compare against
  3358. * @returns true if equal
  3359. */
  3360. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3361. /**
  3362. * Multiplies in place the current Vector4 by the given one.
  3363. * @param otherVector vector to multiple with
  3364. * @returns the updated Vector4.
  3365. */
  3366. multiplyInPlace(otherVector: Vector4): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3369. * @param otherVector vector to multiple with
  3370. * @returns resulting new vector
  3371. */
  3372. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3375. * @param otherVector vector to multiple with
  3376. * @param result vector to store the result
  3377. * @returns the current Vector4.
  3378. */
  3379. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3380. /**
  3381. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3382. * @param x x value multiply with
  3383. * @param y y value multiply with
  3384. * @param z z value multiply with
  3385. * @param w w value multiply with
  3386. * @returns resulting new vector
  3387. */
  3388. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3389. /**
  3390. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3391. * @param otherVector vector to devide with
  3392. * @returns resulting new vector
  3393. */
  3394. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3395. /**
  3396. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3397. * @param otherVector vector to devide with
  3398. * @param result vector to store the result
  3399. * @returns the current Vector4.
  3400. */
  3401. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3402. /**
  3403. * Divides the current Vector3 coordinates by the given ones.
  3404. * @param otherVector vector to devide with
  3405. * @returns the updated Vector3.
  3406. */
  3407. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3408. /**
  3409. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3410. * @param other defines the second operand
  3411. * @returns the current updated Vector4
  3412. */
  3413. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3416. * @param other defines the second operand
  3417. * @returns the current updated Vector4
  3418. */
  3419. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Gets a new Vector4 from current Vector4 floored values
  3422. * @returns a new Vector4
  3423. */
  3424. floor(): Vector4;
  3425. /**
  3426. * Gets a new Vector4 from current Vector3 floored values
  3427. * @returns a new Vector4
  3428. */
  3429. fract(): Vector4;
  3430. /**
  3431. * Returns the Vector4 length (float).
  3432. * @returns the length
  3433. */
  3434. length(): number;
  3435. /**
  3436. * Returns the Vector4 squared length (float).
  3437. * @returns the length squared
  3438. */
  3439. lengthSquared(): number;
  3440. /**
  3441. * Normalizes in place the Vector4.
  3442. * @returns the updated Vector4.
  3443. */
  3444. normalize(): Vector4;
  3445. /**
  3446. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3447. * @returns this converted to a new vector3
  3448. */
  3449. toVector3(): Vector3;
  3450. /**
  3451. * Returns a new Vector4 copied from the current one.
  3452. * @returns the new cloned vector
  3453. */
  3454. clone(): Vector4;
  3455. /**
  3456. * Updates the current Vector4 with the given one coordinates.
  3457. * @param source the source vector to copy from
  3458. * @returns the updated Vector4.
  3459. */
  3460. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Updates the current Vector4 coordinates with the given floats.
  3463. * @param x float to copy from
  3464. * @param y float to copy from
  3465. * @param z float to copy from
  3466. * @param w float to copy from
  3467. * @returns the updated Vector4.
  3468. */
  3469. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3470. /**
  3471. * Updates the current Vector4 coordinates with the given floats.
  3472. * @param x float to set from
  3473. * @param y float to set from
  3474. * @param z float to set from
  3475. * @param w float to set from
  3476. * @returns the updated Vector4.
  3477. */
  3478. set(x: number, y: number, z: number, w: number): Vector4;
  3479. /**
  3480. * Copies the given float to the current Vector3 coordinates
  3481. * @param v defines the x, y, z and w coordinates of the operand
  3482. * @returns the current updated Vector3
  3483. */
  3484. setAll(v: number): Vector4;
  3485. /**
  3486. * Returns a new Vector4 set from the starting index of the given array.
  3487. * @param array the array to pull values from
  3488. * @param offset the offset into the array to start at
  3489. * @returns the new vector
  3490. */
  3491. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3492. /**
  3493. * Updates the given vector "result" from the starting index of the given array.
  3494. * @param array the array to pull values from
  3495. * @param offset the offset into the array to start at
  3496. * @param result the vector to store the result in
  3497. */
  3498. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3499. /**
  3500. * Updates the given vector "result" from the starting index of the given Float32Array.
  3501. * @param array the array to pull values from
  3502. * @param offset the offset into the array to start at
  3503. * @param result the vector to store the result in
  3504. */
  3505. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3506. /**
  3507. * Updates the given vector "result" coordinates from the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @param result the vector to the floats in
  3513. */
  3514. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3515. /**
  3516. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3517. * @returns the new vector
  3518. */
  3519. static Zero(): Vector4;
  3520. /**
  3521. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3522. * @returns the new vector
  3523. */
  3524. static One(): Vector4;
  3525. /**
  3526. * Returns a new normalized Vector4 from the given one.
  3527. * @param vector the vector to normalize
  3528. * @returns the vector
  3529. */
  3530. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3531. /**
  3532. * Updates the given vector "result" from the normalization of the given one.
  3533. * @param vector the vector to normalize
  3534. * @param result the vector to store the result in
  3535. */
  3536. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3537. /**
  3538. * Returns a vector with the minimum values from the left and right vectors
  3539. * @param left left vector to minimize
  3540. * @param right right vector to minimize
  3541. * @returns a new vector with the minimum of the left and right vector values
  3542. */
  3543. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3544. /**
  3545. * Returns a vector with the maximum values from the left and right vectors
  3546. * @param left left vector to maximize
  3547. * @param right right vector to maximize
  3548. * @returns a new vector with the maximum of the left and right vector values
  3549. */
  3550. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Returns the distance (float) between the vectors "value1" and "value2".
  3553. * @param value1 value to calulate the distance between
  3554. * @param value2 value to calulate the distance between
  3555. * @return the distance between the two vectors
  3556. */
  3557. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3558. /**
  3559. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3560. * @param value1 value to calulate the distance between
  3561. * @param value2 value to calulate the distance between
  3562. * @return the distance between the two vectors squared
  3563. */
  3564. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3565. /**
  3566. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3567. * @param value1 value to calulate the center between
  3568. * @param value2 value to calulate the center between
  3569. * @return the center between the two vectors
  3570. */
  3571. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3572. /**
  3573. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3574. * This methods computes transformed normalized direction vectors only.
  3575. * @param vector the vector to transform
  3576. * @param transformation the transformation matrix to apply
  3577. * @returns the new vector
  3578. */
  3579. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3580. /**
  3581. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3582. * This methods computes transformed normalized direction vectors only.
  3583. * @param vector the vector to transform
  3584. * @param transformation the transformation matrix to apply
  3585. * @param result the vector to store the result in
  3586. */
  3587. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3588. /**
  3589. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3590. * This methods computes transformed normalized direction vectors only.
  3591. * @param x value to transform
  3592. * @param y value to transform
  3593. * @param z value to transform
  3594. * @param w value to transform
  3595. * @param transformation the transformation matrix to apply
  3596. * @param result the vector to store the results in
  3597. */
  3598. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3599. /**
  3600. * Creates a new Vector4 from a Vector3
  3601. * @param source defines the source data
  3602. * @param w defines the 4th component (default is 0)
  3603. * @returns a new Vector4
  3604. */
  3605. static FromVector3(source: Vector3, w?: number): Vector4;
  3606. }
  3607. /**
  3608. * Class used to store quaternion data
  3609. * @see https://en.wikipedia.org/wiki/Quaternion
  3610. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3611. */
  3612. export class Quaternion {
  3613. /** @hidden */
  3614. _x: number;
  3615. /** @hidden */
  3616. _y: number;
  3617. /** @hidden */
  3618. _z: number;
  3619. /** @hidden */
  3620. _w: number;
  3621. /** @hidden */
  3622. _isDirty: boolean;
  3623. /** Gets or sets the x coordinate */
  3624. get x(): number;
  3625. set x(value: number);
  3626. /** Gets or sets the y coordinate */
  3627. get y(): number;
  3628. set y(value: number);
  3629. /** Gets or sets the z coordinate */
  3630. get z(): number;
  3631. set z(value: number);
  3632. /** Gets or sets the w coordinate */
  3633. get w(): number;
  3634. set w(value: number);
  3635. /**
  3636. * Creates a new Quaternion from the given floats
  3637. * @param x defines the first component (0 by default)
  3638. * @param y defines the second component (0 by default)
  3639. * @param z defines the third component (0 by default)
  3640. * @param w defines the fourth component (1.0 by default)
  3641. */
  3642. constructor(x?: number, y?: number, z?: number, w?: number);
  3643. /**
  3644. * Gets a string representation for the current quaternion
  3645. * @returns a string with the Quaternion coordinates
  3646. */
  3647. toString(): string;
  3648. /**
  3649. * Gets the class name of the quaternion
  3650. * @returns the string "Quaternion"
  3651. */
  3652. getClassName(): string;
  3653. /**
  3654. * Gets a hash code for this quaternion
  3655. * @returns the quaternion hash code
  3656. */
  3657. getHashCode(): number;
  3658. /**
  3659. * Copy the quaternion to an array
  3660. * @returns a new array populated with 4 elements from the quaternion coordinates
  3661. */
  3662. asArray(): number[];
  3663. /**
  3664. * Check if two quaternions are equals
  3665. * @param otherQuaternion defines the second operand
  3666. * @return true if the current quaternion and the given one coordinates are strictly equals
  3667. */
  3668. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3669. /**
  3670. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3671. * @param otherQuaternion defines the other quaternion
  3672. * @param epsilon defines the minimal distance to consider equality
  3673. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3674. */
  3675. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3676. /**
  3677. * Clone the current quaternion
  3678. * @returns a new quaternion copied from the current one
  3679. */
  3680. clone(): Quaternion;
  3681. /**
  3682. * Copy a quaternion to the current one
  3683. * @param other defines the other quaternion
  3684. * @returns the updated current quaternion
  3685. */
  3686. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Updates the current quaternion with the given float coordinates
  3689. * @param x defines the x coordinate
  3690. * @param y defines the y coordinate
  3691. * @param z defines the z coordinate
  3692. * @param w defines the w coordinate
  3693. * @returns the updated current quaternion
  3694. */
  3695. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given float coordinates
  3698. * @param x defines the x coordinate
  3699. * @param y defines the y coordinate
  3700. * @param z defines the z coordinate
  3701. * @param w defines the w coordinate
  3702. * @returns the updated current quaternion
  3703. */
  3704. set(x: number, y: number, z: number, w: number): Quaternion;
  3705. /**
  3706. * Adds two quaternions
  3707. * @param other defines the second operand
  3708. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3709. */
  3710. add(other: DeepImmutable<Quaternion>): Quaternion;
  3711. /**
  3712. * Add a quaternion to the current one
  3713. * @param other defines the quaternion to add
  3714. * @returns the current quaternion
  3715. */
  3716. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3717. /**
  3718. * Subtract two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the subtraction result of the given one from the current one
  3721. */
  3722. subtract(other: Quaternion): Quaternion;
  3723. /**
  3724. * Multiplies the current quaternion by a scale factor
  3725. * @param value defines the scale factor
  3726. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3727. */
  3728. scale(value: number): Quaternion;
  3729. /**
  3730. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3731. * @param scale defines the scale factor
  3732. * @param result defines the Quaternion object where to store the result
  3733. * @returns the unmodified current quaternion
  3734. */
  3735. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3736. /**
  3737. * Multiplies in place the current quaternion by a scale factor
  3738. * @param value defines the scale factor
  3739. * @returns the current modified quaternion
  3740. */
  3741. scaleInPlace(value: number): Quaternion;
  3742. /**
  3743. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3744. * @param scale defines the scale factor
  3745. * @param result defines the Quaternion object where to store the result
  3746. * @returns the unmodified current quaternion
  3747. */
  3748. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3749. /**
  3750. * Multiplies two quaternions
  3751. * @param q1 defines the second operand
  3752. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3753. */
  3754. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3755. /**
  3756. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3757. * @param q1 defines the second operand
  3758. * @param result defines the target quaternion
  3759. * @returns the current quaternion
  3760. */
  3761. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3762. /**
  3763. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3764. * @param q1 defines the second operand
  3765. * @returns the currentupdated quaternion
  3766. */
  3767. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3768. /**
  3769. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3770. * @param ref defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. conjugateToRef(ref: Quaternion): Quaternion;
  3774. /**
  3775. * Conjugates in place (1-q) the current quaternion
  3776. * @returns the current updated quaternion
  3777. */
  3778. conjugateInPlace(): Quaternion;
  3779. /**
  3780. * Conjugates in place (1-q) the current quaternion
  3781. * @returns a new quaternion
  3782. */
  3783. conjugate(): Quaternion;
  3784. /**
  3785. * Gets length of current quaternion
  3786. * @returns the quaternion length (float)
  3787. */
  3788. length(): number;
  3789. /**
  3790. * Normalize in place the current quaternion
  3791. * @returns the current updated quaternion
  3792. */
  3793. normalize(): Quaternion;
  3794. /**
  3795. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3796. * @param order is a reserved parameter and is ignore for now
  3797. * @returns a new Vector3 containing the Euler angles
  3798. */
  3799. toEulerAngles(order?: string): Vector3;
  3800. /**
  3801. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3802. * @param result defines the vector which will be filled with the Euler angles
  3803. * @param order is a reserved parameter and is ignore for now
  3804. * @returns the current unchanged quaternion
  3805. */
  3806. toEulerAnglesToRef(result: Vector3): Quaternion;
  3807. /**
  3808. * Updates the given rotation matrix with the current quaternion values
  3809. * @param result defines the target matrix
  3810. * @returns the current unchanged quaternion
  3811. */
  3812. toRotationMatrix(result: Matrix): Quaternion;
  3813. /**
  3814. * Updates the current quaternion from the given rotation matrix values
  3815. * @param matrix defines the source matrix
  3816. * @returns the current updated quaternion
  3817. */
  3818. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3819. /**
  3820. * Creates a new quaternion from a rotation matrix
  3821. * @param matrix defines the source matrix
  3822. * @returns a new quaternion created from the given rotation matrix values
  3823. */
  3824. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3825. /**
  3826. * Updates the given quaternion with the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @param result defines the target quaternion
  3829. */
  3830. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3831. /**
  3832. * Returns the dot product (float) between the quaternions "left" and "right"
  3833. * @param left defines the left operand
  3834. * @param right defines the right operand
  3835. * @returns the dot product
  3836. */
  3837. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3838. /**
  3839. * Checks if the two quaternions are close to each other
  3840. * @param quat0 defines the first quaternion to check
  3841. * @param quat1 defines the second quaternion to check
  3842. * @returns true if the two quaternions are close to each other
  3843. */
  3844. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3845. /**
  3846. * Creates an empty quaternion
  3847. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3848. */
  3849. static Zero(): Quaternion;
  3850. /**
  3851. * Inverse a given quaternion
  3852. * @param q defines the source quaternion
  3853. * @returns a new quaternion as the inverted current quaternion
  3854. */
  3855. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3856. /**
  3857. * Inverse a given quaternion
  3858. * @param q defines the source quaternion
  3859. * @param result the quaternion the result will be stored in
  3860. * @returns the result quaternion
  3861. */
  3862. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3863. /**
  3864. * Creates an identity quaternion
  3865. * @returns the identity quaternion
  3866. */
  3867. static Identity(): Quaternion;
  3868. /**
  3869. * Gets a boolean indicating if the given quaternion is identity
  3870. * @param quaternion defines the quaternion to check
  3871. * @returns true if the quaternion is identity
  3872. */
  3873. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3874. /**
  3875. * Creates a quaternion from a rotation around an axis
  3876. * @param axis defines the axis to use
  3877. * @param angle defines the angle to use
  3878. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3879. */
  3880. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3881. /**
  3882. * Creates a rotation around an axis and stores it into the given quaternion
  3883. * @param axis defines the axis to use
  3884. * @param angle defines the angle to use
  3885. * @param result defines the target quaternion
  3886. * @returns the target quaternion
  3887. */
  3888. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3889. /**
  3890. * Creates a new quaternion from data stored into an array
  3891. * @param array defines the data source
  3892. * @param offset defines the offset in the source array where the data starts
  3893. * @returns a new quaternion
  3894. */
  3895. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3896. /**
  3897. * Updates the given quaternion "result" from the starting index of the given array.
  3898. * @param array the array to pull values from
  3899. * @param offset the offset into the array to start at
  3900. * @param result the quaternion to store the result in
  3901. */
  3902. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3903. /**
  3904. * Create a quaternion from Euler rotation angles
  3905. * @param x Pitch
  3906. * @param y Yaw
  3907. * @param z Roll
  3908. * @returns the new Quaternion
  3909. */
  3910. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3911. /**
  3912. * Updates a quaternion from Euler rotation angles
  3913. * @param x Pitch
  3914. * @param y Yaw
  3915. * @param z Roll
  3916. * @param result the quaternion to store the result
  3917. * @returns the updated quaternion
  3918. */
  3919. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3920. /**
  3921. * Create a quaternion from Euler rotation vector
  3922. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3923. * @returns the new Quaternion
  3924. */
  3925. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3926. /**
  3927. * Updates a quaternion from Euler rotation vector
  3928. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3929. * @param result the quaternion to store the result
  3930. * @returns the updated quaternion
  3931. */
  3932. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3935. * @param yaw defines the rotation around Y axis
  3936. * @param pitch defines the rotation around X axis
  3937. * @param roll defines the rotation around Z axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3941. /**
  3942. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3943. * @param yaw defines the rotation around Y axis
  3944. * @param pitch defines the rotation around X axis
  3945. * @param roll defines the rotation around Z axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3949. /**
  3950. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3951. * @param alpha defines the rotation around first axis
  3952. * @param beta defines the rotation around second axis
  3953. * @param gamma defines the rotation around third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3957. /**
  3958. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3959. * @param alpha defines the rotation around first axis
  3960. * @param beta defines the rotation around second axis
  3961. * @param gamma defines the rotation around third axis
  3962. * @param result defines the target quaternion
  3963. */
  3964. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3965. /**
  3966. * 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)
  3967. * @param axis1 defines the first axis
  3968. * @param axis2 defines the second axis
  3969. * @param axis3 defines the third axis
  3970. * @returns the new quaternion
  3971. */
  3972. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3973. /**
  3974. * 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
  3975. * @param axis1 defines the first axis
  3976. * @param axis2 defines the second axis
  3977. * @param axis3 defines the third axis
  3978. * @param ref defines the target quaternion
  3979. */
  3980. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3981. /**
  3982. * Interpolates between two quaternions
  3983. * @param left defines first quaternion
  3984. * @param right defines second quaternion
  3985. * @param amount defines the gradient to use
  3986. * @returns the new interpolated quaternion
  3987. */
  3988. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3989. /**
  3990. * Interpolates between two quaternions and stores it into a target quaternion
  3991. * @param left defines first quaternion
  3992. * @param right defines second quaternion
  3993. * @param amount defines the gradient to use
  3994. * @param result defines the target quaternion
  3995. */
  3996. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3997. /**
  3998. * Interpolate between two quaternions using Hermite interpolation
  3999. * @param value1 defines first quaternion
  4000. * @param tangent1 defines the incoming tangent
  4001. * @param value2 defines second quaternion
  4002. * @param tangent2 defines the outgoing tangent
  4003. * @param amount defines the target quaternion
  4004. * @returns the new interpolated quaternion
  4005. */
  4006. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4007. }
  4008. /**
  4009. * Class used to store matrix data (4x4)
  4010. */
  4011. export class Matrix {
  4012. private static _updateFlagSeed;
  4013. private static _identityReadOnly;
  4014. private _isIdentity;
  4015. private _isIdentityDirty;
  4016. private _isIdentity3x2;
  4017. private _isIdentity3x2Dirty;
  4018. /**
  4019. * Gets the update flag of the matrix which is an unique number for the matrix.
  4020. * It will be incremented every time the matrix data change.
  4021. * You can use it to speed the comparison between two versions of the same matrix.
  4022. */
  4023. updateFlag: number;
  4024. private readonly _m;
  4025. /**
  4026. * Gets the internal data of the matrix
  4027. */
  4028. get m(): DeepImmutable<Float32Array>;
  4029. /** @hidden */
  4030. _markAsUpdated(): void;
  4031. /** @hidden */
  4032. private _updateIdentityStatus;
  4033. /**
  4034. * Creates an empty matrix (filled with zeros)
  4035. */
  4036. constructor();
  4037. /**
  4038. * Check if the current matrix is identity
  4039. * @returns true is the matrix is the identity matrix
  4040. */
  4041. isIdentity(): boolean;
  4042. /**
  4043. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4044. * @returns true is the matrix is the identity matrix
  4045. */
  4046. isIdentityAs3x2(): boolean;
  4047. /**
  4048. * Gets the determinant of the matrix
  4049. * @returns the matrix determinant
  4050. */
  4051. determinant(): number;
  4052. /**
  4053. * Returns the matrix as a Float32Array
  4054. * @returns the matrix underlying array
  4055. */
  4056. toArray(): DeepImmutable<Float32Array>;
  4057. /**
  4058. * Returns the matrix as a Float32Array
  4059. * @returns the matrix underlying array.
  4060. */
  4061. asArray(): DeepImmutable<Float32Array>;
  4062. /**
  4063. * Inverts the current matrix in place
  4064. * @returns the current inverted matrix
  4065. */
  4066. invert(): Matrix;
  4067. /**
  4068. * Sets all the matrix elements to zero
  4069. * @returns the current matrix
  4070. */
  4071. reset(): Matrix;
  4072. /**
  4073. * Adds the current matrix with a second one
  4074. * @param other defines the matrix to add
  4075. * @returns a new matrix as the addition of the current matrix and the given one
  4076. */
  4077. add(other: DeepImmutable<Matrix>): Matrix;
  4078. /**
  4079. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4080. * @param other defines the matrix to add
  4081. * @param result defines the target matrix
  4082. * @returns the current matrix
  4083. */
  4084. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4085. /**
  4086. * Adds in place the given matrix to the current matrix
  4087. * @param other defines the second operand
  4088. * @returns the current updated matrix
  4089. */
  4090. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4091. /**
  4092. * Sets the given matrix to the current inverted Matrix
  4093. * @param other defines the target matrix
  4094. * @returns the unmodified current matrix
  4095. */
  4096. invertToRef(other: Matrix): Matrix;
  4097. /**
  4098. * add a value at the specified position in the current Matrix
  4099. * @param index the index of the value within the matrix. between 0 and 15.
  4100. * @param value the value to be added
  4101. * @returns the current updated matrix
  4102. */
  4103. addAtIndex(index: number, value: number): Matrix;
  4104. /**
  4105. * mutiply the specified position in the current Matrix by a value
  4106. * @param index the index of the value within the matrix. between 0 and 15.
  4107. * @param value the value to be added
  4108. * @returns the current updated matrix
  4109. */
  4110. multiplyAtIndex(index: number, value: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector (using 3 floats) in the current matrix
  4113. * @param x defines the 1st component of the translation
  4114. * @param y defines the 2nd component of the translation
  4115. * @param z defines the 3rd component of the translation
  4116. * @returns the current updated matrix
  4117. */
  4118. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4119. /**
  4120. * Adds the translation vector (using 3 floats) in the current matrix
  4121. * @param x defines the 1st component of the translation
  4122. * @param y defines the 2nd component of the translation
  4123. * @param z defines the 3rd component of the translation
  4124. * @returns the current updated matrix
  4125. */
  4126. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4127. /**
  4128. * Inserts the translation vector in the current matrix
  4129. * @param vector3 defines the translation to insert
  4130. * @returns the current updated matrix
  4131. */
  4132. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4133. /**
  4134. * Gets the translation value of the current matrix
  4135. * @returns a new Vector3 as the extracted translation from the matrix
  4136. */
  4137. getTranslation(): Vector3;
  4138. /**
  4139. * Fill a Vector3 with the extracted translation from the matrix
  4140. * @param result defines the Vector3 where to store the translation
  4141. * @returns the current matrix
  4142. */
  4143. getTranslationToRef(result: Vector3): Matrix;
  4144. /**
  4145. * Remove rotation and scaling part from the matrix
  4146. * @returns the updated matrix
  4147. */
  4148. removeRotationAndScaling(): Matrix;
  4149. /**
  4150. * Multiply two matrices
  4151. * @param other defines the second operand
  4152. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4153. */
  4154. multiply(other: DeepImmutable<Matrix>): Matrix;
  4155. /**
  4156. * Copy the current matrix from the given one
  4157. * @param other defines the source matrix
  4158. * @returns the current updated matrix
  4159. */
  4160. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4161. /**
  4162. * Populates the given array from the starting index with the current matrix values
  4163. * @param array defines the target array
  4164. * @param offset defines the offset in the target array where to start storing values
  4165. * @returns the current matrix
  4166. */
  4167. copyToArray(array: Float32Array, offset?: number): Matrix;
  4168. /**
  4169. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4170. * @param other defines the second operand
  4171. * @param result defines the matrix where to store the multiplication
  4172. * @returns the current matrix
  4173. */
  4174. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4175. /**
  4176. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4177. * @param other defines the second operand
  4178. * @param result defines the array where to store the multiplication
  4179. * @param offset defines the offset in the target array where to start storing values
  4180. * @returns the current matrix
  4181. */
  4182. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4183. /**
  4184. * Check equality between this matrix and a second one
  4185. * @param value defines the second matrix to compare
  4186. * @returns true is the current matrix and the given one values are strictly equal
  4187. */
  4188. equals(value: DeepImmutable<Matrix>): boolean;
  4189. /**
  4190. * Clone the current matrix
  4191. * @returns a new matrix from the current matrix
  4192. */
  4193. clone(): Matrix;
  4194. /**
  4195. * Returns the name of the current matrix class
  4196. * @returns the string "Matrix"
  4197. */
  4198. getClassName(): string;
  4199. /**
  4200. * Gets the hash code of the current matrix
  4201. * @returns the hash code
  4202. */
  4203. getHashCode(): number;
  4204. /**
  4205. * Decomposes the current Matrix into a translation, rotation and scaling components
  4206. * @param scale defines the scale vector3 given as a reference to update
  4207. * @param rotation defines the rotation quaternion given as a reference to update
  4208. * @param translation defines the translation vector3 given as a reference to update
  4209. * @returns true if operation was successful
  4210. */
  4211. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4212. /**
  4213. * Gets specific row of the matrix
  4214. * @param index defines the number of the row to get
  4215. * @returns the index-th row of the current matrix as a new Vector4
  4216. */
  4217. getRow(index: number): Nullable<Vector4>;
  4218. /**
  4219. * Sets the index-th row of the current matrix to the vector4 values
  4220. * @param index defines the number of the row to set
  4221. * @param row defines the target vector4
  4222. * @returns the updated current matrix
  4223. */
  4224. setRow(index: number, row: Vector4): Matrix;
  4225. /**
  4226. * Compute the transpose of the matrix
  4227. * @returns the new transposed matrix
  4228. */
  4229. transpose(): Matrix;
  4230. /**
  4231. * Compute the transpose of the matrix and store it in a given matrix
  4232. * @param result defines the target matrix
  4233. * @returns the current matrix
  4234. */
  4235. transposeToRef(result: Matrix): Matrix;
  4236. /**
  4237. * Sets the index-th row of the current matrix with the given 4 x float values
  4238. * @param index defines the row index
  4239. * @param x defines the x component to set
  4240. * @param y defines the y component to set
  4241. * @param z defines the z component to set
  4242. * @param w defines the w component to set
  4243. * @returns the updated current matrix
  4244. */
  4245. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4246. /**
  4247. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4248. * @param scale defines the scale factor
  4249. * @returns a new matrix
  4250. */
  4251. scale(scale: number): Matrix;
  4252. /**
  4253. * Scale the current matrix values by a factor to a given result matrix
  4254. * @param scale defines the scale factor
  4255. * @param result defines the matrix to store the result
  4256. * @returns the current matrix
  4257. */
  4258. scaleToRef(scale: number, result: Matrix): Matrix;
  4259. /**
  4260. * Scale the current matrix values by a factor and add the result to a given matrix
  4261. * @param scale defines the scale factor
  4262. * @param result defines the Matrix to store the result
  4263. * @returns the current matrix
  4264. */
  4265. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4266. /**
  4267. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4268. * @param ref matrix to store the result
  4269. */
  4270. toNormalMatrix(ref: Matrix): void;
  4271. /**
  4272. * Gets only rotation part of the current matrix
  4273. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4274. */
  4275. getRotationMatrix(): Matrix;
  4276. /**
  4277. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4278. * @param result defines the target matrix to store data to
  4279. * @returns the current matrix
  4280. */
  4281. getRotationMatrixToRef(result: Matrix): Matrix;
  4282. /**
  4283. * Toggles model matrix from being right handed to left handed in place and vice versa
  4284. */
  4285. toggleModelMatrixHandInPlace(): void;
  4286. /**
  4287. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4288. */
  4289. toggleProjectionMatrixHandInPlace(): void;
  4290. /**
  4291. * Creates a matrix from an array
  4292. * @param array defines the source array
  4293. * @param offset defines an offset in the source array
  4294. * @returns a new Matrix set from the starting index of the given array
  4295. */
  4296. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4297. /**
  4298. * Copy the content of an array into a given matrix
  4299. * @param array defines the source array
  4300. * @param offset defines an offset in the source array
  4301. * @param result defines the target matrix
  4302. */
  4303. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4304. /**
  4305. * Stores an array into a matrix after having multiplied each component by a given factor
  4306. * @param array defines the source array
  4307. * @param offset defines the offset in the source array
  4308. * @param scale defines the scaling factor
  4309. * @param result defines the target matrix
  4310. */
  4311. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4312. /**
  4313. * Gets an identity matrix that must not be updated
  4314. */
  4315. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4316. /**
  4317. * Stores a list of values (16) inside a given matrix
  4318. * @param initialM11 defines 1st value of 1st row
  4319. * @param initialM12 defines 2nd value of 1st row
  4320. * @param initialM13 defines 3rd value of 1st row
  4321. * @param initialM14 defines 4th value of 1st row
  4322. * @param initialM21 defines 1st value of 2nd row
  4323. * @param initialM22 defines 2nd value of 2nd row
  4324. * @param initialM23 defines 3rd value of 2nd row
  4325. * @param initialM24 defines 4th value of 2nd row
  4326. * @param initialM31 defines 1st value of 3rd row
  4327. * @param initialM32 defines 2nd value of 3rd row
  4328. * @param initialM33 defines 3rd value of 3rd row
  4329. * @param initialM34 defines 4th value of 3rd row
  4330. * @param initialM41 defines 1st value of 4th row
  4331. * @param initialM42 defines 2nd value of 4th row
  4332. * @param initialM43 defines 3rd value of 4th row
  4333. * @param initialM44 defines 4th value of 4th row
  4334. * @param result defines the target matrix
  4335. */
  4336. 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;
  4337. /**
  4338. * Creates new matrix from a list of values (16)
  4339. * @param initialM11 defines 1st value of 1st row
  4340. * @param initialM12 defines 2nd value of 1st row
  4341. * @param initialM13 defines 3rd value of 1st row
  4342. * @param initialM14 defines 4th value of 1st row
  4343. * @param initialM21 defines 1st value of 2nd row
  4344. * @param initialM22 defines 2nd value of 2nd row
  4345. * @param initialM23 defines 3rd value of 2nd row
  4346. * @param initialM24 defines 4th value of 2nd row
  4347. * @param initialM31 defines 1st value of 3rd row
  4348. * @param initialM32 defines 2nd value of 3rd row
  4349. * @param initialM33 defines 3rd value of 3rd row
  4350. * @param initialM34 defines 4th value of 3rd row
  4351. * @param initialM41 defines 1st value of 4th row
  4352. * @param initialM42 defines 2nd value of 4th row
  4353. * @param initialM43 defines 3rd value of 4th row
  4354. * @param initialM44 defines 4th value of 4th row
  4355. * @returns the new matrix
  4356. */
  4357. 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;
  4358. /**
  4359. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4360. * @param scale defines the scale vector3
  4361. * @param rotation defines the rotation quaternion
  4362. * @param translation defines the translation vector3
  4363. * @returns a new matrix
  4364. */
  4365. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4366. /**
  4367. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4368. * @param scale defines the scale vector3
  4369. * @param rotation defines the rotation quaternion
  4370. * @param translation defines the translation vector3
  4371. * @param result defines the target matrix
  4372. */
  4373. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4374. /**
  4375. * Creates a new identity matrix
  4376. * @returns a new identity matrix
  4377. */
  4378. static Identity(): Matrix;
  4379. /**
  4380. * Creates a new identity matrix and stores the result in a given matrix
  4381. * @param result defines the target matrix
  4382. */
  4383. static IdentityToRef(result: Matrix): void;
  4384. /**
  4385. * Creates a new zero matrix
  4386. * @returns a new zero matrix
  4387. */
  4388. static Zero(): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the X axis
  4391. * @param angle defines the angle (in radians) to use
  4392. * @return the new matrix
  4393. */
  4394. static RotationX(angle: number): Matrix;
  4395. /**
  4396. * Creates a new matrix as the invert of a given matrix
  4397. * @param source defines the source matrix
  4398. * @returns the new matrix
  4399. */
  4400. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationXToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the Y axis
  4409. * @param angle defines the angle (in radians) to use
  4410. * @return the new matrix
  4411. */
  4412. static RotationY(angle: number): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationYToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Z axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationZ(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationZToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the given axis
  4433. * @param axis defines the axis to use
  4434. * @param angle defines the angle (in radians) to use
  4435. * @return the new matrix
  4436. */
  4437. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4440. * @param axis defines the axis to use
  4441. * @param angle defines the angle (in radians) to use
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4445. /**
  4446. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4447. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4448. * @param from defines the vector to align
  4449. * @param to defines the vector to align to
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4453. /**
  4454. * Creates a rotation matrix
  4455. * @param yaw defines the yaw angle in radians (Y axis)
  4456. * @param pitch defines the pitch angle in radians (X axis)
  4457. * @param roll defines the roll angle in radians (X axis)
  4458. * @returns the new rotation matrix
  4459. */
  4460. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4461. /**
  4462. * Creates a rotation matrix and stores it in a given matrix
  4463. * @param yaw defines the yaw angle in radians (Y axis)
  4464. * @param pitch defines the pitch angle in radians (X axis)
  4465. * @param roll defines the roll angle in radians (X axis)
  4466. * @param result defines the target matrix
  4467. */
  4468. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4469. /**
  4470. * Creates a scaling matrix
  4471. * @param x defines the scale factor on X axis
  4472. * @param y defines the scale factor on Y axis
  4473. * @param z defines the scale factor on Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Scaling(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a scaling matrix and stores it in a given matrix
  4479. * @param x defines the scale factor on X axis
  4480. * @param y defines the scale factor on Y axis
  4481. * @param z defines the scale factor on Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Creates a translation matrix
  4487. * @param x defines the translation on X axis
  4488. * @param y defines the translation on Y axis
  4489. * @param z defines the translationon Z axis
  4490. * @returns the new matrix
  4491. */
  4492. static Translation(x: number, y: number, z: number): Matrix;
  4493. /**
  4494. * Creates a translation matrix and stores it in a given matrix
  4495. * @param x defines the translation on X axis
  4496. * @param y defines the translation on Y axis
  4497. * @param z defines the translationon Z axis
  4498. * @param result defines the target matrix
  4499. */
  4500. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4501. /**
  4502. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4503. * @param startValue defines the start value
  4504. * @param endValue defines the end value
  4505. * @param gradient defines the gradient factor
  4506. * @returns the new matrix
  4507. */
  4508. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4509. /**
  4510. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4511. * @param startValue defines the start value
  4512. * @param endValue defines the end value
  4513. * @param gradient defines the gradient factor
  4514. * @param result defines the Matrix object where to store data
  4515. */
  4516. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4517. /**
  4518. * Builds a new matrix whose values are computed by:
  4519. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4520. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4521. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4522. * @param startValue defines the first matrix
  4523. * @param endValue defines the second matrix
  4524. * @param gradient defines the gradient between the two matrices
  4525. * @returns the new matrix
  4526. */
  4527. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Update a matrix to values which are computed by:
  4530. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4531. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4532. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4533. * @param startValue defines the first matrix
  4534. * @param endValue defines the second matrix
  4535. * @param gradient defines the gradient between the two matrices
  4536. * @param result defines the target matrix
  4537. */
  4538. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4539. /**
  4540. * 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"
  4541. * This function works in left handed mode
  4542. * @param eye defines the final position of the entity
  4543. * @param target defines where the entity should look at
  4544. * @param up defines the up vector for the entity
  4545. * @returns the new matrix
  4546. */
  4547. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4548. /**
  4549. * 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".
  4550. * This function works in left handed mode
  4551. * @param eye defines the final position of the entity
  4552. * @param target defines where the entity should look at
  4553. * @param up defines the up vector for the entity
  4554. * @param result defines the target matrix
  4555. */
  4556. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4557. /**
  4558. * 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"
  4559. * This function works in right handed mode
  4560. * @param eye defines the final position of the entity
  4561. * @param target defines where the entity should look at
  4562. * @param up defines the up vector for the entity
  4563. * @returns the new matrix
  4564. */
  4565. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4566. /**
  4567. * 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".
  4568. * This function works in right handed mode
  4569. * @param eye defines the final position of the entity
  4570. * @param target defines where the entity should look at
  4571. * @param up defines the up vector for the entity
  4572. * @param result defines the target matrix
  4573. */
  4574. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4575. /**
  4576. * Create a left-handed orthographic projection matrix
  4577. * @param width defines the viewport width
  4578. * @param height defines the viewport height
  4579. * @param znear defines the near clip plane
  4580. * @param zfar defines the far clip plane
  4581. * @returns a new matrix as a left-handed orthographic projection matrix
  4582. */
  4583. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4584. /**
  4585. * Store a left-handed orthographic projection to a given matrix
  4586. * @param width defines the viewport width
  4587. * @param height defines the viewport height
  4588. * @param znear defines the near clip plane
  4589. * @param zfar defines the far clip plane
  4590. * @param result defines the target matrix
  4591. */
  4592. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4593. /**
  4594. * Create a left-handed orthographic projection matrix
  4595. * @param left defines the viewport left coordinate
  4596. * @param right defines the viewport right coordinate
  4597. * @param bottom defines the viewport bottom coordinate
  4598. * @param top defines the viewport top coordinate
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Stores a left-handed orthographic projection into a given matrix
  4606. * @param left defines the viewport left coordinate
  4607. * @param right defines the viewport right coordinate
  4608. * @param bottom defines the viewport bottom coordinate
  4609. * @param top defines the viewport top coordinate
  4610. * @param znear defines the near clip plane
  4611. * @param zfar defines the far clip plane
  4612. * @param result defines the target matrix
  4613. */
  4614. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4615. /**
  4616. * Creates a right-handed orthographic projection matrix
  4617. * @param left defines the viewport left coordinate
  4618. * @param right defines the viewport right coordinate
  4619. * @param bottom defines the viewport bottom coordinate
  4620. * @param top defines the viewport top coordinate
  4621. * @param znear defines the near clip plane
  4622. * @param zfar defines the far clip plane
  4623. * @returns a new matrix as a right-handed orthographic projection matrix
  4624. */
  4625. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4626. /**
  4627. * Stores a right-handed orthographic projection into a given matrix
  4628. * @param left defines the viewport left coordinate
  4629. * @param right defines the viewport right coordinate
  4630. * @param bottom defines the viewport bottom coordinate
  4631. * @param top defines the viewport top coordinate
  4632. * @param znear defines the near clip plane
  4633. * @param zfar defines the far clip plane
  4634. * @param result defines the target matrix
  4635. */
  4636. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4637. /**
  4638. * Creates a left-handed perspective projection matrix
  4639. * @param width defines the viewport width
  4640. * @param height defines the viewport height
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a left-handed perspective projection matrix
  4644. */
  4645. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Creates a left-handed perspective projection matrix
  4648. * @param fov defines the horizontal field of view
  4649. * @param aspect defines the aspect ratio
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @returns a new matrix as a left-handed perspective projection matrix
  4653. */
  4654. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4655. /**
  4656. * Stores a left-handed perspective projection into a given matrix
  4657. * @param fov defines the horizontal field of view
  4658. * @param aspect defines the aspect ratio
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @param result defines the target matrix
  4662. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4663. */
  4664. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4665. /**
  4666. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar not used as infinity is used as far clip
  4671. * @param result defines the target matrix
  4672. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4673. */
  4674. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4675. /**
  4676. * Creates a right-handed perspective projection matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a right-handed perspective projection matrix
  4682. */
  4683. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a right-handed perspective projection into a given matrix
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar defines the far clip plane
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Stores a right-handed perspective projection into a given matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar not used as infinity is used as far clip
  4700. * @param result defines the target matrix
  4701. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4702. */
  4703. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4704. /**
  4705. * Stores a perspective projection for WebVR info a given matrix
  4706. * @param fov defines the field of view
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4711. */
  4712. static PerspectiveFovWebVRToRef(fov: {
  4713. upDegrees: number;
  4714. downDegrees: number;
  4715. leftDegrees: number;
  4716. rightDegrees: number;
  4717. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4718. /**
  4719. * Computes a complete transformation matrix
  4720. * @param viewport defines the viewport to use
  4721. * @param world defines the world matrix
  4722. * @param view defines the view matrix
  4723. * @param projection defines the projection matrix
  4724. * @param zmin defines the near clip plane
  4725. * @param zmax defines the far clip plane
  4726. * @returns the transformation matrix
  4727. */
  4728. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4729. /**
  4730. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4731. * @param matrix defines the matrix to use
  4732. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4733. */
  4734. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4735. /**
  4736. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4737. * @param matrix defines the matrix to use
  4738. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4739. */
  4740. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4741. /**
  4742. * Compute the transpose of a given matrix
  4743. * @param matrix defines the matrix to transpose
  4744. * @returns the new matrix
  4745. */
  4746. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4747. /**
  4748. * Compute the transpose of a matrix and store it in a target matrix
  4749. * @param matrix defines the matrix to transpose
  4750. * @param result defines the target matrix
  4751. */
  4752. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4753. /**
  4754. * Computes a reflection matrix from a plane
  4755. * @param plane defines the reflection plane
  4756. * @returns a new matrix
  4757. */
  4758. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4759. /**
  4760. * Computes a reflection matrix from a plane
  4761. * @param plane defines the reflection plane
  4762. * @param result defines the target matrix
  4763. */
  4764. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4765. /**
  4766. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4767. * @param xaxis defines the value of the 1st axis
  4768. * @param yaxis defines the value of the 2nd axis
  4769. * @param zaxis defines the value of the 3rd axis
  4770. * @param result defines the target matrix
  4771. */
  4772. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4773. /**
  4774. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4775. * @param quat defines the quaternion to use
  4776. * @param result defines the target matrix
  4777. */
  4778. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4779. }
  4780. /**
  4781. * @hidden
  4782. */
  4783. export class TmpVectors {
  4784. static Vector2: Vector2[];
  4785. static Vector3: Vector3[];
  4786. static Vector4: Vector4[];
  4787. static Quaternion: Quaternion[];
  4788. static Matrix: Matrix[];
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Defines potential orientation for back face culling
  4794. */
  4795. export enum Orientation {
  4796. /**
  4797. * Clockwise
  4798. */
  4799. CW = 0,
  4800. /** Counter clockwise */
  4801. CCW = 1
  4802. }
  4803. /** Class used to represent a Bezier curve */
  4804. export class BezierCurve {
  4805. /**
  4806. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4807. * @param t defines the time
  4808. * @param x1 defines the left coordinate on X axis
  4809. * @param y1 defines the left coordinate on Y axis
  4810. * @param x2 defines the right coordinate on X axis
  4811. * @param y2 defines the right coordinate on Y axis
  4812. * @returns the interpolated value
  4813. */
  4814. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4815. }
  4816. /**
  4817. * Defines angle representation
  4818. */
  4819. export class Angle {
  4820. private _radians;
  4821. /**
  4822. * Creates an Angle object of "radians" radians (float).
  4823. * @param radians the angle in radians
  4824. */
  4825. constructor(radians: number);
  4826. /**
  4827. * Get value in degrees
  4828. * @returns the Angle value in degrees (float)
  4829. */
  4830. degrees(): number;
  4831. /**
  4832. * Get value in radians
  4833. * @returns the Angle value in radians (float)
  4834. */
  4835. radians(): number;
  4836. /**
  4837. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4838. * @param a defines first vector
  4839. * @param b defines second vector
  4840. * @returns a new Angle
  4841. */
  4842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4843. /**
  4844. * Gets a new Angle object from the given float in radians
  4845. * @param radians defines the angle value in radians
  4846. * @returns a new Angle
  4847. */
  4848. static FromRadians(radians: number): Angle;
  4849. /**
  4850. * Gets a new Angle object from the given float in degrees
  4851. * @param degrees defines the angle value in degrees
  4852. * @returns a new Angle
  4853. */
  4854. static FromDegrees(degrees: number): Angle;
  4855. }
  4856. /**
  4857. * This represents an arc in a 2d space.
  4858. */
  4859. export class Arc2 {
  4860. /** Defines the start point of the arc */
  4861. startPoint: Vector2;
  4862. /** Defines the mid point of the arc */
  4863. midPoint: Vector2;
  4864. /** Defines the end point of the arc */
  4865. endPoint: Vector2;
  4866. /**
  4867. * Defines the center point of the arc.
  4868. */
  4869. centerPoint: Vector2;
  4870. /**
  4871. * Defines the radius of the arc.
  4872. */
  4873. radius: number;
  4874. /**
  4875. * Defines the angle of the arc (from mid point to end point).
  4876. */
  4877. angle: Angle;
  4878. /**
  4879. * Defines the start angle of the arc (from start point to middle point).
  4880. */
  4881. startAngle: Angle;
  4882. /**
  4883. * Defines the orientation of the arc (clock wise/counter clock wise).
  4884. */
  4885. orientation: Orientation;
  4886. /**
  4887. * Creates an Arc object from the three given points : start, middle and end.
  4888. * @param startPoint Defines the start point of the arc
  4889. * @param midPoint Defines the midlle point of the arc
  4890. * @param endPoint Defines the end point of the arc
  4891. */
  4892. constructor(
  4893. /** Defines the start point of the arc */
  4894. startPoint: Vector2,
  4895. /** Defines the mid point of the arc */
  4896. midPoint: Vector2,
  4897. /** Defines the end point of the arc */
  4898. endPoint: Vector2);
  4899. }
  4900. /**
  4901. * Represents a 2D path made up of multiple 2D points
  4902. */
  4903. export class Path2 {
  4904. private _points;
  4905. private _length;
  4906. /**
  4907. * If the path start and end point are the same
  4908. */
  4909. closed: boolean;
  4910. /**
  4911. * Creates a Path2 object from the starting 2D coordinates x and y.
  4912. * @param x the starting points x value
  4913. * @param y the starting points y value
  4914. */
  4915. constructor(x: number, y: number);
  4916. /**
  4917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4918. * @param x the added points x value
  4919. * @param y the added points y value
  4920. * @returns the updated Path2.
  4921. */
  4922. addLineTo(x: number, y: number): Path2;
  4923. /**
  4924. * 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.
  4925. * @param midX middle point x value
  4926. * @param midY middle point y value
  4927. * @param endX end point x value
  4928. * @param endY end point y value
  4929. * @param numberOfSegments (default: 36)
  4930. * @returns the updated Path2.
  4931. */
  4932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4933. /**
  4934. * Closes the Path2.
  4935. * @returns the Path2.
  4936. */
  4937. close(): Path2;
  4938. /**
  4939. * Gets the sum of the distance between each sequential point in the path
  4940. * @returns the Path2 total length (float).
  4941. */
  4942. length(): number;
  4943. /**
  4944. * Gets the points which construct the path
  4945. * @returns the Path2 internal array of points.
  4946. */
  4947. getPoints(): Vector2[];
  4948. /**
  4949. * Retreives the point at the distance aways from the starting point
  4950. * @param normalizedLengthPosition the length along the path to retreive the point from
  4951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4952. */
  4953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4954. /**
  4955. * Creates a new path starting from an x and y position
  4956. * @param x starting x value
  4957. * @param y starting y value
  4958. * @returns a new Path2 starting at the coordinates (x, y).
  4959. */
  4960. static StartingAt(x: number, y: number): Path2;
  4961. }
  4962. /**
  4963. * Represents a 3D path made up of multiple 3D points
  4964. */
  4965. export class Path3D {
  4966. /**
  4967. * an array of Vector3, the curve axis of the Path3D
  4968. */
  4969. path: Vector3[];
  4970. private _curve;
  4971. private _distances;
  4972. private _tangents;
  4973. private _normals;
  4974. private _binormals;
  4975. private _raw;
  4976. private _alignTangentsWithPath;
  4977. private readonly _pointAtData;
  4978. /**
  4979. * new Path3D(path, normal, raw)
  4980. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4981. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4982. * @param path an array of Vector3, the curve axis of the Path3D
  4983. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4984. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4985. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4986. */
  4987. constructor(
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4992. /**
  4993. * Returns the Path3D array of successive Vector3 designing its curve.
  4994. * @returns the Path3D array of successive Vector3 designing its curve.
  4995. */
  4996. getCurve(): Vector3[];
  4997. /**
  4998. * Returns the Path3D array of successive Vector3 designing its curve.
  4999. * @returns the Path3D array of successive Vector3 designing its curve.
  5000. */
  5001. getPoints(): Vector3[];
  5002. /**
  5003. * @returns the computed length (float) of the path.
  5004. */
  5005. length(): number;
  5006. /**
  5007. * Returns an array populated with tangent vectors on each Path3D curve point.
  5008. * @returns an array populated with tangent vectors on each Path3D curve point.
  5009. */
  5010. getTangents(): Vector3[];
  5011. /**
  5012. * Returns an array populated with normal vectors on each Path3D curve point.
  5013. * @returns an array populated with normal vectors on each Path3D curve point.
  5014. */
  5015. getNormals(): Vector3[];
  5016. /**
  5017. * Returns an array populated with binormal vectors on each Path3D curve point.
  5018. * @returns an array populated with binormal vectors on each Path3D curve point.
  5019. */
  5020. getBinormals(): Vector3[];
  5021. /**
  5022. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5023. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5024. */
  5025. getDistances(): number[];
  5026. /**
  5027. * Returns an interpolated point along this path
  5028. * @param position the position of the point along this path, from 0.0 to 1.0
  5029. * @returns a new Vector3 as the point
  5030. */
  5031. getPointAt(position: number): Vector3;
  5032. /**
  5033. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5034. * @param position the position of the point along this path, from 0.0 to 1.0
  5035. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5036. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5037. */
  5038. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5039. /**
  5040. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5041. * @param position the position of the point along this path, from 0.0 to 1.0
  5042. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5043. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5044. */
  5045. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5046. /**
  5047. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5050. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5051. */
  5052. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5057. */
  5058. getDistanceAt(position: number): number;
  5059. /**
  5060. * Returns the array index of the previous point of an interpolated point along this path
  5061. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5062. * @returns the array index
  5063. */
  5064. getPreviousPointIndexAt(position: number): number;
  5065. /**
  5066. * 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)
  5067. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5068. * @returns the sub position
  5069. */
  5070. getSubPositionAt(position: number): number;
  5071. /**
  5072. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5073. * @param target the vector of which to get the closest position to
  5074. * @returns the position of the closest virtual point on this path to the target vector
  5075. */
  5076. getClosestPositionTo(target: Vector3): number;
  5077. /**
  5078. * Returns a sub path (slice) of this path
  5079. * @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
  5080. * @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
  5081. * @returns a sub path (slice) of this path
  5082. */
  5083. slice(start?: number, end?: number): Path3D;
  5084. /**
  5085. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5086. * @param path path which all values are copied into the curves points
  5087. * @param firstNormal which should be projected onto the curve
  5088. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5089. * @returns the same object updated.
  5090. */
  5091. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5092. private _compute;
  5093. private _getFirstNonNullVector;
  5094. private _getLastNonNullVector;
  5095. private _normalVector;
  5096. /**
  5097. * Updates the point at data for an interpolated point along this curve
  5098. * @param position the position of the point along this curve, from 0.0 to 1.0
  5099. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5100. * @returns the (updated) point at data
  5101. */
  5102. private _updatePointAtData;
  5103. /**
  5104. * Updates the point at data from the specified parameters
  5105. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5106. * @param point the interpolated point
  5107. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5108. */
  5109. private _setPointAtData;
  5110. /**
  5111. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5112. */
  5113. private _updateInterpolationMatrix;
  5114. }
  5115. /**
  5116. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5117. * A Curve3 is designed from a series of successive Vector3.
  5118. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5119. */
  5120. export class Curve3 {
  5121. private _points;
  5122. private _length;
  5123. /**
  5124. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5125. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5126. * @param v1 (Vector3) the control point
  5127. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5128. * @param nbPoints (integer) the wanted number of points in the curve
  5129. * @returns the created Curve3
  5130. */
  5131. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5132. /**
  5133. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5134. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5135. * @param v1 (Vector3) the first control point
  5136. * @param v2 (Vector3) the second control point
  5137. * @param v3 (Vector3) the end point of the Cubic Bezier
  5138. * @param nbPoints (integer) the wanted number of points in the curve
  5139. * @returns the created Curve3
  5140. */
  5141. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5142. /**
  5143. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5144. * @param p1 (Vector3) the origin point of the Hermite Spline
  5145. * @param t1 (Vector3) the tangent vector at the origin point
  5146. * @param p2 (Vector3) the end point of the Hermite Spline
  5147. * @param t2 (Vector3) the tangent vector at the end point
  5148. * @param nbPoints (integer) the wanted number of points in the curve
  5149. * @returns the created Curve3
  5150. */
  5151. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5152. /**
  5153. * Returns a Curve3 object along a CatmullRom Spline curve :
  5154. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5155. * @param nbPoints (integer) the wanted number of points between each curve control points
  5156. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5157. * @returns the created Curve3
  5158. */
  5159. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5160. /**
  5161. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5162. * A Curve3 is designed from a series of successive Vector3.
  5163. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5164. * @param points points which make up the curve
  5165. */
  5166. constructor(points: Vector3[]);
  5167. /**
  5168. * @returns the Curve3 stored array of successive Vector3
  5169. */
  5170. getPoints(): Vector3[];
  5171. /**
  5172. * @returns the computed length (float) of the curve.
  5173. */
  5174. length(): number;
  5175. /**
  5176. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5177. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5178. * curveA and curveB keep unchanged.
  5179. * @param curve the curve to continue from this curve
  5180. * @returns the newly constructed curve
  5181. */
  5182. continue(curve: DeepImmutable<Curve3>): Curve3;
  5183. private _computeLength;
  5184. }
  5185. }
  5186. declare module BABYLON {
  5187. /**
  5188. * This represents the main contract an easing function should follow.
  5189. * Easing functions are used throughout the animation system.
  5190. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5191. */
  5192. export interface IEasingFunction {
  5193. /**
  5194. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5195. * of the easing function.
  5196. * The link below provides some of the most common examples of easing functions.
  5197. * @see https://easings.net/
  5198. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5199. * @returns the corresponding value on the curve defined by the easing function
  5200. */
  5201. ease(gradient: number): number;
  5202. }
  5203. /**
  5204. * Base class used for every default easing function.
  5205. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class EasingFunction implements IEasingFunction {
  5208. /**
  5209. * Interpolation follows the mathematical formula associated with the easing function.
  5210. */
  5211. static readonly EASINGMODE_EASEIN: number;
  5212. /**
  5213. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5214. */
  5215. static readonly EASINGMODE_EASEOUT: number;
  5216. /**
  5217. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5218. */
  5219. static readonly EASINGMODE_EASEINOUT: number;
  5220. private _easingMode;
  5221. /**
  5222. * Sets the easing mode of the current function.
  5223. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5224. */
  5225. setEasingMode(easingMode: number): void;
  5226. /**
  5227. * Gets the current easing mode.
  5228. * @returns the easing mode
  5229. */
  5230. getEasingMode(): number;
  5231. /**
  5232. * @hidden
  5233. */
  5234. easeInCore(gradient: number): number;
  5235. /**
  5236. * Given an input gradient between 0 and 1, this returns the corresponding value
  5237. * of the easing function.
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Easing function with a circle shape (see link below).
  5245. * @see https://easings.net/#easeInCirc
  5246. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5247. */
  5248. export class CircleEase extends EasingFunction implements IEasingFunction {
  5249. /** @hidden */
  5250. easeInCore(gradient: number): number;
  5251. }
  5252. /**
  5253. * Easing function with a ease back shape (see link below).
  5254. * @see https://easings.net/#easeInBack
  5255. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5256. */
  5257. export class BackEase extends EasingFunction implements IEasingFunction {
  5258. /** Defines the amplitude of the function */
  5259. amplitude: number;
  5260. /**
  5261. * Instantiates a back ease easing
  5262. * @see https://easings.net/#easeInBack
  5263. * @param amplitude Defines the amplitude of the function
  5264. */
  5265. constructor(
  5266. /** Defines the amplitude of the function */
  5267. amplitude?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a bouncing shape (see link below).
  5273. * @see https://easings.net/#easeInBounce
  5274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class BounceEase extends EasingFunction implements IEasingFunction {
  5277. /** Defines the number of bounces */
  5278. bounces: number;
  5279. /** Defines the amplitude of the bounce */
  5280. bounciness: number;
  5281. /**
  5282. * Instantiates a bounce easing
  5283. * @see https://easings.net/#easeInBounce
  5284. * @param bounces Defines the number of bounces
  5285. * @param bounciness Defines the amplitude of the bounce
  5286. */
  5287. constructor(
  5288. /** Defines the number of bounces */
  5289. bounces?: number,
  5290. /** Defines the amplitude of the bounce */
  5291. bounciness?: number);
  5292. /** @hidden */
  5293. easeInCore(gradient: number): number;
  5294. }
  5295. /**
  5296. * Easing function with a power of 3 shape (see link below).
  5297. * @see https://easings.net/#easeInCubic
  5298. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5299. */
  5300. export class CubicEase extends EasingFunction implements IEasingFunction {
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an elastic shape (see link below).
  5306. * @see https://easings.net/#easeInElastic
  5307. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the number of oscillations*/
  5311. oscillations: number;
  5312. /** Defines the amplitude of the oscillations*/
  5313. springiness: number;
  5314. /**
  5315. * Instantiates an elastic easing function
  5316. * @see https://easings.net/#easeInElastic
  5317. * @param oscillations Defines the number of oscillations
  5318. * @param springiness Defines the amplitude of the oscillations
  5319. */
  5320. constructor(
  5321. /** Defines the number of oscillations*/
  5322. oscillations?: number,
  5323. /** Defines the amplitude of the oscillations*/
  5324. springiness?: number);
  5325. /** @hidden */
  5326. easeInCore(gradient: number): number;
  5327. }
  5328. /**
  5329. * Easing function with an exponential shape (see link below).
  5330. * @see https://easings.net/#easeInExpo
  5331. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5332. */
  5333. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5334. /** Defines the exponent of the function */
  5335. exponent: number;
  5336. /**
  5337. * Instantiates an exponential easing function
  5338. * @see https://easings.net/#easeInExpo
  5339. * @param exponent Defines the exponent of the function
  5340. */
  5341. constructor(
  5342. /** Defines the exponent of the function */
  5343. exponent?: number);
  5344. /** @hidden */
  5345. easeInCore(gradient: number): number;
  5346. }
  5347. /**
  5348. * Easing function with a power shape (see link below).
  5349. * @see https://easings.net/#easeInQuad
  5350. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5351. */
  5352. export class PowerEase extends EasingFunction implements IEasingFunction {
  5353. /** Defines the power of the function */
  5354. power: number;
  5355. /**
  5356. * Instantiates an power base easing function
  5357. * @see https://easings.net/#easeInQuad
  5358. * @param power Defines the power of the function
  5359. */
  5360. constructor(
  5361. /** Defines the power of the function */
  5362. power?: number);
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with a power of 2 shape (see link below).
  5368. * @see https://easings.net/#easeInQuad
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 4 shape (see link below).
  5377. * @see https://easings.net/#easeInQuart
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with a power of 5 shape (see link below).
  5386. * @see https://easings.net/#easeInQuint
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5390. /** @hidden */
  5391. easeInCore(gradient: number): number;
  5392. }
  5393. /**
  5394. * Easing function with a sin shape (see link below).
  5395. * @see https://easings.net/#easeInSine
  5396. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5397. */
  5398. export class SineEase extends EasingFunction implements IEasingFunction {
  5399. /** @hidden */
  5400. easeInCore(gradient: number): number;
  5401. }
  5402. /**
  5403. * Easing function with a bezier shape (see link below).
  5404. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5405. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5406. */
  5407. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1: number;
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1: number;
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2: number;
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2: number;
  5416. /**
  5417. * Instantiates a bezier function
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @param x1 Defines the x component of the start tangent in the bezier curve
  5420. * @param y1 Defines the y component of the start tangent in the bezier curve
  5421. * @param x2 Defines the x component of the end tangent in the bezier curve
  5422. * @param y2 Defines the y component of the end tangent in the bezier curve
  5423. */
  5424. constructor(
  5425. /** Defines the x component of the start tangent in the bezier curve */
  5426. x1?: number,
  5427. /** Defines the y component of the start tangent in the bezier curve */
  5428. y1?: number,
  5429. /** Defines the x component of the end tangent in the bezier curve */
  5430. x2?: number,
  5431. /** Defines the y component of the end tangent in the bezier curve */
  5432. y2?: number);
  5433. /** @hidden */
  5434. easeInCore(gradient: number): number;
  5435. }
  5436. }
  5437. declare module BABYLON {
  5438. /**
  5439. * Class used to hold a RBG color
  5440. */
  5441. export class Color3 {
  5442. /**
  5443. * Defines the red component (between 0 and 1, default is 0)
  5444. */
  5445. r: number;
  5446. /**
  5447. * Defines the green component (between 0 and 1, default is 0)
  5448. */
  5449. g: number;
  5450. /**
  5451. * Defines the blue component (between 0 and 1, default is 0)
  5452. */
  5453. b: number;
  5454. /**
  5455. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5456. * @param r defines the red component (between 0 and 1, default is 0)
  5457. * @param g defines the green component (between 0 and 1, default is 0)
  5458. * @param b defines the blue component (between 0 and 1, default is 0)
  5459. */
  5460. constructor(
  5461. /**
  5462. * Defines the red component (between 0 and 1, default is 0)
  5463. */
  5464. r?: number,
  5465. /**
  5466. * Defines the green component (between 0 and 1, default is 0)
  5467. */
  5468. g?: number,
  5469. /**
  5470. * Defines the blue component (between 0 and 1, default is 0)
  5471. */
  5472. b?: number);
  5473. /**
  5474. * Creates a string with the Color3 current values
  5475. * @returns the string representation of the Color3 object
  5476. */
  5477. toString(): string;
  5478. /**
  5479. * Returns the string "Color3"
  5480. * @returns "Color3"
  5481. */
  5482. getClassName(): string;
  5483. /**
  5484. * Compute the Color3 hash code
  5485. * @returns an unique number that can be used to hash Color3 objects
  5486. */
  5487. getHashCode(): number;
  5488. /**
  5489. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5490. * @param array defines the array where to store the r,g,b components
  5491. * @param index defines an optional index in the target array to define where to start storing values
  5492. * @returns the current Color3 object
  5493. */
  5494. toArray(array: FloatArray, index?: number): Color3;
  5495. /**
  5496. * Returns a new Color4 object from the current Color3 and the given alpha
  5497. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5498. * @returns a new Color4 object
  5499. */
  5500. toColor4(alpha?: number): Color4;
  5501. /**
  5502. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5503. * @returns the new array
  5504. */
  5505. asArray(): number[];
  5506. /**
  5507. * Returns the luminance value
  5508. * @returns a float value
  5509. */
  5510. toLuminance(): number;
  5511. /**
  5512. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5513. * @param otherColor defines the second operand
  5514. * @returns the new Color3 object
  5515. */
  5516. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5517. /**
  5518. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5519. * @param otherColor defines the second operand
  5520. * @param result defines the Color3 object where to store the result
  5521. * @returns the current Color3
  5522. */
  5523. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5524. /**
  5525. * Determines equality between Color3 objects
  5526. * @param otherColor defines the second operand
  5527. * @returns true if the rgb values are equal to the given ones
  5528. */
  5529. equals(otherColor: DeepImmutable<Color3>): boolean;
  5530. /**
  5531. * Determines equality between the current Color3 object and a set of r,b,g values
  5532. * @param r defines the red component to check
  5533. * @param g defines the green component to check
  5534. * @param b defines the blue component to check
  5535. * @returns true if the rgb values are equal to the given ones
  5536. */
  5537. equalsFloats(r: number, g: number, b: number): boolean;
  5538. /**
  5539. * Multiplies in place each rgb value by scale
  5540. * @param scale defines the scaling factor
  5541. * @returns the updated Color3
  5542. */
  5543. scale(scale: number): Color3;
  5544. /**
  5545. * Multiplies the rgb values by scale and stores the result into "result"
  5546. * @param scale defines the scaling factor
  5547. * @param result defines the Color3 object where to store the result
  5548. * @returns the unmodified current Color3
  5549. */
  5550. scaleToRef(scale: number, result: Color3): Color3;
  5551. /**
  5552. * Scale the current Color3 values by a factor and add the result to a given Color3
  5553. * @param scale defines the scale factor
  5554. * @param result defines color to store the result into
  5555. * @returns the unmodified current Color3
  5556. */
  5557. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5558. /**
  5559. * Clamps the rgb values by the min and max values and stores the result into "result"
  5560. * @param min defines minimum clamping value (default is 0)
  5561. * @param max defines maximum clamping value (default is 1)
  5562. * @param result defines color to store the result into
  5563. * @returns the original Color3
  5564. */
  5565. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5566. /**
  5567. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5568. * @param otherColor defines the second operand
  5569. * @returns the new Color3
  5570. */
  5571. add(otherColor: DeepImmutable<Color3>): Color3;
  5572. /**
  5573. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5574. * @param otherColor defines the second operand
  5575. * @param result defines Color3 object to store the result into
  5576. * @returns the unmodified current Color3
  5577. */
  5578. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5579. /**
  5580. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5581. * @param otherColor defines the second operand
  5582. * @returns the new Color3
  5583. */
  5584. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5585. /**
  5586. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5587. * @param otherColor defines the second operand
  5588. * @param result defines Color3 object to store the result into
  5589. * @returns the unmodified current Color3
  5590. */
  5591. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5592. /**
  5593. * Copy the current object
  5594. * @returns a new Color3 copied the current one
  5595. */
  5596. clone(): Color3;
  5597. /**
  5598. * Copies the rgb values from the source in the current Color3
  5599. * @param source defines the source Color3 object
  5600. * @returns the updated Color3 object
  5601. */
  5602. copyFrom(source: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Updates the Color3 rgb values from the given floats
  5605. * @param r defines the red component to read from
  5606. * @param g defines the green component to read from
  5607. * @param b defines the blue component to read from
  5608. * @returns the current Color3 object
  5609. */
  5610. copyFromFloats(r: number, g: number, b: number): Color3;
  5611. /**
  5612. * Updates the Color3 rgb values from the given floats
  5613. * @param r defines the red component to read from
  5614. * @param g defines the green component to read from
  5615. * @param b defines the blue component to read from
  5616. * @returns the current Color3 object
  5617. */
  5618. set(r: number, g: number, b: number): Color3;
  5619. /**
  5620. * Compute the Color3 hexadecimal code as a string
  5621. * @returns a string containing the hexadecimal representation of the Color3 object
  5622. */
  5623. toHexString(): string;
  5624. /**
  5625. * Computes a new Color3 converted from the current one to linear space
  5626. * @returns a new Color3 object
  5627. */
  5628. toLinearSpace(): Color3;
  5629. /**
  5630. * Converts current color in rgb space to HSV values
  5631. * @returns a new color3 representing the HSV values
  5632. */
  5633. toHSV(): Color3;
  5634. /**
  5635. * Converts current color in rgb space to HSV values
  5636. * @param result defines the Color3 where to store the HSV values
  5637. */
  5638. toHSVToRef(result: Color3): void;
  5639. /**
  5640. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5641. * @param convertedColor defines the Color3 object where to store the linear space version
  5642. * @returns the unmodified Color3
  5643. */
  5644. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5645. /**
  5646. * Computes a new Color3 converted from the current one to gamma space
  5647. * @returns a new Color3 object
  5648. */
  5649. toGammaSpace(): Color3;
  5650. /**
  5651. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5652. * @param convertedColor defines the Color3 object where to store the gamma space version
  5653. * @returns the unmodified Color3
  5654. */
  5655. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5656. private static _BlackReadOnly;
  5657. /**
  5658. * Convert Hue, saturation and value to a Color3 (RGB)
  5659. * @param hue defines the hue
  5660. * @param saturation defines the saturation
  5661. * @param value defines the value
  5662. * @param result defines the Color3 where to store the RGB values
  5663. */
  5664. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5665. /**
  5666. * Creates a new Color3 from the string containing valid hexadecimal values
  5667. * @param hex defines a string containing valid hexadecimal values
  5668. * @returns a new Color3 object
  5669. */
  5670. static FromHexString(hex: string): Color3;
  5671. /**
  5672. * Creates a new Color3 from the starting index of the given array
  5673. * @param array defines the source array
  5674. * @param offset defines an offset in the source array
  5675. * @returns a new Color3 object
  5676. */
  5677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5678. /**
  5679. * Creates a new Color3 from integer values (< 256)
  5680. * @param r defines the red component to read from (value between 0 and 255)
  5681. * @param g defines the green component to read from (value between 0 and 255)
  5682. * @param b defines the blue component to read from (value between 0 and 255)
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromInts(r: number, g: number, b: number): Color3;
  5686. /**
  5687. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5688. * @param start defines the start Color3 value
  5689. * @param end defines the end Color3 value
  5690. * @param amount defines the gradient value between start and end
  5691. * @returns a new Color3 object
  5692. */
  5693. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5694. /**
  5695. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color3 object where to store the result
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5702. /**
  5703. * Returns a Color3 value containing a red color
  5704. * @returns a new Color3 object
  5705. */
  5706. static Red(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a green color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Green(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a blue color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Blue(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a black color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Black(): Color3;
  5722. /**
  5723. * Gets a Color3 value containing a black color that must not be updated
  5724. */
  5725. static get BlackReadOnly(): DeepImmutable<Color3>;
  5726. /**
  5727. * Returns a Color3 value containing a white color
  5728. * @returns a new Color3 object
  5729. */
  5730. static White(): Color3;
  5731. /**
  5732. * Returns a Color3 value containing a purple color
  5733. * @returns a new Color3 object
  5734. */
  5735. static Purple(): Color3;
  5736. /**
  5737. * Returns a Color3 value containing a magenta color
  5738. * @returns a new Color3 object
  5739. */
  5740. static Magenta(): Color3;
  5741. /**
  5742. * Returns a Color3 value containing a yellow color
  5743. * @returns a new Color3 object
  5744. */
  5745. static Yellow(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a gray color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Gray(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a teal color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Teal(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a random color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Random(): Color3;
  5761. }
  5762. /**
  5763. * Class used to hold a RBGA color
  5764. */
  5765. export class Color4 {
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r: number;
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g: number;
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b: number;
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a: number;
  5782. /**
  5783. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5784. * @param r defines the red component (between 0 and 1, default is 0)
  5785. * @param g defines the green component (between 0 and 1, default is 0)
  5786. * @param b defines the blue component (between 0 and 1, default is 0)
  5787. * @param a defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. constructor(
  5790. /**
  5791. * Defines the red component (between 0 and 1, default is 0)
  5792. */
  5793. r?: number,
  5794. /**
  5795. * Defines the green component (between 0 and 1, default is 0)
  5796. */
  5797. g?: number,
  5798. /**
  5799. * Defines the blue component (between 0 and 1, default is 0)
  5800. */
  5801. b?: number,
  5802. /**
  5803. * Defines the alpha component (between 0 and 1, default is 1)
  5804. */
  5805. a?: number);
  5806. /**
  5807. * Adds in place the given Color4 values to the current Color4 object
  5808. * @param right defines the second operand
  5809. * @returns the current updated Color4 object
  5810. */
  5811. addInPlace(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5814. * @returns the new array
  5815. */
  5816. asArray(): number[];
  5817. /**
  5818. * Stores from the starting index in the given array the Color4 successive values
  5819. * @param array defines the array where to store the r,g,b components
  5820. * @param index defines an optional index in the target array to define where to start storing values
  5821. * @returns the current Color4 object
  5822. */
  5823. toArray(array: number[], index?: number): Color4;
  5824. /**
  5825. * Determines equality between Color4 objects
  5826. * @param otherColor defines the second operand
  5827. * @returns true if the rgba values are equal to the given ones
  5828. */
  5829. equals(otherColor: DeepImmutable<Color4>): boolean;
  5830. /**
  5831. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5832. * @param right defines the second operand
  5833. * @returns a new Color4 object
  5834. */
  5835. add(right: DeepImmutable<Color4>): Color4;
  5836. /**
  5837. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5838. * @param right defines the second operand
  5839. * @returns a new Color4 object
  5840. */
  5841. subtract(right: DeepImmutable<Color4>): Color4;
  5842. /**
  5843. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5844. * @param right defines the second operand
  5845. * @param result defines the Color4 object where to store the result
  5846. * @returns the current Color4 object
  5847. */
  5848. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5849. /**
  5850. * Creates a new Color4 with the current Color4 values multiplied by scale
  5851. * @param scale defines the scaling factor to apply
  5852. * @returns a new Color4 object
  5853. */
  5854. scale(scale: number): Color4;
  5855. /**
  5856. * Multiplies the current Color4 values by scale and stores the result in "result"
  5857. * @param scale defines the scaling factor to apply
  5858. * @param result defines the Color4 object where to store the result
  5859. * @returns the current unmodified Color4
  5860. */
  5861. scaleToRef(scale: number, result: Color4): Color4;
  5862. /**
  5863. * Scale the current Color4 values by a factor and add the result to a given Color4
  5864. * @param scale defines the scale factor
  5865. * @param result defines the Color4 object where to store the result
  5866. * @returns the unmodified current Color4
  5867. */
  5868. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5869. /**
  5870. * Clamps the rgb values by the min and max values and stores the result into "result"
  5871. * @param min defines minimum clamping value (default is 0)
  5872. * @param max defines maximum clamping value (default is 1)
  5873. * @param result defines color to store the result into.
  5874. * @returns the cuurent Color4
  5875. */
  5876. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5877. /**
  5878. * Multipy an Color4 value by another and return a new Color4 object
  5879. * @param color defines the Color4 value to multiply by
  5880. * @returns a new Color4 object
  5881. */
  5882. multiply(color: Color4): Color4;
  5883. /**
  5884. * Multipy a Color4 value by another and push the result in a reference value
  5885. * @param color defines the Color4 value to multiply by
  5886. * @param result defines the Color4 to fill the result in
  5887. * @returns the result Color4
  5888. */
  5889. multiplyToRef(color: Color4, result: Color4): Color4;
  5890. /**
  5891. * Creates a string with the Color4 current values
  5892. * @returns the string representation of the Color4 object
  5893. */
  5894. toString(): string;
  5895. /**
  5896. * Returns the string "Color4"
  5897. * @returns "Color4"
  5898. */
  5899. getClassName(): string;
  5900. /**
  5901. * Compute the Color4 hash code
  5902. * @returns an unique number that can be used to hash Color4 objects
  5903. */
  5904. getHashCode(): number;
  5905. /**
  5906. * Creates a new Color4 copied from the current one
  5907. * @returns a new Color4 object
  5908. */
  5909. clone(): Color4;
  5910. /**
  5911. * Copies the given Color4 values into the current one
  5912. * @param source defines the source Color4 object
  5913. * @returns the current updated Color4 object
  5914. */
  5915. copyFrom(source: Color4): Color4;
  5916. /**
  5917. * Copies the given float values into the current one
  5918. * @param r defines the red component to read from
  5919. * @param g defines the green component to read from
  5920. * @param b defines the blue component to read from
  5921. * @param a defines the alpha component to read from
  5922. * @returns the current updated Color4 object
  5923. */
  5924. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5925. /**
  5926. * Copies the given float values into the current one
  5927. * @param r defines the red component to read from
  5928. * @param g defines the green component to read from
  5929. * @param b defines the blue component to read from
  5930. * @param a defines the alpha component to read from
  5931. * @returns the current updated Color4 object
  5932. */
  5933. set(r: number, g: number, b: number, a: number): Color4;
  5934. /**
  5935. * Compute the Color4 hexadecimal code as a string
  5936. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5937. * @returns a string containing the hexadecimal representation of the Color4 object
  5938. */
  5939. toHexString(returnAsColor3?: boolean): string;
  5940. /**
  5941. * Computes a new Color4 converted from the current one to linear space
  5942. * @returns a new Color4 object
  5943. */
  5944. toLinearSpace(): Color4;
  5945. /**
  5946. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5947. * @param convertedColor defines the Color4 object where to store the linear space version
  5948. * @returns the unmodified Color4
  5949. */
  5950. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5951. /**
  5952. * Computes a new Color4 converted from the current one to gamma space
  5953. * @returns a new Color4 object
  5954. */
  5955. toGammaSpace(): Color4;
  5956. /**
  5957. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5958. * @param convertedColor defines the Color4 object where to store the gamma space version
  5959. * @returns the unmodified Color4
  5960. */
  5961. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5962. /**
  5963. * Creates a new Color4 from the string containing valid hexadecimal values
  5964. * @param hex defines a string containing valid hexadecimal values
  5965. * @returns a new Color4 object
  5966. */
  5967. static FromHexString(hex: string): Color4;
  5968. /**
  5969. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5970. * @param left defines the start value
  5971. * @param right defines the end value
  5972. * @param amount defines the gradient factor
  5973. * @returns a new Color4 object
  5974. */
  5975. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5976. /**
  5977. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5978. * @param left defines the start value
  5979. * @param right defines the end value
  5980. * @param amount defines the gradient factor
  5981. * @param result defines the Color4 object where to store data
  5982. */
  5983. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5984. /**
  5985. * Creates a new Color4 from a Color3 and an alpha value
  5986. * @param color3 defines the source Color3 to read from
  5987. * @param alpha defines the alpha component (1.0 by default)
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5991. /**
  5992. * Creates a new Color4 from the starting index element of the given array
  5993. * @param array defines the source array to read from
  5994. * @param offset defines the offset in the source array
  5995. * @returns a new Color4 object
  5996. */
  5997. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5998. /**
  5999. * Creates a new Color3 from integer values (< 256)
  6000. * @param r defines the red component to read from (value between 0 and 255)
  6001. * @param g defines the green component to read from (value between 0 and 255)
  6002. * @param b defines the blue component to read from (value between 0 and 255)
  6003. * @param a defines the alpha component to read from (value between 0 and 255)
  6004. * @returns a new Color3 object
  6005. */
  6006. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6007. /**
  6008. * Check the content of a given array and convert it to an array containing RGBA data
  6009. * If the original array was already containing count * 4 values then it is returned directly
  6010. * @param colors defines the array to check
  6011. * @param count defines the number of RGBA data to expect
  6012. * @returns an array containing count * 4 values (RGBA)
  6013. */
  6014. static CheckColors4(colors: number[], count: number): number[];
  6015. }
  6016. /**
  6017. * @hidden
  6018. */
  6019. export class TmpColors {
  6020. static Color3: Color3[];
  6021. static Color4: Color4[];
  6022. }
  6023. }
  6024. declare module BABYLON {
  6025. /**
  6026. * Defines an interface which represents an animation key frame
  6027. */
  6028. export interface IAnimationKey {
  6029. /**
  6030. * Frame of the key frame
  6031. */
  6032. frame: number;
  6033. /**
  6034. * Value at the specifies key frame
  6035. */
  6036. value: any;
  6037. /**
  6038. * The input tangent for the cubic hermite spline
  6039. */
  6040. inTangent?: any;
  6041. /**
  6042. * The output tangent for the cubic hermite spline
  6043. */
  6044. outTangent?: any;
  6045. /**
  6046. * The animation interpolation type
  6047. */
  6048. interpolation?: AnimationKeyInterpolation;
  6049. }
  6050. /**
  6051. * Enum for the animation key frame interpolation type
  6052. */
  6053. export enum AnimationKeyInterpolation {
  6054. /**
  6055. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6056. */
  6057. STEP = 1
  6058. }
  6059. }
  6060. declare module BABYLON {
  6061. /**
  6062. * Represents the range of an animation
  6063. */
  6064. export class AnimationRange {
  6065. /**The name of the animation range**/
  6066. name: string;
  6067. /**The starting frame of the animation */
  6068. from: number;
  6069. /**The ending frame of the animation*/
  6070. to: number;
  6071. /**
  6072. * Initializes the range of an animation
  6073. * @param name The name of the animation range
  6074. * @param from The starting frame of the animation
  6075. * @param to The ending frame of the animation
  6076. */
  6077. constructor(
  6078. /**The name of the animation range**/
  6079. name: string,
  6080. /**The starting frame of the animation */
  6081. from: number,
  6082. /**The ending frame of the animation*/
  6083. to: number);
  6084. /**
  6085. * Makes a copy of the animation range
  6086. * @returns A copy of the animation range
  6087. */
  6088. clone(): AnimationRange;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. /**
  6093. * Composed of a frame, and an action function
  6094. */
  6095. export class AnimationEvent {
  6096. /** The frame for which the event is triggered **/
  6097. frame: number;
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void;
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined;
  6102. /**
  6103. * Specifies if the animation event is done
  6104. */
  6105. isDone: boolean;
  6106. /**
  6107. * Initializes the animation event
  6108. * @param frame The frame for which the event is triggered
  6109. * @param action The event to perform when triggered
  6110. * @param onlyOnce Specifies if the event should be triggered only once
  6111. */
  6112. constructor(
  6113. /** The frame for which the event is triggered **/
  6114. frame: number,
  6115. /** The event to perform when triggered **/
  6116. action: (currentFrame: number) => void,
  6117. /** Specifies if the event should be triggered only once**/
  6118. onlyOnce?: boolean | undefined);
  6119. /** @hidden */
  6120. _clone(): AnimationEvent;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * Interface used to define a behavior
  6126. */
  6127. export interface Behavior<T> {
  6128. /** gets or sets behavior's name */
  6129. name: string;
  6130. /**
  6131. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6132. */
  6133. init(): void;
  6134. /**
  6135. * Called when the behavior is attached to a target
  6136. * @param target defines the target where the behavior is attached to
  6137. */
  6138. attach(target: T): void;
  6139. /**
  6140. * Called when the behavior is detached from its target
  6141. */
  6142. detach(): void;
  6143. }
  6144. /**
  6145. * Interface implemented by classes supporting behaviors
  6146. */
  6147. export interface IBehaviorAware<T> {
  6148. /**
  6149. * Attach a behavior
  6150. * @param behavior defines the behavior to attach
  6151. * @returns the current host
  6152. */
  6153. addBehavior(behavior: Behavior<T>): T;
  6154. /**
  6155. * Remove a behavior from the current object
  6156. * @param behavior defines the behavior to detach
  6157. * @returns the current host
  6158. */
  6159. removeBehavior(behavior: Behavior<T>): T;
  6160. /**
  6161. * Gets a behavior using its name to search
  6162. * @param name defines the name to search
  6163. * @returns the behavior or null if not found
  6164. */
  6165. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Defines an array and its length.
  6171. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6172. */
  6173. export interface ISmartArrayLike<T> {
  6174. /**
  6175. * The data of the array.
  6176. */
  6177. data: Array<T>;
  6178. /**
  6179. * The active length of the array.
  6180. */
  6181. length: number;
  6182. }
  6183. /**
  6184. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6185. */
  6186. export class SmartArray<T> implements ISmartArrayLike<T> {
  6187. /**
  6188. * The full set of data from the array.
  6189. */
  6190. data: Array<T>;
  6191. /**
  6192. * The active length of the array.
  6193. */
  6194. length: number;
  6195. protected _id: number;
  6196. /**
  6197. * Instantiates a Smart Array.
  6198. * @param capacity defines the default capacity of the array.
  6199. */
  6200. constructor(capacity: number);
  6201. /**
  6202. * Pushes a value at the end of the active data.
  6203. * @param value defines the object to push in the array.
  6204. */
  6205. push(value: T): void;
  6206. /**
  6207. * Iterates over the active data and apply the lambda to them.
  6208. * @param func defines the action to apply on each value.
  6209. */
  6210. forEach(func: (content: T) => void): void;
  6211. /**
  6212. * Sorts the full sets of data.
  6213. * @param compareFn defines the comparison function to apply.
  6214. */
  6215. sort(compareFn: (a: T, b: T) => number): void;
  6216. /**
  6217. * Resets the active data to an empty array.
  6218. */
  6219. reset(): void;
  6220. /**
  6221. * Releases all the data from the array as well as the array.
  6222. */
  6223. dispose(): void;
  6224. /**
  6225. * Concats the active data with a given array.
  6226. * @param array defines the data to concatenate with.
  6227. */
  6228. concat(array: any): void;
  6229. /**
  6230. * Returns the position of a value in the active data.
  6231. * @param value defines the value to find the index for
  6232. * @returns the index if found in the active data otherwise -1
  6233. */
  6234. indexOf(value: T): number;
  6235. /**
  6236. * Returns whether an element is part of the active data.
  6237. * @param value defines the value to look for
  6238. * @returns true if found in the active data otherwise false
  6239. */
  6240. contains(value: T): boolean;
  6241. private static _GlobalId;
  6242. }
  6243. /**
  6244. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6245. * The data in this array can only be present once
  6246. */
  6247. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6248. private _duplicateId;
  6249. /**
  6250. * Pushes a value at the end of the active data.
  6251. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6252. * @param value defines the object to push in the array.
  6253. */
  6254. push(value: T): void;
  6255. /**
  6256. * Pushes a value at the end of the active data.
  6257. * If the data is already present, it won t be added again
  6258. * @param value defines the object to push in the array.
  6259. * @returns true if added false if it was already present
  6260. */
  6261. pushNoDuplicate(value: T): boolean;
  6262. /**
  6263. * Resets the active data to an empty array.
  6264. */
  6265. reset(): void;
  6266. /**
  6267. * Concats the active data with a given array.
  6268. * This ensures no dupplicate will be present in the result.
  6269. * @param array defines the data to concatenate with.
  6270. */
  6271. concatWithNoDuplicate(array: any): void;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. /**
  6276. * @ignore
  6277. * This is a list of all the different input types that are available in the application.
  6278. * Fo instance: ArcRotateCameraGamepadInput...
  6279. */
  6280. export var CameraInputTypes: {};
  6281. /**
  6282. * This is the contract to implement in order to create a new input class.
  6283. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6284. */
  6285. export interface ICameraInput<TCamera extends Camera> {
  6286. /**
  6287. * Defines the camera the input is attached to.
  6288. */
  6289. camera: Nullable<TCamera>;
  6290. /**
  6291. * Gets the class name of the current intput.
  6292. * @returns the class name
  6293. */
  6294. getClassName(): string;
  6295. /**
  6296. * Get the friendly name associated with the input class.
  6297. * @returns the input friendly name
  6298. */
  6299. getSimpleName(): string;
  6300. /**
  6301. * Attach the input controls to a specific dom element to get the input from.
  6302. * @param element Defines the element the controls should be listened from
  6303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6304. */
  6305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6306. /**
  6307. * Detach the current controls from the specified dom element.
  6308. * @param element Defines the element to stop listening the inputs from
  6309. */
  6310. detachControl(element: Nullable<HTMLElement>): void;
  6311. /**
  6312. * Update the current camera state depending on the inputs that have been used this frame.
  6313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6314. */
  6315. checkInputs?: () => void;
  6316. }
  6317. /**
  6318. * Represents a map of input types to input instance or input index to input instance.
  6319. */
  6320. export interface CameraInputsMap<TCamera extends Camera> {
  6321. /**
  6322. * Accessor to the input by input type.
  6323. */
  6324. [name: string]: ICameraInput<TCamera>;
  6325. /**
  6326. * Accessor to the input by input index.
  6327. */
  6328. [idx: number]: ICameraInput<TCamera>;
  6329. }
  6330. /**
  6331. * This represents the input manager used within a camera.
  6332. * It helps dealing with all the different kind of input attached to a camera.
  6333. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6334. */
  6335. export class CameraInputsManager<TCamera extends Camera> {
  6336. /**
  6337. * Defines the list of inputs attahed to the camera.
  6338. */
  6339. attached: CameraInputsMap<TCamera>;
  6340. /**
  6341. * Defines the dom element the camera is collecting inputs from.
  6342. * This is null if the controls have not been attached.
  6343. */
  6344. attachedElement: Nullable<HTMLElement>;
  6345. /**
  6346. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6347. */
  6348. noPreventDefault: boolean;
  6349. /**
  6350. * Defined the camera the input manager belongs to.
  6351. */
  6352. camera: TCamera;
  6353. /**
  6354. * Update the current camera state depending on the inputs that have been used this frame.
  6355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6356. */
  6357. checkInputs: () => void;
  6358. /**
  6359. * Instantiate a new Camera Input Manager.
  6360. * @param camera Defines the camera the input manager blongs to
  6361. */
  6362. constructor(camera: TCamera);
  6363. /**
  6364. * Add an input method to a camera
  6365. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6366. * @param input camera input method
  6367. */
  6368. add(input: ICameraInput<TCamera>): void;
  6369. /**
  6370. * Remove a specific input method from a camera
  6371. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6372. * @param inputToRemove camera input method
  6373. */
  6374. remove(inputToRemove: ICameraInput<TCamera>): void;
  6375. /**
  6376. * Remove a specific input type from a camera
  6377. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6378. * @param inputType the type of the input to remove
  6379. */
  6380. removeByType(inputType: string): void;
  6381. private _addCheckInputs;
  6382. /**
  6383. * Attach the input controls to the currently attached dom element to listen the events from.
  6384. * @param input Defines the input to attach
  6385. */
  6386. attachInput(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6389. * @param element Defines the dom element to collect the events from
  6390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6391. */
  6392. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6393. /**
  6394. * Detach the current manager inputs controls from a specific dom element.
  6395. * @param element Defines the dom element to collect the events from
  6396. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6397. */
  6398. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6399. /**
  6400. * Rebuild the dynamic inputCheck function from the current list of
  6401. * defined inputs in the manager.
  6402. */
  6403. rebuildInputCheck(): void;
  6404. /**
  6405. * Remove all attached input methods from a camera
  6406. */
  6407. clear(): void;
  6408. /**
  6409. * Serialize the current input manager attached to a camera.
  6410. * This ensures than once parsed,
  6411. * the input associated to the camera will be identical to the current ones
  6412. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6413. */
  6414. serialize(serializedCamera: any): void;
  6415. /**
  6416. * Parses an input manager serialized JSON to restore the previous list of inputs
  6417. * and states associated to a camera.
  6418. * @param parsedCamera Defines the JSON to parse
  6419. */
  6420. parse(parsedCamera: any): void;
  6421. }
  6422. }
  6423. declare module BABYLON {
  6424. /**
  6425. * Class used to store data that will be store in GPU memory
  6426. */
  6427. export class Buffer {
  6428. private _engine;
  6429. private _buffer;
  6430. /** @hidden */
  6431. _data: Nullable<DataArray>;
  6432. private _updatable;
  6433. private _instanced;
  6434. private _divisor;
  6435. /**
  6436. * Gets the byte stride.
  6437. */
  6438. readonly byteStride: number;
  6439. /**
  6440. * Constructor
  6441. * @param engine the engine
  6442. * @param data the data to use for this buffer
  6443. * @param updatable whether the data is updatable
  6444. * @param stride the stride (optional)
  6445. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6446. * @param instanced whether the buffer is instanced (optional)
  6447. * @param useBytes set to true if the stride in in bytes (optional)
  6448. * @param divisor sets an optional divisor for instances (1 by default)
  6449. */
  6450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6451. /**
  6452. * Create a new VertexBuffer based on the current buffer
  6453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6454. * @param offset defines offset in the buffer (0 by default)
  6455. * @param size defines the size in floats of attributes (position is 3 for instance)
  6456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6457. * @param instanced defines if the vertex buffer contains indexed data
  6458. * @param useBytes defines if the offset and stride are in bytes *
  6459. * @param divisor sets an optional divisor for instances (1 by default)
  6460. * @returns the new vertex buffer
  6461. */
  6462. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6463. /**
  6464. * Gets a boolean indicating if the Buffer is updatable?
  6465. * @returns true if the buffer is updatable
  6466. */
  6467. isUpdatable(): boolean;
  6468. /**
  6469. * Gets current buffer's data
  6470. * @returns a DataArray or null
  6471. */
  6472. getData(): Nullable<DataArray>;
  6473. /**
  6474. * Gets underlying native buffer
  6475. * @returns underlying native buffer
  6476. */
  6477. getBuffer(): Nullable<DataBuffer>;
  6478. /**
  6479. * Gets the stride in float32 units (i.e. byte stride / 4).
  6480. * May not be an integer if the byte stride is not divisible by 4.
  6481. * @returns the stride in float32 units
  6482. * @deprecated Please use byteStride instead.
  6483. */
  6484. getStrideSize(): number;
  6485. /**
  6486. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6487. * @param data defines the data to store
  6488. */
  6489. create(data?: Nullable<DataArray>): void;
  6490. /** @hidden */
  6491. _rebuild(): void;
  6492. /**
  6493. * Update current buffer data
  6494. * @param data defines the data to store
  6495. */
  6496. update(data: DataArray): void;
  6497. /**
  6498. * Updates the data directly.
  6499. * @param data the new data
  6500. * @param offset the new offset
  6501. * @param vertexCount the vertex count (optional)
  6502. * @param useBytes set to true if the offset is in bytes
  6503. */
  6504. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6505. /**
  6506. * Release all resources
  6507. */
  6508. dispose(): void;
  6509. }
  6510. /**
  6511. * Specialized buffer used to store vertex data
  6512. */
  6513. export class VertexBuffer {
  6514. /** @hidden */
  6515. _buffer: Buffer;
  6516. private _kind;
  6517. private _size;
  6518. private _ownsBuffer;
  6519. private _instanced;
  6520. private _instanceDivisor;
  6521. /**
  6522. * The byte type.
  6523. */
  6524. static readonly BYTE: number;
  6525. /**
  6526. * The unsigned byte type.
  6527. */
  6528. static readonly UNSIGNED_BYTE: number;
  6529. /**
  6530. * The short type.
  6531. */
  6532. static readonly SHORT: number;
  6533. /**
  6534. * The unsigned short type.
  6535. */
  6536. static readonly UNSIGNED_SHORT: number;
  6537. /**
  6538. * The integer type.
  6539. */
  6540. static readonly INT: number;
  6541. /**
  6542. * The unsigned integer type.
  6543. */
  6544. static readonly UNSIGNED_INT: number;
  6545. /**
  6546. * The float type.
  6547. */
  6548. static readonly FLOAT: number;
  6549. /**
  6550. * Gets or sets the instance divisor when in instanced mode
  6551. */
  6552. get instanceDivisor(): number;
  6553. set instanceDivisor(value: number);
  6554. /**
  6555. * Gets the byte stride.
  6556. */
  6557. readonly byteStride: number;
  6558. /**
  6559. * Gets the byte offset.
  6560. */
  6561. readonly byteOffset: number;
  6562. /**
  6563. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6564. */
  6565. readonly normalized: boolean;
  6566. /**
  6567. * Gets the data type of each component in the array.
  6568. */
  6569. readonly type: number;
  6570. /**
  6571. * Constructor
  6572. * @param engine the engine
  6573. * @param data the data to use for this vertex buffer
  6574. * @param kind the vertex buffer kind
  6575. * @param updatable whether the data is updatable
  6576. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6577. * @param stride the stride (optional)
  6578. * @param instanced whether the buffer is instanced (optional)
  6579. * @param offset the offset of the data (optional)
  6580. * @param size the number of components (optional)
  6581. * @param type the type of the component (optional)
  6582. * @param normalized whether the data contains normalized data (optional)
  6583. * @param useBytes set to true if stride and offset are in bytes (optional)
  6584. * @param divisor defines the instance divisor to use (1 by default)
  6585. */
  6586. 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);
  6587. /** @hidden */
  6588. _rebuild(): void;
  6589. /**
  6590. * Returns the kind of the VertexBuffer (string)
  6591. * @returns a string
  6592. */
  6593. getKind(): string;
  6594. /**
  6595. * Gets a boolean indicating if the VertexBuffer is updatable?
  6596. * @returns true if the buffer is updatable
  6597. */
  6598. isUpdatable(): boolean;
  6599. /**
  6600. * Gets current buffer's data
  6601. * @returns a DataArray or null
  6602. */
  6603. getData(): Nullable<DataArray>;
  6604. /**
  6605. * Gets underlying native buffer
  6606. * @returns underlying native buffer
  6607. */
  6608. getBuffer(): Nullable<DataBuffer>;
  6609. /**
  6610. * Gets the stride in float32 units (i.e. byte stride / 4).
  6611. * May not be an integer if the byte stride is not divisible by 4.
  6612. * @returns the stride in float32 units
  6613. * @deprecated Please use byteStride instead.
  6614. */
  6615. getStrideSize(): number;
  6616. /**
  6617. * Returns the offset as a multiple of the type byte length.
  6618. * @returns the offset in bytes
  6619. * @deprecated Please use byteOffset instead.
  6620. */
  6621. getOffset(): number;
  6622. /**
  6623. * Returns the number of components per vertex attribute (integer)
  6624. * @returns the size in float
  6625. */
  6626. getSize(): number;
  6627. /**
  6628. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6629. * @returns true if this buffer is instanced
  6630. */
  6631. getIsInstanced(): boolean;
  6632. /**
  6633. * Returns the instancing divisor, zero for non-instanced (integer).
  6634. * @returns a number
  6635. */
  6636. getInstanceDivisor(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: DataArray): void;
  6642. /**
  6643. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6644. * This function will create a new buffer if the current one is not updatable
  6645. * @param data defines the data to store
  6646. */
  6647. update(data: DataArray): void;
  6648. /**
  6649. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6650. * Returns the directly updated WebGLBuffer.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param useBytes set to true if the offset is in bytes
  6654. */
  6655. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6656. /**
  6657. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6658. */
  6659. dispose(): void;
  6660. /**
  6661. * Enumerates each value of this vertex buffer as numbers.
  6662. * @param count the number of values to enumerate
  6663. * @param callback the callback function called for each value
  6664. */
  6665. forEach(count: number, callback: (value: number, index: number) => void): void;
  6666. /**
  6667. * Positions
  6668. */
  6669. static readonly PositionKind: string;
  6670. /**
  6671. * Normals
  6672. */
  6673. static readonly NormalKind: string;
  6674. /**
  6675. * Tangents
  6676. */
  6677. static readonly TangentKind: string;
  6678. /**
  6679. * Texture coordinates
  6680. */
  6681. static readonly UVKind: string;
  6682. /**
  6683. * Texture coordinates 2
  6684. */
  6685. static readonly UV2Kind: string;
  6686. /**
  6687. * Texture coordinates 3
  6688. */
  6689. static readonly UV3Kind: string;
  6690. /**
  6691. * Texture coordinates 4
  6692. */
  6693. static readonly UV4Kind: string;
  6694. /**
  6695. * Texture coordinates 5
  6696. */
  6697. static readonly UV5Kind: string;
  6698. /**
  6699. * Texture coordinates 6
  6700. */
  6701. static readonly UV6Kind: string;
  6702. /**
  6703. * Colors
  6704. */
  6705. static readonly ColorKind: string;
  6706. /**
  6707. * Matrix indices (for bones)
  6708. */
  6709. static readonly MatricesIndicesKind: string;
  6710. /**
  6711. * Matrix weights (for bones)
  6712. */
  6713. static readonly MatricesWeightsKind: string;
  6714. /**
  6715. * Additional matrix indices (for bones)
  6716. */
  6717. static readonly MatricesIndicesExtraKind: string;
  6718. /**
  6719. * Additional matrix weights (for bones)
  6720. */
  6721. static readonly MatricesWeightsExtraKind: string;
  6722. /**
  6723. * Deduces the stride given a kind.
  6724. * @param kind The kind string to deduce
  6725. * @returns The deduced stride
  6726. */
  6727. static DeduceStride(kind: string): number;
  6728. /**
  6729. * Gets the byte length of the given type.
  6730. * @param type the type
  6731. * @returns the number of bytes
  6732. */
  6733. static GetTypeByteLength(type: number): number;
  6734. /**
  6735. * Enumerates each value of the given parameters as numbers.
  6736. * @param data the data to enumerate
  6737. * @param byteOffset the byte offset of the data
  6738. * @param byteStride the byte stride of the data
  6739. * @param componentCount the number of components per element
  6740. * @param componentType the type of the component
  6741. * @param count the number of values to enumerate
  6742. * @param normalized whether the data is normalized
  6743. * @param callback the callback function called for each value
  6744. */
  6745. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6746. private static _GetFloatValue;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module BABYLON {
  6763. /**
  6764. * Class used to store bounding sphere information
  6765. */
  6766. export class BoundingSphere {
  6767. /**
  6768. * Gets the center of the bounding sphere in local space
  6769. */
  6770. readonly center: Vector3;
  6771. /**
  6772. * Radius of the bounding sphere in local space
  6773. */
  6774. radius: number;
  6775. /**
  6776. * Gets the center of the bounding sphere in world space
  6777. */
  6778. readonly centerWorld: Vector3;
  6779. /**
  6780. * Radius of the bounding sphere in world space
  6781. */
  6782. radiusWorld: number;
  6783. /**
  6784. * Gets the minimum vector in local space
  6785. */
  6786. readonly minimum: Vector3;
  6787. /**
  6788. * Gets the maximum vector in local space
  6789. */
  6790. readonly maximum: Vector3;
  6791. private _worldMatrix;
  6792. private static readonly TmpVector3;
  6793. /**
  6794. * Creates a new bounding sphere
  6795. * @param min defines the minimum vector (in local space)
  6796. * @param max defines the maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6800. /**
  6801. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6802. * @param min defines the new minimum vector (in local space)
  6803. * @param max defines the new maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6807. /**
  6808. * Scale the current bounding sphere by applying a scale factor
  6809. * @param factor defines the scale factor to apply
  6810. * @returns the current bounding box
  6811. */
  6812. scale(factor: number): BoundingSphere;
  6813. /**
  6814. * Gets the world matrix of the bounding box
  6815. * @returns a matrix
  6816. */
  6817. getWorldMatrix(): DeepImmutable<Matrix>;
  6818. /** @hidden */
  6819. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */
  6902. _tag: number;
  6903. /**
  6904. * Creates a new bounding box
  6905. * @param min defines the minimum vector (in local space)
  6906. * @param max defines the maximum vector (in local space)
  6907. * @param worldMatrix defines the new world matrix
  6908. */
  6909. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6910. /**
  6911. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6912. * @param min defines the new minimum vector (in local space)
  6913. * @param max defines the new maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6917. /**
  6918. * Scale the current bounding box by applying a scale factor
  6919. * @param factor defines the scale factor to apply
  6920. * @returns the current bounding box
  6921. */
  6922. scale(factor: number): BoundingBox;
  6923. /**
  6924. * Gets the world matrix of the bounding box
  6925. * @returns a matrix
  6926. */
  6927. getWorldMatrix(): DeepImmutable<Matrix>;
  6928. /** @hidden */
  6929. _update(world: DeepImmutable<Matrix>): void;
  6930. /**
  6931. * Tests if the bounding box is intersecting the frustum planes
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if there is an intersection
  6934. */
  6935. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if the bounding box is entirely inside the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an inclusion
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a point is inside the bounding box
  6944. * @param point defines the point to test
  6945. * @returns true if the point is inside the bounding box
  6946. */
  6947. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6948. /**
  6949. * Tests if the bounding box intersects with a bounding sphere
  6950. * @param sphere defines the sphere to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6954. /**
  6955. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6956. * @param min defines the min vector to use
  6957. * @param max defines the max vector to use
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Tests if two bounding boxes are intersections
  6963. * @param box0 defines the first box to test
  6964. * @param box1 defines the second box to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6968. /**
  6969. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6970. * @param minPoint defines the minimum vector of the bounding box
  6971. * @param maxPoint defines the maximum vector of the bounding box
  6972. * @param sphereCenter defines the sphere center
  6973. * @param sphereRadius defines the sphere radius
  6974. * @returns true if there is an intersection
  6975. */
  6976. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6977. /**
  6978. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @return true if there is an inclusion
  6982. */
  6983. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an intersection
  6989. */
  6990. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /** @hidden */
  6995. export class Collider {
  6996. /** Define if a collision was found */
  6997. collisionFound: boolean;
  6998. /**
  6999. * Define last intersection point in local space
  7000. */
  7001. intersectionPoint: Vector3;
  7002. /**
  7003. * Define last collided mesh
  7004. */
  7005. collidedMesh: Nullable<AbstractMesh>;
  7006. private _collisionPoint;
  7007. private _planeIntersectionPoint;
  7008. private _tempVector;
  7009. private _tempVector2;
  7010. private _tempVector3;
  7011. private _tempVector4;
  7012. private _edge;
  7013. private _baseToVertex;
  7014. private _destinationPoint;
  7015. private _slidePlaneNormal;
  7016. private _displacementVector;
  7017. /** @hidden */
  7018. _radius: Vector3;
  7019. /** @hidden */
  7020. _retry: number;
  7021. private _velocity;
  7022. private _basePoint;
  7023. private _epsilon;
  7024. /** @hidden */
  7025. _velocityWorldLength: number;
  7026. /** @hidden */
  7027. _basePointWorld: Vector3;
  7028. private _velocityWorld;
  7029. private _normalizedVelocity;
  7030. /** @hidden */
  7031. _initialVelocity: Vector3;
  7032. /** @hidden */
  7033. _initialPosition: Vector3;
  7034. private _nearestDistance;
  7035. private _collisionMask;
  7036. get collisionMask(): number;
  7037. set collisionMask(mask: number);
  7038. /**
  7039. * Gets the plane normal used to compute the sliding response (in local space)
  7040. */
  7041. get slidePlaneNormal(): Vector3;
  7042. /** @hidden */
  7043. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7044. /** @hidden */
  7045. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7046. /** @hidden */
  7047. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7048. /** @hidden */
  7049. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7050. /** @hidden */
  7051. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7052. /** @hidden */
  7053. _getResponse(pos: Vector3, vel: Vector3): void;
  7054. }
  7055. }
  7056. declare module BABYLON {
  7057. /**
  7058. * Interface for cullable objects
  7059. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7060. */
  7061. export interface ICullable {
  7062. /**
  7063. * Checks if the object or part of the object is in the frustum
  7064. * @param frustumPlanes Camera near/planes
  7065. * @returns true if the object is in frustum otherwise false
  7066. */
  7067. isInFrustum(frustumPlanes: Plane[]): boolean;
  7068. /**
  7069. * Checks if a cullable object (mesh...) is in the camera frustum
  7070. * Unlike isInFrustum this cheks the full bounding box
  7071. * @param frustumPlanes Camera near/planes
  7072. * @returns true if the object is in frustum otherwise false
  7073. */
  7074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7075. }
  7076. /**
  7077. * Info for a bounding data of a mesh
  7078. */
  7079. export class BoundingInfo implements ICullable {
  7080. /**
  7081. * Bounding box for the mesh
  7082. */
  7083. readonly boundingBox: BoundingBox;
  7084. /**
  7085. * Bounding sphere for the mesh
  7086. */
  7087. readonly boundingSphere: BoundingSphere;
  7088. private _isLocked;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * Constructs bounding info
  7092. * @param minimum min vector of the bounding box/sphere
  7093. * @param maximum max vector of the bounding box/sphere
  7094. * @param worldMatrix defines the new world matrix
  7095. */
  7096. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7097. /**
  7098. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7099. * @param min defines the new minimum vector (in local space)
  7100. * @param max defines the new maximum vector (in local space)
  7101. * @param worldMatrix defines the new world matrix
  7102. */
  7103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7104. /**
  7105. * min vector of the bounding box/sphere
  7106. */
  7107. get minimum(): Vector3;
  7108. /**
  7109. * max vector of the bounding box/sphere
  7110. */
  7111. get maximum(): Vector3;
  7112. /**
  7113. * If the info is locked and won't be updated to avoid perf overhead
  7114. */
  7115. get isLocked(): boolean;
  7116. set isLocked(value: boolean);
  7117. /**
  7118. * Updates the bounding sphere and box
  7119. * @param world world matrix to be used to update
  7120. */
  7121. update(world: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7124. * @param center New center of the bounding info
  7125. * @param extend New extend of the bounding info
  7126. * @returns the current bounding info
  7127. */
  7128. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7129. /**
  7130. * Scale the current bounding info by applying a scale factor
  7131. * @param factor defines the scale factor to apply
  7132. * @returns the current bounding info
  7133. */
  7134. scale(factor: number): BoundingInfo;
  7135. /**
  7136. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7137. * @param frustumPlanes defines the frustum to test
  7138. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7139. * @returns true if the bounding info is in the frustum planes
  7140. */
  7141. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7142. /**
  7143. * Gets the world distance between the min and max points of the bounding box
  7144. */
  7145. get diagonalLength(): number;
  7146. /**
  7147. * Checks if a cullable object (mesh...) is in the camera frustum
  7148. * Unlike isInFrustum this cheks the full bounding box
  7149. * @param frustumPlanes Camera near/planes
  7150. * @returns true if the object is in frustum otherwise false
  7151. */
  7152. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7153. /** @hidden */
  7154. _checkCollision(collider: Collider): boolean;
  7155. /**
  7156. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7157. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7158. * @param point the point to check intersection with
  7159. * @returns if the point intersects
  7160. */
  7161. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7162. /**
  7163. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7164. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7165. * @param boundingInfo the bounding info to check intersection with
  7166. * @param precise if the intersection should be done using OBB
  7167. * @returns if the bounding info intersects
  7168. */
  7169. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7170. }
  7171. }
  7172. declare module BABYLON {
  7173. /**
  7174. * Extracts minimum and maximum values from a list of indexed positions
  7175. * @param positions defines the positions to use
  7176. * @param indices defines the indices to the positions
  7177. * @param indexStart defines the start index
  7178. * @param indexCount defines the end index
  7179. * @param bias defines bias value to add to the result
  7180. * @return minimum and maximum values
  7181. */
  7182. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7183. minimum: Vector3;
  7184. maximum: Vector3;
  7185. };
  7186. /**
  7187. * Extracts minimum and maximum values from a list of positions
  7188. * @param positions defines the positions to use
  7189. * @param start defines the start index in the positions array
  7190. * @param count defines the number of positions to handle
  7191. * @param bias defines bias value to add to the result
  7192. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7193. * @return minimum and maximum values
  7194. */
  7195. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7196. minimum: Vector3;
  7197. maximum: Vector3;
  7198. };
  7199. }
  7200. declare module BABYLON {
  7201. /** @hidden */
  7202. export class WebGLDataBuffer extends DataBuffer {
  7203. private _buffer;
  7204. constructor(resource: WebGLBuffer);
  7205. get underlyingResource(): any;
  7206. }
  7207. }
  7208. declare module BABYLON {
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. _getVertexShaderCode(): string | null;
  7227. _getFragmentShaderCode(): string | null;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. interface ThinEngine {
  7232. /**
  7233. * Create an uniform buffer
  7234. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7235. * @param elements defines the content of the uniform buffer
  7236. * @returns the webGL uniform buffer
  7237. */
  7238. createUniformBuffer(elements: FloatArray): DataBuffer;
  7239. /**
  7240. * Create a dynamic uniform buffer
  7241. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7242. * @param elements defines the content of the uniform buffer
  7243. * @returns the webGL uniform buffer
  7244. */
  7245. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7246. /**
  7247. * Update an existing uniform buffer
  7248. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7249. * @param uniformBuffer defines the target uniform buffer
  7250. * @param elements defines the content to update
  7251. * @param offset defines the offset in the uniform buffer where update should start
  7252. * @param count defines the size of the data to update
  7253. */
  7254. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7255. /**
  7256. * Bind an uniform buffer to the current webGL context
  7257. * @param buffer defines the buffer to bind
  7258. */
  7259. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7260. /**
  7261. * Bind a buffer to the current webGL context at a given location
  7262. * @param buffer defines the buffer to bind
  7263. * @param location defines the index where to bind the buffer
  7264. */
  7265. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7266. /**
  7267. * Bind a specific block at a given index in a specific shader program
  7268. * @param pipelineContext defines the pipeline context to use
  7269. * @param blockName defines the block name
  7270. * @param index defines the index where to bind the block
  7271. */
  7272. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7273. }
  7274. }
  7275. declare module BABYLON {
  7276. /**
  7277. * Uniform buffer objects.
  7278. *
  7279. * Handles blocks of uniform on the GPU.
  7280. *
  7281. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7282. *
  7283. * For more information, please refer to :
  7284. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7285. */
  7286. export class UniformBuffer {
  7287. private _engine;
  7288. private _buffer;
  7289. private _data;
  7290. private _bufferData;
  7291. private _dynamic?;
  7292. private _uniformLocations;
  7293. private _uniformSizes;
  7294. private _uniformLocationPointer;
  7295. private _needSync;
  7296. private _noUBO;
  7297. private _currentEffect;
  7298. /** @hidden */
  7299. _alreadyBound: boolean;
  7300. private static _MAX_UNIFORM_SIZE;
  7301. private static _tempBuffer;
  7302. /**
  7303. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7308. /**
  7309. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7314. /**
  7315. * Lambda to Update a single float in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateFloat: (name: string, x: number) => void;
  7320. /**
  7321. * Lambda to Update a vec2 of float in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7326. /**
  7327. * Lambda to Update a vec3 of float in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7332. /**
  7333. * Lambda to Update a vec4 of float in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateMatrix: (name: string, mat: Matrix) => void;
  7344. /**
  7345. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7346. * This is dynamic to allow compat with webgl 1 and 2.
  7347. * You will need to pass the name of the uniform as well as the value.
  7348. */
  7349. updateVector3: (name: string, vector: Vector3) => void;
  7350. /**
  7351. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7352. * This is dynamic to allow compat with webgl 1 and 2.
  7353. * You will need to pass the name of the uniform as well as the value.
  7354. */
  7355. updateVector4: (name: string, vector: Vector4) => void;
  7356. /**
  7357. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7358. * This is dynamic to allow compat with webgl 1 and 2.
  7359. * You will need to pass the name of the uniform as well as the value.
  7360. */
  7361. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7362. /**
  7363. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7364. * This is dynamic to allow compat with webgl 1 and 2.
  7365. * You will need to pass the name of the uniform as well as the value.
  7366. */
  7367. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7368. /**
  7369. * Instantiates a new Uniform buffer objects.
  7370. *
  7371. * Handles blocks of uniform on the GPU.
  7372. *
  7373. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7374. *
  7375. * For more information, please refer to :
  7376. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7377. * @param engine Define the engine the buffer is associated with
  7378. * @param data Define the data contained in the buffer
  7379. * @param dynamic Define if the buffer is updatable
  7380. */
  7381. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7382. /**
  7383. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7384. * or just falling back on setUniformXXX calls.
  7385. */
  7386. get useUbo(): boolean;
  7387. /**
  7388. * Indicates if the WebGL underlying uniform buffer is in sync
  7389. * with the javascript cache data.
  7390. */
  7391. get isSync(): boolean;
  7392. /**
  7393. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7394. * Also, a dynamic UniformBuffer will disable cache verification and always
  7395. * update the underlying WebGL uniform buffer to the GPU.
  7396. * @returns if Dynamic, otherwise false
  7397. */
  7398. isDynamic(): boolean;
  7399. /**
  7400. * The data cache on JS side.
  7401. * @returns the underlying data as a float array
  7402. */
  7403. getData(): Float32Array;
  7404. /**
  7405. * The underlying WebGL Uniform buffer.
  7406. * @returns the webgl buffer
  7407. */
  7408. getBuffer(): Nullable<DataBuffer>;
  7409. /**
  7410. * std140 layout specifies how to align data within an UBO structure.
  7411. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7412. * for specs.
  7413. */
  7414. private _fillAlignment;
  7415. /**
  7416. * Adds an uniform in the buffer.
  7417. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7418. * for the layout to be correct !
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param size Data size, or data directly.
  7421. */
  7422. addUniform(name: string, size: number | number[]): void;
  7423. /**
  7424. * Adds a Matrix 4x4 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. * @param mat A 4x4 matrix.
  7427. */
  7428. addMatrix(name: string, mat: Matrix): void;
  7429. /**
  7430. * Adds a vec2 to the uniform buffer.
  7431. * @param name Name of the uniform, as used in the uniform block in the shader.
  7432. * @param x Define the x component value of the vec2
  7433. * @param y Define the y component value of the vec2
  7434. */
  7435. addFloat2(name: string, x: number, y: number): void;
  7436. /**
  7437. * Adds a vec3 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param x Define the x component value of the vec3
  7440. * @param y Define the y component value of the vec3
  7441. * @param z Define the z component value of the vec3
  7442. */
  7443. addFloat3(name: string, x: number, y: number, z: number): void;
  7444. /**
  7445. * Adds a vec3 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. * @param color Define the vec3 from a Color
  7448. */
  7449. addColor3(name: string, color: Color3): void;
  7450. /**
  7451. * Adds a vec4 to the uniform buffer.
  7452. * @param name Name of the uniform, as used in the uniform block in the shader.
  7453. * @param color Define the rgb components from a Color
  7454. * @param alpha Define the a component of the vec4
  7455. */
  7456. addColor4(name: string, color: Color3, alpha: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param vector Define the vec3 components from a Vector
  7461. */
  7462. addVector3(name: string, vector: Vector3): void;
  7463. /**
  7464. * Adds a Matrix 3x3 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. */
  7467. addMatrix3x3(name: string): void;
  7468. /**
  7469. * Adds a Matrix 2x2 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. */
  7472. addMatrix2x2(name: string): void;
  7473. /**
  7474. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7475. */
  7476. create(): void;
  7477. /** @hidden */
  7478. _rebuild(): void;
  7479. /**
  7480. * Updates the WebGL Uniform Buffer on the GPU.
  7481. * If the `dynamic` flag is set to true, no cache comparison is done.
  7482. * Otherwise, the buffer will be updated only if the cache differs.
  7483. */
  7484. update(): void;
  7485. /**
  7486. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7487. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7488. * @param data Define the flattened data
  7489. * @param size Define the size of the data.
  7490. */
  7491. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7492. private _valueCache;
  7493. private _cacheMatrix;
  7494. private _updateMatrix3x3ForUniform;
  7495. private _updateMatrix3x3ForEffect;
  7496. private _updateMatrix2x2ForEffect;
  7497. private _updateMatrix2x2ForUniform;
  7498. private _updateFloatForEffect;
  7499. private _updateFloatForUniform;
  7500. private _updateFloat2ForEffect;
  7501. private _updateFloat2ForUniform;
  7502. private _updateFloat3ForEffect;
  7503. private _updateFloat3ForUniform;
  7504. private _updateFloat4ForEffect;
  7505. private _updateFloat4ForUniform;
  7506. private _updateMatrixForEffect;
  7507. private _updateMatrixForUniform;
  7508. private _updateVector3ForEffect;
  7509. private _updateVector3ForUniform;
  7510. private _updateVector4ForEffect;
  7511. private _updateVector4ForUniform;
  7512. private _updateColor3ForEffect;
  7513. private _updateColor3ForUniform;
  7514. private _updateColor4ForEffect;
  7515. private _updateColor4ForUniform;
  7516. /**
  7517. * Sets a sampler uniform on the effect.
  7518. * @param name Define the name of the sampler.
  7519. * @param texture Define the texture to set in the sampler
  7520. */
  7521. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7522. /**
  7523. * Directly updates the value of the uniform in the cache AND on the GPU.
  7524. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7525. * @param data Define the flattened data
  7526. */
  7527. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7528. /**
  7529. * Binds this uniform buffer to an effect.
  7530. * @param effect Define the effect to bind the buffer to
  7531. * @param name Name of the uniform block in the shader.
  7532. */
  7533. bindToEffect(effect: Effect, name: string): void;
  7534. /**
  7535. * Disposes the uniform buffer.
  7536. */
  7537. dispose(): void;
  7538. }
  7539. }
  7540. declare module BABYLON {
  7541. /**
  7542. * Enum that determines the text-wrapping mode to use.
  7543. */
  7544. export enum InspectableType {
  7545. /**
  7546. * Checkbox for booleans
  7547. */
  7548. Checkbox = 0,
  7549. /**
  7550. * Sliders for numbers
  7551. */
  7552. Slider = 1,
  7553. /**
  7554. * Vector3
  7555. */
  7556. Vector3 = 2,
  7557. /**
  7558. * Quaternions
  7559. */
  7560. Quaternion = 3,
  7561. /**
  7562. * Color3
  7563. */
  7564. Color3 = 4,
  7565. /**
  7566. * String
  7567. */
  7568. String = 5
  7569. }
  7570. /**
  7571. * Interface used to define custom inspectable properties.
  7572. * This interface is used by the inspector to display custom property grids
  7573. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7574. */
  7575. export interface IInspectable {
  7576. /**
  7577. * Gets the label to display
  7578. */
  7579. label: string;
  7580. /**
  7581. * Gets the name of the property to edit
  7582. */
  7583. propertyName: string;
  7584. /**
  7585. * Gets the type of the editor to use
  7586. */
  7587. type: InspectableType;
  7588. /**
  7589. * Gets the minimum value of the property when using in "slider" mode
  7590. */
  7591. min?: number;
  7592. /**
  7593. * Gets the maximum value of the property when using in "slider" mode
  7594. */
  7595. max?: number;
  7596. /**
  7597. * Gets the setp to use when using in "slider" mode
  7598. */
  7599. step?: number;
  7600. }
  7601. }
  7602. declare module BABYLON {
  7603. /**
  7604. * Class used to provide helper for timing
  7605. */
  7606. export class TimingTools {
  7607. /**
  7608. * Polyfill for setImmediate
  7609. * @param action defines the action to execute after the current execution block
  7610. */
  7611. static SetImmediate(action: () => void): void;
  7612. }
  7613. }
  7614. declare module BABYLON {
  7615. /**
  7616. * Class used to enable instatition of objects by class name
  7617. */
  7618. export class InstantiationTools {
  7619. /**
  7620. * Use this object to register external classes like custom textures or material
  7621. * to allow the laoders to instantiate them
  7622. */
  7623. static RegisteredExternalClasses: {
  7624. [key: string]: Object;
  7625. };
  7626. /**
  7627. * Tries to instantiate a new object from a given class name
  7628. * @param className defines the class name to instantiate
  7629. * @returns the new object or null if the system was not able to do the instantiation
  7630. */
  7631. static Instantiate(className: string): any;
  7632. }
  7633. }
  7634. declare module BABYLON {
  7635. /**
  7636. * Define options used to create a depth texture
  7637. */
  7638. export class DepthTextureCreationOptions {
  7639. /** Specifies whether or not a stencil should be allocated in the texture */
  7640. generateStencil?: boolean;
  7641. /** Specifies whether or not bilinear filtering is enable on the texture */
  7642. bilinearFiltering?: boolean;
  7643. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7644. comparisonFunction?: number;
  7645. /** Specifies if the created texture is a cube texture */
  7646. isCube?: boolean;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. interface ThinEngine {
  7651. /**
  7652. * Creates a depth stencil cube texture.
  7653. * This is only available in WebGL 2.
  7654. * @param size The size of face edge in the cube texture.
  7655. * @param options The options defining the cube texture.
  7656. * @returns The cube texture
  7657. */
  7658. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7672. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7673. * @returns the cube texture as an InternalTexture
  7674. */
  7675. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7676. /**
  7677. * Creates a cube texture
  7678. * @param rootUrl defines the url where the files to load is located
  7679. * @param scene defines the current scene
  7680. * @param files defines the list of files to load (1 per face)
  7681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7682. * @param onLoad defines an optional callback raised when the texture is loaded
  7683. * @param onError defines an optional callback raised if there is an issue to load the texture
  7684. * @param format defines the format of the data
  7685. * @param forcedExtension defines the extension to use to pick the right loader
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /**
  7690. * Creates a cube texture
  7691. * @param rootUrl defines the url where the files to load is located
  7692. * @param scene defines the current scene
  7693. * @param files defines the list of files to load (1 per face)
  7694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7695. * @param onLoad defines an optional callback raised when the texture is loaded
  7696. * @param onError defines an optional callback raised if there is an issue to load the texture
  7697. * @param format defines the format of the data
  7698. * @param forcedExtension defines the extension to use to pick the right loader
  7699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. 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;
  7705. /** @hidden */
  7706. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7707. /** @hidden */
  7708. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7709. /** @hidden */
  7710. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7711. /** @hidden */
  7712. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7713. /**
  7714. * @hidden
  7715. */
  7716. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7717. }
  7718. }
  7719. declare module BABYLON {
  7720. /**
  7721. * Class for creating a cube texture
  7722. */
  7723. export class CubeTexture extends BaseTexture {
  7724. private _delayedOnLoad;
  7725. /**
  7726. * Observable triggered once the texture has been loaded.
  7727. */
  7728. onLoadObservable: Observable<CubeTexture>;
  7729. /**
  7730. * The url of the texture
  7731. */
  7732. url: string;
  7733. /**
  7734. * Gets or sets the center of the bounding box associated with the cube texture.
  7735. * It must define where the camera used to render the texture was set
  7736. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7737. */
  7738. boundingBoxPosition: Vector3;
  7739. private _boundingBoxSize;
  7740. /**
  7741. * Gets or sets the size of the bounding box associated with the cube texture
  7742. * When defined, the cubemap will switch to local mode
  7743. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7744. * @example https://www.babylonjs-playground.com/#RNASML
  7745. */
  7746. set boundingBoxSize(value: Vector3);
  7747. /**
  7748. * Returns the bounding box size
  7749. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7750. */
  7751. get boundingBoxSize(): Vector3;
  7752. protected _rotationY: number;
  7753. /**
  7754. * Sets texture matrix rotation angle around Y axis in radians.
  7755. */
  7756. set rotationY(value: number);
  7757. /**
  7758. * Gets texture matrix rotation angle around Y axis radians.
  7759. */
  7760. get rotationY(): number;
  7761. /**
  7762. * Are mip maps generated for this texture or not.
  7763. */
  7764. get noMipmap(): boolean;
  7765. private _noMipmap;
  7766. private _files;
  7767. protected _forcedExtension: Nullable<string>;
  7768. private _extensions;
  7769. private _textureMatrix;
  7770. private _format;
  7771. private _createPolynomials;
  7772. /**
  7773. * Creates a cube texture from an array of image urls
  7774. * @param files defines an array of image urls
  7775. * @param scene defines the hosting scene
  7776. * @param noMipmap specifies if mip maps are not used
  7777. * @returns a cube texture
  7778. */
  7779. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7780. /**
  7781. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7782. * @param url defines the url of the prefiltered texture
  7783. * @param scene defines the scene the texture is attached to
  7784. * @param forcedExtension defines the extension of the file if different from the url
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @return the prefiltered texture
  7787. */
  7788. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7789. /**
  7790. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7791. * as prefiltered data.
  7792. * @param rootUrl defines the url of the texture or the root name of the six images
  7793. * @param null defines the scene or engine the texture is attached to
  7794. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7795. * @param noMipmap defines if mipmaps should be created or not
  7796. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7797. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7798. * @param onError defines a callback triggered in case of error during load
  7799. * @param format defines the internal format to use for the texture once loaded
  7800. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7801. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7802. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7803. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7804. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7805. * @return the cube texture
  7806. */
  7807. 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);
  7808. /**
  7809. * Get the current class name of the texture useful for serialization or dynamic coding.
  7810. * @returns "CubeTexture"
  7811. */
  7812. getClassName(): string;
  7813. /**
  7814. * Update the url (and optional buffer) of this texture if url was null during construction.
  7815. * @param url the url of the texture
  7816. * @param forcedExtension defines the extension to use
  7817. * @param onLoad callback called when the texture is loaded (defaults to null)
  7818. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7819. */
  7820. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7821. /**
  7822. * Delays loading of the cube texture
  7823. * @param forcedExtension defines the extension to use
  7824. */
  7825. delayLoad(forcedExtension?: string): void;
  7826. /**
  7827. * Returns the reflection texture matrix
  7828. * @returns the reflection texture matrix
  7829. */
  7830. getReflectionTextureMatrix(): Matrix;
  7831. /**
  7832. * Sets the reflection texture matrix
  7833. * @param value Reflection texture matrix
  7834. */
  7835. setReflectionTextureMatrix(value: Matrix): void;
  7836. /**
  7837. * Parses text to create a cube texture
  7838. * @param parsedTexture define the serialized text to read from
  7839. * @param scene defines the hosting scene
  7840. * @param rootUrl defines the root url of the cube texture
  7841. * @returns a cube texture
  7842. */
  7843. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7844. /**
  7845. * Makes a clone, or deep copy, of the cube texture
  7846. * @returns a new cube texture
  7847. */
  7848. clone(): CubeTexture;
  7849. }
  7850. }
  7851. declare module BABYLON {
  7852. /**
  7853. * Manages the defines for the Material
  7854. */
  7855. export class MaterialDefines {
  7856. /** @hidden */
  7857. protected _keys: string[];
  7858. private _isDirty;
  7859. /** @hidden */
  7860. _renderId: number;
  7861. /** @hidden */
  7862. _areLightsDirty: boolean;
  7863. /** @hidden */
  7864. _areLightsDisposed: boolean;
  7865. /** @hidden */
  7866. _areAttributesDirty: boolean;
  7867. /** @hidden */
  7868. _areTexturesDirty: boolean;
  7869. /** @hidden */
  7870. _areFresnelDirty: boolean;
  7871. /** @hidden */
  7872. _areMiscDirty: boolean;
  7873. /** @hidden */
  7874. _areImageProcessingDirty: boolean;
  7875. /** @hidden */
  7876. _normals: boolean;
  7877. /** @hidden */
  7878. _uvs: boolean;
  7879. /** @hidden */
  7880. _needNormals: boolean;
  7881. /** @hidden */
  7882. _needUVs: boolean;
  7883. [id: string]: any;
  7884. /**
  7885. * Specifies if the material needs to be re-calculated
  7886. */
  7887. get isDirty(): boolean;
  7888. /**
  7889. * Marks the material to indicate that it has been re-calculated
  7890. */
  7891. markAsProcessed(): void;
  7892. /**
  7893. * Marks the material to indicate that it needs to be re-calculated
  7894. */
  7895. markAsUnprocessed(): void;
  7896. /**
  7897. * Marks the material to indicate all of its defines need to be re-calculated
  7898. */
  7899. markAllAsDirty(): void;
  7900. /**
  7901. * Marks the material to indicate that image processing needs to be re-calculated
  7902. */
  7903. markAsImageProcessingDirty(): void;
  7904. /**
  7905. * Marks the material to indicate the lights need to be re-calculated
  7906. * @param disposed Defines whether the light is dirty due to dispose or not
  7907. */
  7908. markAsLightDirty(disposed?: boolean): void;
  7909. /**
  7910. * Marks the attribute state as changed
  7911. */
  7912. markAsAttributesDirty(): void;
  7913. /**
  7914. * Marks the texture state as changed
  7915. */
  7916. markAsTexturesDirty(): void;
  7917. /**
  7918. * Marks the fresnel state as changed
  7919. */
  7920. markAsFresnelDirty(): void;
  7921. /**
  7922. * Marks the misc state as changed
  7923. */
  7924. markAsMiscDirty(): void;
  7925. /**
  7926. * Rebuilds the material defines
  7927. */
  7928. rebuild(): void;
  7929. /**
  7930. * Specifies if two material defines are equal
  7931. * @param other - A material define instance to compare to
  7932. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7933. */
  7934. isEqual(other: MaterialDefines): boolean;
  7935. /**
  7936. * Clones this instance's defines to another instance
  7937. * @param other - material defines to clone values to
  7938. */
  7939. cloneTo(other: MaterialDefines): void;
  7940. /**
  7941. * Resets the material define values
  7942. */
  7943. reset(): void;
  7944. /**
  7945. * Converts the material define values to a string
  7946. * @returns - String of material define information
  7947. */
  7948. toString(): string;
  7949. }
  7950. }
  7951. declare module BABYLON {
  7952. /**
  7953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7955. * 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;
  7956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7957. */
  7958. export class ColorCurves {
  7959. private _dirty;
  7960. private _tempColor;
  7961. private _globalCurve;
  7962. private _highlightsCurve;
  7963. private _midtonesCurve;
  7964. private _shadowsCurve;
  7965. private _positiveCurve;
  7966. private _negativeCurve;
  7967. private _globalHue;
  7968. private _globalDensity;
  7969. private _globalSaturation;
  7970. private _globalExposure;
  7971. /**
  7972. * Gets the global Hue value.
  7973. * 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).
  7974. */
  7975. get globalHue(): number;
  7976. /**
  7977. * Sets the global Hue value.
  7978. * 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).
  7979. */
  7980. set globalHue(value: number);
  7981. /**
  7982. * Gets the global Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. get globalDensity(): number;
  7987. /**
  7988. * Sets the global Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. set globalDensity(value: number);
  7993. /**
  7994. * Gets the global Saturation value.
  7995. * 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.
  7996. */
  7997. get globalSaturation(): number;
  7998. /**
  7999. * Sets the global Saturation value.
  8000. * 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.
  8001. */
  8002. set globalSaturation(value: number);
  8003. /**
  8004. * Gets the global Exposure value.
  8005. * 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.
  8006. */
  8007. get globalExposure(): number;
  8008. /**
  8009. * Sets the global Exposure value.
  8010. * 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.
  8011. */
  8012. set globalExposure(value: number);
  8013. private _highlightsHue;
  8014. private _highlightsDensity;
  8015. private _highlightsSaturation;
  8016. private _highlightsExposure;
  8017. /**
  8018. * Gets the highlights Hue value.
  8019. * 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).
  8020. */
  8021. get highlightsHue(): number;
  8022. /**
  8023. * Sets the highlights Hue value.
  8024. * 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).
  8025. */
  8026. set highlightsHue(value: number);
  8027. /**
  8028. * Gets the highlights Density value.
  8029. * 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.
  8030. * Values less than zero provide a filter of opposite hue.
  8031. */
  8032. get highlightsDensity(): number;
  8033. /**
  8034. * Sets the highlights Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. set highlightsDensity(value: number);
  8039. /**
  8040. * Gets the highlights Saturation value.
  8041. * 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.
  8042. */
  8043. get highlightsSaturation(): number;
  8044. /**
  8045. * Sets the highlights Saturation value.
  8046. * 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.
  8047. */
  8048. set highlightsSaturation(value: number);
  8049. /**
  8050. * Gets the highlights Exposure value.
  8051. * 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.
  8052. */
  8053. get highlightsExposure(): number;
  8054. /**
  8055. * Sets the highlights Exposure value.
  8056. * 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.
  8057. */
  8058. set highlightsExposure(value: number);
  8059. private _midtonesHue;
  8060. private _midtonesDensity;
  8061. private _midtonesSaturation;
  8062. private _midtonesExposure;
  8063. /**
  8064. * Gets the midtones Hue value.
  8065. * 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).
  8066. */
  8067. get midtonesHue(): number;
  8068. /**
  8069. * Sets the midtones Hue value.
  8070. * 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).
  8071. */
  8072. set midtonesHue(value: number);
  8073. /**
  8074. * Gets the midtones Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. get midtonesDensity(): number;
  8079. /**
  8080. * Sets the midtones Density value.
  8081. * 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.
  8082. * Values less than zero provide a filter of opposite hue.
  8083. */
  8084. set midtonesDensity(value: number);
  8085. /**
  8086. * Gets the midtones Saturation value.
  8087. * 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.
  8088. */
  8089. get midtonesSaturation(): number;
  8090. /**
  8091. * Sets the midtones Saturation value.
  8092. * 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.
  8093. */
  8094. set midtonesSaturation(value: number);
  8095. /**
  8096. * Gets the midtones Exposure value.
  8097. * 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.
  8098. */
  8099. get midtonesExposure(): number;
  8100. /**
  8101. * Sets the midtones Exposure value.
  8102. * 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.
  8103. */
  8104. set midtonesExposure(value: number);
  8105. private _shadowsHue;
  8106. private _shadowsDensity;
  8107. private _shadowsSaturation;
  8108. private _shadowsExposure;
  8109. /**
  8110. * Gets the shadows Hue value.
  8111. * 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).
  8112. */
  8113. get shadowsHue(): number;
  8114. /**
  8115. * Sets the shadows Hue value.
  8116. * 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).
  8117. */
  8118. set shadowsHue(value: number);
  8119. /**
  8120. * Gets the shadows Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. get shadowsDensity(): number;
  8125. /**
  8126. * Sets the shadows Density value.
  8127. * 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.
  8128. * Values less than zero provide a filter of opposite hue.
  8129. */
  8130. set shadowsDensity(value: number);
  8131. /**
  8132. * Gets the shadows Saturation value.
  8133. * 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.
  8134. */
  8135. get shadowsSaturation(): number;
  8136. /**
  8137. * Sets the shadows Saturation value.
  8138. * 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.
  8139. */
  8140. set shadowsSaturation(value: number);
  8141. /**
  8142. * Gets the shadows Exposure value.
  8143. * 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.
  8144. */
  8145. get shadowsExposure(): number;
  8146. /**
  8147. * Sets the shadows Exposure value.
  8148. * 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.
  8149. */
  8150. set shadowsExposure(value: number);
  8151. /**
  8152. * Returns the class name
  8153. * @returns The class name
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Binds the color curves to the shader.
  8158. * @param colorCurves The color curve to bind
  8159. * @param effect The effect to bind to
  8160. * @param positiveUniform The positive uniform shader parameter
  8161. * @param neutralUniform The neutral uniform shader parameter
  8162. * @param negativeUniform The negative uniform shader parameter
  8163. */
  8164. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8165. /**
  8166. * Prepare the list of uniforms associated with the ColorCurves effects.
  8167. * @param uniformsList The list of uniforms used in the effect
  8168. */
  8169. static PrepareUniforms(uniformsList: string[]): void;
  8170. /**
  8171. * Returns color grading data based on a hue, density, saturation and exposure value.
  8172. * @param filterHue The hue of the color filter.
  8173. * @param filterDensity The density of the color filter.
  8174. * @param saturation The saturation.
  8175. * @param exposure The exposure.
  8176. * @param result The result data container.
  8177. */
  8178. private getColorGradingDataToRef;
  8179. /**
  8180. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8181. * @param value The input slider value in range [-100,100].
  8182. * @returns Adjusted value.
  8183. */
  8184. private static applyColorGradingSliderNonlinear;
  8185. /**
  8186. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8187. * @param hue The hue (H) input.
  8188. * @param saturation The saturation (S) input.
  8189. * @param brightness The brightness (B) input.
  8190. * @result An RGBA color represented as Vector4.
  8191. */
  8192. private static fromHSBToRef;
  8193. /**
  8194. * Returns a value clamped between min and max
  8195. * @param value The value to clamp
  8196. * @param min The minimum of value
  8197. * @param max The maximum of value
  8198. * @returns The clamped value.
  8199. */
  8200. private static clamp;
  8201. /**
  8202. * Clones the current color curve instance.
  8203. * @return The cloned curves
  8204. */
  8205. clone(): ColorCurves;
  8206. /**
  8207. * Serializes the current color curve instance to a json representation.
  8208. * @return a JSON representation
  8209. */
  8210. serialize(): any;
  8211. /**
  8212. * Parses the color curve from a json representation.
  8213. * @param source the JSON source to parse
  8214. * @return The parsed curves
  8215. */
  8216. static Parse(source: any): ColorCurves;
  8217. }
  8218. }
  8219. declare module BABYLON {
  8220. /**
  8221. * Interface to follow in your material defines to integrate easily the
  8222. * Image proccessing functions.
  8223. * @hidden
  8224. */
  8225. export interface IImageProcessingConfigurationDefines {
  8226. IMAGEPROCESSING: boolean;
  8227. VIGNETTE: boolean;
  8228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8229. VIGNETTEBLENDMODEOPAQUE: boolean;
  8230. TONEMAPPING: boolean;
  8231. TONEMAPPING_ACES: boolean;
  8232. CONTRAST: boolean;
  8233. EXPOSURE: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. }
  8241. /**
  8242. * @hidden
  8243. */
  8244. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8245. IMAGEPROCESSING: boolean;
  8246. VIGNETTE: boolean;
  8247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8248. VIGNETTEBLENDMODEOPAQUE: boolean;
  8249. TONEMAPPING: boolean;
  8250. TONEMAPPING_ACES: boolean;
  8251. CONTRAST: boolean;
  8252. COLORCURVES: boolean;
  8253. COLORGRADING: boolean;
  8254. COLORGRADING3D: boolean;
  8255. SAMPLER3DGREENDEPTH: boolean;
  8256. SAMPLER3DBGRMAP: boolean;
  8257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8258. EXPOSURE: boolean;
  8259. constructor();
  8260. }
  8261. /**
  8262. * This groups together the common properties used for image processing either in direct forward pass
  8263. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8264. * or not.
  8265. */
  8266. export class ImageProcessingConfiguration {
  8267. /**
  8268. * Default tone mapping applied in BabylonJS.
  8269. */
  8270. static readonly TONEMAPPING_STANDARD: number;
  8271. /**
  8272. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8273. * to other engines rendering to increase portability.
  8274. */
  8275. static readonly TONEMAPPING_ACES: number;
  8276. /**
  8277. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8278. */
  8279. colorCurves: Nullable<ColorCurves>;
  8280. private _colorCurvesEnabled;
  8281. /**
  8282. * Gets wether the color curves effect is enabled.
  8283. */
  8284. get colorCurvesEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color curves effect is enabled.
  8287. */
  8288. set colorCurvesEnabled(value: boolean);
  8289. private _colorGradingTexture;
  8290. /**
  8291. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8292. */
  8293. get colorGradingTexture(): Nullable<BaseTexture>;
  8294. /**
  8295. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8296. */
  8297. set colorGradingTexture(value: Nullable<BaseTexture>);
  8298. private _colorGradingEnabled;
  8299. /**
  8300. * Gets wether the color grading effect is enabled.
  8301. */
  8302. get colorGradingEnabled(): boolean;
  8303. /**
  8304. * Sets wether the color grading effect is enabled.
  8305. */
  8306. set colorGradingEnabled(value: boolean);
  8307. private _colorGradingWithGreenDepth;
  8308. /**
  8309. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8310. */
  8311. get colorGradingWithGreenDepth(): boolean;
  8312. /**
  8313. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8314. */
  8315. set colorGradingWithGreenDepth(value: boolean);
  8316. private _colorGradingBGR;
  8317. /**
  8318. * Gets wether the color grading texture contains BGR values.
  8319. */
  8320. get colorGradingBGR(): boolean;
  8321. /**
  8322. * Sets wether the color grading texture contains BGR values.
  8323. */
  8324. set colorGradingBGR(value: boolean);
  8325. /** @hidden */
  8326. _exposure: number;
  8327. /**
  8328. * Gets the Exposure used in the effect.
  8329. */
  8330. get exposure(): number;
  8331. /**
  8332. * Sets the Exposure used in the effect.
  8333. */
  8334. set exposure(value: number);
  8335. private _toneMappingEnabled;
  8336. /**
  8337. * Gets wether the tone mapping effect is enabled.
  8338. */
  8339. get toneMappingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the tone mapping effect is enabled.
  8342. */
  8343. set toneMappingEnabled(value: boolean);
  8344. private _toneMappingType;
  8345. /**
  8346. * Gets the type of tone mapping effect.
  8347. */
  8348. get toneMappingType(): number;
  8349. /**
  8350. * Sets the type of tone mapping effect used in BabylonJS.
  8351. */
  8352. set toneMappingType(value: number);
  8353. protected _contrast: number;
  8354. /**
  8355. * Gets the contrast used in the effect.
  8356. */
  8357. get contrast(): number;
  8358. /**
  8359. * Sets the contrast used in the effect.
  8360. */
  8361. set contrast(value: number);
  8362. /**
  8363. * Vignette stretch size.
  8364. */
  8365. vignetteStretch: number;
  8366. /**
  8367. * Vignette centre X Offset.
  8368. */
  8369. vignetteCentreX: number;
  8370. /**
  8371. * Vignette centre Y Offset.
  8372. */
  8373. vignetteCentreY: number;
  8374. /**
  8375. * Vignette weight or intensity of the vignette effect.
  8376. */
  8377. vignetteWeight: number;
  8378. /**
  8379. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8380. * if vignetteEnabled is set to true.
  8381. */
  8382. vignetteColor: Color4;
  8383. /**
  8384. * Camera field of view used by the Vignette effect.
  8385. */
  8386. vignetteCameraFov: number;
  8387. private _vignetteBlendMode;
  8388. /**
  8389. * Gets the vignette blend mode allowing different kind of effect.
  8390. */
  8391. get vignetteBlendMode(): number;
  8392. /**
  8393. * Sets the vignette blend mode allowing different kind of effect.
  8394. */
  8395. set vignetteBlendMode(value: number);
  8396. private _vignetteEnabled;
  8397. /**
  8398. * Gets wether the vignette effect is enabled.
  8399. */
  8400. get vignetteEnabled(): boolean;
  8401. /**
  8402. * Sets wether the vignette effect is enabled.
  8403. */
  8404. set vignetteEnabled(value: boolean);
  8405. private _applyByPostProcess;
  8406. /**
  8407. * Gets wether the image processing is applied through a post process or not.
  8408. */
  8409. get applyByPostProcess(): boolean;
  8410. /**
  8411. * Sets wether the image processing is applied through a post process or not.
  8412. */
  8413. set applyByPostProcess(value: boolean);
  8414. private _isEnabled;
  8415. /**
  8416. * Gets wether the image processing is enabled or not.
  8417. */
  8418. get isEnabled(): boolean;
  8419. /**
  8420. * Sets wether the image processing is enabled or not.
  8421. */
  8422. set isEnabled(value: boolean);
  8423. /**
  8424. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8425. */
  8426. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8427. /**
  8428. * Method called each time the image processing information changes requires to recompile the effect.
  8429. */
  8430. protected _updateParameters(): void;
  8431. /**
  8432. * Gets the current class name.
  8433. * @return "ImageProcessingConfiguration"
  8434. */
  8435. getClassName(): string;
  8436. /**
  8437. * Prepare the list of uniforms associated with the Image Processing effects.
  8438. * @param uniforms The list of uniforms used in the effect
  8439. * @param defines the list of defines currently in use
  8440. */
  8441. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8442. /**
  8443. * Prepare the list of samplers associated with the Image Processing effects.
  8444. * @param samplersList The list of uniforms used in the effect
  8445. * @param defines the list of defines currently in use
  8446. */
  8447. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8448. /**
  8449. * Prepare the list of defines associated to the shader.
  8450. * @param defines the list of defines to complete
  8451. * @param forPostProcess Define if we are currently in post process mode or not
  8452. */
  8453. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8454. /**
  8455. * Returns true if all the image processing information are ready.
  8456. * @returns True if ready, otherwise, false
  8457. */
  8458. isReady(): boolean;
  8459. /**
  8460. * Binds the image processing to the shader.
  8461. * @param effect The effect to bind to
  8462. * @param overrideAspectRatio Override the aspect ratio of the effect
  8463. */
  8464. bind(effect: Effect, overrideAspectRatio?: number): void;
  8465. /**
  8466. * Clones the current image processing instance.
  8467. * @return The cloned image processing
  8468. */
  8469. clone(): ImageProcessingConfiguration;
  8470. /**
  8471. * Serializes the current image processing instance to a json representation.
  8472. * @return a JSON representation
  8473. */
  8474. serialize(): any;
  8475. /**
  8476. * Parses the image processing from a json representation.
  8477. * @param source the JSON source to parse
  8478. * @return The parsed image processing
  8479. */
  8480. static Parse(source: any): ImageProcessingConfiguration;
  8481. private static _VIGNETTEMODE_MULTIPLY;
  8482. private static _VIGNETTEMODE_OPAQUE;
  8483. /**
  8484. * Used to apply the vignette as a mix with the pixel color.
  8485. */
  8486. static get VIGNETTEMODE_MULTIPLY(): number;
  8487. /**
  8488. * Used to apply the vignette as a replacement of the pixel color.
  8489. */
  8490. static get VIGNETTEMODE_OPAQUE(): number;
  8491. }
  8492. }
  8493. declare module BABYLON {
  8494. /** @hidden */
  8495. export var postprocessVertexShader: {
  8496. name: string;
  8497. shader: string;
  8498. };
  8499. }
  8500. declare module BABYLON {
  8501. interface ThinEngine {
  8502. /**
  8503. * Creates a new render target texture
  8504. * @param size defines the size of the texture
  8505. * @param options defines the options used to create the texture
  8506. * @returns a new render target texture stored in an InternalTexture
  8507. */
  8508. createRenderTargetTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8513. /**
  8514. * Creates a depth stencil texture.
  8515. * This is only available in WebGL 2 or with the depth texture extension available.
  8516. * @param size The size of face edge in the texture.
  8517. * @param options The options defining the texture.
  8518. * @returns The texture
  8519. */
  8520. createDepthStencilTexture(size: number | {
  8521. width: number;
  8522. height: number;
  8523. layers?: number;
  8524. }, options: DepthTextureCreationOptions): InternalTexture;
  8525. /** @hidden */
  8526. _createDepthStencilTexture(size: number | {
  8527. width: number;
  8528. height: number;
  8529. layers?: number;
  8530. }, options: DepthTextureCreationOptions): InternalTexture;
  8531. }
  8532. }
  8533. declare module BABYLON {
  8534. /**
  8535. * Defines the kind of connection point for node based material
  8536. */
  8537. export enum NodeMaterialBlockConnectionPointTypes {
  8538. /** Float */
  8539. Float = 1,
  8540. /** Int */
  8541. Int = 2,
  8542. /** Vector2 */
  8543. Vector2 = 4,
  8544. /** Vector3 */
  8545. Vector3 = 8,
  8546. /** Vector4 */
  8547. Vector4 = 16,
  8548. /** Color3 */
  8549. Color3 = 32,
  8550. /** Color4 */
  8551. Color4 = 64,
  8552. /** Matrix */
  8553. Matrix = 128,
  8554. /** Custom object */
  8555. Object = 256,
  8556. /** Detect type based on connection */
  8557. AutoDetect = 1024,
  8558. /** Output type that will be defined by input type */
  8559. BasedOnInput = 2048
  8560. }
  8561. }
  8562. declare module BABYLON {
  8563. /**
  8564. * Enum used to define the target of a block
  8565. */
  8566. export enum NodeMaterialBlockTargets {
  8567. /** Vertex shader */
  8568. Vertex = 1,
  8569. /** Fragment shader */
  8570. Fragment = 2,
  8571. /** Neutral */
  8572. Neutral = 4,
  8573. /** Vertex and Fragment */
  8574. VertexAndFragment = 3
  8575. }
  8576. }
  8577. declare module BABYLON {
  8578. /**
  8579. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8580. */
  8581. export enum NodeMaterialBlockConnectionPointMode {
  8582. /** Value is an uniform */
  8583. Uniform = 0,
  8584. /** Value is a mesh attribute */
  8585. Attribute = 1,
  8586. /** Value is a varying between vertex and fragment shaders */
  8587. Varying = 2,
  8588. /** Mode is undefined */
  8589. Undefined = 3
  8590. }
  8591. }
  8592. declare module BABYLON {
  8593. /**
  8594. * Enum used to define system values e.g. values automatically provided by the system
  8595. */
  8596. export enum NodeMaterialSystemValues {
  8597. /** World */
  8598. World = 1,
  8599. /** View */
  8600. View = 2,
  8601. /** Projection */
  8602. Projection = 3,
  8603. /** ViewProjection */
  8604. ViewProjection = 4,
  8605. /** WorldView */
  8606. WorldView = 5,
  8607. /** WorldViewProjection */
  8608. WorldViewProjection = 6,
  8609. /** CameraPosition */
  8610. CameraPosition = 7,
  8611. /** Fog Color */
  8612. FogColor = 8,
  8613. /** Delta time */
  8614. DeltaTime = 9
  8615. }
  8616. }
  8617. declare module BABYLON {
  8618. /** Defines supported spaces */
  8619. export enum Space {
  8620. /** Local (object) space */
  8621. LOCAL = 0,
  8622. /** World space */
  8623. WORLD = 1,
  8624. /** Bone space */
  8625. BONE = 2
  8626. }
  8627. /** Defines the 3 main axes */
  8628. export class Axis {
  8629. /** X axis */
  8630. static X: Vector3;
  8631. /** Y axis */
  8632. static Y: Vector3;
  8633. /** Z axis */
  8634. static Z: Vector3;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Represents a camera frustum
  8640. */
  8641. export class Frustum {
  8642. /**
  8643. * Gets the planes representing the frustum
  8644. * @param transform matrix to be applied to the returned planes
  8645. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8646. */
  8647. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8648. /**
  8649. * Gets the near frustum plane transformed by the transform matrix
  8650. * @param transform transformation matrix to be applied to the resulting frustum plane
  8651. * @param frustumPlane the resuling frustum plane
  8652. */
  8653. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8654. /**
  8655. * Gets the far frustum plane transformed by the transform matrix
  8656. * @param transform transformation matrix to be applied to the resulting frustum plane
  8657. * @param frustumPlane the resuling frustum plane
  8658. */
  8659. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8660. /**
  8661. * Gets the left frustum plane transformed by the transform matrix
  8662. * @param transform transformation matrix to be applied to the resulting frustum plane
  8663. * @param frustumPlane the resuling frustum plane
  8664. */
  8665. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8666. /**
  8667. * Gets the right frustum plane transformed by the transform matrix
  8668. * @param transform transformation matrix to be applied to the resulting frustum plane
  8669. * @param frustumPlane the resuling frustum plane
  8670. */
  8671. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8672. /**
  8673. * Gets the top frustum plane transformed by the transform matrix
  8674. * @param transform transformation matrix to be applied to the resulting frustum plane
  8675. * @param frustumPlane the resuling frustum plane
  8676. */
  8677. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8678. /**
  8679. * Gets the bottom frustum plane transformed by the transform matrix
  8680. * @param transform transformation matrix to be applied to the resulting frustum plane
  8681. * @param frustumPlane the resuling frustum plane
  8682. */
  8683. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8684. /**
  8685. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8686. * @param transform transformation matrix to be applied to the resulting frustum planes
  8687. * @param frustumPlanes the resuling frustum planes
  8688. */
  8689. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Interface for the size containing width and height
  8695. */
  8696. export interface ISize {
  8697. /**
  8698. * Width
  8699. */
  8700. width: number;
  8701. /**
  8702. * Heighht
  8703. */
  8704. height: number;
  8705. }
  8706. /**
  8707. * Size containing widht and height
  8708. */
  8709. export class Size implements ISize {
  8710. /**
  8711. * Width
  8712. */
  8713. width: number;
  8714. /**
  8715. * Height
  8716. */
  8717. height: number;
  8718. /**
  8719. * Creates a Size object from the given width and height (floats).
  8720. * @param width width of the new size
  8721. * @param height height of the new size
  8722. */
  8723. constructor(width: number, height: number);
  8724. /**
  8725. * Returns a string with the Size width and height
  8726. * @returns a string with the Size width and height
  8727. */
  8728. toString(): string;
  8729. /**
  8730. * "Size"
  8731. * @returns the string "Size"
  8732. */
  8733. getClassName(): string;
  8734. /**
  8735. * Returns the Size hash code.
  8736. * @returns a hash code for a unique width and height
  8737. */
  8738. getHashCode(): number;
  8739. /**
  8740. * Updates the current size from the given one.
  8741. * @param src the given size
  8742. */
  8743. copyFrom(src: Size): void;
  8744. /**
  8745. * Updates in place the current Size from the given floats.
  8746. * @param width width of the new size
  8747. * @param height height of the new size
  8748. * @returns the updated Size.
  8749. */
  8750. copyFromFloats(width: number, height: number): Size;
  8751. /**
  8752. * Updates in place the current Size from the given floats.
  8753. * @param width width to set
  8754. * @param height height to set
  8755. * @returns the updated Size.
  8756. */
  8757. set(width: number, height: number): Size;
  8758. /**
  8759. * Multiplies the width and height by numbers
  8760. * @param w factor to multiple the width by
  8761. * @param h factor to multiple the height by
  8762. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8763. */
  8764. multiplyByFloats(w: number, h: number): Size;
  8765. /**
  8766. * Clones the size
  8767. * @returns a new Size copied from the given one.
  8768. */
  8769. clone(): Size;
  8770. /**
  8771. * True if the current Size and the given one width and height are strictly equal.
  8772. * @param other the other size to compare against
  8773. * @returns True if the current Size and the given one width and height are strictly equal.
  8774. */
  8775. equals(other: Size): boolean;
  8776. /**
  8777. * The surface of the Size : width * height (float).
  8778. */
  8779. get surface(): number;
  8780. /**
  8781. * Create a new size of zero
  8782. * @returns a new Size set to (0.0, 0.0)
  8783. */
  8784. static Zero(): Size;
  8785. /**
  8786. * Sums the width and height of two sizes
  8787. * @param otherSize size to add to this size
  8788. * @returns a new Size set as the addition result of the current Size and the given one.
  8789. */
  8790. add(otherSize: Size): Size;
  8791. /**
  8792. * Subtracts the width and height of two
  8793. * @param otherSize size to subtract to this size
  8794. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8795. */
  8796. subtract(otherSize: Size): Size;
  8797. /**
  8798. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8799. * @param start starting size to lerp between
  8800. * @param end end size to lerp between
  8801. * @param amount amount to lerp between the start and end values
  8802. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8803. */
  8804. static Lerp(start: Size, end: Size, amount: number): Size;
  8805. }
  8806. }
  8807. declare module BABYLON {
  8808. /**
  8809. * Contains position and normal vectors for a vertex
  8810. */
  8811. export class PositionNormalVertex {
  8812. /** the position of the vertex (defaut: 0,0,0) */
  8813. position: Vector3;
  8814. /** the normal of the vertex (defaut: 0,1,0) */
  8815. normal: Vector3;
  8816. /**
  8817. * Creates a PositionNormalVertex
  8818. * @param position the position of the vertex (defaut: 0,0,0)
  8819. * @param normal the normal of the vertex (defaut: 0,1,0)
  8820. */
  8821. constructor(
  8822. /** the position of the vertex (defaut: 0,0,0) */
  8823. position?: Vector3,
  8824. /** the normal of the vertex (defaut: 0,1,0) */
  8825. normal?: Vector3);
  8826. /**
  8827. * Clones the PositionNormalVertex
  8828. * @returns the cloned PositionNormalVertex
  8829. */
  8830. clone(): PositionNormalVertex;
  8831. }
  8832. /**
  8833. * Contains position, normal and uv vectors for a vertex
  8834. */
  8835. export class PositionNormalTextureVertex {
  8836. /** the position of the vertex (defaut: 0,0,0) */
  8837. position: Vector3;
  8838. /** the normal of the vertex (defaut: 0,1,0) */
  8839. normal: Vector3;
  8840. /** the uv of the vertex (default: 0,0) */
  8841. uv: Vector2;
  8842. /**
  8843. * Creates a PositionNormalTextureVertex
  8844. * @param position the position of the vertex (defaut: 0,0,0)
  8845. * @param normal the normal of the vertex (defaut: 0,1,0)
  8846. * @param uv the uv of the vertex (default: 0,0)
  8847. */
  8848. constructor(
  8849. /** the position of the vertex (defaut: 0,0,0) */
  8850. position?: Vector3,
  8851. /** the normal of the vertex (defaut: 0,1,0) */
  8852. normal?: Vector3,
  8853. /** the uv of the vertex (default: 0,0) */
  8854. uv?: Vector2);
  8855. /**
  8856. * Clones the PositionNormalTextureVertex
  8857. * @returns the cloned PositionNormalTextureVertex
  8858. */
  8859. clone(): PositionNormalTextureVertex;
  8860. }
  8861. }
  8862. declare module BABYLON {
  8863. /**
  8864. * Enum defining the type of animations supported by InputBlock
  8865. */
  8866. export enum AnimatedInputBlockTypes {
  8867. /** No animation */
  8868. None = 0,
  8869. /** Time based animation. Will only work for floats */
  8870. Time = 1
  8871. }
  8872. }
  8873. declare module BABYLON {
  8874. /**
  8875. * Interface describing all the common properties and methods a shadow light needs to implement.
  8876. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8877. * as well as binding the different shadow properties to the effects.
  8878. */
  8879. export interface IShadowLight extends Light {
  8880. /**
  8881. * The light id in the scene (used in scene.findLighById for instance)
  8882. */
  8883. id: string;
  8884. /**
  8885. * The position the shdow will be casted from.
  8886. */
  8887. position: Vector3;
  8888. /**
  8889. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8890. */
  8891. direction: Vector3;
  8892. /**
  8893. * The transformed position. Position of the light in world space taking parenting in account.
  8894. */
  8895. transformedPosition: Vector3;
  8896. /**
  8897. * The transformed direction. Direction of the light in world space taking parenting in account.
  8898. */
  8899. transformedDirection: Vector3;
  8900. /**
  8901. * The friendly name of the light in the scene.
  8902. */
  8903. name: string;
  8904. /**
  8905. * Defines the shadow projection clipping minimum z value.
  8906. */
  8907. shadowMinZ: number;
  8908. /**
  8909. * Defines the shadow projection clipping maximum z value.
  8910. */
  8911. shadowMaxZ: number;
  8912. /**
  8913. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8914. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8915. */
  8916. computeTransformedInformation(): boolean;
  8917. /**
  8918. * Gets the scene the light belongs to.
  8919. * @returns The scene
  8920. */
  8921. getScene(): Scene;
  8922. /**
  8923. * Callback defining a custom Projection Matrix Builder.
  8924. * This can be used to override the default projection matrix computation.
  8925. */
  8926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8927. /**
  8928. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8929. * @param matrix The materix to updated with the projection information
  8930. * @param viewMatrix The transform matrix of the light
  8931. * @param renderList The list of mesh to render in the map
  8932. * @returns The current light
  8933. */
  8934. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8935. /**
  8936. * Gets the current depth scale used in ESM.
  8937. * @returns The scale
  8938. */
  8939. getDepthScale(): number;
  8940. /**
  8941. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8942. * @returns true if a cube texture needs to be use
  8943. */
  8944. needCube(): boolean;
  8945. /**
  8946. * Detects if the projection matrix requires to be recomputed this frame.
  8947. * @returns true if it requires to be recomputed otherwise, false.
  8948. */
  8949. needProjectionMatrixCompute(): boolean;
  8950. /**
  8951. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8952. */
  8953. forceProjectionMatrixCompute(): void;
  8954. /**
  8955. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8956. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8957. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8958. */
  8959. getShadowDirection(faceIndex?: number): Vector3;
  8960. /**
  8961. * Gets the minZ used for shadow according to both the scene and the light.
  8962. * @param activeCamera The camera we are returning the min for
  8963. * @returns the depth min z
  8964. */
  8965. getDepthMinZ(activeCamera: Camera): number;
  8966. /**
  8967. * Gets the maxZ used for shadow according to both the scene and the light.
  8968. * @param activeCamera The camera we are returning the max for
  8969. * @returns the depth max z
  8970. */
  8971. getDepthMaxZ(activeCamera: Camera): number;
  8972. }
  8973. /**
  8974. * Base implementation IShadowLight
  8975. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8976. */
  8977. export abstract class ShadowLight extends Light implements IShadowLight {
  8978. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8979. protected _position: Vector3;
  8980. protected _setPosition(value: Vector3): void;
  8981. /**
  8982. * Sets the position the shadow will be casted from. Also use as the light position for both
  8983. * point and spot lights.
  8984. */
  8985. get position(): Vector3;
  8986. /**
  8987. * Sets the position the shadow will be casted from. Also use as the light position for both
  8988. * point and spot lights.
  8989. */
  8990. set position(value: Vector3);
  8991. protected _direction: Vector3;
  8992. protected _setDirection(value: Vector3): void;
  8993. /**
  8994. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8995. * Also use as the light direction on spot and directional lights.
  8996. */
  8997. get direction(): Vector3;
  8998. /**
  8999. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9000. * Also use as the light direction on spot and directional lights.
  9001. */
  9002. set direction(value: Vector3);
  9003. protected _shadowMinZ: number;
  9004. /**
  9005. * Gets the shadow projection clipping minimum z value.
  9006. */
  9007. get shadowMinZ(): number;
  9008. /**
  9009. * Sets the shadow projection clipping minimum z value.
  9010. */
  9011. set shadowMinZ(value: number);
  9012. protected _shadowMaxZ: number;
  9013. /**
  9014. * Sets the shadow projection clipping maximum z value.
  9015. */
  9016. get shadowMaxZ(): number;
  9017. /**
  9018. * Gets the shadow projection clipping maximum z value.
  9019. */
  9020. set shadowMaxZ(value: number);
  9021. /**
  9022. * Callback defining a custom Projection Matrix Builder.
  9023. * This can be used to override the default projection matrix computation.
  9024. */
  9025. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9026. /**
  9027. * The transformed position. Position of the light in world space taking parenting in account.
  9028. */
  9029. transformedPosition: Vector3;
  9030. /**
  9031. * The transformed direction. Direction of the light in world space taking parenting in account.
  9032. */
  9033. transformedDirection: Vector3;
  9034. private _needProjectionMatrixCompute;
  9035. /**
  9036. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9037. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9038. */
  9039. computeTransformedInformation(): boolean;
  9040. /**
  9041. * Return the depth scale used for the shadow map.
  9042. * @returns the depth scale.
  9043. */
  9044. getDepthScale(): number;
  9045. /**
  9046. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9047. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9048. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9049. */
  9050. getShadowDirection(faceIndex?: number): Vector3;
  9051. /**
  9052. * Returns the ShadowLight absolute position in the World.
  9053. * @returns the position vector in world space
  9054. */
  9055. getAbsolutePosition(): Vector3;
  9056. /**
  9057. * Sets the ShadowLight direction toward the passed target.
  9058. * @param target The point to target in local space
  9059. * @returns the updated ShadowLight direction
  9060. */
  9061. setDirectionToTarget(target: Vector3): Vector3;
  9062. /**
  9063. * Returns the light rotation in euler definition.
  9064. * @returns the x y z rotation in local space.
  9065. */
  9066. getRotation(): Vector3;
  9067. /**
  9068. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9069. * @returns true if a cube texture needs to be use
  9070. */
  9071. needCube(): boolean;
  9072. /**
  9073. * Detects if the projection matrix requires to be recomputed this frame.
  9074. * @returns true if it requires to be recomputed otherwise, false.
  9075. */
  9076. needProjectionMatrixCompute(): boolean;
  9077. /**
  9078. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9079. */
  9080. forceProjectionMatrixCompute(): void;
  9081. /** @hidden */
  9082. _initCache(): void;
  9083. /** @hidden */
  9084. _isSynchronized(): boolean;
  9085. /**
  9086. * Computes the world matrix of the node
  9087. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9088. * @returns the world matrix
  9089. */
  9090. computeWorldMatrix(force?: boolean): Matrix;
  9091. /**
  9092. * Gets the minZ used for shadow according to both the scene and the light.
  9093. * @param activeCamera The camera we are returning the min for
  9094. * @returns the depth min z
  9095. */
  9096. getDepthMinZ(activeCamera: Camera): number;
  9097. /**
  9098. * Gets the maxZ used for shadow according to both the scene and the light.
  9099. * @param activeCamera The camera we are returning the max for
  9100. * @returns the depth max z
  9101. */
  9102. getDepthMaxZ(activeCamera: Camera): number;
  9103. /**
  9104. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9105. * @param matrix The materix to updated with the projection information
  9106. * @param viewMatrix The transform matrix of the light
  9107. * @param renderList The list of mesh to render in the map
  9108. * @returns The current light
  9109. */
  9110. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9111. }
  9112. }
  9113. declare module BABYLON {
  9114. /** @hidden */
  9115. export var packingFunctions: {
  9116. name: string;
  9117. shader: string;
  9118. };
  9119. }
  9120. declare module BABYLON {
  9121. /** @hidden */
  9122. export var bayerDitherFunctions: {
  9123. name: string;
  9124. shader: string;
  9125. };
  9126. }
  9127. declare module BABYLON {
  9128. /** @hidden */
  9129. export var shadowMapFragmentDeclaration: {
  9130. name: string;
  9131. shader: string;
  9132. };
  9133. }
  9134. declare module BABYLON {
  9135. /** @hidden */
  9136. export var clipPlaneFragmentDeclaration: {
  9137. name: string;
  9138. shader: string;
  9139. };
  9140. }
  9141. declare module BABYLON {
  9142. /** @hidden */
  9143. export var clipPlaneFragment: {
  9144. name: string;
  9145. shader: string;
  9146. };
  9147. }
  9148. declare module BABYLON {
  9149. /** @hidden */
  9150. export var shadowMapFragment: {
  9151. name: string;
  9152. shader: string;
  9153. };
  9154. }
  9155. declare module BABYLON {
  9156. /** @hidden */
  9157. export var shadowMapPixelShader: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module BABYLON {
  9163. /** @hidden */
  9164. export var bonesDeclaration: {
  9165. name: string;
  9166. shader: string;
  9167. };
  9168. }
  9169. declare module BABYLON {
  9170. /** @hidden */
  9171. export var morphTargetsVertexGlobalDeclaration: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module BABYLON {
  9177. /** @hidden */
  9178. export var morphTargetsVertexDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module BABYLON {
  9184. /** @hidden */
  9185. export var instancesDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module BABYLON {
  9191. /** @hidden */
  9192. export var helperFunctions: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module BABYLON {
  9198. /** @hidden */
  9199. export var shadowMapVertexDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module BABYLON {
  9205. /** @hidden */
  9206. export var clipPlaneVertexDeclaration: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module BABYLON {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module BABYLON {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module BABYLON {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module BABYLON {
  9233. /** @hidden */
  9234. export var shadowMapVertexNormalBias: {
  9235. name: string;
  9236. shader: string;
  9237. };
  9238. }
  9239. declare module BABYLON {
  9240. /** @hidden */
  9241. export var shadowMapVertexMetric: {
  9242. name: string;
  9243. shader: string;
  9244. };
  9245. }
  9246. declare module BABYLON {
  9247. /** @hidden */
  9248. export var clipPlaneVertex: {
  9249. name: string;
  9250. shader: string;
  9251. };
  9252. }
  9253. declare module BABYLON {
  9254. /** @hidden */
  9255. export var shadowMapVertexShader: {
  9256. name: string;
  9257. shader: string;
  9258. };
  9259. }
  9260. declare module BABYLON {
  9261. /** @hidden */
  9262. export var depthBoxBlurPixelShader: {
  9263. name: string;
  9264. shader: string;
  9265. };
  9266. }
  9267. declare module BABYLON {
  9268. /** @hidden */
  9269. export var shadowMapFragmentSoftTransparentShadow: {
  9270. name: string;
  9271. shader: string;
  9272. };
  9273. }
  9274. declare module BABYLON {
  9275. /**
  9276. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9277. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9278. */
  9279. export class EffectFallbacks implements IEffectFallbacks {
  9280. private _defines;
  9281. private _currentRank;
  9282. private _maxRank;
  9283. private _mesh;
  9284. /**
  9285. * Removes the fallback from the bound mesh.
  9286. */
  9287. unBindMesh(): void;
  9288. /**
  9289. * Adds a fallback on the specified property.
  9290. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9291. * @param define The name of the define in the shader
  9292. */
  9293. addFallback(rank: number, define: string): void;
  9294. /**
  9295. * Sets the mesh to use CPU skinning when needing to fallback.
  9296. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9297. * @param mesh The mesh to use the fallbacks.
  9298. */
  9299. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9300. /**
  9301. * Checks to see if more fallbacks are still availible.
  9302. */
  9303. get hasMoreFallbacks(): boolean;
  9304. /**
  9305. * Removes the defines that should be removed when falling back.
  9306. * @param currentDefines defines the current define statements for the shader.
  9307. * @param effect defines the current effect we try to compile
  9308. * @returns The resulting defines with defines of the current rank removed.
  9309. */
  9310. reduce(currentDefines: string, effect: Effect): string;
  9311. }
  9312. }
  9313. declare module BABYLON {
  9314. /**
  9315. * Interface used to define Action
  9316. */
  9317. export interface IAction {
  9318. /**
  9319. * Trigger for the action
  9320. */
  9321. trigger: number;
  9322. /** Options of the trigger */
  9323. triggerOptions: any;
  9324. /**
  9325. * Gets the trigger parameters
  9326. * @returns the trigger parameters
  9327. */
  9328. getTriggerParameter(): any;
  9329. /**
  9330. * Internal only - executes current action event
  9331. * @hidden
  9332. */
  9333. _executeCurrent(evt?: ActionEvent): void;
  9334. /**
  9335. * Serialize placeholder for child classes
  9336. * @param parent of child
  9337. * @returns the serialized object
  9338. */
  9339. serialize(parent: any): any;
  9340. /**
  9341. * Internal only
  9342. * @hidden
  9343. */
  9344. _prepare(): void;
  9345. /**
  9346. * Internal only - manager for action
  9347. * @hidden
  9348. */
  9349. _actionManager: AbstractActionManager;
  9350. /**
  9351. * Adds action to chain of actions, may be a DoNothingAction
  9352. * @param action defines the next action to execute
  9353. * @returns The action passed in
  9354. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9355. */
  9356. then(action: IAction): IAction;
  9357. }
  9358. /**
  9359. * The action to be carried out following a trigger
  9360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9361. */
  9362. export class Action implements IAction {
  9363. /** the trigger, with or without parameters, for the action */
  9364. triggerOptions: any;
  9365. /**
  9366. * Trigger for the action
  9367. */
  9368. trigger: number;
  9369. /**
  9370. * Internal only - manager for action
  9371. * @hidden
  9372. */
  9373. _actionManager: ActionManager;
  9374. private _nextActiveAction;
  9375. private _child;
  9376. private _condition?;
  9377. private _triggerParameter;
  9378. /**
  9379. * An event triggered prior to action being executed.
  9380. */
  9381. onBeforeExecuteObservable: Observable<Action>;
  9382. /**
  9383. * Creates a new Action
  9384. * @param triggerOptions the trigger, with or without parameters, for the action
  9385. * @param condition an optional determinant of action
  9386. */
  9387. constructor(
  9388. /** the trigger, with or without parameters, for the action */
  9389. triggerOptions: any, condition?: Condition);
  9390. /**
  9391. * Internal only
  9392. * @hidden
  9393. */
  9394. _prepare(): void;
  9395. /**
  9396. * Gets the trigger parameters
  9397. * @returns the trigger parameters
  9398. */
  9399. getTriggerParameter(): any;
  9400. /**
  9401. * Internal only - executes current action event
  9402. * @hidden
  9403. */
  9404. _executeCurrent(evt?: ActionEvent): void;
  9405. /**
  9406. * Execute placeholder for child classes
  9407. * @param evt optional action event
  9408. */
  9409. execute(evt?: ActionEvent): void;
  9410. /**
  9411. * Skips to next active action
  9412. */
  9413. skipToNextActiveAction(): void;
  9414. /**
  9415. * Adds action to chain of actions, may be a DoNothingAction
  9416. * @param action defines the next action to execute
  9417. * @returns The action passed in
  9418. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9419. */
  9420. then(action: Action): Action;
  9421. /**
  9422. * Internal only
  9423. * @hidden
  9424. */
  9425. _getProperty(propertyPath: string): string;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. _getEffectiveTarget(target: any, propertyPath: string): any;
  9431. /**
  9432. * Serialize placeholder for child classes
  9433. * @param parent of child
  9434. * @returns the serialized object
  9435. */
  9436. serialize(parent: any): any;
  9437. /**
  9438. * Internal only called by serialize
  9439. * @hidden
  9440. */
  9441. protected _serialize(serializedAction: any, parent?: any): any;
  9442. /**
  9443. * Internal only
  9444. * @hidden
  9445. */
  9446. static _SerializeValueAsString: (value: any) => string;
  9447. /**
  9448. * Internal only
  9449. * @hidden
  9450. */
  9451. static _GetTargetProperty: (target: Scene | Node) => {
  9452. name: string;
  9453. targetType: string;
  9454. value: string;
  9455. };
  9456. }
  9457. }
  9458. declare module BABYLON {
  9459. /**
  9460. * A Condition applied to an Action
  9461. */
  9462. export class Condition {
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: ActionManager;
  9468. /**
  9469. * Internal only
  9470. * @hidden
  9471. */
  9472. _evaluationId: number;
  9473. /**
  9474. * Internal only
  9475. * @hidden
  9476. */
  9477. _currentResult: boolean;
  9478. /**
  9479. * Creates a new Condition
  9480. * @param actionManager the manager of the action the condition is applied to
  9481. */
  9482. constructor(actionManager: ActionManager);
  9483. /**
  9484. * Check if the current condition is valid
  9485. * @returns a boolean
  9486. */
  9487. isValid(): boolean;
  9488. /**
  9489. * Internal only
  9490. * @hidden
  9491. */
  9492. _getProperty(propertyPath: string): string;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. _getEffectiveTarget(target: any, propertyPath: string): any;
  9498. /**
  9499. * Serialize placeholder for child classes
  9500. * @returns the serialized object
  9501. */
  9502. serialize(): any;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. protected _serialize(serializedCondition: any): any;
  9508. }
  9509. /**
  9510. * Defines specific conditional operators as extensions of Condition
  9511. */
  9512. export class ValueCondition extends Condition {
  9513. /** path to specify the property of the target the conditional operator uses */
  9514. propertyPath: string;
  9515. /** the value compared by the conditional operator against the current value of the property */
  9516. value: any;
  9517. /** the conditional operator, default ValueCondition.IsEqual */
  9518. operator: number;
  9519. /**
  9520. * Internal only
  9521. * @hidden
  9522. */
  9523. private static _IsEqual;
  9524. /**
  9525. * Internal only
  9526. * @hidden
  9527. */
  9528. private static _IsDifferent;
  9529. /**
  9530. * Internal only
  9531. * @hidden
  9532. */
  9533. private static _IsGreater;
  9534. /**
  9535. * Internal only
  9536. * @hidden
  9537. */
  9538. private static _IsLesser;
  9539. /**
  9540. * returns the number for IsEqual
  9541. */
  9542. static get IsEqual(): number;
  9543. /**
  9544. * Returns the number for IsDifferent
  9545. */
  9546. static get IsDifferent(): number;
  9547. /**
  9548. * Returns the number for IsGreater
  9549. */
  9550. static get IsGreater(): number;
  9551. /**
  9552. * Returns the number for IsLesser
  9553. */
  9554. static get IsLesser(): number;
  9555. /**
  9556. * Internal only The action manager for the condition
  9557. * @hidden
  9558. */
  9559. _actionManager: ActionManager;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. private _target;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. private _effectiveTarget;
  9570. /**
  9571. * Internal only
  9572. * @hidden
  9573. */
  9574. private _property;
  9575. /**
  9576. * Creates a new ValueCondition
  9577. * @param actionManager manager for the action the condition applies to
  9578. * @param target for the action
  9579. * @param propertyPath path to specify the property of the target the conditional operator uses
  9580. * @param value the value compared by the conditional operator against the current value of the property
  9581. * @param operator the conditional operator, default ValueCondition.IsEqual
  9582. */
  9583. constructor(actionManager: ActionManager, target: any,
  9584. /** path to specify the property of the target the conditional operator uses */
  9585. propertyPath: string,
  9586. /** the value compared by the conditional operator against the current value of the property */
  9587. value: any,
  9588. /** the conditional operator, default ValueCondition.IsEqual */
  9589. operator?: number);
  9590. /**
  9591. * Compares the given value with the property value for the specified conditional operator
  9592. * @returns the result of the comparison
  9593. */
  9594. isValid(): boolean;
  9595. /**
  9596. * Serialize the ValueCondition into a JSON compatible object
  9597. * @returns serialization object
  9598. */
  9599. serialize(): any;
  9600. /**
  9601. * Gets the name of the conditional operator for the ValueCondition
  9602. * @param operator the conditional operator
  9603. * @returns the name
  9604. */
  9605. static GetOperatorName(operator: number): string;
  9606. }
  9607. /**
  9608. * Defines a predicate condition as an extension of Condition
  9609. */
  9610. export class PredicateCondition extends Condition {
  9611. /** defines the predicate function used to validate the condition */
  9612. predicate: () => boolean;
  9613. /**
  9614. * Internal only - manager for action
  9615. * @hidden
  9616. */
  9617. _actionManager: ActionManager;
  9618. /**
  9619. * Creates a new PredicateCondition
  9620. * @param actionManager manager for the action the condition applies to
  9621. * @param predicate defines the predicate function used to validate the condition
  9622. */
  9623. constructor(actionManager: ActionManager,
  9624. /** defines the predicate function used to validate the condition */
  9625. predicate: () => boolean);
  9626. /**
  9627. * @returns the validity of the predicate condition
  9628. */
  9629. isValid(): boolean;
  9630. }
  9631. /**
  9632. * Defines a state condition as an extension of Condition
  9633. */
  9634. export class StateCondition extends Condition {
  9635. /** Value to compare with target state */
  9636. value: string;
  9637. /**
  9638. * Internal only - manager for action
  9639. * @hidden
  9640. */
  9641. _actionManager: ActionManager;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private _target;
  9647. /**
  9648. * Creates a new StateCondition
  9649. * @param actionManager manager for the action the condition applies to
  9650. * @param target of the condition
  9651. * @param value to compare with target state
  9652. */
  9653. constructor(actionManager: ActionManager, target: any,
  9654. /** Value to compare with target state */
  9655. value: string);
  9656. /**
  9657. * Gets a boolean indicating if the current condition is met
  9658. * @returns the validity of the state
  9659. */
  9660. isValid(): boolean;
  9661. /**
  9662. * Serialize the StateCondition into a JSON compatible object
  9663. * @returns serialization object
  9664. */
  9665. serialize(): any;
  9666. }
  9667. }
  9668. declare module BABYLON {
  9669. /**
  9670. * This defines an action responsible to toggle a boolean once triggered.
  9671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9672. */
  9673. export class SwitchBooleanAction extends Action {
  9674. /**
  9675. * The path to the boolean property in the target object
  9676. */
  9677. propertyPath: string;
  9678. private _target;
  9679. private _effectiveTarget;
  9680. private _property;
  9681. /**
  9682. * Instantiate the action
  9683. * @param triggerOptions defines the trigger options
  9684. * @param target defines the object containing the boolean
  9685. * @param propertyPath defines the path to the boolean property in the target object
  9686. * @param condition defines the trigger related conditions
  9687. */
  9688. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9689. /** @hidden */
  9690. _prepare(): void;
  9691. /**
  9692. * Execute the action toggle the boolean value.
  9693. */
  9694. execute(): void;
  9695. /**
  9696. * Serializes the actions and its related information.
  9697. * @param parent defines the object to serialize in
  9698. * @returns the serialized object
  9699. */
  9700. serialize(parent: any): any;
  9701. }
  9702. /**
  9703. * This defines an action responsible to set a the state field of the target
  9704. * to a desired value once triggered.
  9705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9706. */
  9707. export class SetStateAction extends Action {
  9708. /**
  9709. * The value to store in the state field.
  9710. */
  9711. value: string;
  9712. private _target;
  9713. /**
  9714. * Instantiate the action
  9715. * @param triggerOptions defines the trigger options
  9716. * @param target defines the object containing the state property
  9717. * @param value defines the value to store in the state field
  9718. * @param condition defines the trigger related conditions
  9719. */
  9720. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9721. /**
  9722. * Execute the action and store the value on the target state property.
  9723. */
  9724. execute(): void;
  9725. /**
  9726. * Serializes the actions and its related information.
  9727. * @param parent defines the object to serialize in
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. }
  9732. /**
  9733. * This defines an action responsible to set a property of the target
  9734. * to a desired value once triggered.
  9735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9736. */
  9737. export class SetValueAction extends Action {
  9738. /**
  9739. * The path of the property to set in the target.
  9740. */
  9741. propertyPath: string;
  9742. /**
  9743. * The value to set in the property
  9744. */
  9745. value: any;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the property
  9753. * @param propertyPath defines the path of the property to set in the target
  9754. * @param value defines the value to set in the property
  9755. * @param condition defines the trigger related conditions
  9756. */
  9757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9758. /** @hidden */
  9759. _prepare(): void;
  9760. /**
  9761. * Execute the action and set the targetted property to the desired value.
  9762. */
  9763. execute(): void;
  9764. /**
  9765. * Serializes the actions and its related information.
  9766. * @param parent defines the object to serialize in
  9767. * @returns the serialized object
  9768. */
  9769. serialize(parent: any): any;
  9770. }
  9771. /**
  9772. * This defines an action responsible to increment the target value
  9773. * to a desired value once triggered.
  9774. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9775. */
  9776. export class IncrementValueAction extends Action {
  9777. /**
  9778. * The path of the property to increment in the target.
  9779. */
  9780. propertyPath: string;
  9781. /**
  9782. * The value we should increment the property by.
  9783. */
  9784. value: any;
  9785. private _target;
  9786. private _effectiveTarget;
  9787. private _property;
  9788. /**
  9789. * Instantiate the action
  9790. * @param triggerOptions defines the trigger options
  9791. * @param target defines the object containing the property
  9792. * @param propertyPath defines the path of the property to increment in the target
  9793. * @param value defines the value value we should increment the property by
  9794. * @param condition defines the trigger related conditions
  9795. */
  9796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9797. /** @hidden */
  9798. _prepare(): void;
  9799. /**
  9800. * Execute the action and increment the target of the value amount.
  9801. */
  9802. execute(): void;
  9803. /**
  9804. * Serializes the actions and its related information.
  9805. * @param parent defines the object to serialize in
  9806. * @returns the serialized object
  9807. */
  9808. serialize(parent: any): any;
  9809. }
  9810. /**
  9811. * This defines an action responsible to start an animation once triggered.
  9812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9813. */
  9814. export class PlayAnimationAction extends Action {
  9815. /**
  9816. * Where the animation should start (animation frame)
  9817. */
  9818. from: number;
  9819. /**
  9820. * Where the animation should stop (animation frame)
  9821. */
  9822. to: number;
  9823. /**
  9824. * Define if the animation should loop or stop after the first play.
  9825. */
  9826. loop?: boolean;
  9827. private _target;
  9828. /**
  9829. * Instantiate the action
  9830. * @param triggerOptions defines the trigger options
  9831. * @param target defines the target animation or animation name
  9832. * @param from defines from where the animation should start (animation frame)
  9833. * @param end defines where the animation should stop (animation frame)
  9834. * @param loop defines if the animation should loop or stop after the first play
  9835. * @param condition defines the trigger related conditions
  9836. */
  9837. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9838. /** @hidden */
  9839. _prepare(): void;
  9840. /**
  9841. * Execute the action and play the animation.
  9842. */
  9843. execute(): void;
  9844. /**
  9845. * Serializes the actions and its related information.
  9846. * @param parent defines the object to serialize in
  9847. * @returns the serialized object
  9848. */
  9849. serialize(parent: any): any;
  9850. }
  9851. /**
  9852. * This defines an action responsible to stop an animation once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class StopAnimationAction extends Action {
  9856. private _target;
  9857. /**
  9858. * Instantiate the action
  9859. * @param triggerOptions defines the trigger options
  9860. * @param target defines the target animation or animation name
  9861. * @param condition defines the trigger related conditions
  9862. */
  9863. constructor(triggerOptions: any, target: any, condition?: Condition);
  9864. /** @hidden */
  9865. _prepare(): void;
  9866. /**
  9867. * Execute the action and stop the animation.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible that does nothing once triggered.
  9879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9880. */
  9881. export class DoNothingAction extends Action {
  9882. /**
  9883. * Instantiate the action
  9884. * @param triggerOptions defines the trigger options
  9885. * @param condition defines the trigger related conditions
  9886. */
  9887. constructor(triggerOptions?: any, condition?: Condition);
  9888. /**
  9889. * Execute the action and do nothing.
  9890. */
  9891. execute(): void;
  9892. /**
  9893. * Serializes the actions and its related information.
  9894. * @param parent defines the object to serialize in
  9895. * @returns the serialized object
  9896. */
  9897. serialize(parent: any): any;
  9898. }
  9899. /**
  9900. * This defines an action responsible to trigger several actions once triggered.
  9901. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9902. */
  9903. export class CombineAction extends Action {
  9904. /**
  9905. * The list of aggregated animations to run.
  9906. */
  9907. children: Action[];
  9908. /**
  9909. * Instantiate the action
  9910. * @param triggerOptions defines the trigger options
  9911. * @param children defines the list of aggregated animations to run
  9912. * @param condition defines the trigger related conditions
  9913. */
  9914. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9915. /** @hidden */
  9916. _prepare(): void;
  9917. /**
  9918. * Execute the action and executes all the aggregated actions.
  9919. */
  9920. execute(evt: ActionEvent): void;
  9921. /**
  9922. * Serializes the actions and its related information.
  9923. * @param parent defines the object to serialize in
  9924. * @returns the serialized object
  9925. */
  9926. serialize(parent: any): any;
  9927. }
  9928. /**
  9929. * This defines an action responsible to run code (external event) once triggered.
  9930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9931. */
  9932. export class ExecuteCodeAction extends Action {
  9933. /**
  9934. * The callback function to run.
  9935. */
  9936. func: (evt: ActionEvent) => void;
  9937. /**
  9938. * Instantiate the action
  9939. * @param triggerOptions defines the trigger options
  9940. * @param func defines the callback function to run
  9941. * @param condition defines the trigger related conditions
  9942. */
  9943. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9944. /**
  9945. * Execute the action and run the attached code.
  9946. */
  9947. execute(evt: ActionEvent): void;
  9948. }
  9949. /**
  9950. * This defines an action responsible to set the parent property of the target once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class SetParentAction extends Action {
  9954. private _parent;
  9955. private _target;
  9956. /**
  9957. * Instantiate the action
  9958. * @param triggerOptions defines the trigger options
  9959. * @param target defines the target containing the parent property
  9960. * @param parent defines from where the animation should start (animation frame)
  9961. * @param condition defines the trigger related conditions
  9962. */
  9963. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9964. /** @hidden */
  9965. _prepare(): void;
  9966. /**
  9967. * Execute the action and set the parent property.
  9968. */
  9969. execute(): void;
  9970. /**
  9971. * Serializes the actions and its related information.
  9972. * @param parent defines the object to serialize in
  9973. * @returns the serialized object
  9974. */
  9975. serialize(parent: any): any;
  9976. }
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9981. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9983. */
  9984. export class ActionManager extends AbstractActionManager {
  9985. /**
  9986. * Nothing
  9987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9988. */
  9989. static readonly NothingTrigger: number;
  9990. /**
  9991. * On pick
  9992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9993. */
  9994. static readonly OnPickTrigger: number;
  9995. /**
  9996. * On left pick
  9997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9998. */
  9999. static readonly OnLeftPickTrigger: number;
  10000. /**
  10001. * On right pick
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10003. */
  10004. static readonly OnRightPickTrigger: number;
  10005. /**
  10006. * On center pick
  10007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10008. */
  10009. static readonly OnCenterPickTrigger: number;
  10010. /**
  10011. * On pick down
  10012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickDownTrigger: number;
  10015. /**
  10016. * On double pick
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnDoublePickTrigger: number;
  10020. /**
  10021. * On pick up
  10022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPickUpTrigger: number;
  10025. /**
  10026. * On pick out.
  10027. * This trigger will only be raised if you also declared a OnPickDown
  10028. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnPickOutTrigger: number;
  10031. /**
  10032. * On long press
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10034. */
  10035. static readonly OnLongPressTrigger: number;
  10036. /**
  10037. * On pointer over
  10038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10039. */
  10040. static readonly OnPointerOverTrigger: number;
  10041. /**
  10042. * On pointer out
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10044. */
  10045. static readonly OnPointerOutTrigger: number;
  10046. /**
  10047. * On every frame
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10049. */
  10050. static readonly OnEveryFrameTrigger: number;
  10051. /**
  10052. * On intersection enter
  10053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10054. */
  10055. static readonly OnIntersectionEnterTrigger: number;
  10056. /**
  10057. * On intersection exit
  10058. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10059. */
  10060. static readonly OnIntersectionExitTrigger: number;
  10061. /**
  10062. * On key down
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10064. */
  10065. static readonly OnKeyDownTrigger: number;
  10066. /**
  10067. * On key up
  10068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10069. */
  10070. static readonly OnKeyUpTrigger: number;
  10071. private _scene;
  10072. /**
  10073. * Creates a new action manager
  10074. * @param scene defines the hosting scene
  10075. */
  10076. constructor(scene: Scene);
  10077. /**
  10078. * Releases all associated resources
  10079. */
  10080. dispose(): void;
  10081. /**
  10082. * Gets hosting scene
  10083. * @returns the hosting scene
  10084. */
  10085. getScene(): Scene;
  10086. /**
  10087. * Does this action manager handles actions of any of the given triggers
  10088. * @param triggers defines the triggers to be tested
  10089. * @return a boolean indicating whether one (or more) of the triggers is handled
  10090. */
  10091. hasSpecificTriggers(triggers: number[]): boolean;
  10092. /**
  10093. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10094. * speed.
  10095. * @param triggerA defines the trigger to be tested
  10096. * @param triggerB defines the trigger to be tested
  10097. * @return a boolean indicating whether one (or more) of the triggers is handled
  10098. */
  10099. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10100. /**
  10101. * Does this action manager handles actions of a given trigger
  10102. * @param trigger defines the trigger to be tested
  10103. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10104. * @return whether the trigger is handled
  10105. */
  10106. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10107. /**
  10108. * Does this action manager has pointer triggers
  10109. */
  10110. get hasPointerTriggers(): boolean;
  10111. /**
  10112. * Does this action manager has pick triggers
  10113. */
  10114. get hasPickTriggers(): boolean;
  10115. /**
  10116. * Registers an action to this action manager
  10117. * @param action defines the action to be registered
  10118. * @return the action amended (prepared) after registration
  10119. */
  10120. registerAction(action: IAction): Nullable<IAction>;
  10121. /**
  10122. * Unregisters an action to this action manager
  10123. * @param action defines the action to be unregistered
  10124. * @return a boolean indicating whether the action has been unregistered
  10125. */
  10126. unregisterAction(action: IAction): Boolean;
  10127. /**
  10128. * Process a specific trigger
  10129. * @param trigger defines the trigger to process
  10130. * @param evt defines the event details to be processed
  10131. */
  10132. processTrigger(trigger: number, evt?: IActionEvent): void;
  10133. /** @hidden */
  10134. _getEffectiveTarget(target: any, propertyPath: string): any;
  10135. /** @hidden */
  10136. _getProperty(propertyPath: string): string;
  10137. /**
  10138. * Serialize this manager to a JSON object
  10139. * @param name defines the property name to store this manager
  10140. * @returns a JSON representation of this manager
  10141. */
  10142. serialize(name: string): any;
  10143. /**
  10144. * Creates a new ActionManager from a JSON data
  10145. * @param parsedActions defines the JSON data to read from
  10146. * @param object defines the hosting mesh
  10147. * @param scene defines the hosting scene
  10148. */
  10149. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10150. /**
  10151. * Get a trigger name by index
  10152. * @param trigger defines the trigger index
  10153. * @returns a trigger name
  10154. */
  10155. static GetTriggerName(trigger: number): string;
  10156. }
  10157. }
  10158. declare module BABYLON {
  10159. /**
  10160. * Class used to represent a sprite
  10161. * @see https://doc.babylonjs.com/babylon101/sprites
  10162. */
  10163. export class Sprite implements IAnimatable {
  10164. /** defines the name */
  10165. name: string;
  10166. /** Gets or sets the current world position */
  10167. position: Vector3;
  10168. /** Gets or sets the main color */
  10169. color: Color4;
  10170. /** Gets or sets the width */
  10171. width: number;
  10172. /** Gets or sets the height */
  10173. height: number;
  10174. /** Gets or sets rotation angle */
  10175. angle: number;
  10176. /** Gets or sets the cell index in the sprite sheet */
  10177. cellIndex: number;
  10178. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10179. cellRef: string;
  10180. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10181. invertU: boolean;
  10182. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10183. invertV: boolean;
  10184. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10185. disposeWhenFinishedAnimating: boolean;
  10186. /** Gets the list of attached animations */
  10187. animations: Nullable<Array<Animation>>;
  10188. /** Gets or sets a boolean indicating if the sprite can be picked */
  10189. isPickable: boolean;
  10190. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10191. useAlphaForPicking: boolean;
  10192. /** @hidden */
  10193. _xOffset: number;
  10194. /** @hidden */
  10195. _yOffset: number;
  10196. /** @hidden */
  10197. _xSize: number;
  10198. /** @hidden */
  10199. _ySize: number;
  10200. /**
  10201. * Gets or sets the associated action manager
  10202. */
  10203. actionManager: Nullable<ActionManager>;
  10204. /**
  10205. * An event triggered when the control has been disposed
  10206. */
  10207. onDisposeObservable: Observable<Sprite>;
  10208. private _animationStarted;
  10209. private _loopAnimation;
  10210. private _fromIndex;
  10211. private _toIndex;
  10212. private _delay;
  10213. private _direction;
  10214. private _manager;
  10215. private _time;
  10216. private _onAnimationEnd;
  10217. /**
  10218. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10219. */
  10220. isVisible: boolean;
  10221. /**
  10222. * Gets or sets the sprite size
  10223. */
  10224. get size(): number;
  10225. set size(value: number);
  10226. /**
  10227. * Returns a boolean indicating if the animation is started
  10228. */
  10229. get animationStarted(): boolean;
  10230. /**
  10231. * Gets or sets the unique id of the sprite
  10232. */
  10233. uniqueId: number;
  10234. /**
  10235. * Gets the manager of this sprite
  10236. */
  10237. get manager(): ISpriteManager;
  10238. /**
  10239. * Creates a new Sprite
  10240. * @param name defines the name
  10241. * @param manager defines the manager
  10242. */
  10243. constructor(
  10244. /** defines the name */
  10245. name: string, manager: ISpriteManager);
  10246. /**
  10247. * Returns the string "Sprite"
  10248. * @returns "Sprite"
  10249. */
  10250. getClassName(): string;
  10251. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10252. get fromIndex(): number;
  10253. set fromIndex(value: number);
  10254. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10255. get toIndex(): number;
  10256. set toIndex(value: number);
  10257. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10258. get loopAnimation(): boolean;
  10259. set loopAnimation(value: boolean);
  10260. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10261. get delay(): number;
  10262. set delay(value: number);
  10263. /**
  10264. * Starts an animation
  10265. * @param from defines the initial key
  10266. * @param to defines the end key
  10267. * @param loop defines if the animation must loop
  10268. * @param delay defines the start delay (in ms)
  10269. * @param onAnimationEnd defines a callback to call when animation ends
  10270. */
  10271. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10272. /** Stops current animation (if any) */
  10273. stopAnimation(): void;
  10274. /** @hidden */
  10275. _animate(deltaTime: number): void;
  10276. /** Release associated resources */
  10277. dispose(): void;
  10278. /**
  10279. * Serializes the sprite to a JSON object
  10280. * @returns the JSON object
  10281. */
  10282. serialize(): any;
  10283. /**
  10284. * Parses a JSON object to create a new sprite
  10285. * @param parsedSprite The JSON object to parse
  10286. * @param manager defines the hosting manager
  10287. * @returns the new sprite
  10288. */
  10289. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10290. }
  10291. }
  10292. declare module BABYLON {
  10293. /**
  10294. * Information about the result of picking within a scene
  10295. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10296. */
  10297. export class PickingInfo {
  10298. /** @hidden */
  10299. _pickingUnavailable: boolean;
  10300. /**
  10301. * If the pick collided with an object
  10302. */
  10303. hit: boolean;
  10304. /**
  10305. * Distance away where the pick collided
  10306. */
  10307. distance: number;
  10308. /**
  10309. * The location of pick collision
  10310. */
  10311. pickedPoint: Nullable<Vector3>;
  10312. /**
  10313. * The mesh corresponding the the pick collision
  10314. */
  10315. pickedMesh: Nullable<AbstractMesh>;
  10316. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10317. bu: number;
  10318. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10319. bv: number;
  10320. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10321. faceId: number;
  10322. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10323. subMeshFaceId: number;
  10324. /** Id of the the submesh that was picked */
  10325. subMeshId: number;
  10326. /** If a sprite was picked, this will be the sprite the pick collided with */
  10327. pickedSprite: Nullable<Sprite>;
  10328. /**
  10329. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10330. */
  10331. originMesh: Nullable<AbstractMesh>;
  10332. /**
  10333. * The ray that was used to perform the picking.
  10334. */
  10335. ray: Nullable<Ray>;
  10336. /**
  10337. * Gets the normal correspodning to the face the pick collided with
  10338. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10339. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10340. * @returns The normal correspodning to the face the pick collided with
  10341. */
  10342. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10343. /**
  10344. * Gets the texture coordinates of where the pick occured
  10345. * @returns the vector containing the coordnates of the texture
  10346. */
  10347. getTextureCoordinates(): Nullable<Vector2>;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. /**
  10352. * Class representing a ray with position and direction
  10353. */
  10354. export class Ray {
  10355. /** origin point */
  10356. origin: Vector3;
  10357. /** direction */
  10358. direction: Vector3;
  10359. /** length of the ray */
  10360. length: number;
  10361. private static readonly TmpVector3;
  10362. private _tmpRay;
  10363. /**
  10364. * Creates a new ray
  10365. * @param origin origin point
  10366. * @param direction direction
  10367. * @param length length of the ray
  10368. */
  10369. constructor(
  10370. /** origin point */
  10371. origin: Vector3,
  10372. /** direction */
  10373. direction: Vector3,
  10374. /** length of the ray */
  10375. length?: number);
  10376. /**
  10377. * Checks if the ray intersects a box
  10378. * This does not account for the ray lenght by design to improve perfs.
  10379. * @param minimum bound of the box
  10380. * @param maximum bound of the box
  10381. * @param intersectionTreshold extra extend to be added to the box in all direction
  10382. * @returns if the box was hit
  10383. */
  10384. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10385. /**
  10386. * Checks if the ray intersects a box
  10387. * This does not account for the ray lenght by design to improve perfs.
  10388. * @param box the bounding box to check
  10389. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10390. * @returns if the box was hit
  10391. */
  10392. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10393. /**
  10394. * If the ray hits a sphere
  10395. * @param sphere the bounding sphere to check
  10396. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10397. * @returns true if it hits the sphere
  10398. */
  10399. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10400. /**
  10401. * If the ray hits a triange
  10402. * @param vertex0 triangle vertex
  10403. * @param vertex1 triangle vertex
  10404. * @param vertex2 triangle vertex
  10405. * @returns intersection information if hit
  10406. */
  10407. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10408. /**
  10409. * Checks if ray intersects a plane
  10410. * @param plane the plane to check
  10411. * @returns the distance away it was hit
  10412. */
  10413. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10414. /**
  10415. * Calculate the intercept of a ray on a given axis
  10416. * @param axis to check 'x' | 'y' | 'z'
  10417. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10418. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10419. */
  10420. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10421. /**
  10422. * Checks if ray intersects a mesh
  10423. * @param mesh the mesh to check
  10424. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10425. * @returns picking info of the intersecton
  10426. */
  10427. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10428. /**
  10429. * Checks if ray intersects a mesh
  10430. * @param meshes the meshes to check
  10431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10432. * @param results array to store result in
  10433. * @returns Array of picking infos
  10434. */
  10435. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10436. private _comparePickingInfo;
  10437. private static smallnum;
  10438. private static rayl;
  10439. /**
  10440. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10441. * @param sega the first point of the segment to test the intersection against
  10442. * @param segb the second point of the segment to test the intersection against
  10443. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10444. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10445. */
  10446. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10447. /**
  10448. * Update the ray from viewport position
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns this ray updated
  10457. */
  10458. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * Creates a ray with origin and direction of 0,0,0
  10461. * @returns the new ray
  10462. */
  10463. static Zero(): Ray;
  10464. /**
  10465. * Creates a new ray from screen space and viewport
  10466. * @param x position
  10467. * @param y y position
  10468. * @param viewportWidth viewport width
  10469. * @param viewportHeight viewport height
  10470. * @param world world matrix
  10471. * @param view view matrix
  10472. * @param projection projection matrix
  10473. * @returns new ray
  10474. */
  10475. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * 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
  10478. * transformed to the given world matrix.
  10479. * @param origin The origin point
  10480. * @param end The end point
  10481. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10482. * @returns the new ray
  10483. */
  10484. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10485. /**
  10486. * Transforms a ray by a matrix
  10487. * @param ray ray to transform
  10488. * @param matrix matrix to apply
  10489. * @returns the resulting new ray
  10490. */
  10491. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10492. /**
  10493. * Transforms a ray by a matrix
  10494. * @param ray ray to transform
  10495. * @param matrix matrix to apply
  10496. * @param result ray to store result in
  10497. */
  10498. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10499. /**
  10500. * Unproject a ray from screen space to object space
  10501. * @param sourceX defines the screen space x coordinate to use
  10502. * @param sourceY defines the screen space y coordinate to use
  10503. * @param viewportWidth defines the current width of the viewport
  10504. * @param viewportHeight defines the current height of the viewport
  10505. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10506. * @param view defines the view matrix to use
  10507. * @param projection defines the projection matrix to use
  10508. */
  10509. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10510. }
  10511. /**
  10512. * Type used to define predicate used to select faces when a mesh intersection is detected
  10513. */
  10514. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10515. interface Scene {
  10516. /** @hidden */
  10517. _tempPickingRay: Nullable<Ray>;
  10518. /** @hidden */
  10519. _cachedRayForTransform: Ray;
  10520. /** @hidden */
  10521. _pickWithRayInverseMatrix: Matrix;
  10522. /** @hidden */
  10523. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10524. /** @hidden */
  10525. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10526. }
  10527. }
  10528. declare module BABYLON {
  10529. /**
  10530. * Groups all the scene component constants in one place to ease maintenance.
  10531. * @hidden
  10532. */
  10533. export class SceneComponentConstants {
  10534. static readonly NAME_EFFECTLAYER: string;
  10535. static readonly NAME_LAYER: string;
  10536. static readonly NAME_LENSFLARESYSTEM: string;
  10537. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10538. static readonly NAME_PARTICLESYSTEM: string;
  10539. static readonly NAME_GAMEPAD: string;
  10540. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10541. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10542. static readonly NAME_PREPASSRENDERER: string;
  10543. static readonly NAME_DEPTHRENDERER: string;
  10544. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10545. static readonly NAME_SPRITE: string;
  10546. static readonly NAME_OUTLINERENDERER: string;
  10547. static readonly NAME_PROCEDURALTEXTURE: string;
  10548. static readonly NAME_SHADOWGENERATOR: string;
  10549. static readonly NAME_OCTREE: string;
  10550. static readonly NAME_PHYSICSENGINE: string;
  10551. static readonly NAME_AUDIO: string;
  10552. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10553. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10554. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10555. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10556. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10557. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10558. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10559. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10560. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10561. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10562. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10563. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10564. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10565. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10566. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10567. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10568. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10572. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10573. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10574. static readonly STEP_AFTERRENDER_AUDIO: number;
  10575. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10576. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10577. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10578. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10579. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10580. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10581. static readonly STEP_POINTERMOVE_SPRITE: number;
  10582. static readonly STEP_POINTERDOWN_SPRITE: number;
  10583. static readonly STEP_POINTERUP_SPRITE: number;
  10584. }
  10585. /**
  10586. * This represents a scene component.
  10587. *
  10588. * This is used to decouple the dependency the scene is having on the different workloads like
  10589. * layers, post processes...
  10590. */
  10591. export interface ISceneComponent {
  10592. /**
  10593. * The name of the component. Each component must have a unique name.
  10594. */
  10595. name: string;
  10596. /**
  10597. * The scene the component belongs to.
  10598. */
  10599. scene: Scene;
  10600. /**
  10601. * Register the component to one instance of a scene.
  10602. */
  10603. register(): void;
  10604. /**
  10605. * Rebuilds the elements related to this component in case of
  10606. * context lost for instance.
  10607. */
  10608. rebuild(): void;
  10609. /**
  10610. * Disposes the component and the associated ressources.
  10611. */
  10612. dispose(): void;
  10613. }
  10614. /**
  10615. * This represents a SERIALIZABLE scene component.
  10616. *
  10617. * This extends Scene Component to add Serialization methods on top.
  10618. */
  10619. export interface ISceneSerializableComponent extends ISceneComponent {
  10620. /**
  10621. * Adds all the elements from the container to the scene
  10622. * @param container the container holding the elements
  10623. */
  10624. addFromContainer(container: AbstractScene): void;
  10625. /**
  10626. * Removes all the elements in the container from the scene
  10627. * @param container contains the elements to remove
  10628. * @param dispose if the removed element should be disposed (default: false)
  10629. */
  10630. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10631. /**
  10632. * Serializes the component data to the specified json object
  10633. * @param serializationObject The object to serialize to
  10634. */
  10635. serialize(serializationObject: any): void;
  10636. }
  10637. /**
  10638. * Strong typing of a Mesh related stage step action
  10639. */
  10640. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10641. /**
  10642. * Strong typing of a Evaluate Sub Mesh related stage step action
  10643. */
  10644. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10645. /**
  10646. * Strong typing of a Active Mesh related stage step action
  10647. */
  10648. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10649. /**
  10650. * Strong typing of a Camera related stage step action
  10651. */
  10652. export type CameraStageAction = (camera: Camera) => void;
  10653. /**
  10654. * Strong typing of a Camera Frame buffer related stage step action
  10655. */
  10656. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10657. /**
  10658. * Strong typing of a Render Target related stage step action
  10659. */
  10660. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10661. /**
  10662. * Strong typing of a RenderingGroup related stage step action
  10663. */
  10664. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10665. /**
  10666. * Strong typing of a Mesh Render related stage step action
  10667. */
  10668. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10669. /**
  10670. * Strong typing of a simple stage step action
  10671. */
  10672. export type SimpleStageAction = () => void;
  10673. /**
  10674. * Strong typing of a render target action.
  10675. */
  10676. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10677. /**
  10678. * Strong typing of a pointer move action.
  10679. */
  10680. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10681. /**
  10682. * Strong typing of a pointer up/down action.
  10683. */
  10684. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10685. /**
  10686. * Representation of a stage in the scene (Basically a list of ordered steps)
  10687. * @hidden
  10688. */
  10689. export class Stage<T extends Function> extends Array<{
  10690. index: number;
  10691. component: ISceneComponent;
  10692. action: T;
  10693. }> {
  10694. /**
  10695. * Hide ctor from the rest of the world.
  10696. * @param items The items to add.
  10697. */
  10698. private constructor();
  10699. /**
  10700. * Creates a new Stage.
  10701. * @returns A new instance of a Stage
  10702. */
  10703. static Create<T extends Function>(): Stage<T>;
  10704. /**
  10705. * Registers a step in an ordered way in the targeted stage.
  10706. * @param index Defines the position to register the step in
  10707. * @param component Defines the component attached to the step
  10708. * @param action Defines the action to launch during the step
  10709. */
  10710. registerStep(index: number, component: ISceneComponent, action: T): void;
  10711. /**
  10712. * Clears all the steps from the stage.
  10713. */
  10714. clear(): void;
  10715. }
  10716. }
  10717. declare module BABYLON {
  10718. interface Scene {
  10719. /** @hidden */
  10720. _pointerOverSprite: Nullable<Sprite>;
  10721. /** @hidden */
  10722. _pickedDownSprite: Nullable<Sprite>;
  10723. /** @hidden */
  10724. _tempSpritePickingRay: Nullable<Ray>;
  10725. /**
  10726. * All of the sprite managers added to this scene
  10727. * @see https://doc.babylonjs.com/babylon101/sprites
  10728. */
  10729. spriteManagers: Array<ISpriteManager>;
  10730. /**
  10731. * An event triggered when sprites rendering is about to start
  10732. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10733. */
  10734. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10735. /**
  10736. * An event triggered when sprites rendering is done
  10737. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10738. */
  10739. onAfterSpritesRenderingObservable: Observable<Scene>;
  10740. /** @hidden */
  10741. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10742. /** Launch a ray to try to pick a sprite in the scene
  10743. * @param x position on screen
  10744. * @param y position on screen
  10745. * @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
  10746. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10747. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10748. * @returns a PickingInfo
  10749. */
  10750. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10751. /** Use the given ray to pick a sprite in the scene
  10752. * @param ray The ray (in world space) to use to pick meshes
  10753. * @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
  10754. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10755. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10756. * @returns a PickingInfo
  10757. */
  10758. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10759. /** @hidden */
  10760. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10761. /** Launch a ray to try to pick sprites in the scene
  10762. * @param x position on screen
  10763. * @param y position on screen
  10764. * @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
  10765. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10766. * @returns a PickingInfo array
  10767. */
  10768. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10769. /** Use the given ray to pick sprites in the scene
  10770. * @param ray The ray (in world space) to use to pick meshes
  10771. * @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
  10772. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10773. * @returns a PickingInfo array
  10774. */
  10775. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10776. /**
  10777. * Force the sprite under the pointer
  10778. * @param sprite defines the sprite to use
  10779. */
  10780. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10781. /**
  10782. * Gets the sprite under the pointer
  10783. * @returns a Sprite or null if no sprite is under the pointer
  10784. */
  10785. getPointerOverSprite(): Nullable<Sprite>;
  10786. }
  10787. /**
  10788. * Defines the sprite scene component responsible to manage sprites
  10789. * in a given scene.
  10790. */
  10791. export class SpriteSceneComponent implements ISceneComponent {
  10792. /**
  10793. * The component name helpfull to identify the component in the list of scene components.
  10794. */
  10795. readonly name: string;
  10796. /**
  10797. * The scene the component belongs to.
  10798. */
  10799. scene: Scene;
  10800. /** @hidden */
  10801. private _spritePredicate;
  10802. /**
  10803. * Creates a new instance of the component for the given scene
  10804. * @param scene Defines the scene to register the component in
  10805. */
  10806. constructor(scene: Scene);
  10807. /**
  10808. * Registers the component in a given scene
  10809. */
  10810. register(): void;
  10811. /**
  10812. * Rebuilds the elements related to this component in case of
  10813. * context lost for instance.
  10814. */
  10815. rebuild(): void;
  10816. /**
  10817. * Disposes the component and the associated ressources.
  10818. */
  10819. dispose(): void;
  10820. private _pickSpriteButKeepRay;
  10821. private _pointerMove;
  10822. private _pointerDown;
  10823. private _pointerUp;
  10824. }
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogFragmentDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var fogFragment: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /** @hidden */
  10842. export var spritesPixelShader: {
  10843. name: string;
  10844. shader: string;
  10845. };
  10846. }
  10847. declare module BABYLON {
  10848. /** @hidden */
  10849. export var fogVertexDeclaration: {
  10850. name: string;
  10851. shader: string;
  10852. };
  10853. }
  10854. declare module BABYLON {
  10855. /** @hidden */
  10856. export var spritesVertexShader: {
  10857. name: string;
  10858. shader: string;
  10859. };
  10860. }
  10861. declare module BABYLON {
  10862. /**
  10863. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10864. */
  10865. export interface ISpriteManager extends IDisposable {
  10866. /**
  10867. * Gets manager's name
  10868. */
  10869. name: string;
  10870. /**
  10871. * Restricts the camera to viewing objects with the same layerMask.
  10872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10873. */
  10874. layerMask: number;
  10875. /**
  10876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10877. */
  10878. isPickable: boolean;
  10879. /**
  10880. * Gets the hosting scene
  10881. */
  10882. scene: Scene;
  10883. /**
  10884. * Specifies the rendering group id for this mesh (0 by default)
  10885. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10886. */
  10887. renderingGroupId: number;
  10888. /**
  10889. * Defines the list of sprites managed by the manager.
  10890. */
  10891. sprites: Array<Sprite>;
  10892. /**
  10893. * Gets or sets the spritesheet texture
  10894. */
  10895. texture: Texture;
  10896. /** Defines the default width of a cell in the spritesheet */
  10897. cellWidth: number;
  10898. /** Defines the default height of a cell in the spritesheet */
  10899. cellHeight: number;
  10900. /**
  10901. * Tests the intersection of a sprite with a specific ray.
  10902. * @param ray The ray we are sending to test the collision
  10903. * @param camera The camera space we are sending rays in
  10904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10905. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10906. * @returns picking info or null.
  10907. */
  10908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10909. /**
  10910. * Intersects the sprites with a ray
  10911. * @param ray defines the ray to intersect with
  10912. * @param camera defines the current active camera
  10913. * @param predicate defines a predicate used to select candidate sprites
  10914. * @returns null if no hit or a PickingInfo array
  10915. */
  10916. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10917. /**
  10918. * Renders the list of sprites on screen.
  10919. */
  10920. render(): void;
  10921. }
  10922. /**
  10923. * Class used to manage multiple sprites on the same spritesheet
  10924. * @see https://doc.babylonjs.com/babylon101/sprites
  10925. */
  10926. export class SpriteManager implements ISpriteManager {
  10927. /** defines the manager's name */
  10928. name: string;
  10929. /** Define the Url to load snippets */
  10930. static SnippetUrl: string;
  10931. /** Snippet ID if the manager was created from the snippet server */
  10932. snippetId: string;
  10933. /** Gets the list of sprites */
  10934. sprites: Sprite[];
  10935. /** Gets or sets the rendering group id (0 by default) */
  10936. renderingGroupId: number;
  10937. /** Gets or sets camera layer mask */
  10938. layerMask: number;
  10939. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10940. fogEnabled: boolean;
  10941. /** Gets or sets a boolean indicating if the sprites are pickable */
  10942. isPickable: boolean;
  10943. /** Defines the default width of a cell in the spritesheet */
  10944. cellWidth: number;
  10945. /** Defines the default height of a cell in the spritesheet */
  10946. cellHeight: number;
  10947. /** Associative array from JSON sprite data file */
  10948. private _cellData;
  10949. /** Array of sprite names from JSON sprite data file */
  10950. private _spriteMap;
  10951. /** True when packed cell data from JSON file is ready*/
  10952. private _packedAndReady;
  10953. private _textureContent;
  10954. /**
  10955. * An event triggered when the manager is disposed.
  10956. */
  10957. onDisposeObservable: Observable<SpriteManager>;
  10958. private _onDisposeObserver;
  10959. /**
  10960. * Callback called when the manager is disposed
  10961. */
  10962. set onDispose(callback: () => void);
  10963. private _capacity;
  10964. private _fromPacked;
  10965. private _spriteTexture;
  10966. private _epsilon;
  10967. private _scene;
  10968. private _vertexData;
  10969. private _buffer;
  10970. private _vertexBuffers;
  10971. private _indexBuffer;
  10972. private _effectBase;
  10973. private _effectFog;
  10974. /**
  10975. * Gets or sets the unique id of the sprite
  10976. */
  10977. uniqueId: number;
  10978. /**
  10979. * Gets the array of sprites
  10980. */
  10981. get children(): Sprite[];
  10982. /**
  10983. * Gets the hosting scene
  10984. */
  10985. get scene(): Scene;
  10986. /**
  10987. * Gets the capacity of the manager
  10988. */
  10989. get capacity(): number;
  10990. /**
  10991. * Gets or sets the spritesheet texture
  10992. */
  10993. get texture(): Texture;
  10994. set texture(value: Texture);
  10995. private _blendMode;
  10996. /**
  10997. * Blend mode use to render the particle, it can be any of
  10998. * the static Constants.ALPHA_x properties provided in this class.
  10999. * Default value is Constants.ALPHA_COMBINE
  11000. */
  11001. get blendMode(): number;
  11002. set blendMode(blendMode: number);
  11003. /** Disables writing to the depth buffer when rendering the sprites.
  11004. * It can be handy to disable depth writing when using textures without alpha channel
  11005. * and setting some specific blend modes.
  11006. */
  11007. disableDepthWrite: boolean;
  11008. /**
  11009. * Creates a new sprite manager
  11010. * @param name defines the manager's name
  11011. * @param imgUrl defines the sprite sheet url
  11012. * @param capacity defines the maximum allowed number of sprites
  11013. * @param cellSize defines the size of a sprite cell
  11014. * @param scene defines the hosting scene
  11015. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11016. * @param samplingMode defines the smapling mode to use with spritesheet
  11017. * @param fromPacked set to false; do not alter
  11018. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11019. */
  11020. constructor(
  11021. /** defines the manager's name */
  11022. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11023. /**
  11024. * Returns the string "SpriteManager"
  11025. * @returns "SpriteManager"
  11026. */
  11027. getClassName(): string;
  11028. private _makePacked;
  11029. private _appendSpriteVertex;
  11030. private _checkTextureAlpha;
  11031. /**
  11032. * Intersects the sprites with a ray
  11033. * @param ray defines the ray to intersect with
  11034. * @param camera defines the current active camera
  11035. * @param predicate defines a predicate used to select candidate sprites
  11036. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11037. * @returns null if no hit or a PickingInfo
  11038. */
  11039. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11040. /**
  11041. * Intersects the sprites with a ray
  11042. * @param ray defines the ray to intersect with
  11043. * @param camera defines the current active camera
  11044. * @param predicate defines a predicate used to select candidate sprites
  11045. * @returns null if no hit or a PickingInfo array
  11046. */
  11047. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11048. /**
  11049. * Render all child sprites
  11050. */
  11051. render(): void;
  11052. /**
  11053. * Release associated resources
  11054. */
  11055. dispose(): void;
  11056. /**
  11057. * Serializes the sprite manager to a JSON object
  11058. * @param serializeTexture defines if the texture must be serialized as well
  11059. * @returns the JSON object
  11060. */
  11061. serialize(serializeTexture?: boolean): any;
  11062. /**
  11063. * Parses a JSON object to create a new sprite manager.
  11064. * @param parsedManager The JSON object to parse
  11065. * @param scene The scene to create the sprite managerin
  11066. * @param rootUrl The root url to use to load external dependencies like texture
  11067. * @returns the new sprite manager
  11068. */
  11069. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11070. /**
  11071. * Creates a sprite manager from a snippet saved in a remote file
  11072. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11073. * @param url defines the url to load from
  11074. * @param scene defines the hosting scene
  11075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11076. * @returns a promise that will resolve to the new sprite manager
  11077. */
  11078. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11079. /**
  11080. * Creates a sprite manager from a snippet saved by the sprite editor
  11081. * @param snippetId defines the snippet to load
  11082. * @param scene defines the hosting scene
  11083. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11084. * @returns a promise that will resolve to the new sprite manager
  11085. */
  11086. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11087. }
  11088. }
  11089. declare module BABYLON {
  11090. /** Interface used by value gradients (color, factor, ...) */
  11091. export interface IValueGradient {
  11092. /**
  11093. * Gets or sets the gradient value (between 0 and 1)
  11094. */
  11095. gradient: number;
  11096. }
  11097. /** Class used to store color4 gradient */
  11098. export class ColorGradient implements IValueGradient {
  11099. /**
  11100. * Gets or sets the gradient value (between 0 and 1)
  11101. */
  11102. gradient: number;
  11103. /**
  11104. * Gets or sets first associated color
  11105. */
  11106. color1: Color4;
  11107. /**
  11108. * Gets or sets second associated color
  11109. */
  11110. color2?: Color4 | undefined;
  11111. /**
  11112. * Creates a new color4 gradient
  11113. * @param gradient gets or sets the gradient value (between 0 and 1)
  11114. * @param color1 gets or sets first associated color
  11115. * @param color2 gets or sets first second color
  11116. */
  11117. constructor(
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number,
  11122. /**
  11123. * Gets or sets first associated color
  11124. */
  11125. color1: Color4,
  11126. /**
  11127. * Gets or sets second associated color
  11128. */
  11129. color2?: Color4 | undefined);
  11130. /**
  11131. * Will get a color picked randomly between color1 and color2.
  11132. * If color2 is undefined then color1 will be used
  11133. * @param result defines the target Color4 to store the result in
  11134. */
  11135. getColorToRef(result: Color4): void;
  11136. }
  11137. /** Class used to store color 3 gradient */
  11138. export class Color3Gradient implements IValueGradient {
  11139. /**
  11140. * Gets or sets the gradient value (between 0 and 1)
  11141. */
  11142. gradient: number;
  11143. /**
  11144. * Gets or sets the associated color
  11145. */
  11146. color: Color3;
  11147. /**
  11148. * Creates a new color3 gradient
  11149. * @param gradient gets or sets the gradient value (between 0 and 1)
  11150. * @param color gets or sets associated color
  11151. */
  11152. constructor(
  11153. /**
  11154. * Gets or sets the gradient value (between 0 and 1)
  11155. */
  11156. gradient: number,
  11157. /**
  11158. * Gets or sets the associated color
  11159. */
  11160. color: Color3);
  11161. }
  11162. /** Class used to store factor gradient */
  11163. export class FactorGradient implements IValueGradient {
  11164. /**
  11165. * Gets or sets the gradient value (between 0 and 1)
  11166. */
  11167. gradient: number;
  11168. /**
  11169. * Gets or sets first associated factor
  11170. */
  11171. factor1: number;
  11172. /**
  11173. * Gets or sets second associated factor
  11174. */
  11175. factor2?: number | undefined;
  11176. /**
  11177. * Creates a new factor gradient
  11178. * @param gradient gets or sets the gradient value (between 0 and 1)
  11179. * @param factor1 gets or sets first associated factor
  11180. * @param factor2 gets or sets second associated factor
  11181. */
  11182. constructor(
  11183. /**
  11184. * Gets or sets the gradient value (between 0 and 1)
  11185. */
  11186. gradient: number,
  11187. /**
  11188. * Gets or sets first associated factor
  11189. */
  11190. factor1: number,
  11191. /**
  11192. * Gets or sets second associated factor
  11193. */
  11194. factor2?: number | undefined);
  11195. /**
  11196. * Will get a number picked randomly between factor1 and factor2.
  11197. * If factor2 is undefined then factor1 will be used
  11198. * @returns the picked number
  11199. */
  11200. getFactor(): number;
  11201. }
  11202. /**
  11203. * Helper used to simplify some generic gradient tasks
  11204. */
  11205. export class GradientHelper {
  11206. /**
  11207. * Gets the current gradient from an array of IValueGradient
  11208. * @param ratio defines the current ratio to get
  11209. * @param gradients defines the array of IValueGradient
  11210. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11211. */
  11212. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11213. }
  11214. }
  11215. declare module BABYLON {
  11216. interface ThinEngine {
  11217. /**
  11218. * Creates a raw texture
  11219. * @param data defines the data to store in the texture
  11220. * @param width defines the width of the texture
  11221. * @param height defines the height of the texture
  11222. * @param format defines the format of the data
  11223. * @param generateMipMaps defines if the engine should generate the mip levels
  11224. * @param invertY defines if data must be stored with Y axis inverted
  11225. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11226. * @param compression defines the compression used (null by default)
  11227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11228. * @returns the raw texture inside an InternalTexture
  11229. */
  11230. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11231. /**
  11232. * Update a raw texture
  11233. * @param texture defines the texture to update
  11234. * @param data defines the data to store in the texture
  11235. * @param format defines the format of the data
  11236. * @param invertY defines if data must be stored with Y axis inverted
  11237. */
  11238. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11239. /**
  11240. * Update a raw texture
  11241. * @param texture defines the texture to update
  11242. * @param data defines the data to store in the texture
  11243. * @param format defines the format of the data
  11244. * @param invertY defines if data must be stored with Y axis inverted
  11245. * @param compression defines the compression used (null by default)
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. */
  11248. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11249. /**
  11250. * Creates a new raw cube texture
  11251. * @param data defines the array of data to use to create each face
  11252. * @param size defines the size of the textures
  11253. * @param format defines the format of the data
  11254. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11255. * @param generateMipMaps defines if the engine should generate the mip levels
  11256. * @param invertY defines if data must be stored with Y axis inverted
  11257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11258. * @param compression defines the compression used (null by default)
  11259. * @returns the cube texture as an InternalTexture
  11260. */
  11261. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11262. /**
  11263. * Update a raw cube texture
  11264. * @param texture defines the texture to udpdate
  11265. * @param data defines the data to store
  11266. * @param format defines the data format
  11267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11268. * @param invertY defines if data must be stored with Y axis inverted
  11269. */
  11270. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11271. /**
  11272. * Update a raw cube texture
  11273. * @param texture defines the texture to udpdate
  11274. * @param data defines the data to store
  11275. * @param format defines the data format
  11276. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11277. * @param invertY defines if data must be stored with Y axis inverted
  11278. * @param compression defines the compression used (null by default)
  11279. */
  11280. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11281. /**
  11282. * Update a raw cube texture
  11283. * @param texture defines the texture to udpdate
  11284. * @param data defines the data to store
  11285. * @param format defines the data format
  11286. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11287. * @param invertY defines if data must be stored with Y axis inverted
  11288. * @param compression defines the compression used (null by default)
  11289. * @param level defines which level of the texture to update
  11290. */
  11291. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11292. /**
  11293. * Creates a new raw cube texture from a specified url
  11294. * @param url defines the url where the data is located
  11295. * @param scene defines the current scene
  11296. * @param size defines the size of the textures
  11297. * @param format defines the format of the data
  11298. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11299. * @param noMipmap defines if the engine should avoid generating the mip levels
  11300. * @param callback defines a callback used to extract texture data from loaded data
  11301. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11302. * @param onLoad defines a callback called when texture is loaded
  11303. * @param onError defines a callback called if there is an error
  11304. * @returns the cube texture as an InternalTexture
  11305. */
  11306. 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;
  11307. /**
  11308. * Creates a new raw cube texture from a specified url
  11309. * @param url defines the url where the data is located
  11310. * @param scene defines the current scene
  11311. * @param size defines the size of the textures
  11312. * @param format defines the format of the data
  11313. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11314. * @param noMipmap defines if the engine should avoid generating the mip levels
  11315. * @param callback defines a callback used to extract texture data from loaded data
  11316. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11317. * @param onLoad defines a callback called when texture is loaded
  11318. * @param onError defines a callback called if there is an error
  11319. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @returns the cube texture as an InternalTexture
  11322. */
  11323. 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;
  11324. /**
  11325. * Creates a new raw 3D texture
  11326. * @param data defines the data used to create the texture
  11327. * @param width defines the width of the texture
  11328. * @param height defines the height of the texture
  11329. * @param depth defines the depth of the texture
  11330. * @param format defines the format of the texture
  11331. * @param generateMipMaps defines if the engine must generate mip levels
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11334. * @param compression defines the compressed used (can be null)
  11335. * @param textureType defines the compressed used (can be null)
  11336. * @returns a new raw 3D texture (stored in an InternalTexture)
  11337. */
  11338. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11339. /**
  11340. * Update a raw 3D texture
  11341. * @param texture defines the texture to update
  11342. * @param data defines the data to store
  11343. * @param format defines the data format
  11344. * @param invertY defines if data must be stored with Y axis inverted
  11345. */
  11346. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11347. /**
  11348. * Update a raw 3D texture
  11349. * @param texture defines the texture to update
  11350. * @param data defines the data to store
  11351. * @param format defines the data format
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the used compression (can be null)
  11354. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11355. */
  11356. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11357. /**
  11358. * Creates a new raw 2D array texture
  11359. * @param data defines the data used to create the texture
  11360. * @param width defines the width of the texture
  11361. * @param height defines the height of the texture
  11362. * @param depth defines the number of layers of the texture
  11363. * @param format defines the format of the texture
  11364. * @param generateMipMaps defines if the engine must generate mip levels
  11365. * @param invertY defines if data must be stored with Y axis inverted
  11366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11367. * @param compression defines the compressed used (can be null)
  11368. * @param textureType defines the compressed used (can be null)
  11369. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11370. */
  11371. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11372. /**
  11373. * Update a raw 2D array texture
  11374. * @param texture defines the texture to update
  11375. * @param data defines the data to store
  11376. * @param format defines the data format
  11377. * @param invertY defines if data must be stored with Y axis inverted
  11378. */
  11379. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11380. /**
  11381. * Update a raw 2D array texture
  11382. * @param texture defines the texture to update
  11383. * @param data defines the data to store
  11384. * @param format defines the data format
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the used compression (can be null)
  11387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11388. */
  11389. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /**
  11394. * Raw texture can help creating a texture directly from an array of data.
  11395. * This can be super useful if you either get the data from an uncompressed source or
  11396. * if you wish to create your texture pixel by pixel.
  11397. */
  11398. export class RawTexture extends Texture {
  11399. /**
  11400. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11401. */
  11402. format: number;
  11403. /**
  11404. * Instantiates a new RawTexture.
  11405. * Raw texture can help creating a texture directly from an array of data.
  11406. * This can be super useful if you either get the data from an uncompressed source or
  11407. * if you wish to create your texture pixel by pixel.
  11408. * @param data define the array of data to use to create the texture
  11409. * @param width define the width of the texture
  11410. * @param height define the height of the texture
  11411. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11412. * @param scene define the scene the texture belongs to
  11413. * @param generateMipMaps define whether mip maps should be generated or not
  11414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11416. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11417. */
  11418. constructor(data: ArrayBufferView, width: number, height: number,
  11419. /**
  11420. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11421. */
  11422. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11423. /**
  11424. * Updates the texture underlying data.
  11425. * @param data Define the new data of the texture
  11426. */
  11427. update(data: ArrayBufferView): void;
  11428. /**
  11429. * Creates a luminance texture from some data.
  11430. * @param data Define the texture data
  11431. * @param width Define the width of the texture
  11432. * @param height Define the height of the texture
  11433. * @param scene Define the scene the texture belongs to
  11434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11437. * @returns the luminance texture
  11438. */
  11439. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11440. /**
  11441. * Creates a luminance alpha texture from some data.
  11442. * @param data Define the texture data
  11443. * @param width Define the width of the texture
  11444. * @param height Define the height of the texture
  11445. * @param scene Define the scene the texture belongs to
  11446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11449. * @returns the luminance alpha texture
  11450. */
  11451. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11452. /**
  11453. * Creates an alpha texture from some data.
  11454. * @param data Define the texture data
  11455. * @param width Define the width of the texture
  11456. * @param height Define the height of the texture
  11457. * @param scene Define the scene the texture belongs to
  11458. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11459. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11460. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11461. * @returns the alpha texture
  11462. */
  11463. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11464. /**
  11465. * Creates a RGB texture from some data.
  11466. * @param data Define the texture data
  11467. * @param width Define the width of the texture
  11468. * @param height Define the height of the texture
  11469. * @param scene Define the scene the texture belongs to
  11470. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11471. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11472. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11473. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11474. * @returns the RGB alpha texture
  11475. */
  11476. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11477. /**
  11478. * Creates a RGBA texture from some data.
  11479. * @param data Define the texture data
  11480. * @param width Define the width of the texture
  11481. * @param height Define the height of the texture
  11482. * @param scene Define the scene the texture belongs to
  11483. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11487. * @returns the RGBA texture
  11488. */
  11489. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11490. /**
  11491. * Creates a R texture from some data.
  11492. * @param data Define the texture data
  11493. * @param width Define the width of the texture
  11494. * @param height Define the height of the texture
  11495. * @param scene Define the scene the texture belongs to
  11496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11499. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11500. * @returns the R texture
  11501. */
  11502. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11503. }
  11504. }
  11505. declare module BABYLON {
  11506. interface AbstractScene {
  11507. /**
  11508. * The list of procedural textures added to the scene
  11509. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11510. */
  11511. proceduralTextures: Array<ProceduralTexture>;
  11512. }
  11513. /**
  11514. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11515. * in a given scene.
  11516. */
  11517. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11518. /**
  11519. * The component name helpfull to identify the component in the list of scene components.
  11520. */
  11521. readonly name: string;
  11522. /**
  11523. * The scene the component belongs to.
  11524. */
  11525. scene: Scene;
  11526. /**
  11527. * Creates a new instance of the component for the given scene
  11528. * @param scene Defines the scene to register the component in
  11529. */
  11530. constructor(scene: Scene);
  11531. /**
  11532. * Registers the component in a given scene
  11533. */
  11534. register(): void;
  11535. /**
  11536. * Rebuilds the elements related to this component in case of
  11537. * context lost for instance.
  11538. */
  11539. rebuild(): void;
  11540. /**
  11541. * Disposes the component and the associated ressources.
  11542. */
  11543. dispose(): void;
  11544. private _beforeClear;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. interface ThinEngine {
  11549. /**
  11550. * Creates a new render target cube texture
  11551. * @param size defines the size of the texture
  11552. * @param options defines the options used to create the texture
  11553. * @returns a new render target cube texture stored in an InternalTexture
  11554. */
  11555. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11556. }
  11557. }
  11558. declare module BABYLON {
  11559. /** @hidden */
  11560. export var proceduralVertexShader: {
  11561. name: string;
  11562. shader: string;
  11563. };
  11564. }
  11565. declare module BABYLON {
  11566. /**
  11567. * 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.
  11568. * This is the base class of any Procedural texture and contains most of the shareable code.
  11569. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11570. */
  11571. export class ProceduralTexture extends Texture {
  11572. isCube: boolean;
  11573. /**
  11574. * Define if the texture is enabled or not (disabled texture will not render)
  11575. */
  11576. isEnabled: boolean;
  11577. /**
  11578. * Define if the texture must be cleared before rendering (default is true)
  11579. */
  11580. autoClear: boolean;
  11581. /**
  11582. * Callback called when the texture is generated
  11583. */
  11584. onGenerated: () => void;
  11585. /**
  11586. * Event raised when the texture is generated
  11587. */
  11588. onGeneratedObservable: Observable<ProceduralTexture>;
  11589. /** @hidden */
  11590. _generateMipMaps: boolean;
  11591. /** @hidden **/
  11592. _effect: Effect;
  11593. /** @hidden */
  11594. _textures: {
  11595. [key: string]: Texture;
  11596. };
  11597. /** @hidden */
  11598. protected _fallbackTexture: Nullable<Texture>;
  11599. private _size;
  11600. private _currentRefreshId;
  11601. private _frameId;
  11602. private _refreshRate;
  11603. private _vertexBuffers;
  11604. private _indexBuffer;
  11605. private _uniforms;
  11606. private _samplers;
  11607. private _fragment;
  11608. private _floats;
  11609. private _ints;
  11610. private _floatsArrays;
  11611. private _colors3;
  11612. private _colors4;
  11613. private _vectors2;
  11614. private _vectors3;
  11615. private _matrices;
  11616. private _fallbackTextureUsed;
  11617. private _fullEngine;
  11618. private _cachedDefines;
  11619. private _contentUpdateId;
  11620. private _contentData;
  11621. /**
  11622. * Instantiates a new procedural texture.
  11623. * 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.
  11624. * This is the base class of any Procedural texture and contains most of the shareable code.
  11625. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11626. * @param name Define the name of the texture
  11627. * @param size Define the size of the texture to create
  11628. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11629. * @param scene Define the scene the texture belongs to
  11630. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11631. * @param generateMipMaps Define if the texture should creates mip maps or not
  11632. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11633. */
  11634. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11635. /**
  11636. * The effect that is created when initializing the post process.
  11637. * @returns The created effect corresponding the the postprocess.
  11638. */
  11639. getEffect(): Effect;
  11640. /**
  11641. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11642. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11643. */
  11644. getContent(): Nullable<ArrayBufferView>;
  11645. private _createIndexBuffer;
  11646. /** @hidden */
  11647. _rebuild(): void;
  11648. /**
  11649. * Resets the texture in order to recreate its associated resources.
  11650. * This can be called in case of context loss
  11651. */
  11652. reset(): void;
  11653. protected _getDefines(): string;
  11654. /**
  11655. * Is the texture ready to be used ? (rendered at least once)
  11656. * @returns true if ready, otherwise, false.
  11657. */
  11658. isReady(): boolean;
  11659. /**
  11660. * Resets the refresh counter of the texture and start bak from scratch.
  11661. * Could be useful to regenerate the texture if it is setup to render only once.
  11662. */
  11663. resetRefreshCounter(): void;
  11664. /**
  11665. * Set the fragment shader to use in order to render the texture.
  11666. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11667. */
  11668. setFragment(fragment: any): void;
  11669. /**
  11670. * Define the refresh rate of the texture or the rendering frequency.
  11671. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11672. */
  11673. get refreshRate(): number;
  11674. set refreshRate(value: number);
  11675. /** @hidden */
  11676. _shouldRender(): boolean;
  11677. /**
  11678. * Get the size the texture is rendering at.
  11679. * @returns the size (texture is always squared)
  11680. */
  11681. getRenderSize(): number;
  11682. /**
  11683. * Resize the texture to new value.
  11684. * @param size Define the new size the texture should have
  11685. * @param generateMipMaps Define whether the new texture should create mip maps
  11686. */
  11687. resize(size: number, generateMipMaps: boolean): void;
  11688. private _checkUniform;
  11689. /**
  11690. * Set a texture in the shader program used to render.
  11691. * @param name Define the name of the uniform samplers as defined in the shader
  11692. * @param texture Define the texture to bind to this sampler
  11693. * @return the texture itself allowing "fluent" like uniform updates
  11694. */
  11695. setTexture(name: string, texture: Texture): ProceduralTexture;
  11696. /**
  11697. * Set a float in the shader.
  11698. * @param name Define the name of the uniform as defined in the shader
  11699. * @param value Define the value to give to the uniform
  11700. * @return the texture itself allowing "fluent" like uniform updates
  11701. */
  11702. setFloat(name: string, value: number): ProceduralTexture;
  11703. /**
  11704. * Set a int in the shader.
  11705. * @param name Define the name of the uniform as defined in the shader
  11706. * @param value Define the value to give to the uniform
  11707. * @return the texture itself allowing "fluent" like uniform updates
  11708. */
  11709. setInt(name: string, value: number): ProceduralTexture;
  11710. /**
  11711. * Set an array of floats in the shader.
  11712. * @param name Define the name of the uniform as defined in the shader
  11713. * @param value Define the value to give to the uniform
  11714. * @return the texture itself allowing "fluent" like uniform updates
  11715. */
  11716. setFloats(name: string, value: number[]): ProceduralTexture;
  11717. /**
  11718. * Set a vec3 in the shader from a Color3.
  11719. * @param name Define the name of the uniform as defined in the shader
  11720. * @param value Define the value to give to the uniform
  11721. * @return the texture itself allowing "fluent" like uniform updates
  11722. */
  11723. setColor3(name: string, value: Color3): ProceduralTexture;
  11724. /**
  11725. * Set a vec4 in the shader from a Color4.
  11726. * @param name Define the name of the uniform as defined in the shader
  11727. * @param value Define the value to give to the uniform
  11728. * @return the texture itself allowing "fluent" like uniform updates
  11729. */
  11730. setColor4(name: string, value: Color4): ProceduralTexture;
  11731. /**
  11732. * Set a vec2 in the shader from a Vector2.
  11733. * @param name Define the name of the uniform as defined in the shader
  11734. * @param value Define the value to give to the uniform
  11735. * @return the texture itself allowing "fluent" like uniform updates
  11736. */
  11737. setVector2(name: string, value: Vector2): ProceduralTexture;
  11738. /**
  11739. * Set a vec3 in the shader from a Vector3.
  11740. * @param name Define the name of the uniform as defined in the shader
  11741. * @param value Define the value to give to the uniform
  11742. * @return the texture itself allowing "fluent" like uniform updates
  11743. */
  11744. setVector3(name: string, value: Vector3): ProceduralTexture;
  11745. /**
  11746. * Set a mat4 in the shader from a MAtrix.
  11747. * @param name Define the name of the uniform as defined in the shader
  11748. * @param value Define the value to give to the uniform
  11749. * @return the texture itself allowing "fluent" like uniform updates
  11750. */
  11751. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11752. /**
  11753. * Render the texture to its associated render target.
  11754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11755. */
  11756. render(useCameraPostProcess?: boolean): void;
  11757. /**
  11758. * Clone the texture.
  11759. * @returns the cloned texture
  11760. */
  11761. clone(): ProceduralTexture;
  11762. /**
  11763. * Dispose the texture and release its asoociated resources.
  11764. */
  11765. dispose(): void;
  11766. }
  11767. }
  11768. declare module BABYLON {
  11769. /**
  11770. * This represents the base class for particle system in Babylon.
  11771. * 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.
  11772. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11773. * @example https://doc.babylonjs.com/babylon101/particles
  11774. */
  11775. export class BaseParticleSystem {
  11776. /**
  11777. * Source color is added to the destination color without alpha affecting the result
  11778. */
  11779. static BLENDMODE_ONEONE: number;
  11780. /**
  11781. * Blend current color and particle color using particle’s alpha
  11782. */
  11783. static BLENDMODE_STANDARD: number;
  11784. /**
  11785. * Add current color and particle color multiplied by particle’s alpha
  11786. */
  11787. static BLENDMODE_ADD: number;
  11788. /**
  11789. * Multiply current color with particle color
  11790. */
  11791. static BLENDMODE_MULTIPLY: number;
  11792. /**
  11793. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11794. */
  11795. static BLENDMODE_MULTIPLYADD: number;
  11796. /**
  11797. * List of animations used by the particle system.
  11798. */
  11799. animations: Animation[];
  11800. /**
  11801. * Gets or sets the unique id of the particle system
  11802. */
  11803. uniqueId: number;
  11804. /**
  11805. * The id of the Particle system.
  11806. */
  11807. id: string;
  11808. /**
  11809. * The friendly name of the Particle system.
  11810. */
  11811. name: string;
  11812. /**
  11813. * Snippet ID if the particle system was created from the snippet server
  11814. */
  11815. snippetId: string;
  11816. /**
  11817. * The rendering group used by the Particle system to chose when to render.
  11818. */
  11819. renderingGroupId: number;
  11820. /**
  11821. * The emitter represents the Mesh or position we are attaching the particle system to.
  11822. */
  11823. emitter: Nullable<AbstractMesh | Vector3>;
  11824. /**
  11825. * The maximum number of particles to emit per frame
  11826. */
  11827. emitRate: number;
  11828. /**
  11829. * If you want to launch only a few particles at once, that can be done, as well.
  11830. */
  11831. manualEmitCount: number;
  11832. /**
  11833. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11834. */
  11835. updateSpeed: number;
  11836. /**
  11837. * The amount of time the particle system is running (depends of the overall update speed).
  11838. */
  11839. targetStopDuration: number;
  11840. /**
  11841. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11842. */
  11843. disposeOnStop: boolean;
  11844. /**
  11845. * Minimum power of emitting particles.
  11846. */
  11847. minEmitPower: number;
  11848. /**
  11849. * Maximum power of emitting particles.
  11850. */
  11851. maxEmitPower: number;
  11852. /**
  11853. * Minimum life time of emitting particles.
  11854. */
  11855. minLifeTime: number;
  11856. /**
  11857. * Maximum life time of emitting particles.
  11858. */
  11859. maxLifeTime: number;
  11860. /**
  11861. * Minimum Size of emitting particles.
  11862. */
  11863. minSize: number;
  11864. /**
  11865. * Maximum Size of emitting particles.
  11866. */
  11867. maxSize: number;
  11868. /**
  11869. * Minimum scale of emitting particles on X axis.
  11870. */
  11871. minScaleX: number;
  11872. /**
  11873. * Maximum scale of emitting particles on X axis.
  11874. */
  11875. maxScaleX: number;
  11876. /**
  11877. * Minimum scale of emitting particles on Y axis.
  11878. */
  11879. minScaleY: number;
  11880. /**
  11881. * Maximum scale of emitting particles on Y axis.
  11882. */
  11883. maxScaleY: number;
  11884. /**
  11885. * Gets or sets the minimal initial rotation in radians.
  11886. */
  11887. minInitialRotation: number;
  11888. /**
  11889. * Gets or sets the maximal initial rotation in radians.
  11890. */
  11891. maxInitialRotation: number;
  11892. /**
  11893. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11894. */
  11895. minAngularSpeed: number;
  11896. /**
  11897. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11898. */
  11899. maxAngularSpeed: number;
  11900. /**
  11901. * The texture used to render each particle. (this can be a spritesheet)
  11902. */
  11903. particleTexture: Nullable<Texture>;
  11904. /**
  11905. * The layer mask we are rendering the particles through.
  11906. */
  11907. layerMask: number;
  11908. /**
  11909. * This can help using your own shader to render the particle system.
  11910. * The according effect will be created
  11911. */
  11912. customShader: any;
  11913. /**
  11914. * By default particle system starts as soon as they are created. This prevents the
  11915. * automatic start to happen and let you decide when to start emitting particles.
  11916. */
  11917. preventAutoStart: boolean;
  11918. private _noiseTexture;
  11919. /**
  11920. * Gets or sets a texture used to add random noise to particle positions
  11921. */
  11922. get noiseTexture(): Nullable<ProceduralTexture>;
  11923. set noiseTexture(value: Nullable<ProceduralTexture>);
  11924. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11925. noiseStrength: Vector3;
  11926. /**
  11927. * Callback triggered when the particle animation is ending.
  11928. */
  11929. onAnimationEnd: Nullable<() => void>;
  11930. /**
  11931. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11932. */
  11933. blendMode: number;
  11934. /**
  11935. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11936. * to override the particles.
  11937. */
  11938. forceDepthWrite: boolean;
  11939. /** 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 */
  11940. preWarmCycles: number;
  11941. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11942. preWarmStepOffset: number;
  11943. /**
  11944. * 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)
  11945. */
  11946. spriteCellChangeSpeed: number;
  11947. /**
  11948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11949. */
  11950. startSpriteCellID: number;
  11951. /**
  11952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11953. */
  11954. endSpriteCellID: number;
  11955. /**
  11956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11957. */
  11958. spriteCellWidth: number;
  11959. /**
  11960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11961. */
  11962. spriteCellHeight: number;
  11963. /**
  11964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11965. */
  11966. spriteRandomStartCell: boolean;
  11967. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11968. translationPivot: Vector2;
  11969. /** @hidden */
  11970. protected _isAnimationSheetEnabled: boolean;
  11971. /**
  11972. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11973. */
  11974. beginAnimationOnStart: boolean;
  11975. /**
  11976. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11977. */
  11978. beginAnimationFrom: number;
  11979. /**
  11980. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11981. */
  11982. beginAnimationTo: number;
  11983. /**
  11984. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11985. */
  11986. beginAnimationLoop: boolean;
  11987. /**
  11988. * Gets or sets a world offset applied to all particles
  11989. */
  11990. worldOffset: Vector3;
  11991. /**
  11992. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11993. */
  11994. get isAnimationSheetEnabled(): boolean;
  11995. set isAnimationSheetEnabled(value: boolean);
  11996. /**
  11997. * Get hosting scene
  11998. * @returns the scene
  11999. */
  12000. getScene(): Scene;
  12001. /**
  12002. * You can use gravity if you want to give an orientation to your particles.
  12003. */
  12004. gravity: Vector3;
  12005. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12006. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12007. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12008. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12009. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12010. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12011. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12012. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12013. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12014. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12015. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12016. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12017. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12018. /**
  12019. * Defines the delay in milliseconds before starting the system (0 by default)
  12020. */
  12021. startDelay: number;
  12022. /**
  12023. * Gets the current list of drag gradients.
  12024. * You must use addDragGradient and removeDragGradient to udpate this list
  12025. * @returns the list of drag gradients
  12026. */
  12027. getDragGradients(): Nullable<Array<FactorGradient>>;
  12028. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12029. limitVelocityDamping: number;
  12030. /**
  12031. * Gets the current list of limit velocity gradients.
  12032. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12033. * @returns the list of limit velocity gradients
  12034. */
  12035. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12036. /**
  12037. * Gets the current list of color gradients.
  12038. * You must use addColorGradient and removeColorGradient to udpate this list
  12039. * @returns the list of color gradients
  12040. */
  12041. getColorGradients(): Nullable<Array<ColorGradient>>;
  12042. /**
  12043. * Gets the current list of size gradients.
  12044. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12045. * @returns the list of size gradients
  12046. */
  12047. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12048. /**
  12049. * Gets the current list of color remap gradients.
  12050. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12051. * @returns the list of color remap gradients
  12052. */
  12053. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12054. /**
  12055. * Gets the current list of alpha remap gradients.
  12056. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12057. * @returns the list of alpha remap gradients
  12058. */
  12059. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12060. /**
  12061. * Gets the current list of life time gradients.
  12062. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12063. * @returns the list of life time gradients
  12064. */
  12065. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12066. /**
  12067. * Gets the current list of angular speed gradients.
  12068. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12069. * @returns the list of angular speed gradients
  12070. */
  12071. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12072. /**
  12073. * Gets the current list of velocity gradients.
  12074. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12075. * @returns the list of velocity gradients
  12076. */
  12077. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12078. /**
  12079. * Gets the current list of start size gradients.
  12080. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12081. * @returns the list of start size gradients
  12082. */
  12083. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12084. /**
  12085. * Gets the current list of emit rate gradients.
  12086. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12087. * @returns the list of emit rate gradients
  12088. */
  12089. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12090. /**
  12091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12092. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12093. */
  12094. get direction1(): Vector3;
  12095. set direction1(value: Vector3);
  12096. /**
  12097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12099. */
  12100. get direction2(): Vector3;
  12101. set direction2(value: Vector3);
  12102. /**
  12103. * 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.
  12104. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12105. */
  12106. get minEmitBox(): Vector3;
  12107. set minEmitBox(value: Vector3);
  12108. /**
  12109. * 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.
  12110. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12111. */
  12112. get maxEmitBox(): Vector3;
  12113. set maxEmitBox(value: Vector3);
  12114. /**
  12115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12116. */
  12117. color1: Color4;
  12118. /**
  12119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12120. */
  12121. color2: Color4;
  12122. /**
  12123. * Color the particle will have at the end of its lifetime
  12124. */
  12125. colorDead: Color4;
  12126. /**
  12127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12128. */
  12129. textureMask: Color4;
  12130. /**
  12131. * The particle emitter type defines the emitter used by the particle system.
  12132. * It can be for example box, sphere, or cone...
  12133. */
  12134. particleEmitterType: IParticleEmitterType;
  12135. /** @hidden */
  12136. _isSubEmitter: boolean;
  12137. /**
  12138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12140. */
  12141. billboardMode: number;
  12142. protected _isBillboardBased: boolean;
  12143. /**
  12144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12145. */
  12146. get isBillboardBased(): boolean;
  12147. set isBillboardBased(value: boolean);
  12148. /**
  12149. * The scene the particle system belongs to.
  12150. */
  12151. protected _scene: Scene;
  12152. /**
  12153. * Local cache of defines for image processing.
  12154. */
  12155. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12156. /**
  12157. * Default configuration related to image processing available in the standard Material.
  12158. */
  12159. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12160. /**
  12161. * Gets the image processing configuration used either in this material.
  12162. */
  12163. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12164. /**
  12165. * Sets the Default image processing configuration used either in the this material.
  12166. *
  12167. * If sets to null, the scene one is in use.
  12168. */
  12169. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12170. /**
  12171. * Attaches a new image processing configuration to the Standard Material.
  12172. * @param configuration
  12173. */
  12174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12175. /** @hidden */
  12176. protected _reset(): void;
  12177. /** @hidden */
  12178. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12179. /**
  12180. * Instantiates a particle system.
  12181. * 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.
  12182. * @param name The name of the particle system
  12183. */
  12184. constructor(name: string);
  12185. /**
  12186. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12189. * @returns the emitter
  12190. */
  12191. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12192. /**
  12193. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12194. * @param radius The radius of the hemisphere to emit from
  12195. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12196. * @returns the emitter
  12197. */
  12198. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12199. /**
  12200. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12201. * @param radius The radius of the sphere to emit from
  12202. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12203. * @returns the emitter
  12204. */
  12205. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12206. /**
  12207. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12208. * @param radius The radius of the sphere to emit from
  12209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12211. * @returns the emitter
  12212. */
  12213. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12214. /**
  12215. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12216. * @param radius The radius of the emission cylinder
  12217. * @param height The height of the emission cylinder
  12218. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12219. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12220. * @returns the emitter
  12221. */
  12222. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12223. /**
  12224. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12225. * @param radius The radius of the cylinder to emit from
  12226. * @param height The height of the emission cylinder
  12227. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12230. * @returns the emitter
  12231. */
  12232. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12233. /**
  12234. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12235. * @param radius The radius of the cone to emit from
  12236. * @param angle The base angle of the cone
  12237. * @returns the emitter
  12238. */
  12239. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12240. /**
  12241. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12242. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12243. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12244. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12245. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12246. * @returns the emitter
  12247. */
  12248. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12249. }
  12250. }
  12251. declare module BABYLON {
  12252. /**
  12253. * Type of sub emitter
  12254. */
  12255. export enum SubEmitterType {
  12256. /**
  12257. * Attached to the particle over it's lifetime
  12258. */
  12259. ATTACHED = 0,
  12260. /**
  12261. * Created when the particle dies
  12262. */
  12263. END = 1
  12264. }
  12265. /**
  12266. * Sub emitter class used to emit particles from an existing particle
  12267. */
  12268. export class SubEmitter {
  12269. /**
  12270. * the particle system to be used by the sub emitter
  12271. */
  12272. particleSystem: ParticleSystem;
  12273. /**
  12274. * Type of the submitter (Default: END)
  12275. */
  12276. type: SubEmitterType;
  12277. /**
  12278. * 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)
  12279. * Note: This only is supported when using an emitter of type Mesh
  12280. */
  12281. inheritDirection: boolean;
  12282. /**
  12283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12284. */
  12285. inheritedVelocityAmount: number;
  12286. /**
  12287. * Creates a sub emitter
  12288. * @param particleSystem the particle system to be used by the sub emitter
  12289. */
  12290. constructor(
  12291. /**
  12292. * the particle system to be used by the sub emitter
  12293. */
  12294. particleSystem: ParticleSystem);
  12295. /**
  12296. * Clones the sub emitter
  12297. * @returns the cloned sub emitter
  12298. */
  12299. clone(): SubEmitter;
  12300. /**
  12301. * Serialize current object to a JSON object
  12302. * @returns the serialized object
  12303. */
  12304. serialize(): any;
  12305. /** @hidden */
  12306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12307. /**
  12308. * Creates a new SubEmitter from a serialized JSON version
  12309. * @param serializationObject defines the JSON object to read from
  12310. * @param scene defines the hosting scene
  12311. * @param rootUrl defines the rootUrl for data loading
  12312. * @returns a new SubEmitter
  12313. */
  12314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12315. /** Release associated resources */
  12316. dispose(): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /** @hidden */
  12321. export var imageProcessingDeclaration: {
  12322. name: string;
  12323. shader: string;
  12324. };
  12325. }
  12326. declare module BABYLON {
  12327. /** @hidden */
  12328. export var imageProcessingFunctions: {
  12329. name: string;
  12330. shader: string;
  12331. };
  12332. }
  12333. declare module BABYLON {
  12334. /** @hidden */
  12335. export var particlesPixelShader: {
  12336. name: string;
  12337. shader: string;
  12338. };
  12339. }
  12340. declare module BABYLON {
  12341. /** @hidden */
  12342. export var particlesVertexShader: {
  12343. name: string;
  12344. shader: string;
  12345. };
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * This represents a particle system in Babylon.
  12350. * 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.
  12351. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12352. * @example https://doc.babylonjs.com/babylon101/particles
  12353. */
  12354. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12355. /**
  12356. * Billboard mode will only apply to Y axis
  12357. */
  12358. static readonly BILLBOARDMODE_Y: number;
  12359. /**
  12360. * Billboard mode will apply to all axes
  12361. */
  12362. static readonly BILLBOARDMODE_ALL: number;
  12363. /**
  12364. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12365. */
  12366. static readonly BILLBOARDMODE_STRETCHED: number;
  12367. /**
  12368. * This function can be defined to provide custom update for active particles.
  12369. * This function will be called instead of regular update (age, position, color, etc.).
  12370. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12371. */
  12372. updateFunction: (particles: Particle[]) => void;
  12373. private _emitterWorldMatrix;
  12374. /**
  12375. * This function can be defined to specify initial direction for every new particle.
  12376. * It by default use the emitterType defined function
  12377. */
  12378. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12379. /**
  12380. * This function can be defined to specify initial position for every new particle.
  12381. * It by default use the emitterType defined function
  12382. */
  12383. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12384. /**
  12385. * @hidden
  12386. */
  12387. _inheritedVelocityOffset: Vector3;
  12388. /**
  12389. * An event triggered when the system is disposed
  12390. */
  12391. onDisposeObservable: Observable<IParticleSystem>;
  12392. private _onDisposeObserver;
  12393. /**
  12394. * Sets a callback that will be triggered when the system is disposed
  12395. */
  12396. set onDispose(callback: () => void);
  12397. private _particles;
  12398. private _epsilon;
  12399. private _capacity;
  12400. private _stockParticles;
  12401. private _newPartsExcess;
  12402. private _vertexData;
  12403. private _vertexBuffer;
  12404. private _vertexBuffers;
  12405. private _spriteBuffer;
  12406. private _indexBuffer;
  12407. private _effect;
  12408. private _customEffect;
  12409. private _cachedDefines;
  12410. private _scaledColorStep;
  12411. private _colorDiff;
  12412. private _scaledDirection;
  12413. private _scaledGravity;
  12414. private _currentRenderId;
  12415. private _alive;
  12416. private _useInstancing;
  12417. private _started;
  12418. private _stopped;
  12419. private _actualFrame;
  12420. private _scaledUpdateSpeed;
  12421. private _vertexBufferSize;
  12422. /** @hidden */
  12423. _currentEmitRateGradient: Nullable<FactorGradient>;
  12424. /** @hidden */
  12425. _currentEmitRate1: number;
  12426. /** @hidden */
  12427. _currentEmitRate2: number;
  12428. /** @hidden */
  12429. _currentStartSizeGradient: Nullable<FactorGradient>;
  12430. /** @hidden */
  12431. _currentStartSize1: number;
  12432. /** @hidden */
  12433. _currentStartSize2: number;
  12434. private readonly _rawTextureWidth;
  12435. private _rampGradientsTexture;
  12436. private _useRampGradients;
  12437. /** Gets or sets a boolean indicating that ramp gradients must be used
  12438. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12439. */
  12440. get useRampGradients(): boolean;
  12441. set useRampGradients(value: boolean);
  12442. /**
  12443. * 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.
  12444. * 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: [])
  12445. */
  12446. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12447. private _subEmitters;
  12448. /**
  12449. * @hidden
  12450. * If the particle systems emitter should be disposed when the particle system is disposed
  12451. */
  12452. _disposeEmitterOnDispose: boolean;
  12453. /**
  12454. * The current active Sub-systems, this property is used by the root particle system only.
  12455. */
  12456. activeSubSystems: Array<ParticleSystem>;
  12457. /**
  12458. * Specifies if the particles are updated in emitter local space or world space
  12459. */
  12460. isLocal: boolean;
  12461. private _rootParticleSystem;
  12462. /**
  12463. * Gets the current list of active particles
  12464. */
  12465. get particles(): Particle[];
  12466. /**
  12467. * Gets the number of particles active at the same time.
  12468. * @returns The number of active particles.
  12469. */
  12470. getActiveCount(): number;
  12471. /**
  12472. * Returns the string "ParticleSystem"
  12473. * @returns a string containing the class name
  12474. */
  12475. getClassName(): string;
  12476. /**
  12477. * Gets a boolean indicating that the system is stopping
  12478. * @returns true if the system is currently stopping
  12479. */
  12480. isStopping(): boolean;
  12481. /**
  12482. * Gets the custom effect used to render the particles
  12483. * @param blendMode Blend mode for which the effect should be retrieved
  12484. * @returns The effect
  12485. */
  12486. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12487. /**
  12488. * Sets the custom effect used to render the particles
  12489. * @param effect The effect to set
  12490. * @param blendMode Blend mode for which the effect should be set
  12491. */
  12492. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12493. /** @hidden */
  12494. private _onBeforeDrawParticlesObservable;
  12495. /**
  12496. * Observable that will be called just before the particles are drawn
  12497. */
  12498. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12499. /**
  12500. * Gets the name of the particle vertex shader
  12501. */
  12502. get vertexShaderName(): string;
  12503. /**
  12504. * Instantiates a particle system.
  12505. * 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.
  12506. * @param name The name of the particle system
  12507. * @param capacity The max number of particles alive at the same time
  12508. * @param scene The scene the particle system belongs to
  12509. * @param customEffect a custom effect used to change the way particles are rendered by default
  12510. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12511. * @param epsilon Offset used to render the particles
  12512. */
  12513. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12514. private _addFactorGradient;
  12515. private _removeFactorGradient;
  12516. /**
  12517. * Adds a new life time gradient
  12518. * @param gradient defines the gradient to use (between 0 and 1)
  12519. * @param factor defines the life time factor to affect to the specified gradient
  12520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12521. * @returns the current particle system
  12522. */
  12523. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12524. /**
  12525. * Remove a specific life time gradient
  12526. * @param gradient defines the gradient to remove
  12527. * @returns the current particle system
  12528. */
  12529. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12530. /**
  12531. * Adds a new size gradient
  12532. * @param gradient defines the gradient to use (between 0 and 1)
  12533. * @param factor defines the size factor to affect to the specified gradient
  12534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12535. * @returns the current particle system
  12536. */
  12537. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12538. /**
  12539. * Remove a specific size gradient
  12540. * @param gradient defines the gradient to remove
  12541. * @returns the current particle system
  12542. */
  12543. removeSizeGradient(gradient: number): IParticleSystem;
  12544. /**
  12545. * Adds a new color remap gradient
  12546. * @param gradient defines the gradient to use (between 0 and 1)
  12547. * @param min defines the color remap minimal range
  12548. * @param max defines the color remap maximal range
  12549. * @returns the current particle system
  12550. */
  12551. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12552. /**
  12553. * Remove a specific color remap gradient
  12554. * @param gradient defines the gradient to remove
  12555. * @returns the current particle system
  12556. */
  12557. removeColorRemapGradient(gradient: number): IParticleSystem;
  12558. /**
  12559. * Adds a new alpha remap gradient
  12560. * @param gradient defines the gradient to use (between 0 and 1)
  12561. * @param min defines the alpha remap minimal range
  12562. * @param max defines the alpha remap maximal range
  12563. * @returns the current particle system
  12564. */
  12565. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12566. /**
  12567. * Remove a specific alpha remap gradient
  12568. * @param gradient defines the gradient to remove
  12569. * @returns the current particle system
  12570. */
  12571. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12572. /**
  12573. * Adds a new angular speed gradient
  12574. * @param gradient defines the gradient to use (between 0 and 1)
  12575. * @param factor defines the angular speed to affect to the specified gradient
  12576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12577. * @returns the current particle system
  12578. */
  12579. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12580. /**
  12581. * Remove a specific angular speed gradient
  12582. * @param gradient defines the gradient to remove
  12583. * @returns the current particle system
  12584. */
  12585. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12586. /**
  12587. * Adds a new velocity gradient
  12588. * @param gradient defines the gradient to use (between 0 and 1)
  12589. * @param factor defines the velocity to affect to the specified gradient
  12590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12591. * @returns the current particle system
  12592. */
  12593. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12594. /**
  12595. * Remove a specific velocity gradient
  12596. * @param gradient defines the gradient to remove
  12597. * @returns the current particle system
  12598. */
  12599. removeVelocityGradient(gradient: number): IParticleSystem;
  12600. /**
  12601. * Adds a new limit velocity gradient
  12602. * @param gradient defines the gradient to use (between 0 and 1)
  12603. * @param factor defines the limit velocity value to affect to the specified gradient
  12604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12605. * @returns the current particle system
  12606. */
  12607. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12608. /**
  12609. * Remove a specific limit velocity gradient
  12610. * @param gradient defines the gradient to remove
  12611. * @returns the current particle system
  12612. */
  12613. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12614. /**
  12615. * Adds a new drag gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the drag value to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific drag gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeDragGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the emit rate value to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific emit rate gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeEmitRateGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param factor defines the start size value to affect to the specified gradient
  12646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12647. * @returns the current particle system
  12648. */
  12649. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific start size gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeStartSizeGradient(gradient: number): IParticleSystem;
  12656. private _createRampGradientTexture;
  12657. /**
  12658. * Gets the current list of ramp gradients.
  12659. * You must use addRampGradient and removeRampGradient to udpate this list
  12660. * @returns the list of ramp gradients
  12661. */
  12662. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12663. /** Force the system to rebuild all gradients that need to be resync */
  12664. forceRefreshGradients(): void;
  12665. private _syncRampGradientTexture;
  12666. /**
  12667. * Adds a new ramp gradient used to remap particle colors
  12668. * @param gradient defines the gradient to use (between 0 and 1)
  12669. * @param color defines the color to affect to the specified gradient
  12670. * @returns the current particle system
  12671. */
  12672. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12673. /**
  12674. * Remove a specific ramp gradient
  12675. * @param gradient defines the gradient to remove
  12676. * @returns the current particle system
  12677. */
  12678. removeRampGradient(gradient: number): ParticleSystem;
  12679. /**
  12680. * Adds a new color gradient
  12681. * @param gradient defines the gradient to use (between 0 and 1)
  12682. * @param color1 defines the color to affect to the specified gradient
  12683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12684. * @returns this particle system
  12685. */
  12686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12687. /**
  12688. * Remove a specific color gradient
  12689. * @param gradient defines the gradient to remove
  12690. * @returns this particle system
  12691. */
  12692. removeColorGradient(gradient: number): IParticleSystem;
  12693. private _fetchR;
  12694. protected _reset(): void;
  12695. private _resetEffect;
  12696. private _createVertexBuffers;
  12697. private _createIndexBuffer;
  12698. /**
  12699. * Gets the maximum number of particles active at the same time.
  12700. * @returns The max number of active particles.
  12701. */
  12702. getCapacity(): number;
  12703. /**
  12704. * Gets whether there are still active particles in the system.
  12705. * @returns True if it is alive, otherwise false.
  12706. */
  12707. isAlive(): boolean;
  12708. /**
  12709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12710. * @returns True if it has been started, otherwise false.
  12711. */
  12712. isStarted(): boolean;
  12713. private _prepareSubEmitterInternalArray;
  12714. /**
  12715. * Starts the particle system and begins to emit
  12716. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12717. */
  12718. start(delay?: number): void;
  12719. /**
  12720. * Stops the particle system.
  12721. * @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.
  12722. */
  12723. stop(stopSubEmitters?: boolean): void;
  12724. /**
  12725. * Remove all active particles
  12726. */
  12727. reset(): void;
  12728. /**
  12729. * @hidden (for internal use only)
  12730. */
  12731. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12732. /**
  12733. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12734. * Its lifetime will start back at 0.
  12735. */
  12736. recycleParticle: (particle: Particle) => void;
  12737. private _stopSubEmitters;
  12738. private _createParticle;
  12739. private _removeFromRoot;
  12740. private _emitFromParticle;
  12741. private _update;
  12742. /** @hidden */
  12743. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12744. /** @hidden */
  12745. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12746. /**
  12747. * Fill the defines array according to the current settings of the particle system
  12748. * @param defines Array to be updated
  12749. * @param blendMode blend mode to take into account when updating the array
  12750. */
  12751. fillDefines(defines: Array<string>, blendMode: number): void;
  12752. /**
  12753. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12754. * @param uniforms Uniforms array to fill
  12755. * @param attributes Attributes array to fill
  12756. * @param samplers Samplers array to fill
  12757. */
  12758. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12759. /** @hidden */
  12760. private _getEffect;
  12761. /**
  12762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12764. */
  12765. animate(preWarmOnly?: boolean): void;
  12766. private _appendParticleVertices;
  12767. /**
  12768. * Rebuilds the particle system.
  12769. */
  12770. rebuild(): void;
  12771. /**
  12772. * Is this system ready to be used/rendered
  12773. * @return true if the system is ready
  12774. */
  12775. isReady(): boolean;
  12776. private _render;
  12777. /**
  12778. * Renders the particle system in its current state.
  12779. * @returns the current number of particles
  12780. */
  12781. render(): number;
  12782. /**
  12783. * Disposes the particle system and free the associated resources
  12784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12785. */
  12786. dispose(disposeTexture?: boolean): void;
  12787. /**
  12788. * Clones the particle system.
  12789. * @param name The name of the cloned object
  12790. * @param newEmitter The new emitter to use
  12791. * @returns the cloned particle system
  12792. */
  12793. clone(name: string, newEmitter: any): ParticleSystem;
  12794. /**
  12795. * Serializes the particle system to a JSON object
  12796. * @param serializeTexture defines if the texture must be serialized as well
  12797. * @returns the JSON object
  12798. */
  12799. serialize(serializeTexture?: boolean): any;
  12800. /** @hidden */
  12801. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12802. /** @hidden */
  12803. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12804. /**
  12805. * Parses a JSON object to create a particle system.
  12806. * @param parsedParticleSystem The JSON object to parse
  12807. * @param scene The scene to create the particle system in
  12808. * @param rootUrl The root url to use to load external dependencies like texture
  12809. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12810. * @returns the Parsed particle system
  12811. */
  12812. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12813. }
  12814. }
  12815. declare module BABYLON {
  12816. /**
  12817. * A particle represents one of the element emitted by a particle system.
  12818. * This is mainly define by its coordinates, direction, velocity and age.
  12819. */
  12820. export class Particle {
  12821. /**
  12822. * The particle system the particle belongs to.
  12823. */
  12824. particleSystem: ParticleSystem;
  12825. private static _Count;
  12826. /**
  12827. * Unique ID of the particle
  12828. */
  12829. id: number;
  12830. /**
  12831. * The world position of the particle in the scene.
  12832. */
  12833. position: Vector3;
  12834. /**
  12835. * The world direction of the particle in the scene.
  12836. */
  12837. direction: Vector3;
  12838. /**
  12839. * The color of the particle.
  12840. */
  12841. color: Color4;
  12842. /**
  12843. * The color change of the particle per step.
  12844. */
  12845. colorStep: Color4;
  12846. /**
  12847. * Defines how long will the life of the particle be.
  12848. */
  12849. lifeTime: number;
  12850. /**
  12851. * The current age of the particle.
  12852. */
  12853. age: number;
  12854. /**
  12855. * The current size of the particle.
  12856. */
  12857. size: number;
  12858. /**
  12859. * The current scale of the particle.
  12860. */
  12861. scale: Vector2;
  12862. /**
  12863. * The current angle of the particle.
  12864. */
  12865. angle: number;
  12866. /**
  12867. * Defines how fast is the angle changing.
  12868. */
  12869. angularSpeed: number;
  12870. /**
  12871. * Defines the cell index used by the particle to be rendered from a sprite.
  12872. */
  12873. cellIndex: number;
  12874. /**
  12875. * The information required to support color remapping
  12876. */
  12877. remapData: Vector4;
  12878. /** @hidden */
  12879. _randomCellOffset?: number;
  12880. /** @hidden */
  12881. _initialDirection: Nullable<Vector3>;
  12882. /** @hidden */
  12883. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12884. /** @hidden */
  12885. _initialStartSpriteCellID: number;
  12886. /** @hidden */
  12887. _initialEndSpriteCellID: number;
  12888. /** @hidden */
  12889. _currentColorGradient: Nullable<ColorGradient>;
  12890. /** @hidden */
  12891. _currentColor1: Color4;
  12892. /** @hidden */
  12893. _currentColor2: Color4;
  12894. /** @hidden */
  12895. _currentSizeGradient: Nullable<FactorGradient>;
  12896. /** @hidden */
  12897. _currentSize1: number;
  12898. /** @hidden */
  12899. _currentSize2: number;
  12900. /** @hidden */
  12901. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12902. /** @hidden */
  12903. _currentAngularSpeed1: number;
  12904. /** @hidden */
  12905. _currentAngularSpeed2: number;
  12906. /** @hidden */
  12907. _currentVelocityGradient: Nullable<FactorGradient>;
  12908. /** @hidden */
  12909. _currentVelocity1: number;
  12910. /** @hidden */
  12911. _currentVelocity2: number;
  12912. /** @hidden */
  12913. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12914. /** @hidden */
  12915. _currentLimitVelocity1: number;
  12916. /** @hidden */
  12917. _currentLimitVelocity2: number;
  12918. /** @hidden */
  12919. _currentDragGradient: Nullable<FactorGradient>;
  12920. /** @hidden */
  12921. _currentDrag1: number;
  12922. /** @hidden */
  12923. _currentDrag2: number;
  12924. /** @hidden */
  12925. _randomNoiseCoordinates1: Vector3;
  12926. /** @hidden */
  12927. _randomNoiseCoordinates2: Vector3;
  12928. /** @hidden */
  12929. _localPosition?: Vector3;
  12930. /**
  12931. * Creates a new instance Particle
  12932. * @param particleSystem the particle system the particle belongs to
  12933. */
  12934. constructor(
  12935. /**
  12936. * The particle system the particle belongs to.
  12937. */
  12938. particleSystem: ParticleSystem);
  12939. private updateCellInfoFromSystem;
  12940. /**
  12941. * Defines how the sprite cell index is updated for the particle
  12942. */
  12943. updateCellIndex(): void;
  12944. /** @hidden */
  12945. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12946. /** @hidden */
  12947. _inheritParticleInfoToSubEmitters(): void;
  12948. /** @hidden */
  12949. _reset(): void;
  12950. /**
  12951. * Copy the properties of particle to another one.
  12952. * @param other the particle to copy the information to.
  12953. */
  12954. copyTo(other: Particle): void;
  12955. }
  12956. }
  12957. declare module BABYLON {
  12958. /**
  12959. * Particle emitter represents a volume emitting particles.
  12960. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12961. */
  12962. export interface IParticleEmitterType {
  12963. /**
  12964. * Called by the particle System when the direction is computed for the created particle.
  12965. * @param worldMatrix is the world matrix of the particle system
  12966. * @param directionToUpdate is the direction vector to update with the result
  12967. * @param particle is the particle we are computed the direction for
  12968. * @param isLocal defines if the direction should be set in local space
  12969. */
  12970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12971. /**
  12972. * Called by the particle System when the position is computed for the created particle.
  12973. * @param worldMatrix is the world matrix of the particle system
  12974. * @param positionToUpdate is the position vector to update with the result
  12975. * @param particle is the particle we are computed the position for
  12976. * @param isLocal defines if the position should be set in local space
  12977. */
  12978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12979. /**
  12980. * Clones the current emitter and returns a copy of it
  12981. * @returns the new emitter
  12982. */
  12983. clone(): IParticleEmitterType;
  12984. /**
  12985. * Called by the GPUParticleSystem to setup the update shader
  12986. * @param effect defines the update shader
  12987. */
  12988. applyToShader(effect: Effect): void;
  12989. /**
  12990. * Returns a string to use to update the GPU particles update shader
  12991. * @returns the effect defines string
  12992. */
  12993. getEffectDefines(): string;
  12994. /**
  12995. * Returns a string representing the class name
  12996. * @returns a string containing the class name
  12997. */
  12998. getClassName(): string;
  12999. /**
  13000. * Serializes the particle system to a JSON object.
  13001. * @returns the JSON object
  13002. */
  13003. serialize(): any;
  13004. /**
  13005. * Parse properties from a JSON object
  13006. * @param serializationObject defines the JSON object
  13007. * @param scene defines the hosting scene
  13008. */
  13009. parse(serializationObject: any, scene: Scene): void;
  13010. }
  13011. }
  13012. declare module BABYLON {
  13013. /**
  13014. * Particle emitter emitting particles from the inside of a box.
  13015. * It emits the particles randomly between 2 given directions.
  13016. */
  13017. export class BoxParticleEmitter implements IParticleEmitterType {
  13018. /**
  13019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13020. */
  13021. direction1: Vector3;
  13022. /**
  13023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13024. */
  13025. direction2: Vector3;
  13026. /**
  13027. * 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.
  13028. */
  13029. minEmitBox: Vector3;
  13030. /**
  13031. * 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.
  13032. */
  13033. maxEmitBox: Vector3;
  13034. /**
  13035. * Creates a new instance BoxParticleEmitter
  13036. */
  13037. constructor();
  13038. /**
  13039. * Called by the particle System when the direction is computed for the created particle.
  13040. * @param worldMatrix is the world matrix of the particle system
  13041. * @param directionToUpdate is the direction vector to update with the result
  13042. * @param particle is the particle we are computed the direction for
  13043. * @param isLocal defines if the direction should be set in local space
  13044. */
  13045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13046. /**
  13047. * Called by the particle System when the position is computed for the created particle.
  13048. * @param worldMatrix is the world matrix of the particle system
  13049. * @param positionToUpdate is the position vector to update with the result
  13050. * @param particle is the particle we are computed the position for
  13051. * @param isLocal defines if the position should be set in local space
  13052. */
  13053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13054. /**
  13055. * Clones the current emitter and returns a copy of it
  13056. * @returns the new emitter
  13057. */
  13058. clone(): BoxParticleEmitter;
  13059. /**
  13060. * Called by the GPUParticleSystem to setup the update shader
  13061. * @param effect defines the update shader
  13062. */
  13063. applyToShader(effect: Effect): void;
  13064. /**
  13065. * Returns a string to use to update the GPU particles update shader
  13066. * @returns a string containng the defines string
  13067. */
  13068. getEffectDefines(): string;
  13069. /**
  13070. * Returns the string "BoxParticleEmitter"
  13071. * @returns a string containing the class name
  13072. */
  13073. getClassName(): string;
  13074. /**
  13075. * Serializes the particle system to a JSON object.
  13076. * @returns the JSON object
  13077. */
  13078. serialize(): any;
  13079. /**
  13080. * Parse properties from a JSON object
  13081. * @param serializationObject defines the JSON object
  13082. */
  13083. parse(serializationObject: any): void;
  13084. }
  13085. }
  13086. declare module BABYLON {
  13087. /**
  13088. * Particle emitter emitting particles from the inside of a cone.
  13089. * It emits the particles alongside the cone volume from the base to the particle.
  13090. * The emission direction might be randomized.
  13091. */
  13092. export class ConeParticleEmitter implements IParticleEmitterType {
  13093. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13094. directionRandomizer: number;
  13095. private _radius;
  13096. private _angle;
  13097. private _height;
  13098. /**
  13099. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13100. */
  13101. radiusRange: number;
  13102. /**
  13103. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13104. */
  13105. heightRange: number;
  13106. /**
  13107. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13108. */
  13109. emitFromSpawnPointOnly: boolean;
  13110. /**
  13111. * Gets or sets the radius of the emission cone
  13112. */
  13113. get radius(): number;
  13114. set radius(value: number);
  13115. /**
  13116. * Gets or sets the angle of the emission cone
  13117. */
  13118. get angle(): number;
  13119. set angle(value: number);
  13120. private _buildHeight;
  13121. /**
  13122. * Creates a new instance ConeParticleEmitter
  13123. * @param radius the radius of the emission cone (1 by default)
  13124. * @param angle the cone base angle (PI by default)
  13125. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13126. */
  13127. constructor(radius?: number, angle?: number,
  13128. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13129. directionRandomizer?: number);
  13130. /**
  13131. * Called by the particle System when the direction is computed for the created particle.
  13132. * @param worldMatrix is the world matrix of the particle system
  13133. * @param directionToUpdate is the direction vector to update with the result
  13134. * @param particle is the particle we are computed the direction for
  13135. * @param isLocal defines if the direction should be set in local space
  13136. */
  13137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13138. /**
  13139. * Called by the particle System when the position is computed for the created particle.
  13140. * @param worldMatrix is the world matrix of the particle system
  13141. * @param positionToUpdate is the position vector to update with the result
  13142. * @param particle is the particle we are computed the position for
  13143. * @param isLocal defines if the position should be set in local space
  13144. */
  13145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13146. /**
  13147. * Clones the current emitter and returns a copy of it
  13148. * @returns the new emitter
  13149. */
  13150. clone(): ConeParticleEmitter;
  13151. /**
  13152. * Called by the GPUParticleSystem to setup the update shader
  13153. * @param effect defines the update shader
  13154. */
  13155. applyToShader(effect: Effect): void;
  13156. /**
  13157. * Returns a string to use to update the GPU particles update shader
  13158. * @returns a string containng the defines string
  13159. */
  13160. getEffectDefines(): string;
  13161. /**
  13162. * Returns the string "ConeParticleEmitter"
  13163. * @returns a string containing the class name
  13164. */
  13165. getClassName(): string;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Parse properties from a JSON object
  13173. * @param serializationObject defines the JSON object
  13174. */
  13175. parse(serializationObject: any): void;
  13176. }
  13177. }
  13178. declare module BABYLON {
  13179. /**
  13180. * Particle emitter emitting particles from the inside of a cylinder.
  13181. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13182. */
  13183. export class CylinderParticleEmitter implements IParticleEmitterType {
  13184. /**
  13185. * The radius of the emission cylinder.
  13186. */
  13187. radius: number;
  13188. /**
  13189. * The height of the emission cylinder.
  13190. */
  13191. height: number;
  13192. /**
  13193. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13194. */
  13195. radiusRange: number;
  13196. /**
  13197. * How much to randomize the particle direction [0-1].
  13198. */
  13199. directionRandomizer: number;
  13200. /**
  13201. * Creates a new instance CylinderParticleEmitter
  13202. * @param radius the radius of the emission cylinder (1 by default)
  13203. * @param height the height of the emission cylinder (1 by default)
  13204. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13205. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13206. */
  13207. constructor(
  13208. /**
  13209. * The radius of the emission cylinder.
  13210. */
  13211. radius?: number,
  13212. /**
  13213. * The height of the emission cylinder.
  13214. */
  13215. height?: number,
  13216. /**
  13217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13218. */
  13219. radiusRange?: number,
  13220. /**
  13221. * How much to randomize the particle direction [0-1].
  13222. */
  13223. directionRandomizer?: number);
  13224. /**
  13225. * Called by the particle System when the direction is computed for the created particle.
  13226. * @param worldMatrix is the world matrix of the particle system
  13227. * @param directionToUpdate is the direction vector to update with the result
  13228. * @param particle is the particle we are computed the direction for
  13229. * @param isLocal defines if the direction should be set in local space
  13230. */
  13231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13232. /**
  13233. * Called by the particle System when the position is computed for the created particle.
  13234. * @param worldMatrix is the world matrix of the particle system
  13235. * @param positionToUpdate is the position vector to update with the result
  13236. * @param particle is the particle we are computed the position for
  13237. * @param isLocal defines if the position should be set in local space
  13238. */
  13239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13240. /**
  13241. * Clones the current emitter and returns a copy of it
  13242. * @returns the new emitter
  13243. */
  13244. clone(): CylinderParticleEmitter;
  13245. /**
  13246. * Called by the GPUParticleSystem to setup the update shader
  13247. * @param effect defines the update shader
  13248. */
  13249. applyToShader(effect: Effect): void;
  13250. /**
  13251. * Returns a string to use to update the GPU particles update shader
  13252. * @returns a string containng the defines string
  13253. */
  13254. getEffectDefines(): string;
  13255. /**
  13256. * Returns the string "CylinderParticleEmitter"
  13257. * @returns a string containing the class name
  13258. */
  13259. getClassName(): string;
  13260. /**
  13261. * Serializes the particle system to a JSON object.
  13262. * @returns the JSON object
  13263. */
  13264. serialize(): any;
  13265. /**
  13266. * Parse properties from a JSON object
  13267. * @param serializationObject defines the JSON object
  13268. */
  13269. parse(serializationObject: any): void;
  13270. }
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cylinder.
  13273. * It emits the particles randomly between two vectors.
  13274. */
  13275. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13276. /**
  13277. * The min limit of the emission direction.
  13278. */
  13279. direction1: Vector3;
  13280. /**
  13281. * The max limit of the emission direction.
  13282. */
  13283. direction2: Vector3;
  13284. /**
  13285. * Creates a new instance CylinderDirectedParticleEmitter
  13286. * @param radius the radius of the emission cylinder (1 by default)
  13287. * @param height the height of the emission cylinder (1 by default)
  13288. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13289. * @param direction1 the min limit of the emission direction (up vector by default)
  13290. * @param direction2 the max limit of the emission direction (up vector by default)
  13291. */
  13292. constructor(radius?: number, height?: number, radiusRange?: number,
  13293. /**
  13294. * The min limit of the emission direction.
  13295. */
  13296. direction1?: Vector3,
  13297. /**
  13298. * The max limit of the emission direction.
  13299. */
  13300. direction2?: Vector3);
  13301. /**
  13302. * Called by the particle System when the direction is computed for the created particle.
  13303. * @param worldMatrix is the world matrix of the particle system
  13304. * @param directionToUpdate is the direction vector to update with the result
  13305. * @param particle is the particle we are computed the direction for
  13306. */
  13307. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13308. /**
  13309. * Clones the current emitter and returns a copy of it
  13310. * @returns the new emitter
  13311. */
  13312. clone(): CylinderDirectedParticleEmitter;
  13313. /**
  13314. * Called by the GPUParticleSystem to setup the update shader
  13315. * @param effect defines the update shader
  13316. */
  13317. applyToShader(effect: Effect): void;
  13318. /**
  13319. * Returns a string to use to update the GPU particles update shader
  13320. * @returns a string containng the defines string
  13321. */
  13322. getEffectDefines(): string;
  13323. /**
  13324. * Returns the string "CylinderDirectedParticleEmitter"
  13325. * @returns a string containing the class name
  13326. */
  13327. getClassName(): string;
  13328. /**
  13329. * Serializes the particle system to a JSON object.
  13330. * @returns the JSON object
  13331. */
  13332. serialize(): any;
  13333. /**
  13334. * Parse properties from a JSON object
  13335. * @param serializationObject defines the JSON object
  13336. */
  13337. parse(serializationObject: any): void;
  13338. }
  13339. }
  13340. declare module BABYLON {
  13341. /**
  13342. * Particle emitter emitting particles from the inside of a hemisphere.
  13343. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13344. */
  13345. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13346. /**
  13347. * The radius of the emission hemisphere.
  13348. */
  13349. radius: number;
  13350. /**
  13351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13352. */
  13353. radiusRange: number;
  13354. /**
  13355. * How much to randomize the particle direction [0-1].
  13356. */
  13357. directionRandomizer: number;
  13358. /**
  13359. * Creates a new instance HemisphericParticleEmitter
  13360. * @param radius the radius of the emission hemisphere (1 by default)
  13361. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13362. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13363. */
  13364. constructor(
  13365. /**
  13366. * The radius of the emission hemisphere.
  13367. */
  13368. radius?: number,
  13369. /**
  13370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13371. */
  13372. radiusRange?: number,
  13373. /**
  13374. * How much to randomize the particle direction [0-1].
  13375. */
  13376. directionRandomizer?: number);
  13377. /**
  13378. * Called by the particle System when the direction is computed for the created particle.
  13379. * @param worldMatrix is the world matrix of the particle system
  13380. * @param directionToUpdate is the direction vector to update with the result
  13381. * @param particle is the particle we are computed the direction for
  13382. * @param isLocal defines if the direction should be set in local space
  13383. */
  13384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13385. /**
  13386. * Called by the particle System when the position is computed for the created particle.
  13387. * @param worldMatrix is the world matrix of the particle system
  13388. * @param positionToUpdate is the position vector to update with the result
  13389. * @param particle is the particle we are computed the position for
  13390. * @param isLocal defines if the position should be set in local space
  13391. */
  13392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13393. /**
  13394. * Clones the current emitter and returns a copy of it
  13395. * @returns the new emitter
  13396. */
  13397. clone(): HemisphericParticleEmitter;
  13398. /**
  13399. * Called by the GPUParticleSystem to setup the update shader
  13400. * @param effect defines the update shader
  13401. */
  13402. applyToShader(effect: Effect): void;
  13403. /**
  13404. * Returns a string to use to update the GPU particles update shader
  13405. * @returns a string containng the defines string
  13406. */
  13407. getEffectDefines(): string;
  13408. /**
  13409. * Returns the string "HemisphericParticleEmitter"
  13410. * @returns a string containing the class name
  13411. */
  13412. getClassName(): string;
  13413. /**
  13414. * Serializes the particle system to a JSON object.
  13415. * @returns the JSON object
  13416. */
  13417. serialize(): any;
  13418. /**
  13419. * Parse properties from a JSON object
  13420. * @param serializationObject defines the JSON object
  13421. */
  13422. parse(serializationObject: any): void;
  13423. }
  13424. }
  13425. declare module BABYLON {
  13426. /**
  13427. * Particle emitter emitting particles from a point.
  13428. * It emits the particles randomly between 2 given directions.
  13429. */
  13430. export class PointParticleEmitter implements IParticleEmitterType {
  13431. /**
  13432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13433. */
  13434. direction1: Vector3;
  13435. /**
  13436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13437. */
  13438. direction2: Vector3;
  13439. /**
  13440. * Creates a new instance PointParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): PointParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "PointParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module BABYLON {
  13492. /**
  13493. * Particle emitter emitting particles from the inside of a sphere.
  13494. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13495. */
  13496. export class SphereParticleEmitter implements IParticleEmitterType {
  13497. /**
  13498. * The radius of the emission sphere.
  13499. */
  13500. radius: number;
  13501. /**
  13502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13503. */
  13504. radiusRange: number;
  13505. /**
  13506. * How much to randomize the particle direction [0-1].
  13507. */
  13508. directionRandomizer: number;
  13509. /**
  13510. * Creates a new instance SphereParticleEmitter
  13511. * @param radius the radius of the emission sphere (1 by default)
  13512. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13513. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13514. */
  13515. constructor(
  13516. /**
  13517. * The radius of the emission sphere.
  13518. */
  13519. radius?: number,
  13520. /**
  13521. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13522. */
  13523. radiusRange?: number,
  13524. /**
  13525. * How much to randomize the particle direction [0-1].
  13526. */
  13527. directionRandomizer?: number);
  13528. /**
  13529. * Called by the particle System when the direction is computed for the created particle.
  13530. * @param worldMatrix is the world matrix of the particle system
  13531. * @param directionToUpdate is the direction vector to update with the result
  13532. * @param particle is the particle we are computed the direction for
  13533. * @param isLocal defines if the direction should be set in local space
  13534. */
  13535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13536. /**
  13537. * Called by the particle System when the position is computed for the created particle.
  13538. * @param worldMatrix is the world matrix of the particle system
  13539. * @param positionToUpdate is the position vector to update with the result
  13540. * @param particle is the particle we are computed the position for
  13541. * @param isLocal defines if the position should be set in local space
  13542. */
  13543. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13544. /**
  13545. * Clones the current emitter and returns a copy of it
  13546. * @returns the new emitter
  13547. */
  13548. clone(): SphereParticleEmitter;
  13549. /**
  13550. * Called by the GPUParticleSystem to setup the update shader
  13551. * @param effect defines the update shader
  13552. */
  13553. applyToShader(effect: Effect): void;
  13554. /**
  13555. * Returns a string to use to update the GPU particles update shader
  13556. * @returns a string containng the defines string
  13557. */
  13558. getEffectDefines(): string;
  13559. /**
  13560. * Returns the string "SphereParticleEmitter"
  13561. * @returns a string containing the class name
  13562. */
  13563. getClassName(): string;
  13564. /**
  13565. * Serializes the particle system to a JSON object.
  13566. * @returns the JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Parse properties from a JSON object
  13571. * @param serializationObject defines the JSON object
  13572. */
  13573. parse(serializationObject: any): void;
  13574. }
  13575. /**
  13576. * Particle emitter emitting particles from the inside of a sphere.
  13577. * It emits the particles randomly between two vectors.
  13578. */
  13579. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13580. /**
  13581. * The min limit of the emission direction.
  13582. */
  13583. direction1: Vector3;
  13584. /**
  13585. * The max limit of the emission direction.
  13586. */
  13587. direction2: Vector3;
  13588. /**
  13589. * Creates a new instance SphereDirectedParticleEmitter
  13590. * @param radius the radius of the emission sphere (1 by default)
  13591. * @param direction1 the min limit of the emission direction (up vector by default)
  13592. * @param direction2 the max limit of the emission direction (up vector by default)
  13593. */
  13594. constructor(radius?: number,
  13595. /**
  13596. * The min limit of the emission direction.
  13597. */
  13598. direction1?: Vector3,
  13599. /**
  13600. * The max limit of the emission direction.
  13601. */
  13602. direction2?: Vector3);
  13603. /**
  13604. * Called by the particle System when the direction is computed for the created particle.
  13605. * @param worldMatrix is the world matrix of the particle system
  13606. * @param directionToUpdate is the direction vector to update with the result
  13607. * @param particle is the particle we are computed the direction for
  13608. */
  13609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13610. /**
  13611. * Clones the current emitter and returns a copy of it
  13612. * @returns the new emitter
  13613. */
  13614. clone(): SphereDirectedParticleEmitter;
  13615. /**
  13616. * Called by the GPUParticleSystem to setup the update shader
  13617. * @param effect defines the update shader
  13618. */
  13619. applyToShader(effect: Effect): void;
  13620. /**
  13621. * Returns a string to use to update the GPU particles update shader
  13622. * @returns a string containng the defines string
  13623. */
  13624. getEffectDefines(): string;
  13625. /**
  13626. * Returns the string "SphereDirectedParticleEmitter"
  13627. * @returns a string containing the class name
  13628. */
  13629. getClassName(): string;
  13630. /**
  13631. * Serializes the particle system to a JSON object.
  13632. * @returns the JSON object
  13633. */
  13634. serialize(): any;
  13635. /**
  13636. * Parse properties from a JSON object
  13637. * @param serializationObject defines the JSON object
  13638. */
  13639. parse(serializationObject: any): void;
  13640. }
  13641. }
  13642. declare module BABYLON {
  13643. /**
  13644. * Particle emitter emitting particles from a custom list of positions.
  13645. */
  13646. export class CustomParticleEmitter implements IParticleEmitterType {
  13647. /**
  13648. * Gets or sets the position generator that will create the inital position of each particle.
  13649. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13650. */
  13651. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13652. /**
  13653. * Gets or sets the destination generator that will create the final destination of each particle.
  13654. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13655. */
  13656. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13657. /**
  13658. * Creates a new instance CustomParticleEmitter
  13659. */
  13660. constructor();
  13661. /**
  13662. * Called by the particle System when the direction is computed for the created particle.
  13663. * @param worldMatrix is the world matrix of the particle system
  13664. * @param directionToUpdate is the direction vector to update with the result
  13665. * @param particle is the particle we are computed the direction for
  13666. * @param isLocal defines if the direction should be set in local space
  13667. */
  13668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13669. /**
  13670. * Called by the particle System when the position is computed for the created particle.
  13671. * @param worldMatrix is the world matrix of the particle system
  13672. * @param positionToUpdate is the position vector to update with the result
  13673. * @param particle is the particle we are computed the position for
  13674. * @param isLocal defines if the position should be set in local space
  13675. */
  13676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13677. /**
  13678. * Clones the current emitter and returns a copy of it
  13679. * @returns the new emitter
  13680. */
  13681. clone(): CustomParticleEmitter;
  13682. /**
  13683. * Called by the GPUParticleSystem to setup the update shader
  13684. * @param effect defines the update shader
  13685. */
  13686. applyToShader(effect: Effect): void;
  13687. /**
  13688. * Returns a string to use to update the GPU particles update shader
  13689. * @returns a string containng the defines string
  13690. */
  13691. getEffectDefines(): string;
  13692. /**
  13693. * Returns the string "PointParticleEmitter"
  13694. * @returns a string containing the class name
  13695. */
  13696. getClassName(): string;
  13697. /**
  13698. * Serializes the particle system to a JSON object.
  13699. * @returns the JSON object
  13700. */
  13701. serialize(): any;
  13702. /**
  13703. * Parse properties from a JSON object
  13704. * @param serializationObject defines the JSON object
  13705. */
  13706. parse(serializationObject: any): void;
  13707. }
  13708. }
  13709. declare module BABYLON {
  13710. /**
  13711. * Particle emitter emitting particles from the inside of a box.
  13712. * It emits the particles randomly between 2 given directions.
  13713. */
  13714. export class MeshParticleEmitter implements IParticleEmitterType {
  13715. private _indices;
  13716. private _positions;
  13717. private _normals;
  13718. private _storedNormal;
  13719. private _mesh;
  13720. /**
  13721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13722. */
  13723. direction1: Vector3;
  13724. /**
  13725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13726. */
  13727. direction2: Vector3;
  13728. /**
  13729. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13730. */
  13731. useMeshNormalsForDirection: boolean;
  13732. /** Defines the mesh to use as source */
  13733. get mesh(): Nullable<AbstractMesh>;
  13734. set mesh(value: Nullable<AbstractMesh>);
  13735. /**
  13736. * Creates a new instance MeshParticleEmitter
  13737. * @param mesh defines the mesh to use as source
  13738. */
  13739. constructor(mesh?: Nullable<AbstractMesh>);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): MeshParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "BoxParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. * @param scene defines the hosting scene
  13785. */
  13786. parse(serializationObject: any, scene: Scene): void;
  13787. }
  13788. }
  13789. declare module BABYLON {
  13790. /**
  13791. * Interface representing a particle system in Babylon.js.
  13792. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13793. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13794. */
  13795. export interface IParticleSystem {
  13796. /**
  13797. * List of animations used by the particle system.
  13798. */
  13799. animations: Animation[];
  13800. /**
  13801. * The id of the Particle system.
  13802. */
  13803. id: string;
  13804. /**
  13805. * The name of the Particle system.
  13806. */
  13807. name: string;
  13808. /**
  13809. * The emitter represents the Mesh or position we are attaching the particle system to.
  13810. */
  13811. emitter: Nullable<AbstractMesh | Vector3>;
  13812. /**
  13813. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13814. */
  13815. isBillboardBased: boolean;
  13816. /**
  13817. * The rendering group used by the Particle system to chose when to render.
  13818. */
  13819. renderingGroupId: number;
  13820. /**
  13821. * The layer mask we are rendering the particles through.
  13822. */
  13823. layerMask: number;
  13824. /**
  13825. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13826. */
  13827. updateSpeed: number;
  13828. /**
  13829. * The amount of time the particle system is running (depends of the overall update speed).
  13830. */
  13831. targetStopDuration: number;
  13832. /**
  13833. * The texture used to render each particle. (this can be a spritesheet)
  13834. */
  13835. particleTexture: Nullable<Texture>;
  13836. /**
  13837. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13838. */
  13839. blendMode: number;
  13840. /**
  13841. * Minimum life time of emitting particles.
  13842. */
  13843. minLifeTime: number;
  13844. /**
  13845. * Maximum life time of emitting particles.
  13846. */
  13847. maxLifeTime: number;
  13848. /**
  13849. * Minimum Size of emitting particles.
  13850. */
  13851. minSize: number;
  13852. /**
  13853. * Maximum Size of emitting particles.
  13854. */
  13855. maxSize: number;
  13856. /**
  13857. * Minimum scale of emitting particles on X axis.
  13858. */
  13859. minScaleX: number;
  13860. /**
  13861. * Maximum scale of emitting particles on X axis.
  13862. */
  13863. maxScaleX: number;
  13864. /**
  13865. * Minimum scale of emitting particles on Y axis.
  13866. */
  13867. minScaleY: number;
  13868. /**
  13869. * Maximum scale of emitting particles on Y axis.
  13870. */
  13871. maxScaleY: number;
  13872. /**
  13873. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13874. */
  13875. color1: Color4;
  13876. /**
  13877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13878. */
  13879. color2: Color4;
  13880. /**
  13881. * Color the particle will have at the end of its lifetime.
  13882. */
  13883. colorDead: Color4;
  13884. /**
  13885. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13886. */
  13887. emitRate: number;
  13888. /**
  13889. * You can use gravity if you want to give an orientation to your particles.
  13890. */
  13891. gravity: Vector3;
  13892. /**
  13893. * Minimum power of emitting particles.
  13894. */
  13895. minEmitPower: number;
  13896. /**
  13897. * Maximum power of emitting particles.
  13898. */
  13899. maxEmitPower: number;
  13900. /**
  13901. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13902. */
  13903. minAngularSpeed: number;
  13904. /**
  13905. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13906. */
  13907. maxAngularSpeed: number;
  13908. /**
  13909. * Gets or sets the minimal initial rotation in radians.
  13910. */
  13911. minInitialRotation: number;
  13912. /**
  13913. * Gets or sets the maximal initial rotation in radians.
  13914. */
  13915. maxInitialRotation: number;
  13916. /**
  13917. * The particle emitter type defines the emitter used by the particle system.
  13918. * It can be for example box, sphere, or cone...
  13919. */
  13920. particleEmitterType: Nullable<IParticleEmitterType>;
  13921. /**
  13922. * Defines the delay in milliseconds before starting the system (0 by default)
  13923. */
  13924. startDelay: number;
  13925. /**
  13926. * 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
  13927. */
  13928. preWarmCycles: number;
  13929. /**
  13930. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13931. */
  13932. preWarmStepOffset: number;
  13933. /**
  13934. * 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)
  13935. */
  13936. spriteCellChangeSpeed: number;
  13937. /**
  13938. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13939. */
  13940. startSpriteCellID: number;
  13941. /**
  13942. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13943. */
  13944. endSpriteCellID: number;
  13945. /**
  13946. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13947. */
  13948. spriteCellWidth: number;
  13949. /**
  13950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13951. */
  13952. spriteCellHeight: number;
  13953. /**
  13954. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13955. */
  13956. spriteRandomStartCell: boolean;
  13957. /**
  13958. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13959. */
  13960. isAnimationSheetEnabled: boolean;
  13961. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13962. translationPivot: Vector2;
  13963. /**
  13964. * Gets or sets a texture used to add random noise to particle positions
  13965. */
  13966. noiseTexture: Nullable<BaseTexture>;
  13967. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13968. noiseStrength: Vector3;
  13969. /**
  13970. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13971. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13972. */
  13973. billboardMode: number;
  13974. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13975. limitVelocityDamping: number;
  13976. /**
  13977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13978. */
  13979. beginAnimationOnStart: boolean;
  13980. /**
  13981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13982. */
  13983. beginAnimationFrom: number;
  13984. /**
  13985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13986. */
  13987. beginAnimationTo: number;
  13988. /**
  13989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13990. */
  13991. beginAnimationLoop: boolean;
  13992. /**
  13993. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13994. */
  13995. disposeOnStop: boolean;
  13996. /**
  13997. * Specifies if the particles are updated in emitter local space or world space
  13998. */
  13999. isLocal: boolean;
  14000. /** Snippet ID if the particle system was created from the snippet server */
  14001. snippetId: string;
  14002. /**
  14003. * Gets the maximum number of particles active at the same time.
  14004. * @returns The max number of active particles.
  14005. */
  14006. getCapacity(): number;
  14007. /**
  14008. * Gets the number of particles active at the same time.
  14009. * @returns The number of active particles.
  14010. */
  14011. getActiveCount(): number;
  14012. /**
  14013. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14014. * @returns True if it has been started, otherwise false.
  14015. */
  14016. isStarted(): boolean;
  14017. /**
  14018. * Animates the particle system for this frame.
  14019. */
  14020. animate(): void;
  14021. /**
  14022. * Renders the particle system in its current state.
  14023. * @returns the current number of particles
  14024. */
  14025. render(): number;
  14026. /**
  14027. * Dispose the particle system and frees its associated resources.
  14028. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14029. */
  14030. dispose(disposeTexture?: boolean): void;
  14031. /**
  14032. * An event triggered when the system is disposed
  14033. */
  14034. onDisposeObservable: Observable<IParticleSystem>;
  14035. /**
  14036. * Clones the particle system.
  14037. * @param name The name of the cloned object
  14038. * @param newEmitter The new emitter to use
  14039. * @returns the cloned particle system
  14040. */
  14041. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14042. /**
  14043. * Serializes the particle system to a JSON object
  14044. * @param serializeTexture defines if the texture must be serialized as well
  14045. * @returns the JSON object
  14046. */
  14047. serialize(serializeTexture: boolean): any;
  14048. /**
  14049. * Rebuild the particle system
  14050. */
  14051. rebuild(): void;
  14052. /** Force the system to rebuild all gradients that need to be resync */
  14053. forceRefreshGradients(): void;
  14054. /**
  14055. * Starts the particle system and begins to emit
  14056. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14057. */
  14058. start(delay?: number): void;
  14059. /**
  14060. * Stops the particle system.
  14061. */
  14062. stop(): void;
  14063. /**
  14064. * Remove all active particles
  14065. */
  14066. reset(): void;
  14067. /**
  14068. * Gets a boolean indicating that the system is stopping
  14069. * @returns true if the system is currently stopping
  14070. */
  14071. isStopping(): boolean;
  14072. /**
  14073. * Is this system ready to be used/rendered
  14074. * @return true if the system is ready
  14075. */
  14076. isReady(): boolean;
  14077. /**
  14078. * Returns the string "ParticleSystem"
  14079. * @returns a string containing the class name
  14080. */
  14081. getClassName(): string;
  14082. /**
  14083. * Gets the custom effect used to render the particles
  14084. * @param blendMode Blend mode for which the effect should be retrieved
  14085. * @returns The effect
  14086. */
  14087. getCustomEffect(blendMode: number): Nullable<Effect>;
  14088. /**
  14089. * Sets the custom effect used to render the particles
  14090. * @param effect The effect to set
  14091. * @param blendMode Blend mode for which the effect should be set
  14092. */
  14093. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14094. /**
  14095. * Fill the defines array according to the current settings of the particle system
  14096. * @param defines Array to be updated
  14097. * @param blendMode blend mode to take into account when updating the array
  14098. */
  14099. fillDefines(defines: Array<string>, blendMode: number): void;
  14100. /**
  14101. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14102. * @param uniforms Uniforms array to fill
  14103. * @param attributes Attributes array to fill
  14104. * @param samplers Samplers array to fill
  14105. */
  14106. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14107. /**
  14108. * Observable that will be called just before the particles are drawn
  14109. */
  14110. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14111. /**
  14112. * Gets the name of the particle vertex shader
  14113. */
  14114. vertexShaderName: string;
  14115. /**
  14116. * Adds a new color gradient
  14117. * @param gradient defines the gradient to use (between 0 and 1)
  14118. * @param color1 defines the color to affect to the specified gradient
  14119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14120. * @returns the current particle system
  14121. */
  14122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14123. /**
  14124. * Remove a specific color gradient
  14125. * @param gradient defines the gradient to remove
  14126. * @returns the current particle system
  14127. */
  14128. removeColorGradient(gradient: number): IParticleSystem;
  14129. /**
  14130. * Adds a new size gradient
  14131. * @param gradient defines the gradient to use (between 0 and 1)
  14132. * @param factor defines the size factor to affect to the specified gradient
  14133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14134. * @returns the current particle system
  14135. */
  14136. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14137. /**
  14138. * Remove a specific size gradient
  14139. * @param gradient defines the gradient to remove
  14140. * @returns the current particle system
  14141. */
  14142. removeSizeGradient(gradient: number): IParticleSystem;
  14143. /**
  14144. * Gets the current list of color gradients.
  14145. * You must use addColorGradient and removeColorGradient to udpate this list
  14146. * @returns the list of color gradients
  14147. */
  14148. getColorGradients(): Nullable<Array<ColorGradient>>;
  14149. /**
  14150. * Gets the current list of size gradients.
  14151. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14152. * @returns the list of size gradients
  14153. */
  14154. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14155. /**
  14156. * Gets the current list of angular speed gradients.
  14157. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14158. * @returns the list of angular speed gradients
  14159. */
  14160. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14161. /**
  14162. * Adds a new angular speed gradient
  14163. * @param gradient defines the gradient to use (between 0 and 1)
  14164. * @param factor defines the angular speed to affect to the specified gradient
  14165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14166. * @returns the current particle system
  14167. */
  14168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14169. /**
  14170. * Remove a specific angular speed gradient
  14171. * @param gradient defines the gradient to remove
  14172. * @returns the current particle system
  14173. */
  14174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14175. /**
  14176. * Gets the current list of velocity gradients.
  14177. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14178. * @returns the list of velocity gradients
  14179. */
  14180. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14181. /**
  14182. * Adds a new velocity gradient
  14183. * @param gradient defines the gradient to use (between 0 and 1)
  14184. * @param factor defines the velocity to affect to the specified gradient
  14185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14186. * @returns the current particle system
  14187. */
  14188. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14189. /**
  14190. * Remove a specific velocity gradient
  14191. * @param gradient defines the gradient to remove
  14192. * @returns the current particle system
  14193. */
  14194. removeVelocityGradient(gradient: number): IParticleSystem;
  14195. /**
  14196. * Gets the current list of limit velocity gradients.
  14197. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14198. * @returns the list of limit velocity gradients
  14199. */
  14200. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14201. /**
  14202. * Adds a new limit velocity gradient
  14203. * @param gradient defines the gradient to use (between 0 and 1)
  14204. * @param factor defines the limit velocity to affect to the specified gradient
  14205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14206. * @returns the current particle system
  14207. */
  14208. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14209. /**
  14210. * Remove a specific limit velocity gradient
  14211. * @param gradient defines the gradient to remove
  14212. * @returns the current particle system
  14213. */
  14214. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14215. /**
  14216. * Adds a new drag gradient
  14217. * @param gradient defines the gradient to use (between 0 and 1)
  14218. * @param factor defines the drag to affect to the specified gradient
  14219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14220. * @returns the current particle system
  14221. */
  14222. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14223. /**
  14224. * Remove a specific drag gradient
  14225. * @param gradient defines the gradient to remove
  14226. * @returns the current particle system
  14227. */
  14228. removeDragGradient(gradient: number): IParticleSystem;
  14229. /**
  14230. * Gets the current list of drag gradients.
  14231. * You must use addDragGradient and removeDragGradient to udpate this list
  14232. * @returns the list of drag gradients
  14233. */
  14234. getDragGradients(): Nullable<Array<FactorGradient>>;
  14235. /**
  14236. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14237. * @param gradient defines the gradient to use (between 0 and 1)
  14238. * @param factor defines the emit rate to affect to the specified gradient
  14239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14240. * @returns the current particle system
  14241. */
  14242. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14243. /**
  14244. * Remove a specific emit rate gradient
  14245. * @param gradient defines the gradient to remove
  14246. * @returns the current particle system
  14247. */
  14248. removeEmitRateGradient(gradient: number): IParticleSystem;
  14249. /**
  14250. * Gets the current list of emit rate gradients.
  14251. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14252. * @returns the list of emit rate gradients
  14253. */
  14254. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14255. /**
  14256. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14257. * @param gradient defines the gradient to use (between 0 and 1)
  14258. * @param factor defines the start size to affect to the specified gradient
  14259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14260. * @returns the current particle system
  14261. */
  14262. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14263. /**
  14264. * Remove a specific start size gradient
  14265. * @param gradient defines the gradient to remove
  14266. * @returns the current particle system
  14267. */
  14268. removeStartSizeGradient(gradient: number): IParticleSystem;
  14269. /**
  14270. * Gets the current list of start size gradients.
  14271. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14272. * @returns the list of start size gradients
  14273. */
  14274. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14275. /**
  14276. * Adds a new life time gradient
  14277. * @param gradient defines the gradient to use (between 0 and 1)
  14278. * @param factor defines the life time factor to affect to the specified gradient
  14279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14280. * @returns the current particle system
  14281. */
  14282. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14283. /**
  14284. * Remove a specific life time gradient
  14285. * @param gradient defines the gradient to remove
  14286. * @returns the current particle system
  14287. */
  14288. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14289. /**
  14290. * Gets the current list of life time gradients.
  14291. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14292. * @returns the list of life time gradients
  14293. */
  14294. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of color gradients.
  14297. * You must use addColorGradient and removeColorGradient to udpate this list
  14298. * @returns the list of color gradients
  14299. */
  14300. getColorGradients(): Nullable<Array<ColorGradient>>;
  14301. /**
  14302. * Adds a new ramp gradient used to remap particle colors
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color defines the color to affect to the specified gradient
  14305. * @returns the current particle system
  14306. */
  14307. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14308. /**
  14309. * Gets the current list of ramp gradients.
  14310. * You must use addRampGradient and removeRampGradient to udpate this list
  14311. * @returns the list of ramp gradients
  14312. */
  14313. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14314. /** Gets or sets a boolean indicating that ramp gradients must be used
  14315. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14316. */
  14317. useRampGradients: boolean;
  14318. /**
  14319. * Adds a new color remap gradient
  14320. * @param gradient defines the gradient to use (between 0 and 1)
  14321. * @param min defines the color remap minimal range
  14322. * @param max defines the color remap maximal range
  14323. * @returns the current particle system
  14324. */
  14325. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14326. /**
  14327. * Gets the current list of color remap gradients.
  14328. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14329. * @returns the list of color remap gradients
  14330. */
  14331. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14332. /**
  14333. * Adds a new alpha remap gradient
  14334. * @param gradient defines the gradient to use (between 0 and 1)
  14335. * @param min defines the alpha remap minimal range
  14336. * @param max defines the alpha remap maximal range
  14337. * @returns the current particle system
  14338. */
  14339. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14340. /**
  14341. * Gets the current list of alpha remap gradients.
  14342. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14343. * @returns the list of alpha remap gradients
  14344. */
  14345. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14346. /**
  14347. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14350. * @returns the emitter
  14351. */
  14352. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14353. /**
  14354. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14355. * @param radius The radius of the hemisphere to emit from
  14356. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14357. * @returns the emitter
  14358. */
  14359. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14360. /**
  14361. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14362. * @param radius The radius of the sphere to emit from
  14363. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14364. * @returns the emitter
  14365. */
  14366. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14367. /**
  14368. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14369. * @param radius The radius of the sphere to emit from
  14370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14372. * @returns the emitter
  14373. */
  14374. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14375. /**
  14376. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14377. * @param radius The radius of the emission cylinder
  14378. * @param height The height of the emission cylinder
  14379. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14380. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14381. * @returns the emitter
  14382. */
  14383. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14384. /**
  14385. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14386. * @param radius The radius of the cylinder to emit from
  14387. * @param height The height of the emission cylinder
  14388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14391. * @returns the emitter
  14392. */
  14393. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14394. /**
  14395. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14396. * @param radius The radius of the cone to emit from
  14397. * @param angle The base angle of the cone
  14398. * @returns the emitter
  14399. */
  14400. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14401. /**
  14402. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14405. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14406. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14407. * @returns the emitter
  14408. */
  14409. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14410. /**
  14411. * Get hosting scene
  14412. * @returns the scene
  14413. */
  14414. getScene(): Scene;
  14415. }
  14416. }
  14417. declare module BABYLON {
  14418. /**
  14419. * 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.
  14420. * @see https://doc.babylonjs.com/how_to/transformnode
  14421. */
  14422. export class TransformNode extends Node {
  14423. /**
  14424. * Object will not rotate to face the camera
  14425. */
  14426. static BILLBOARDMODE_NONE: number;
  14427. /**
  14428. * Object will rotate to face the camera but only on the x axis
  14429. */
  14430. static BILLBOARDMODE_X: number;
  14431. /**
  14432. * Object will rotate to face the camera but only on the y axis
  14433. */
  14434. static BILLBOARDMODE_Y: number;
  14435. /**
  14436. * Object will rotate to face the camera but only on the z axis
  14437. */
  14438. static BILLBOARDMODE_Z: number;
  14439. /**
  14440. * Object will rotate to face the camera
  14441. */
  14442. static BILLBOARDMODE_ALL: number;
  14443. /**
  14444. * Object will rotate to face the camera's position instead of orientation
  14445. */
  14446. static BILLBOARDMODE_USE_POSITION: number;
  14447. private static _TmpRotation;
  14448. private static _TmpScaling;
  14449. private static _TmpTranslation;
  14450. private _forward;
  14451. private _forwardInverted;
  14452. private _up;
  14453. private _right;
  14454. private _rightInverted;
  14455. private _position;
  14456. private _rotation;
  14457. private _rotationQuaternion;
  14458. protected _scaling: Vector3;
  14459. protected _isDirty: boolean;
  14460. private _transformToBoneReferal;
  14461. private _isAbsoluteSynced;
  14462. private _billboardMode;
  14463. /**
  14464. * Gets or sets the billboard mode. Default is 0.
  14465. *
  14466. * | Value | Type | Description |
  14467. * | --- | --- | --- |
  14468. * | 0 | BILLBOARDMODE_NONE | |
  14469. * | 1 | BILLBOARDMODE_X | |
  14470. * | 2 | BILLBOARDMODE_Y | |
  14471. * | 4 | BILLBOARDMODE_Z | |
  14472. * | 7 | BILLBOARDMODE_ALL | |
  14473. *
  14474. */
  14475. get billboardMode(): number;
  14476. set billboardMode(value: number);
  14477. private _preserveParentRotationForBillboard;
  14478. /**
  14479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14481. */
  14482. get preserveParentRotationForBillboard(): boolean;
  14483. set preserveParentRotationForBillboard(value: boolean);
  14484. /**
  14485. * 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
  14486. */
  14487. scalingDeterminant: number;
  14488. private _infiniteDistance;
  14489. /**
  14490. * Gets or sets the distance of the object to max, often used by skybox
  14491. */
  14492. get infiniteDistance(): boolean;
  14493. set infiniteDistance(value: boolean);
  14494. /**
  14495. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14496. * By default the system will update normals to compensate
  14497. */
  14498. ignoreNonUniformScaling: boolean;
  14499. /**
  14500. * 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
  14501. */
  14502. reIntegrateRotationIntoRotationQuaternion: boolean;
  14503. /** @hidden */
  14504. _poseMatrix: Nullable<Matrix>;
  14505. /** @hidden */
  14506. _localMatrix: Matrix;
  14507. private _usePivotMatrix;
  14508. private _absolutePosition;
  14509. private _absoluteScaling;
  14510. private _absoluteRotationQuaternion;
  14511. private _pivotMatrix;
  14512. private _pivotMatrixInverse;
  14513. protected _postMultiplyPivotMatrix: boolean;
  14514. protected _isWorldMatrixFrozen: boolean;
  14515. /** @hidden */
  14516. _indexInSceneTransformNodesArray: number;
  14517. /**
  14518. * An event triggered after the world matrix is updated
  14519. */
  14520. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14521. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14522. /**
  14523. * Gets a string identifying the name of the class
  14524. * @returns "TransformNode" string
  14525. */
  14526. getClassName(): string;
  14527. /**
  14528. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14529. */
  14530. get position(): Vector3;
  14531. set position(newPosition: Vector3);
  14532. /**
  14533. * 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)).
  14534. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14535. */
  14536. get rotation(): Vector3;
  14537. set rotation(newRotation: Vector3);
  14538. /**
  14539. * 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)).
  14540. */
  14541. get scaling(): Vector3;
  14542. set scaling(newScaling: Vector3);
  14543. /**
  14544. * 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).
  14545. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14546. */
  14547. get rotationQuaternion(): Nullable<Quaternion>;
  14548. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14549. /**
  14550. * The forward direction of that transform in world space.
  14551. */
  14552. get forward(): Vector3;
  14553. /**
  14554. * The up direction of that transform in world space.
  14555. */
  14556. get up(): Vector3;
  14557. /**
  14558. * The right direction of that transform in world space.
  14559. */
  14560. get right(): Vector3;
  14561. /**
  14562. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14563. * @param matrix the matrix to copy the pose from
  14564. * @returns this TransformNode.
  14565. */
  14566. updatePoseMatrix(matrix: Matrix): TransformNode;
  14567. /**
  14568. * Returns the mesh Pose matrix.
  14569. * @returns the pose matrix
  14570. */
  14571. getPoseMatrix(): Matrix;
  14572. /** @hidden */
  14573. _isSynchronized(): boolean;
  14574. /** @hidden */
  14575. _initCache(): void;
  14576. /**
  14577. * Flag the transform node as dirty (Forcing it to update everything)
  14578. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14579. * @returns this transform node
  14580. */
  14581. markAsDirty(property: string): TransformNode;
  14582. /**
  14583. * Returns the current mesh absolute position.
  14584. * Returns a Vector3.
  14585. */
  14586. get absolutePosition(): Vector3;
  14587. /**
  14588. * Returns the current mesh absolute scaling.
  14589. * Returns a Vector3.
  14590. */
  14591. get absoluteScaling(): Vector3;
  14592. /**
  14593. * Returns the current mesh absolute rotation.
  14594. * Returns a Quaternion.
  14595. */
  14596. get absoluteRotationQuaternion(): Quaternion;
  14597. /**
  14598. * Sets a new matrix to apply before all other transformation
  14599. * @param matrix defines the transform matrix
  14600. * @returns the current TransformNode
  14601. */
  14602. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14603. /**
  14604. * Sets a new pivot matrix to the current node
  14605. * @param matrix defines the new pivot matrix to use
  14606. * @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
  14607. * @returns the current TransformNode
  14608. */
  14609. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14610. /**
  14611. * Returns the mesh pivot matrix.
  14612. * Default : Identity.
  14613. * @returns the matrix
  14614. */
  14615. getPivotMatrix(): Matrix;
  14616. /**
  14617. * Instantiate (when possible) or clone that node with its hierarchy
  14618. * @param newParent defines the new parent to use for the instance (or clone)
  14619. * @param options defines options to configure how copy is done
  14620. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14621. * @returns an instance (or a clone) of the current node with its hiearchy
  14622. */
  14623. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14624. doNotInstantiate: boolean;
  14625. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14626. /**
  14627. * Prevents the World matrix to be computed any longer
  14628. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14629. * @returns the TransformNode.
  14630. */
  14631. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14632. /**
  14633. * Allows back the World matrix computation.
  14634. * @returns the TransformNode.
  14635. */
  14636. unfreezeWorldMatrix(): this;
  14637. /**
  14638. * True if the World matrix has been frozen.
  14639. */
  14640. get isWorldMatrixFrozen(): boolean;
  14641. /**
  14642. * Retuns the mesh absolute position in the World.
  14643. * @returns a Vector3.
  14644. */
  14645. getAbsolutePosition(): Vector3;
  14646. /**
  14647. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14648. * @param absolutePosition the absolute position to set
  14649. * @returns the TransformNode.
  14650. */
  14651. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14652. /**
  14653. * Sets the mesh position in its local space.
  14654. * @param vector3 the position to set in localspace
  14655. * @returns the TransformNode.
  14656. */
  14657. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14658. /**
  14659. * Returns the mesh position in the local space from the current World matrix values.
  14660. * @returns a new Vector3.
  14661. */
  14662. getPositionExpressedInLocalSpace(): Vector3;
  14663. /**
  14664. * Translates the mesh along the passed Vector3 in its local space.
  14665. * @param vector3 the distance to translate in localspace
  14666. * @returns the TransformNode.
  14667. */
  14668. locallyTranslate(vector3: Vector3): TransformNode;
  14669. private static _lookAtVectorCache;
  14670. /**
  14671. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14672. * @param targetPoint the position (must be in same space as current mesh) to look at
  14673. * @param yawCor optional yaw (y-axis) correction in radians
  14674. * @param pitchCor optional pitch (x-axis) correction in radians
  14675. * @param rollCor optional roll (z-axis) correction in radians
  14676. * @param space the choosen space of the target
  14677. * @returns the TransformNode.
  14678. */
  14679. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14680. /**
  14681. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14682. * This Vector3 is expressed in the World space.
  14683. * @param localAxis axis to rotate
  14684. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14685. */
  14686. getDirection(localAxis: Vector3): Vector3;
  14687. /**
  14688. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14689. * localAxis is expressed in the mesh local space.
  14690. * result is computed in the Wordl space from the mesh World matrix.
  14691. * @param localAxis axis to rotate
  14692. * @param result the resulting transformnode
  14693. * @returns this TransformNode.
  14694. */
  14695. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14696. /**
  14697. * Sets this transform node rotation to the given local axis.
  14698. * @param localAxis the axis in local space
  14699. * @param yawCor optional yaw (y-axis) correction in radians
  14700. * @param pitchCor optional pitch (x-axis) correction in radians
  14701. * @param rollCor optional roll (z-axis) correction in radians
  14702. * @returns this TransformNode
  14703. */
  14704. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14705. /**
  14706. * Sets a new pivot point to the current node
  14707. * @param point defines the new pivot point to use
  14708. * @param space defines if the point is in world or local space (local by default)
  14709. * @returns the current TransformNode
  14710. */
  14711. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14712. /**
  14713. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14714. * @returns the pivot point
  14715. */
  14716. getPivotPoint(): Vector3;
  14717. /**
  14718. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14719. * @param result the vector3 to store the result
  14720. * @returns this TransformNode.
  14721. */
  14722. getPivotPointToRef(result: Vector3): TransformNode;
  14723. /**
  14724. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14725. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14726. */
  14727. getAbsolutePivotPoint(): Vector3;
  14728. /**
  14729. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14730. * @param result vector3 to store the result
  14731. * @returns this TransformNode.
  14732. */
  14733. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14734. /**
  14735. * Defines the passed node as the parent of the current node.
  14736. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14737. * @see https://doc.babylonjs.com/how_to/parenting
  14738. * @param node the node ot set as the parent
  14739. * @returns this TransformNode.
  14740. */
  14741. setParent(node: Nullable<Node>): TransformNode;
  14742. private _nonUniformScaling;
  14743. /**
  14744. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14745. */
  14746. get nonUniformScaling(): boolean;
  14747. /** @hidden */
  14748. _updateNonUniformScalingState(value: boolean): boolean;
  14749. /**
  14750. * Attach the current TransformNode to another TransformNode associated with a bone
  14751. * @param bone Bone affecting the TransformNode
  14752. * @param affectedTransformNode TransformNode associated with the bone
  14753. * @returns this object
  14754. */
  14755. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14756. /**
  14757. * Detach the transform node if its associated with a bone
  14758. * @returns this object
  14759. */
  14760. detachFromBone(): TransformNode;
  14761. private static _rotationAxisCache;
  14762. /**
  14763. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14764. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14765. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14766. * The passed axis is also normalized.
  14767. * @param axis the axis to rotate around
  14768. * @param amount the amount to rotate in radians
  14769. * @param space Space to rotate in (Default: local)
  14770. * @returns the TransformNode.
  14771. */
  14772. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14773. /**
  14774. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14775. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14776. * The passed axis is also normalized. .
  14777. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14778. * @param point the point to rotate around
  14779. * @param axis the axis to rotate around
  14780. * @param amount the amount to rotate in radians
  14781. * @returns the TransformNode
  14782. */
  14783. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14784. /**
  14785. * Translates the mesh along the axis vector for the passed distance in the given space.
  14786. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14787. * @param axis the axis to translate in
  14788. * @param distance the distance to translate
  14789. * @param space Space to rotate in (Default: local)
  14790. * @returns the TransformNode.
  14791. */
  14792. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14793. /**
  14794. * Adds a rotation step to the mesh current rotation.
  14795. * x, y, z are Euler angles expressed in radians.
  14796. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14797. * This means this rotation is made in the mesh local space only.
  14798. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14799. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14800. * ```javascript
  14801. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14802. * ```
  14803. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14804. * 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.
  14805. * @param x Rotation to add
  14806. * @param y Rotation to add
  14807. * @param z Rotation to add
  14808. * @returns the TransformNode.
  14809. */
  14810. addRotation(x: number, y: number, z: number): TransformNode;
  14811. /**
  14812. * @hidden
  14813. */
  14814. protected _getEffectiveParent(): Nullable<Node>;
  14815. /**
  14816. * Computes the world matrix of the node
  14817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14818. * @returns the world matrix
  14819. */
  14820. computeWorldMatrix(force?: boolean): Matrix;
  14821. /**
  14822. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14823. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14824. */
  14825. resetLocalMatrix(independentOfChildren?: boolean): void;
  14826. protected _afterComputeWorldMatrix(): void;
  14827. /**
  14828. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14829. * @param func callback function to add
  14830. *
  14831. * @returns the TransformNode.
  14832. */
  14833. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14834. /**
  14835. * Removes a registered callback function.
  14836. * @param func callback function to remove
  14837. * @returns the TransformNode.
  14838. */
  14839. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14840. /**
  14841. * Gets the position of the current mesh in camera space
  14842. * @param camera defines the camera to use
  14843. * @returns a position
  14844. */
  14845. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14846. /**
  14847. * Returns the distance from the mesh to the active camera
  14848. * @param camera defines the camera to use
  14849. * @returns the distance
  14850. */
  14851. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14852. /**
  14853. * Clone the current transform node
  14854. * @param name Name of the new clone
  14855. * @param newParent New parent for the clone
  14856. * @param doNotCloneChildren Do not clone children hierarchy
  14857. * @returns the new transform node
  14858. */
  14859. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14860. /**
  14861. * Serializes the objects information.
  14862. * @param currentSerializationObject defines the object to serialize in
  14863. * @returns the serialized object
  14864. */
  14865. serialize(currentSerializationObject?: any): any;
  14866. /**
  14867. * Returns a new TransformNode object parsed from the source provided.
  14868. * @param parsedTransformNode is the source.
  14869. * @param scene the scne the object belongs to
  14870. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14871. * @returns a new TransformNode object parsed from the source provided.
  14872. */
  14873. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14874. /**
  14875. * Get all child-transformNodes of this node
  14876. * @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
  14877. * @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
  14878. * @returns an array of TransformNode
  14879. */
  14880. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14881. /**
  14882. * Releases resources associated with this transform node.
  14883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14885. */
  14886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14887. /**
  14888. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14889. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14890. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14891. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14892. * @returns the current mesh
  14893. */
  14894. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14895. private _syncAbsoluteScalingAndRotation;
  14896. }
  14897. }
  14898. declare module BABYLON {
  14899. /**
  14900. * Class used to override all child animations of a given target
  14901. */
  14902. export class AnimationPropertiesOverride {
  14903. /**
  14904. * Gets or sets a value indicating if animation blending must be used
  14905. */
  14906. enableBlending: boolean;
  14907. /**
  14908. * Gets or sets the blending speed to use when enableBlending is true
  14909. */
  14910. blendingSpeed: number;
  14911. /**
  14912. * Gets or sets the default loop mode to use
  14913. */
  14914. loopMode: number;
  14915. }
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * Class used to store bone information
  14920. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14921. */
  14922. export class Bone extends Node {
  14923. /**
  14924. * defines the bone name
  14925. */
  14926. name: string;
  14927. private static _tmpVecs;
  14928. private static _tmpQuat;
  14929. private static _tmpMats;
  14930. /**
  14931. * Gets the list of child bones
  14932. */
  14933. children: Bone[];
  14934. /** Gets the animations associated with this bone */
  14935. animations: Animation[];
  14936. /**
  14937. * Gets or sets bone length
  14938. */
  14939. length: number;
  14940. /**
  14941. * @hidden Internal only
  14942. * Set this value to map this bone to a different index in the transform matrices
  14943. * Set this value to -1 to exclude the bone from the transform matrices
  14944. */
  14945. _index: Nullable<number>;
  14946. private _skeleton;
  14947. private _localMatrix;
  14948. private _restPose;
  14949. private _baseMatrix;
  14950. private _absoluteTransform;
  14951. private _invertedAbsoluteTransform;
  14952. private _parent;
  14953. private _scalingDeterminant;
  14954. private _worldTransform;
  14955. private _localScaling;
  14956. private _localRotation;
  14957. private _localPosition;
  14958. private _needToDecompose;
  14959. private _needToCompose;
  14960. /** @hidden */
  14961. _linkedTransformNode: Nullable<TransformNode>;
  14962. /** @hidden */
  14963. _waitingTransformNodeId: Nullable<string>;
  14964. /** @hidden */
  14965. get _matrix(): Matrix;
  14966. /** @hidden */
  14967. set _matrix(value: Matrix);
  14968. /**
  14969. * Create a new bone
  14970. * @param name defines the bone name
  14971. * @param skeleton defines the parent skeleton
  14972. * @param parentBone defines the parent (can be null if the bone is the root)
  14973. * @param localMatrix defines the local matrix
  14974. * @param restPose defines the rest pose matrix
  14975. * @param baseMatrix defines the base matrix
  14976. * @param index defines index of the bone in the hiearchy
  14977. */
  14978. constructor(
  14979. /**
  14980. * defines the bone name
  14981. */
  14982. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14983. /**
  14984. * Gets the current object class name.
  14985. * @return the class name
  14986. */
  14987. getClassName(): string;
  14988. /**
  14989. * Gets the parent skeleton
  14990. * @returns a skeleton
  14991. */
  14992. getSkeleton(): Skeleton;
  14993. /**
  14994. * Gets parent bone
  14995. * @returns a bone or null if the bone is the root of the bone hierarchy
  14996. */
  14997. getParent(): Nullable<Bone>;
  14998. /**
  14999. * Returns an array containing the root bones
  15000. * @returns an array containing the root bones
  15001. */
  15002. getChildren(): Array<Bone>;
  15003. /**
  15004. * Gets the node index in matrix array generated for rendering
  15005. * @returns the node index
  15006. */
  15007. getIndex(): number;
  15008. /**
  15009. * Sets the parent bone
  15010. * @param parent defines the parent (can be null if the bone is the root)
  15011. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15012. */
  15013. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15014. /**
  15015. * Gets the local matrix
  15016. * @returns a matrix
  15017. */
  15018. getLocalMatrix(): Matrix;
  15019. /**
  15020. * Gets the base matrix (initial matrix which remains unchanged)
  15021. * @returns a matrix
  15022. */
  15023. getBaseMatrix(): Matrix;
  15024. /**
  15025. * Gets the rest pose matrix
  15026. * @returns a matrix
  15027. */
  15028. getRestPose(): Matrix;
  15029. /**
  15030. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15031. */
  15032. getWorldMatrix(): Matrix;
  15033. /**
  15034. * Sets the local matrix to rest pose matrix
  15035. */
  15036. returnToRest(): void;
  15037. /**
  15038. * Gets the inverse of the absolute transform matrix.
  15039. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15040. * @returns a matrix
  15041. */
  15042. getInvertedAbsoluteTransform(): Matrix;
  15043. /**
  15044. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15045. * @returns a matrix
  15046. */
  15047. getAbsoluteTransform(): Matrix;
  15048. /**
  15049. * Links with the given transform node.
  15050. * The local matrix of this bone is copied from the transform node every frame.
  15051. * @param transformNode defines the transform node to link to
  15052. */
  15053. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15054. /**
  15055. * Gets the node used to drive the bone's transformation
  15056. * @returns a transform node or null
  15057. */
  15058. getTransformNode(): Nullable<TransformNode>;
  15059. /** Gets or sets current position (in local space) */
  15060. get position(): Vector3;
  15061. set position(newPosition: Vector3);
  15062. /** Gets or sets current rotation (in local space) */
  15063. get rotation(): Vector3;
  15064. set rotation(newRotation: Vector3);
  15065. /** Gets or sets current rotation quaternion (in local space) */
  15066. get rotationQuaternion(): Quaternion;
  15067. set rotationQuaternion(newRotation: Quaternion);
  15068. /** Gets or sets current scaling (in local space) */
  15069. get scaling(): Vector3;
  15070. set scaling(newScaling: Vector3);
  15071. /**
  15072. * Gets the animation properties override
  15073. */
  15074. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15075. private _decompose;
  15076. private _compose;
  15077. /**
  15078. * Update the base and local matrices
  15079. * @param matrix defines the new base or local matrix
  15080. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15081. * @param updateLocalMatrix defines if the local matrix should be updated
  15082. */
  15083. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15084. /** @hidden */
  15085. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15086. /**
  15087. * Flag the bone as dirty (Forcing it to update everything)
  15088. */
  15089. markAsDirty(): void;
  15090. /** @hidden */
  15091. _markAsDirtyAndCompose(): void;
  15092. private _markAsDirtyAndDecompose;
  15093. /**
  15094. * Translate the bone in local or world space
  15095. * @param vec The amount to translate the bone
  15096. * @param space The space that the translation is in
  15097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15098. */
  15099. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15100. /**
  15101. * Set the postion of the bone in local or world space
  15102. * @param position The position to set the bone
  15103. * @param space The space that the position is in
  15104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15105. */
  15106. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15107. /**
  15108. * Set the absolute position of the bone (world space)
  15109. * @param position The position to set the bone
  15110. * @param mesh The mesh that this bone is attached to
  15111. */
  15112. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15113. /**
  15114. * Scale the bone on the x, y and z axes (in local space)
  15115. * @param x The amount to scale the bone on the x axis
  15116. * @param y The amount to scale the bone on the y axis
  15117. * @param z The amount to scale the bone on the z axis
  15118. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15119. */
  15120. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15121. /**
  15122. * Set the bone scaling in local space
  15123. * @param scale defines the scaling vector
  15124. */
  15125. setScale(scale: Vector3): void;
  15126. /**
  15127. * Gets the current scaling in local space
  15128. * @returns the current scaling vector
  15129. */
  15130. getScale(): Vector3;
  15131. /**
  15132. * Gets the current scaling in local space and stores it in a target vector
  15133. * @param result defines the target vector
  15134. */
  15135. getScaleToRef(result: Vector3): void;
  15136. /**
  15137. * Set the yaw, pitch, and roll of the bone in local or world space
  15138. * @param yaw The rotation of the bone on the y axis
  15139. * @param pitch The rotation of the bone on the x axis
  15140. * @param roll The rotation of the bone on the z axis
  15141. * @param space The space that the axes of rotation are in
  15142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15143. */
  15144. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15145. /**
  15146. * Add a rotation to the bone on an axis in local or world space
  15147. * @param axis The axis to rotate the bone on
  15148. * @param amount The amount to rotate the bone
  15149. * @param space The space that the axis is in
  15150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15151. */
  15152. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15153. /**
  15154. * Set the rotation of the bone to a particular axis angle in local or world space
  15155. * @param axis The axis to rotate the bone on
  15156. * @param angle The angle that the bone should be rotated to
  15157. * @param space The space that the axis is in
  15158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15159. */
  15160. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15161. /**
  15162. * Set the euler rotation of the bone in local of world space
  15163. * @param rotation The euler rotation that the bone should be set to
  15164. * @param space The space that the rotation is in
  15165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15166. */
  15167. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15168. /**
  15169. * Set the quaternion rotation of the bone in local of world space
  15170. * @param quat The quaternion rotation that the bone should be set to
  15171. * @param space The space that the rotation is in
  15172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15173. */
  15174. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15175. /**
  15176. * Set the rotation matrix of the bone in local of world space
  15177. * @param rotMat The rotation matrix that the bone should be set to
  15178. * @param space The space that the rotation is in
  15179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15180. */
  15181. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15182. private _rotateWithMatrix;
  15183. private _getNegativeRotationToRef;
  15184. /**
  15185. * Get the position of the bone in local or world space
  15186. * @param space The space that the returned position is in
  15187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15188. * @returns The position of the bone
  15189. */
  15190. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15191. /**
  15192. * Copy the position of the bone to a vector3 in local or world space
  15193. * @param space The space that the returned position is in
  15194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15195. * @param result The vector3 to copy the position to
  15196. */
  15197. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15198. /**
  15199. * Get the absolute position of the bone (world space)
  15200. * @param mesh The mesh that this bone is attached to
  15201. * @returns The absolute position of the bone
  15202. */
  15203. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15204. /**
  15205. * Copy the absolute position of the bone (world space) to the result param
  15206. * @param mesh The mesh that this bone is attached to
  15207. * @param result The vector3 to copy the absolute position to
  15208. */
  15209. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15210. /**
  15211. * Compute the absolute transforms of this bone and its children
  15212. */
  15213. computeAbsoluteTransforms(): void;
  15214. /**
  15215. * Get the world direction from an axis that is in the local space of the bone
  15216. * @param localAxis The local direction that is used to compute the world direction
  15217. * @param mesh The mesh that this bone is attached to
  15218. * @returns The world direction
  15219. */
  15220. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15221. /**
  15222. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15223. * @param localAxis The local direction that is used to compute the world direction
  15224. * @param mesh The mesh that this bone is attached to
  15225. * @param result The vector3 that the world direction will be copied to
  15226. */
  15227. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15228. /**
  15229. * Get the euler rotation of the bone in local or world space
  15230. * @param space The space that the rotation should be in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. * @returns The euler rotation
  15233. */
  15234. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15235. /**
  15236. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15237. * @param space The space that the rotation should be in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. * @param result The vector3 that the rotation should be copied to
  15240. */
  15241. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15242. /**
  15243. * Get the quaternion rotation of the bone in either local or world space
  15244. * @param space The space that the rotation should be in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. * @returns The quaternion rotation
  15247. */
  15248. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15249. /**
  15250. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15251. * @param space The space that the rotation should be in
  15252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15253. * @param result The quaternion that the rotation should be copied to
  15254. */
  15255. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15256. /**
  15257. * Get the rotation matrix of the bone in local or world space
  15258. * @param space The space that the rotation should be in
  15259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15260. * @returns The rotation matrix
  15261. */
  15262. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15263. /**
  15264. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15265. * @param space The space that the rotation should be in
  15266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15267. * @param result The quaternion that the rotation should be copied to
  15268. */
  15269. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15270. /**
  15271. * Get the world position of a point that is in the local space of the bone
  15272. * @param position The local position
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @returns The world position
  15275. */
  15276. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15277. /**
  15278. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15279. * @param position The local position
  15280. * @param mesh The mesh that this bone is attached to
  15281. * @param result The vector3 that the world position should be copied to
  15282. */
  15283. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15284. /**
  15285. * Get the local position of a point that is in world space
  15286. * @param position The world position
  15287. * @param mesh The mesh that this bone is attached to
  15288. * @returns The local position
  15289. */
  15290. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15291. /**
  15292. * Get the local position of a point that is in world space and copy it to the result param
  15293. * @param position The world position
  15294. * @param mesh The mesh that this bone is attached to
  15295. * @param result The vector3 that the local position should be copied to
  15296. */
  15297. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15298. }
  15299. }
  15300. declare module BABYLON {
  15301. /**
  15302. * Defines a runtime animation
  15303. */
  15304. export class RuntimeAnimation {
  15305. private _events;
  15306. /**
  15307. * The current frame of the runtime animation
  15308. */
  15309. private _currentFrame;
  15310. /**
  15311. * The animation used by the runtime animation
  15312. */
  15313. private _animation;
  15314. /**
  15315. * The target of the runtime animation
  15316. */
  15317. private _target;
  15318. /**
  15319. * The initiating animatable
  15320. */
  15321. private _host;
  15322. /**
  15323. * The original value of the runtime animation
  15324. */
  15325. private _originalValue;
  15326. /**
  15327. * The original blend value of the runtime animation
  15328. */
  15329. private _originalBlendValue;
  15330. /**
  15331. * The offsets cache of the runtime animation
  15332. */
  15333. private _offsetsCache;
  15334. /**
  15335. * The high limits cache of the runtime animation
  15336. */
  15337. private _highLimitsCache;
  15338. /**
  15339. * Specifies if the runtime animation has been stopped
  15340. */
  15341. private _stopped;
  15342. /**
  15343. * The blending factor of the runtime animation
  15344. */
  15345. private _blendingFactor;
  15346. /**
  15347. * The BabylonJS scene
  15348. */
  15349. private _scene;
  15350. /**
  15351. * The current value of the runtime animation
  15352. */
  15353. private _currentValue;
  15354. /** @hidden */
  15355. _animationState: _IAnimationState;
  15356. /**
  15357. * The active target of the runtime animation
  15358. */
  15359. private _activeTargets;
  15360. private _currentActiveTarget;
  15361. private _directTarget;
  15362. /**
  15363. * The target path of the runtime animation
  15364. */
  15365. private _targetPath;
  15366. /**
  15367. * The weight of the runtime animation
  15368. */
  15369. private _weight;
  15370. /**
  15371. * The ratio offset of the runtime animation
  15372. */
  15373. private _ratioOffset;
  15374. /**
  15375. * The previous delay of the runtime animation
  15376. */
  15377. private _previousDelay;
  15378. /**
  15379. * The previous ratio of the runtime animation
  15380. */
  15381. private _previousRatio;
  15382. private _enableBlending;
  15383. private _keys;
  15384. private _minFrame;
  15385. private _maxFrame;
  15386. private _minValue;
  15387. private _maxValue;
  15388. private _targetIsArray;
  15389. /**
  15390. * Gets the current frame of the runtime animation
  15391. */
  15392. get currentFrame(): number;
  15393. /**
  15394. * Gets the weight of the runtime animation
  15395. */
  15396. get weight(): number;
  15397. /**
  15398. * Gets the current value of the runtime animation
  15399. */
  15400. get currentValue(): any;
  15401. /**
  15402. * Gets the target path of the runtime animation
  15403. */
  15404. get targetPath(): string;
  15405. /**
  15406. * Gets the actual target of the runtime animation
  15407. */
  15408. get target(): any;
  15409. /**
  15410. * Gets the additive state of the runtime animation
  15411. */
  15412. get isAdditive(): boolean;
  15413. /** @hidden */
  15414. _onLoop: () => void;
  15415. /**
  15416. * Create a new RuntimeAnimation object
  15417. * @param target defines the target of the animation
  15418. * @param animation defines the source animation object
  15419. * @param scene defines the hosting scene
  15420. * @param host defines the initiating Animatable
  15421. */
  15422. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15423. private _preparePath;
  15424. /**
  15425. * Gets the animation from the runtime animation
  15426. */
  15427. get animation(): Animation;
  15428. /**
  15429. * Resets the runtime animation to the beginning
  15430. * @param restoreOriginal defines whether to restore the target property to the original value
  15431. */
  15432. reset(restoreOriginal?: boolean): void;
  15433. /**
  15434. * Specifies if the runtime animation is stopped
  15435. * @returns Boolean specifying if the runtime animation is stopped
  15436. */
  15437. isStopped(): boolean;
  15438. /**
  15439. * Disposes of the runtime animation
  15440. */
  15441. dispose(): void;
  15442. /**
  15443. * Apply the interpolated value to the target
  15444. * @param currentValue defines the value computed by the animation
  15445. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15446. */
  15447. setValue(currentValue: any, weight: number): void;
  15448. private _getOriginalValues;
  15449. private _setValue;
  15450. /**
  15451. * Gets the loop pmode of the runtime animation
  15452. * @returns Loop Mode
  15453. */
  15454. private _getCorrectLoopMode;
  15455. /**
  15456. * Move the current animation to a given frame
  15457. * @param frame defines the frame to move to
  15458. */
  15459. goToFrame(frame: number): void;
  15460. /**
  15461. * @hidden Internal use only
  15462. */
  15463. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15464. /**
  15465. * Execute the current animation
  15466. * @param delay defines the delay to add to the current frame
  15467. * @param from defines the lower bound of the animation range
  15468. * @param to defines the upper bound of the animation range
  15469. * @param loop defines if the current animation must loop
  15470. * @param speedRatio defines the current speed ratio
  15471. * @param weight defines the weight of the animation (default is -1 so no weight)
  15472. * @param onLoop optional callback called when animation loops
  15473. * @returns a boolean indicating if the animation is running
  15474. */
  15475. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15476. }
  15477. }
  15478. declare module BABYLON {
  15479. /**
  15480. * Class used to store an actual running animation
  15481. */
  15482. export class Animatable {
  15483. /** defines the target object */
  15484. target: any;
  15485. /** defines the starting frame number (default is 0) */
  15486. fromFrame: number;
  15487. /** defines the ending frame number (default is 100) */
  15488. toFrame: number;
  15489. /** defines if the animation must loop (default is false) */
  15490. loopAnimation: boolean;
  15491. /** defines a callback to call when animation ends if it is not looping */
  15492. onAnimationEnd?: (() => void) | null | undefined;
  15493. /** defines a callback to call when animation loops */
  15494. onAnimationLoop?: (() => void) | null | undefined;
  15495. /** defines whether the animation should be evaluated additively */
  15496. isAdditive: boolean;
  15497. private _localDelayOffset;
  15498. private _pausedDelay;
  15499. private _runtimeAnimations;
  15500. private _paused;
  15501. private _scene;
  15502. private _speedRatio;
  15503. private _weight;
  15504. private _syncRoot;
  15505. /**
  15506. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15507. * This will only apply for non looping animation (default is true)
  15508. */
  15509. disposeOnEnd: boolean;
  15510. /**
  15511. * Gets a boolean indicating if the animation has started
  15512. */
  15513. animationStarted: boolean;
  15514. /**
  15515. * Observer raised when the animation ends
  15516. */
  15517. onAnimationEndObservable: Observable<Animatable>;
  15518. /**
  15519. * Observer raised when the animation loops
  15520. */
  15521. onAnimationLoopObservable: Observable<Animatable>;
  15522. /**
  15523. * Gets the root Animatable used to synchronize and normalize animations
  15524. */
  15525. get syncRoot(): Nullable<Animatable>;
  15526. /**
  15527. * Gets the current frame of the first RuntimeAnimation
  15528. * Used to synchronize Animatables
  15529. */
  15530. get masterFrame(): number;
  15531. /**
  15532. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15533. */
  15534. get weight(): number;
  15535. set weight(value: number);
  15536. /**
  15537. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15538. */
  15539. get speedRatio(): number;
  15540. set speedRatio(value: number);
  15541. /**
  15542. * Creates a new Animatable
  15543. * @param scene defines the hosting scene
  15544. * @param target defines the target object
  15545. * @param fromFrame defines the starting frame number (default is 0)
  15546. * @param toFrame defines the ending frame number (default is 100)
  15547. * @param loopAnimation defines if the animation must loop (default is false)
  15548. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15549. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15550. * @param animations defines a group of animation to add to the new Animatable
  15551. * @param onAnimationLoop defines a callback to call when animation loops
  15552. * @param isAdditive defines whether the animation should be evaluated additively
  15553. */
  15554. constructor(scene: Scene,
  15555. /** defines the target object */
  15556. target: any,
  15557. /** defines the starting frame number (default is 0) */
  15558. fromFrame?: number,
  15559. /** defines the ending frame number (default is 100) */
  15560. toFrame?: number,
  15561. /** defines if the animation must loop (default is false) */
  15562. loopAnimation?: boolean, speedRatio?: number,
  15563. /** defines a callback to call when animation ends if it is not looping */
  15564. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15565. /** defines a callback to call when animation loops */
  15566. onAnimationLoop?: (() => void) | null | undefined,
  15567. /** defines whether the animation should be evaluated additively */
  15568. isAdditive?: boolean);
  15569. /**
  15570. * Synchronize and normalize current Animatable with a source Animatable
  15571. * This is useful when using animation weights and when animations are not of the same length
  15572. * @param root defines the root Animatable to synchronize with
  15573. * @returns the current Animatable
  15574. */
  15575. syncWith(root: Animatable): Animatable;
  15576. /**
  15577. * Gets the list of runtime animations
  15578. * @returns an array of RuntimeAnimation
  15579. */
  15580. getAnimations(): RuntimeAnimation[];
  15581. /**
  15582. * Adds more animations to the current animatable
  15583. * @param target defines the target of the animations
  15584. * @param animations defines the new animations to add
  15585. */
  15586. appendAnimations(target: any, animations: Animation[]): void;
  15587. /**
  15588. * Gets the source animation for a specific property
  15589. * @param property defines the propertyu to look for
  15590. * @returns null or the source animation for the given property
  15591. */
  15592. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15593. /**
  15594. * Gets the runtime animation for a specific property
  15595. * @param property defines the propertyu to look for
  15596. * @returns null or the runtime animation for the given property
  15597. */
  15598. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15599. /**
  15600. * Resets the animatable to its original state
  15601. */
  15602. reset(): void;
  15603. /**
  15604. * Allows the animatable to blend with current running animations
  15605. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15606. * @param blendingSpeed defines the blending speed to use
  15607. */
  15608. enableBlending(blendingSpeed: number): void;
  15609. /**
  15610. * Disable animation blending
  15611. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15612. */
  15613. disableBlending(): void;
  15614. /**
  15615. * Jump directly to a given frame
  15616. * @param frame defines the frame to jump to
  15617. */
  15618. goToFrame(frame: number): void;
  15619. /**
  15620. * Pause the animation
  15621. */
  15622. pause(): void;
  15623. /**
  15624. * Restart the animation
  15625. */
  15626. restart(): void;
  15627. private _raiseOnAnimationEnd;
  15628. /**
  15629. * Stop and delete the current animation
  15630. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15631. * @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)
  15632. */
  15633. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15634. /**
  15635. * Wait asynchronously for the animation to end
  15636. * @returns a promise which will be fullfilled when the animation ends
  15637. */
  15638. waitAsync(): Promise<Animatable>;
  15639. /** @hidden */
  15640. _animate(delay: number): boolean;
  15641. }
  15642. interface Scene {
  15643. /** @hidden */
  15644. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15645. /** @hidden */
  15646. _processLateAnimationBindingsForMatrices(holder: {
  15647. totalWeight: number;
  15648. totalAdditiveWeight: number;
  15649. animations: RuntimeAnimation[];
  15650. additiveAnimations: RuntimeAnimation[];
  15651. originalValue: Matrix;
  15652. }): any;
  15653. /** @hidden */
  15654. _processLateAnimationBindingsForQuaternions(holder: {
  15655. totalWeight: number;
  15656. totalAdditiveWeight: number;
  15657. animations: RuntimeAnimation[];
  15658. additiveAnimations: RuntimeAnimation[];
  15659. originalValue: Quaternion;
  15660. }, refQuaternion: Quaternion): Quaternion;
  15661. /** @hidden */
  15662. _processLateAnimationBindings(): void;
  15663. /**
  15664. * Will start the animation sequence of a given target
  15665. * @param target defines the target
  15666. * @param from defines from which frame should animation start
  15667. * @param to defines until which frame should animation run.
  15668. * @param weight defines the weight to apply to the animation (1.0 by default)
  15669. * @param loop defines if the animation loops
  15670. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15671. * @param onAnimationEnd defines the function to be executed when the animation ends
  15672. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15673. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15674. * @param onAnimationLoop defines the callback to call when an animation loops
  15675. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15676. * @returns the animatable object created for this animation
  15677. */
  15678. 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;
  15679. /**
  15680. * Will start the animation sequence of a given target
  15681. * @param target defines the target
  15682. * @param from defines from which frame should animation start
  15683. * @param to defines until which frame should animation run.
  15684. * @param loop defines if the animation loops
  15685. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15686. * @param onAnimationEnd defines the function to be executed when the animation ends
  15687. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15688. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15689. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15690. * @param onAnimationLoop defines the callback to call when an animation loops
  15691. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15692. * @returns the animatable object created for this animation
  15693. */
  15694. 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;
  15695. /**
  15696. * Will start the animation sequence of a given target and its hierarchy
  15697. * @param target defines the target
  15698. * @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.
  15699. * @param from defines from which frame should animation start
  15700. * @param to defines until which frame should animation run.
  15701. * @param loop defines if the animation loops
  15702. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15703. * @param onAnimationEnd defines the function to be executed when the animation ends
  15704. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15705. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15706. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15707. * @param onAnimationLoop defines the callback to call when an animation loops
  15708. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15709. * @returns the list of created animatables
  15710. */
  15711. 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[];
  15712. /**
  15713. * Begin a new animation on a given node
  15714. * @param target defines the target where the animation will take place
  15715. * @param animations defines the list of animations to start
  15716. * @param from defines the initial value
  15717. * @param to defines the final value
  15718. * @param loop defines if you want animation to loop (off by default)
  15719. * @param speedRatio defines the speed ratio to apply to all animations
  15720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15721. * @param onAnimationLoop defines the callback to call when an animation loops
  15722. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15723. * @returns the list of created animatables
  15724. */
  15725. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15726. /**
  15727. * Begin a new animation on a given node and its hierarchy
  15728. * @param target defines the root node where the animation will take place
  15729. * @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.
  15730. * @param animations defines the list of animations to start
  15731. * @param from defines the initial value
  15732. * @param to defines the final value
  15733. * @param loop defines if you want animation to loop (off by default)
  15734. * @param speedRatio defines the speed ratio to apply to all animations
  15735. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15736. * @param onAnimationLoop defines the callback to call when an animation loops
  15737. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15738. * @returns the list of animatables created for all nodes
  15739. */
  15740. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15741. /**
  15742. * Gets the animatable associated with a specific target
  15743. * @param target defines the target of the animatable
  15744. * @returns the required animatable if found
  15745. */
  15746. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15747. /**
  15748. * Gets all animatables associated with a given target
  15749. * @param target defines the target to look animatables for
  15750. * @returns an array of Animatables
  15751. */
  15752. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15753. /**
  15754. * Stops and removes all animations that have been applied to the scene
  15755. */
  15756. stopAllAnimations(): void;
  15757. /**
  15758. * Gets the current delta time used by animation engine
  15759. */
  15760. deltaTime: number;
  15761. }
  15762. interface Bone {
  15763. /**
  15764. * Copy an animation range from another bone
  15765. * @param source defines the source bone
  15766. * @param rangeName defines the range name to copy
  15767. * @param frameOffset defines the frame offset
  15768. * @param rescaleAsRequired defines if rescaling must be applied if required
  15769. * @param skelDimensionsRatio defines the scaling ratio
  15770. * @returns true if operation was successful
  15771. */
  15772. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15773. }
  15774. }
  15775. declare module BABYLON {
  15776. /**
  15777. * Class used to handle skinning animations
  15778. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15779. */
  15780. export class Skeleton implements IAnimatable {
  15781. /** defines the skeleton name */
  15782. name: string;
  15783. /** defines the skeleton Id */
  15784. id: string;
  15785. /**
  15786. * Defines the list of child bones
  15787. */
  15788. bones: Bone[];
  15789. /**
  15790. * Defines an estimate of the dimension of the skeleton at rest
  15791. */
  15792. dimensionsAtRest: Vector3;
  15793. /**
  15794. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15795. */
  15796. needInitialSkinMatrix: boolean;
  15797. /**
  15798. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15799. */
  15800. overrideMesh: Nullable<AbstractMesh>;
  15801. /**
  15802. * Gets the list of animations attached to this skeleton
  15803. */
  15804. animations: Array<Animation>;
  15805. private _scene;
  15806. private _isDirty;
  15807. private _transformMatrices;
  15808. private _transformMatrixTexture;
  15809. private _meshesWithPoseMatrix;
  15810. private _animatables;
  15811. private _identity;
  15812. private _synchronizedWithMesh;
  15813. private _ranges;
  15814. private _lastAbsoluteTransformsUpdateId;
  15815. private _canUseTextureForBones;
  15816. private _uniqueId;
  15817. /** @hidden */
  15818. _numBonesWithLinkedTransformNode: number;
  15819. /** @hidden */
  15820. _hasWaitingData: Nullable<boolean>;
  15821. /**
  15822. * Specifies if the skeleton should be serialized
  15823. */
  15824. doNotSerialize: boolean;
  15825. private _useTextureToStoreBoneMatrices;
  15826. /**
  15827. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15828. * Please note that this option is not available if the hardware does not support it
  15829. */
  15830. get useTextureToStoreBoneMatrices(): boolean;
  15831. set useTextureToStoreBoneMatrices(value: boolean);
  15832. private _animationPropertiesOverride;
  15833. /**
  15834. * Gets or sets the animation properties override
  15835. */
  15836. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15837. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15838. /**
  15839. * List of inspectable custom properties (used by the Inspector)
  15840. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15841. */
  15842. inspectableCustomProperties: IInspectable[];
  15843. /**
  15844. * An observable triggered before computing the skeleton's matrices
  15845. */
  15846. onBeforeComputeObservable: Observable<Skeleton>;
  15847. /**
  15848. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15849. */
  15850. get isUsingTextureForMatrices(): boolean;
  15851. /**
  15852. * Gets the unique ID of this skeleton
  15853. */
  15854. get uniqueId(): number;
  15855. /**
  15856. * Creates a new skeleton
  15857. * @param name defines the skeleton name
  15858. * @param id defines the skeleton Id
  15859. * @param scene defines the hosting scene
  15860. */
  15861. constructor(
  15862. /** defines the skeleton name */
  15863. name: string,
  15864. /** defines the skeleton Id */
  15865. id: string, scene: Scene);
  15866. /**
  15867. * Gets the current object class name.
  15868. * @return the class name
  15869. */
  15870. getClassName(): string;
  15871. /**
  15872. * Returns an array containing the root bones
  15873. * @returns an array containing the root bones
  15874. */
  15875. getChildren(): Array<Bone>;
  15876. /**
  15877. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15878. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15879. * @returns a Float32Array containing matrices data
  15880. */
  15881. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15882. /**
  15883. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15884. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15885. * @returns a raw texture containing the data
  15886. */
  15887. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15888. /**
  15889. * Gets the current hosting scene
  15890. * @returns a scene object
  15891. */
  15892. getScene(): Scene;
  15893. /**
  15894. * Gets a string representing the current skeleton data
  15895. * @param fullDetails defines a boolean indicating if we want a verbose version
  15896. * @returns a string representing the current skeleton data
  15897. */
  15898. toString(fullDetails?: boolean): string;
  15899. /**
  15900. * Get bone's index searching by name
  15901. * @param name defines bone's name to search for
  15902. * @return the indice of the bone. Returns -1 if not found
  15903. */
  15904. getBoneIndexByName(name: string): number;
  15905. /**
  15906. * Creater a new animation range
  15907. * @param name defines the name of the range
  15908. * @param from defines the start key
  15909. * @param to defines the end key
  15910. */
  15911. createAnimationRange(name: string, from: number, to: number): void;
  15912. /**
  15913. * Delete a specific animation range
  15914. * @param name defines the name of the range
  15915. * @param deleteFrames defines if frames must be removed as well
  15916. */
  15917. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15918. /**
  15919. * Gets a specific animation range
  15920. * @param name defines the name of the range to look for
  15921. * @returns the requested animation range or null if not found
  15922. */
  15923. getAnimationRange(name: string): Nullable<AnimationRange>;
  15924. /**
  15925. * Gets the list of all animation ranges defined on this skeleton
  15926. * @returns an array
  15927. */
  15928. getAnimationRanges(): Nullable<AnimationRange>[];
  15929. /**
  15930. * Copy animation range from a source skeleton.
  15931. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15932. * @param source defines the source skeleton
  15933. * @param name defines the name of the range to copy
  15934. * @param rescaleAsRequired defines if rescaling must be applied if required
  15935. * @returns true if operation was successful
  15936. */
  15937. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15938. /**
  15939. * Forces the skeleton to go to rest pose
  15940. */
  15941. returnToRest(): void;
  15942. private _getHighestAnimationFrame;
  15943. /**
  15944. * Begin a specific animation range
  15945. * @param name defines the name of the range to start
  15946. * @param loop defines if looping must be turned on (false by default)
  15947. * @param speedRatio defines the speed ratio to apply (1 by default)
  15948. * @param onAnimationEnd defines a callback which will be called when animation will end
  15949. * @returns a new animatable
  15950. */
  15951. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15952. /**
  15953. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15954. * @param skeleton defines the Skeleton containing the animation range to convert
  15955. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15956. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15957. * @returns the original skeleton
  15958. */
  15959. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15960. /** @hidden */
  15961. _markAsDirty(): void;
  15962. /** @hidden */
  15963. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15964. /** @hidden */
  15965. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15966. private _computeTransformMatrices;
  15967. /**
  15968. * Build all resources required to render a skeleton
  15969. */
  15970. prepare(): void;
  15971. /**
  15972. * Gets the list of animatables currently running for this skeleton
  15973. * @returns an array of animatables
  15974. */
  15975. getAnimatables(): IAnimatable[];
  15976. /**
  15977. * Clone the current skeleton
  15978. * @param name defines the name of the new skeleton
  15979. * @param id defines the id of the new skeleton
  15980. * @returns the new skeleton
  15981. */
  15982. clone(name: string, id?: string): Skeleton;
  15983. /**
  15984. * Enable animation blending for this skeleton
  15985. * @param blendingSpeed defines the blending speed to apply
  15986. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15987. */
  15988. enableBlending(blendingSpeed?: number): void;
  15989. /**
  15990. * Releases all resources associated with the current skeleton
  15991. */
  15992. dispose(): void;
  15993. /**
  15994. * Serialize the skeleton in a JSON object
  15995. * @returns a JSON object
  15996. */
  15997. serialize(): any;
  15998. /**
  15999. * Creates a new skeleton from serialized data
  16000. * @param parsedSkeleton defines the serialized data
  16001. * @param scene defines the hosting scene
  16002. * @returns a new skeleton
  16003. */
  16004. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16005. /**
  16006. * Compute all node absolute transforms
  16007. * @param forceUpdate defines if computation must be done even if cache is up to date
  16008. */
  16009. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16010. /**
  16011. * Gets the root pose matrix
  16012. * @returns a matrix
  16013. */
  16014. getPoseMatrix(): Nullable<Matrix>;
  16015. /**
  16016. * Sorts bones per internal index
  16017. */
  16018. sortBones(): void;
  16019. private _sortBones;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * Creates an instance based on a source mesh.
  16025. */
  16026. export class InstancedMesh extends AbstractMesh {
  16027. private _sourceMesh;
  16028. private _currentLOD;
  16029. /** @hidden */
  16030. _indexInSourceMeshInstanceArray: number;
  16031. constructor(name: string, source: Mesh);
  16032. /**
  16033. * Returns the string "InstancedMesh".
  16034. */
  16035. getClassName(): string;
  16036. /** Gets the list of lights affecting that mesh */
  16037. get lightSources(): Light[];
  16038. _resyncLightSources(): void;
  16039. _resyncLightSource(light: Light): void;
  16040. _removeLightSource(light: Light, dispose: boolean): void;
  16041. /**
  16042. * If the source mesh receives shadows
  16043. */
  16044. get receiveShadows(): boolean;
  16045. /**
  16046. * The material of the source mesh
  16047. */
  16048. get material(): Nullable<Material>;
  16049. /**
  16050. * Visibility of the source mesh
  16051. */
  16052. get visibility(): number;
  16053. /**
  16054. * Skeleton of the source mesh
  16055. */
  16056. get skeleton(): Nullable<Skeleton>;
  16057. /**
  16058. * Rendering ground id of the source mesh
  16059. */
  16060. get renderingGroupId(): number;
  16061. set renderingGroupId(value: number);
  16062. /**
  16063. * Returns the total number of vertices (integer).
  16064. */
  16065. getTotalVertices(): number;
  16066. /**
  16067. * Returns a positive integer : the total number of indices in this mesh geometry.
  16068. * @returns the numner of indices or zero if the mesh has no geometry.
  16069. */
  16070. getTotalIndices(): number;
  16071. /**
  16072. * The source mesh of the instance
  16073. */
  16074. get sourceMesh(): Mesh;
  16075. /**
  16076. * Creates a new InstancedMesh object from the mesh model.
  16077. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16078. * @param name defines the name of the new instance
  16079. * @returns a new InstancedMesh
  16080. */
  16081. createInstance(name: string): InstancedMesh;
  16082. /**
  16083. * Is this node ready to be used/rendered
  16084. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16085. * @return {boolean} is it ready
  16086. */
  16087. isReady(completeCheck?: boolean): boolean;
  16088. /**
  16089. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16090. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16091. * @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.
  16092. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16093. */
  16094. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16095. /**
  16096. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16097. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16098. * The `data` are either a numeric array either a Float32Array.
  16099. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16100. * 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).
  16101. * Note that a new underlying VertexBuffer object is created each call.
  16102. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16103. *
  16104. * Possible `kind` values :
  16105. * - VertexBuffer.PositionKind
  16106. * - VertexBuffer.UVKind
  16107. * - VertexBuffer.UV2Kind
  16108. * - VertexBuffer.UV3Kind
  16109. * - VertexBuffer.UV4Kind
  16110. * - VertexBuffer.UV5Kind
  16111. * - VertexBuffer.UV6Kind
  16112. * - VertexBuffer.ColorKind
  16113. * - VertexBuffer.MatricesIndicesKind
  16114. * - VertexBuffer.MatricesIndicesExtraKind
  16115. * - VertexBuffer.MatricesWeightsKind
  16116. * - VertexBuffer.MatricesWeightsExtraKind
  16117. *
  16118. * Returns the Mesh.
  16119. */
  16120. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16121. /**
  16122. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16123. * If the mesh has no geometry, it is simply returned as it is.
  16124. * The `data` are either a numeric array either a Float32Array.
  16125. * No new underlying VertexBuffer object is created.
  16126. * 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.
  16127. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16128. *
  16129. * Possible `kind` values :
  16130. * - VertexBuffer.PositionKind
  16131. * - VertexBuffer.UVKind
  16132. * - VertexBuffer.UV2Kind
  16133. * - VertexBuffer.UV3Kind
  16134. * - VertexBuffer.UV4Kind
  16135. * - VertexBuffer.UV5Kind
  16136. * - VertexBuffer.UV6Kind
  16137. * - VertexBuffer.ColorKind
  16138. * - VertexBuffer.MatricesIndicesKind
  16139. * - VertexBuffer.MatricesIndicesExtraKind
  16140. * - VertexBuffer.MatricesWeightsKind
  16141. * - VertexBuffer.MatricesWeightsExtraKind
  16142. *
  16143. * Returns the Mesh.
  16144. */
  16145. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16146. /**
  16147. * Sets the mesh indices.
  16148. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16149. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16150. * This method creates a new index buffer each call.
  16151. * Returns the Mesh.
  16152. */
  16153. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16154. /**
  16155. * Boolean : True if the mesh owns the requested kind of data.
  16156. */
  16157. isVerticesDataPresent(kind: string): boolean;
  16158. /**
  16159. * Returns an array of indices (IndicesArray).
  16160. */
  16161. getIndices(): Nullable<IndicesArray>;
  16162. get _positions(): Nullable<Vector3[]>;
  16163. /**
  16164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16165. * This means the mesh underlying bounding box and sphere are recomputed.
  16166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16167. * @returns the current mesh
  16168. */
  16169. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16170. /** @hidden */
  16171. _preActivate(): InstancedMesh;
  16172. /** @hidden */
  16173. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16174. /** @hidden */
  16175. _postActivate(): void;
  16176. getWorldMatrix(): Matrix;
  16177. get isAnInstance(): boolean;
  16178. /**
  16179. * Returns the current associated LOD AbstractMesh.
  16180. */
  16181. getLOD(camera: Camera): AbstractMesh;
  16182. /** @hidden */
  16183. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16184. /** @hidden */
  16185. _syncSubMeshes(): InstancedMesh;
  16186. /** @hidden */
  16187. _generatePointsArray(): boolean;
  16188. /**
  16189. * Creates a new InstancedMesh from the current mesh.
  16190. * - name (string) : the cloned mesh name
  16191. * - newParent (optional Node) : the optional Node to parent the clone to.
  16192. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16193. *
  16194. * Returns the clone.
  16195. */
  16196. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16197. /**
  16198. * Disposes the InstancedMesh.
  16199. * Returns nothing.
  16200. */
  16201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16202. }
  16203. interface Mesh {
  16204. /**
  16205. * Register a custom buffer that will be instanced
  16206. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16207. * @param kind defines the buffer kind
  16208. * @param stride defines the stride in floats
  16209. */
  16210. registerInstancedBuffer(kind: string, stride: number): void;
  16211. /**
  16212. * true to use the edge renderer for all instances of this mesh
  16213. */
  16214. edgesShareWithInstances: boolean;
  16215. /** @hidden */
  16216. _userInstancedBuffersStorage: {
  16217. data: {
  16218. [key: string]: Float32Array;
  16219. };
  16220. sizes: {
  16221. [key: string]: number;
  16222. };
  16223. vertexBuffers: {
  16224. [key: string]: Nullable<VertexBuffer>;
  16225. };
  16226. strides: {
  16227. [key: string]: number;
  16228. };
  16229. };
  16230. }
  16231. interface AbstractMesh {
  16232. /**
  16233. * Object used to store instanced buffers defined by user
  16234. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16235. */
  16236. instancedBuffers: {
  16237. [key: string]: any;
  16238. };
  16239. }
  16240. }
  16241. declare module BABYLON {
  16242. /**
  16243. * Defines the options associated with the creation of a shader material.
  16244. */
  16245. export interface IShaderMaterialOptions {
  16246. /**
  16247. * Does the material work in alpha blend mode
  16248. */
  16249. needAlphaBlending: boolean;
  16250. /**
  16251. * Does the material work in alpha test mode
  16252. */
  16253. needAlphaTesting: boolean;
  16254. /**
  16255. * The list of attribute names used in the shader
  16256. */
  16257. attributes: string[];
  16258. /**
  16259. * The list of unifrom names used in the shader
  16260. */
  16261. uniforms: string[];
  16262. /**
  16263. * The list of UBO names used in the shader
  16264. */
  16265. uniformBuffers: string[];
  16266. /**
  16267. * The list of sampler names used in the shader
  16268. */
  16269. samplers: string[];
  16270. /**
  16271. * The list of defines used in the shader
  16272. */
  16273. defines: string[];
  16274. }
  16275. /**
  16276. * 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.
  16277. *
  16278. * This returned material effects how the mesh will look based on the code in the shaders.
  16279. *
  16280. * @see https://doc.babylonjs.com/how_to/shader_material
  16281. */
  16282. export class ShaderMaterial extends Material {
  16283. private _shaderPath;
  16284. private _options;
  16285. private _textures;
  16286. private _textureArrays;
  16287. private _floats;
  16288. private _ints;
  16289. private _floatsArrays;
  16290. private _colors3;
  16291. private _colors3Arrays;
  16292. private _colors4;
  16293. private _colors4Arrays;
  16294. private _vectors2;
  16295. private _vectors3;
  16296. private _vectors4;
  16297. private _matrices;
  16298. private _matrixArrays;
  16299. private _matrices3x3;
  16300. private _matrices2x2;
  16301. private _vectors2Arrays;
  16302. private _vectors3Arrays;
  16303. private _vectors4Arrays;
  16304. private _cachedWorldViewMatrix;
  16305. private _cachedWorldViewProjectionMatrix;
  16306. private _renderId;
  16307. private _multiview;
  16308. private _cachedDefines;
  16309. /** Define the Url to load snippets */
  16310. static SnippetUrl: string;
  16311. /** Snippet ID if the material was created from the snippet server */
  16312. snippetId: string;
  16313. /**
  16314. * Instantiate a new shader material.
  16315. * 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.
  16316. * This returned material effects how the mesh will look based on the code in the shaders.
  16317. * @see https://doc.babylonjs.com/how_to/shader_material
  16318. * @param name Define the name of the material in the scene
  16319. * @param scene Define the scene the material belongs to
  16320. * @param shaderPath Defines the route to the shader code in one of three ways:
  16321. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16322. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16323. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16324. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16325. * @param options Define the options used to create the shader
  16326. */
  16327. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16328. /**
  16329. * Gets the shader path used to define the shader code
  16330. * It can be modified to trigger a new compilation
  16331. */
  16332. get shaderPath(): any;
  16333. /**
  16334. * Sets the shader path used to define the shader code
  16335. * It can be modified to trigger a new compilation
  16336. */
  16337. set shaderPath(shaderPath: any);
  16338. /**
  16339. * Gets the options used to compile the shader.
  16340. * They can be modified to trigger a new compilation
  16341. */
  16342. get options(): IShaderMaterialOptions;
  16343. /**
  16344. * Gets the current class name of the material e.g. "ShaderMaterial"
  16345. * Mainly use in serialization.
  16346. * @returns the class name
  16347. */
  16348. getClassName(): string;
  16349. /**
  16350. * Specifies if the material will require alpha blending
  16351. * @returns a boolean specifying if alpha blending is needed
  16352. */
  16353. needAlphaBlending(): boolean;
  16354. /**
  16355. * Specifies if this material should be rendered in alpha test mode
  16356. * @returns a boolean specifying if an alpha test is needed.
  16357. */
  16358. needAlphaTesting(): boolean;
  16359. private _checkUniform;
  16360. /**
  16361. * Set a texture in the shader.
  16362. * @param name Define the name of the uniform samplers as defined in the shader
  16363. * @param texture Define the texture to bind to this sampler
  16364. * @return the material itself allowing "fluent" like uniform updates
  16365. */
  16366. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16367. /**
  16368. * Set a texture array in the shader.
  16369. * @param name Define the name of the uniform sampler array as defined in the shader
  16370. * @param textures Define the list of textures to bind to this sampler
  16371. * @return the material itself allowing "fluent" like uniform updates
  16372. */
  16373. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16374. /**
  16375. * Set a float in the shader.
  16376. * @param name Define the name of the uniform as defined in the shader
  16377. * @param value Define the value to give to the uniform
  16378. * @return the material itself allowing "fluent" like uniform updates
  16379. */
  16380. setFloat(name: string, value: number): ShaderMaterial;
  16381. /**
  16382. * Set a int in the shader.
  16383. * @param name Define the name of the uniform as defined in the shader
  16384. * @param value Define the value to give to the uniform
  16385. * @return the material itself allowing "fluent" like uniform updates
  16386. */
  16387. setInt(name: string, value: number): ShaderMaterial;
  16388. /**
  16389. * Set an array of floats in the shader.
  16390. * @param name Define the name of the uniform as defined in the shader
  16391. * @param value Define the value to give to the uniform
  16392. * @return the material itself allowing "fluent" like uniform updates
  16393. */
  16394. setFloats(name: string, value: number[]): ShaderMaterial;
  16395. /**
  16396. * Set a vec3 in the shader from a Color3.
  16397. * @param name Define the name of the uniform as defined in the shader
  16398. * @param value Define the value to give to the uniform
  16399. * @return the material itself allowing "fluent" like uniform updates
  16400. */
  16401. setColor3(name: string, value: Color3): ShaderMaterial;
  16402. /**
  16403. * Set a vec3 array in the shader from a Color3 array.
  16404. * @param name Define the name of the uniform as defined in the shader
  16405. * @param value Define the value to give to the uniform
  16406. * @return the material itself allowing "fluent" like uniform updates
  16407. */
  16408. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16409. /**
  16410. * Set a vec4 in the shader from a Color4.
  16411. * @param name Define the name of the uniform as defined in the shader
  16412. * @param value Define the value to give to the uniform
  16413. * @return the material itself allowing "fluent" like uniform updates
  16414. */
  16415. setColor4(name: string, value: Color4): ShaderMaterial;
  16416. /**
  16417. * Set a vec4 array in the shader from a Color4 array.
  16418. * @param name Define the name of the uniform as defined in the shader
  16419. * @param value Define the value to give to the uniform
  16420. * @return the material itself allowing "fluent" like uniform updates
  16421. */
  16422. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16423. /**
  16424. * Set a vec2 in the shader from a Vector2.
  16425. * @param name Define the name of the uniform as defined in the shader
  16426. * @param value Define the value to give to the uniform
  16427. * @return the material itself allowing "fluent" like uniform updates
  16428. */
  16429. setVector2(name: string, value: Vector2): ShaderMaterial;
  16430. /**
  16431. * Set a vec3 in the shader from a Vector3.
  16432. * @param name Define the name of the uniform as defined in the shader
  16433. * @param value Define the value to give to the uniform
  16434. * @return the material itself allowing "fluent" like uniform updates
  16435. */
  16436. setVector3(name: string, value: Vector3): ShaderMaterial;
  16437. /**
  16438. * Set a vec4 in the shader from a Vector4.
  16439. * @param name Define the name of the uniform as defined in the shader
  16440. * @param value Define the value to give to the uniform
  16441. * @return the material itself allowing "fluent" like uniform updates
  16442. */
  16443. setVector4(name: string, value: Vector4): ShaderMaterial;
  16444. /**
  16445. * Set a mat4 in the shader from a Matrix.
  16446. * @param name Define the name of the uniform as defined in the shader
  16447. * @param value Define the value to give to the uniform
  16448. * @return the material itself allowing "fluent" like uniform updates
  16449. */
  16450. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16451. /**
  16452. * Set a float32Array in the shader from a matrix array.
  16453. * @param name Define the name of the uniform as defined in the shader
  16454. * @param value Define the value to give to the uniform
  16455. * @return the material itself allowing "fluent" like uniform updates
  16456. */
  16457. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16458. /**
  16459. * Set a mat3 in the shader from a Float32Array.
  16460. * @param name Define the name of the uniform as defined in the shader
  16461. * @param value Define the value to give to the uniform
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16465. /**
  16466. * Set a mat2 in the shader from a Float32Array.
  16467. * @param name Define the name of the uniform as defined in the shader
  16468. * @param value Define the value to give to the uniform
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16472. /**
  16473. * Set a vec2 array in the shader from a number array.
  16474. * @param name Define the name of the uniform as defined in the shader
  16475. * @param value Define the value to give to the uniform
  16476. * @return the material itself allowing "fluent" like uniform updates
  16477. */
  16478. setArray2(name: string, value: number[]): ShaderMaterial;
  16479. /**
  16480. * Set a vec3 array in the shader from a number array.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the material itself allowing "fluent" like uniform updates
  16484. */
  16485. setArray3(name: string, value: number[]): ShaderMaterial;
  16486. /**
  16487. * Set a vec4 array in the shader from a number array.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the material itself allowing "fluent" like uniform updates
  16491. */
  16492. setArray4(name: string, value: number[]): ShaderMaterial;
  16493. private _checkCache;
  16494. /**
  16495. * Specifies that the submesh is ready to be used
  16496. * @param mesh defines the mesh to check
  16497. * @param subMesh defines which submesh to check
  16498. * @param useInstances specifies that instances should be used
  16499. * @returns a boolean indicating that the submesh is ready or not
  16500. */
  16501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16502. /**
  16503. * Checks if the material is ready to render the requested mesh
  16504. * @param mesh Define the mesh to render
  16505. * @param useInstances Define whether or not the material is used with instances
  16506. * @returns true if ready, otherwise false
  16507. */
  16508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16509. /**
  16510. * Binds the world matrix to the material
  16511. * @param world defines the world transformation matrix
  16512. * @param effectOverride - If provided, use this effect instead of internal effect
  16513. */
  16514. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16515. /**
  16516. * Binds the submesh to this material by preparing the effect and shader to draw
  16517. * @param world defines the world transformation matrix
  16518. * @param mesh defines the mesh containing the submesh
  16519. * @param subMesh defines the submesh to bind the material to
  16520. */
  16521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16522. /**
  16523. * Binds the material to the mesh
  16524. * @param world defines the world transformation matrix
  16525. * @param mesh defines the mesh to bind the material to
  16526. * @param effectOverride - If provided, use this effect instead of internal effect
  16527. */
  16528. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16529. protected _afterBind(mesh?: Mesh): void;
  16530. /**
  16531. * Gets the active textures from the material
  16532. * @returns an array of textures
  16533. */
  16534. getActiveTextures(): BaseTexture[];
  16535. /**
  16536. * Specifies if the material uses a texture
  16537. * @param texture defines the texture to check against the material
  16538. * @returns a boolean specifying if the material uses the texture
  16539. */
  16540. hasTexture(texture: BaseTexture): boolean;
  16541. /**
  16542. * Makes a duplicate of the material, and gives it a new name
  16543. * @param name defines the new name for the duplicated material
  16544. * @returns the cloned material
  16545. */
  16546. clone(name: string): ShaderMaterial;
  16547. /**
  16548. * Disposes the material
  16549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16552. */
  16553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16554. /**
  16555. * Serializes this material in a JSON representation
  16556. * @returns the serialized material object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Creates a shader material from parsed shader material data
  16561. * @param source defines the JSON represnetation of the material
  16562. * @param scene defines the hosting scene
  16563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16564. * @returns a new material
  16565. */
  16566. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16567. /**
  16568. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16569. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16570. * @param url defines the url to load from
  16571. * @param scene defines the hosting scene
  16572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16573. * @returns a promise that will resolve to the new ShaderMaterial
  16574. */
  16575. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16576. /**
  16577. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16578. * @param snippetId defines the snippet to load
  16579. * @param scene defines the hosting scene
  16580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16581. * @returns a promise that will resolve to the new ShaderMaterial
  16582. */
  16583. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16584. }
  16585. }
  16586. declare module BABYLON {
  16587. /** @hidden */
  16588. export var colorPixelShader: {
  16589. name: string;
  16590. shader: string;
  16591. };
  16592. }
  16593. declare module BABYLON {
  16594. /** @hidden */
  16595. export var colorVertexShader: {
  16596. name: string;
  16597. shader: string;
  16598. };
  16599. }
  16600. declare module BABYLON {
  16601. /**
  16602. * Line mesh
  16603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16604. */
  16605. export class LinesMesh extends Mesh {
  16606. /**
  16607. * If vertex color should be applied to the mesh
  16608. */
  16609. readonly useVertexColor?: boolean | undefined;
  16610. /**
  16611. * If vertex alpha should be applied to the mesh
  16612. */
  16613. readonly useVertexAlpha?: boolean | undefined;
  16614. /**
  16615. * Color of the line (Default: White)
  16616. */
  16617. color: Color3;
  16618. /**
  16619. * Alpha of the line (Default: 1)
  16620. */
  16621. alpha: number;
  16622. /**
  16623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16624. * This margin is expressed in world space coordinates, so its value may vary.
  16625. * Default value is 0.1
  16626. */
  16627. intersectionThreshold: number;
  16628. private _colorShader;
  16629. private color4;
  16630. /**
  16631. * Creates a new LinesMesh
  16632. * @param name defines the name
  16633. * @param scene defines the hosting scene
  16634. * @param parent defines the parent mesh if any
  16635. * @param source defines the optional source LinesMesh used to clone data from
  16636. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16637. * When false, achieved by calling a clone(), also passing False.
  16638. * This will make creation of children, recursive.
  16639. * @param useVertexColor defines if this LinesMesh supports vertex color
  16640. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16641. */
  16642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16643. /**
  16644. * If vertex color should be applied to the mesh
  16645. */
  16646. useVertexColor?: boolean | undefined,
  16647. /**
  16648. * If vertex alpha should be applied to the mesh
  16649. */
  16650. useVertexAlpha?: boolean | undefined);
  16651. private _addClipPlaneDefine;
  16652. private _removeClipPlaneDefine;
  16653. isReady(): boolean;
  16654. /**
  16655. * Returns the string "LineMesh"
  16656. */
  16657. getClassName(): string;
  16658. /**
  16659. * @hidden
  16660. */
  16661. get material(): Material;
  16662. /**
  16663. * @hidden
  16664. */
  16665. set material(value: Material);
  16666. /**
  16667. * @hidden
  16668. */
  16669. get checkCollisions(): boolean;
  16670. /** @hidden */
  16671. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16672. /** @hidden */
  16673. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16674. /**
  16675. * Disposes of the line mesh
  16676. * @param doNotRecurse If children should be disposed
  16677. */
  16678. dispose(doNotRecurse?: boolean): void;
  16679. /**
  16680. * Returns a new LineMesh object cloned from the current one.
  16681. */
  16682. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16683. /**
  16684. * Creates a new InstancedLinesMesh object from the mesh model.
  16685. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16686. * @param name defines the name of the new instance
  16687. * @returns a new InstancedLinesMesh
  16688. */
  16689. createInstance(name: string): InstancedLinesMesh;
  16690. }
  16691. /**
  16692. * Creates an instance based on a source LinesMesh
  16693. */
  16694. export class InstancedLinesMesh extends InstancedMesh {
  16695. /**
  16696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16697. * This margin is expressed in world space coordinates, so its value may vary.
  16698. * Initilized with the intersectionThreshold value of the source LinesMesh
  16699. */
  16700. intersectionThreshold: number;
  16701. constructor(name: string, source: LinesMesh);
  16702. /**
  16703. * Returns the string "InstancedLinesMesh".
  16704. */
  16705. getClassName(): string;
  16706. }
  16707. }
  16708. declare module BABYLON {
  16709. /** @hidden */
  16710. export var linePixelShader: {
  16711. name: string;
  16712. shader: string;
  16713. };
  16714. }
  16715. declare module BABYLON {
  16716. /** @hidden */
  16717. export var lineVertexShader: {
  16718. name: string;
  16719. shader: string;
  16720. };
  16721. }
  16722. declare module BABYLON {
  16723. interface Scene {
  16724. /** @hidden */
  16725. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16726. }
  16727. interface AbstractMesh {
  16728. /**
  16729. * Gets the edgesRenderer associated with the mesh
  16730. */
  16731. edgesRenderer: Nullable<EdgesRenderer>;
  16732. }
  16733. interface LinesMesh {
  16734. /**
  16735. * Enables the edge rendering mode on the mesh.
  16736. * This mode makes the mesh edges visible
  16737. * @param epsilon defines the maximal distance between two angles to detect a face
  16738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16739. * @returns the currentAbstractMesh
  16740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16741. */
  16742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16743. }
  16744. interface InstancedLinesMesh {
  16745. /**
  16746. * Enables the edge rendering mode on the mesh.
  16747. * This mode makes the mesh edges visible
  16748. * @param epsilon defines the maximal distance between two angles to detect a face
  16749. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16750. * @returns the current InstancedLinesMesh
  16751. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16752. */
  16753. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16754. }
  16755. /**
  16756. * Defines the minimum contract an Edges renderer should follow.
  16757. */
  16758. export interface IEdgesRenderer extends IDisposable {
  16759. /**
  16760. * Gets or sets a boolean indicating if the edgesRenderer is active
  16761. */
  16762. isEnabled: boolean;
  16763. /**
  16764. * Renders the edges of the attached mesh,
  16765. */
  16766. render(): void;
  16767. /**
  16768. * Checks wether or not the edges renderer is ready to render.
  16769. * @return true if ready, otherwise false.
  16770. */
  16771. isReady(): boolean;
  16772. /**
  16773. * List of instances to render in case the source mesh has instances
  16774. */
  16775. customInstances: SmartArray<Matrix>;
  16776. }
  16777. /**
  16778. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16779. */
  16780. export class EdgesRenderer implements IEdgesRenderer {
  16781. /**
  16782. * Define the size of the edges with an orthographic camera
  16783. */
  16784. edgesWidthScalerForOrthographic: number;
  16785. /**
  16786. * Define the size of the edges with a perspective camera
  16787. */
  16788. edgesWidthScalerForPerspective: number;
  16789. protected _source: AbstractMesh;
  16790. protected _linesPositions: number[];
  16791. protected _linesNormals: number[];
  16792. protected _linesIndices: number[];
  16793. protected _epsilon: number;
  16794. protected _indicesCount: number;
  16795. protected _lineShader: ShaderMaterial;
  16796. protected _ib: DataBuffer;
  16797. protected _buffers: {
  16798. [key: string]: Nullable<VertexBuffer>;
  16799. };
  16800. protected _buffersForInstances: {
  16801. [key: string]: Nullable<VertexBuffer>;
  16802. };
  16803. protected _checkVerticesInsteadOfIndices: boolean;
  16804. private _meshRebuildObserver;
  16805. private _meshDisposeObserver;
  16806. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16807. isEnabled: boolean;
  16808. /**
  16809. * List of instances to render in case the source mesh has instances
  16810. */
  16811. customInstances: SmartArray<Matrix>;
  16812. private static GetShader;
  16813. /**
  16814. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16815. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16816. * @param source Mesh used to create edges
  16817. * @param epsilon sum of angles in adjacency to check for edge
  16818. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16819. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16820. */
  16821. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16822. protected _prepareRessources(): void;
  16823. /** @hidden */
  16824. _rebuild(): void;
  16825. /**
  16826. * Releases the required resources for the edges renderer
  16827. */
  16828. dispose(): void;
  16829. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16830. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16831. /**
  16832. * Checks if the pair of p0 and p1 is en edge
  16833. * @param faceIndex
  16834. * @param edge
  16835. * @param faceNormals
  16836. * @param p0
  16837. * @param p1
  16838. * @private
  16839. */
  16840. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16841. /**
  16842. * push line into the position, normal and index buffer
  16843. * @protected
  16844. */
  16845. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16846. /**
  16847. * Generates lines edges from adjacencjes
  16848. * @private
  16849. */
  16850. _generateEdgesLines(): void;
  16851. /**
  16852. * Checks wether or not the edges renderer is ready to render.
  16853. * @return true if ready, otherwise false.
  16854. */
  16855. isReady(): boolean;
  16856. /**
  16857. * Renders the edges of the attached mesh,
  16858. */
  16859. render(): void;
  16860. }
  16861. /**
  16862. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16863. */
  16864. export class LineEdgesRenderer extends EdgesRenderer {
  16865. /**
  16866. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16867. * @param source LineMesh used to generate edges
  16868. * @param epsilon not important (specified angle for edge detection)
  16869. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16870. */
  16871. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16872. /**
  16873. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16874. */
  16875. _generateEdgesLines(): void;
  16876. }
  16877. }
  16878. declare module BABYLON {
  16879. /**
  16880. * This represents the object necessary to create a rendering group.
  16881. * This is exclusively used and created by the rendering manager.
  16882. * To modify the behavior, you use the available helpers in your scene or meshes.
  16883. * @hidden
  16884. */
  16885. export class RenderingGroup {
  16886. index: number;
  16887. private static _zeroVector;
  16888. private _scene;
  16889. private _opaqueSubMeshes;
  16890. private _transparentSubMeshes;
  16891. private _alphaTestSubMeshes;
  16892. private _depthOnlySubMeshes;
  16893. private _particleSystems;
  16894. private _spriteManagers;
  16895. private _opaqueSortCompareFn;
  16896. private _alphaTestSortCompareFn;
  16897. private _transparentSortCompareFn;
  16898. private _renderOpaque;
  16899. private _renderAlphaTest;
  16900. private _renderTransparent;
  16901. /** @hidden */
  16902. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16903. onBeforeTransparentRendering: () => void;
  16904. /**
  16905. * Set the opaque sort comparison function.
  16906. * If null the sub meshes will be render in the order they were created
  16907. */
  16908. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16909. /**
  16910. * Set the alpha test sort comparison function.
  16911. * If null the sub meshes will be render in the order they were created
  16912. */
  16913. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16914. /**
  16915. * Set the transparent sort comparison function.
  16916. * If null the sub meshes will be render in the order they were created
  16917. */
  16918. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16919. /**
  16920. * Creates a new rendering group.
  16921. * @param index The rendering group index
  16922. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16923. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16924. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16925. */
  16926. 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>);
  16927. /**
  16928. * Render all the sub meshes contained in the group.
  16929. * @param customRenderFunction Used to override the default render behaviour of the group.
  16930. * @returns true if rendered some submeshes.
  16931. */
  16932. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16933. /**
  16934. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16935. * @param subMeshes The submeshes to render
  16936. */
  16937. private renderOpaqueSorted;
  16938. /**
  16939. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16940. * @param subMeshes The submeshes to render
  16941. */
  16942. private renderAlphaTestSorted;
  16943. /**
  16944. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16945. * @param subMeshes The submeshes to render
  16946. */
  16947. private renderTransparentSorted;
  16948. /**
  16949. * Renders the submeshes in a specified order.
  16950. * @param subMeshes The submeshes to sort before render
  16951. * @param sortCompareFn The comparison function use to sort
  16952. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16953. * @param transparent Specifies to activate blending if true
  16954. */
  16955. private static renderSorted;
  16956. /**
  16957. * Renders the submeshes in the order they were dispatched (no sort applied).
  16958. * @param subMeshes The submeshes to render
  16959. */
  16960. private static renderUnsorted;
  16961. /**
  16962. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16963. * are rendered back to front if in the same alpha index.
  16964. *
  16965. * @param a The first submesh
  16966. * @param b The second submesh
  16967. * @returns The result of the comparison
  16968. */
  16969. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16970. /**
  16971. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16972. * are rendered back to front.
  16973. *
  16974. * @param a The first submesh
  16975. * @param b The second submesh
  16976. * @returns The result of the comparison
  16977. */
  16978. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16979. /**
  16980. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16981. * are rendered front to back (prevent overdraw).
  16982. *
  16983. * @param a The first submesh
  16984. * @param b The second submesh
  16985. * @returns The result of the comparison
  16986. */
  16987. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16988. /**
  16989. * Resets the different lists of submeshes to prepare a new frame.
  16990. */
  16991. prepare(): void;
  16992. dispose(): void;
  16993. /**
  16994. * Inserts the submesh in its correct queue depending on its material.
  16995. * @param subMesh The submesh to dispatch
  16996. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16997. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16998. */
  16999. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17000. dispatchSprites(spriteManager: ISpriteManager): void;
  17001. dispatchParticles(particleSystem: IParticleSystem): void;
  17002. private _renderParticles;
  17003. private _renderSprites;
  17004. }
  17005. }
  17006. declare module BABYLON {
  17007. /**
  17008. * Interface describing the different options available in the rendering manager
  17009. * regarding Auto Clear between groups.
  17010. */
  17011. export interface IRenderingManagerAutoClearSetup {
  17012. /**
  17013. * Defines whether or not autoclear is enable.
  17014. */
  17015. autoClear: boolean;
  17016. /**
  17017. * Defines whether or not to autoclear the depth buffer.
  17018. */
  17019. depth: boolean;
  17020. /**
  17021. * Defines whether or not to autoclear the stencil buffer.
  17022. */
  17023. stencil: boolean;
  17024. }
  17025. /**
  17026. * This class is used by the onRenderingGroupObservable
  17027. */
  17028. export class RenderingGroupInfo {
  17029. /**
  17030. * The Scene that being rendered
  17031. */
  17032. scene: Scene;
  17033. /**
  17034. * The camera currently used for the rendering pass
  17035. */
  17036. camera: Nullable<Camera>;
  17037. /**
  17038. * The ID of the renderingGroup being processed
  17039. */
  17040. renderingGroupId: number;
  17041. }
  17042. /**
  17043. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17044. * It is enable to manage the different groups as well as the different necessary sort functions.
  17045. * This should not be used directly aside of the few static configurations
  17046. */
  17047. export class RenderingManager {
  17048. /**
  17049. * The max id used for rendering groups (not included)
  17050. */
  17051. static MAX_RENDERINGGROUPS: number;
  17052. /**
  17053. * The min id used for rendering groups (included)
  17054. */
  17055. static MIN_RENDERINGGROUPS: number;
  17056. /**
  17057. * Used to globally prevent autoclearing scenes.
  17058. */
  17059. static AUTOCLEAR: boolean;
  17060. /**
  17061. * @hidden
  17062. */
  17063. _useSceneAutoClearSetup: boolean;
  17064. private _scene;
  17065. private _renderingGroups;
  17066. private _depthStencilBufferAlreadyCleaned;
  17067. private _autoClearDepthStencil;
  17068. private _customOpaqueSortCompareFn;
  17069. private _customAlphaTestSortCompareFn;
  17070. private _customTransparentSortCompareFn;
  17071. private _renderingGroupInfo;
  17072. /**
  17073. * Instantiates a new rendering group for a particular scene
  17074. * @param scene Defines the scene the groups belongs to
  17075. */
  17076. constructor(scene: Scene);
  17077. private _clearDepthStencilBuffer;
  17078. /**
  17079. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17080. * @hidden
  17081. */
  17082. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17083. /**
  17084. * Resets the different information of the group to prepare a new frame
  17085. * @hidden
  17086. */
  17087. reset(): void;
  17088. /**
  17089. * Dispose and release the group and its associated resources.
  17090. * @hidden
  17091. */
  17092. dispose(): void;
  17093. /**
  17094. * Clear the info related to rendering groups preventing retention points during dispose.
  17095. */
  17096. freeRenderingGroups(): void;
  17097. private _prepareRenderingGroup;
  17098. /**
  17099. * Add a sprite manager to the rendering manager in order to render it this frame.
  17100. * @param spriteManager Define the sprite manager to render
  17101. */
  17102. dispatchSprites(spriteManager: ISpriteManager): void;
  17103. /**
  17104. * Add a particle system to the rendering manager in order to render it this frame.
  17105. * @param particleSystem Define the particle system to render
  17106. */
  17107. dispatchParticles(particleSystem: IParticleSystem): void;
  17108. /**
  17109. * Add a submesh to the manager in order to render it this frame
  17110. * @param subMesh The submesh to dispatch
  17111. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17112. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17113. */
  17114. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17115. /**
  17116. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17117. * This allowed control for front to back rendering or reversly depending of the special needs.
  17118. *
  17119. * @param renderingGroupId The rendering group id corresponding to its index
  17120. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17121. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17122. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17123. */
  17124. 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;
  17125. /**
  17126. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17127. *
  17128. * @param renderingGroupId The rendering group id corresponding to its index
  17129. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17130. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17131. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17132. */
  17133. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17134. /**
  17135. * Gets the current auto clear configuration for one rendering group of the rendering
  17136. * manager.
  17137. * @param index the rendering group index to get the information for
  17138. * @returns The auto clear setup for the requested rendering group
  17139. */
  17140. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17141. }
  17142. }
  17143. declare module BABYLON {
  17144. /**
  17145. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17146. */
  17147. export interface ICustomShaderOptions {
  17148. /**
  17149. * Gets or sets the custom shader name to use
  17150. */
  17151. shaderName: string;
  17152. /**
  17153. * The list of attribute names used in the shader
  17154. */
  17155. attributes?: string[];
  17156. /**
  17157. * The list of unifrom names used in the shader
  17158. */
  17159. uniforms?: string[];
  17160. /**
  17161. * The list of sampler names used in the shader
  17162. */
  17163. samplers?: string[];
  17164. /**
  17165. * The list of defines used in the shader
  17166. */
  17167. defines?: string[];
  17168. }
  17169. /**
  17170. * Interface to implement to create a shadow generator compatible with BJS.
  17171. */
  17172. export interface IShadowGenerator {
  17173. /**
  17174. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17175. * @returns The render target texture if present otherwise, null
  17176. */
  17177. getShadowMap(): Nullable<RenderTargetTexture>;
  17178. /**
  17179. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17180. * @param subMesh The submesh we want to render in the shadow map
  17181. * @param useInstances Defines wether will draw in the map using instances
  17182. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17183. * @returns true if ready otherwise, false
  17184. */
  17185. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17186. /**
  17187. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17188. * @param defines Defines of the material we want to update
  17189. * @param lightIndex Index of the light in the enabled light list of the material
  17190. */
  17191. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17192. /**
  17193. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17194. * defined in the generator but impacting the effect).
  17195. * It implies the unifroms available on the materials are the standard BJS ones.
  17196. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17197. * @param effect The effect we are binfing the information for
  17198. */
  17199. bindShadowLight(lightIndex: string, effect: Effect): void;
  17200. /**
  17201. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17202. * (eq to shadow prjection matrix * light transform matrix)
  17203. * @returns The transform matrix used to create the shadow map
  17204. */
  17205. getTransformMatrix(): Matrix;
  17206. /**
  17207. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17208. * Cube and 2D textures for instance.
  17209. */
  17210. recreateShadowMap(): void;
  17211. /**
  17212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17213. * @param onCompiled Callback triggered at the and of the effects compilation
  17214. * @param options Sets of optional options forcing the compilation with different modes
  17215. */
  17216. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17217. useInstances: boolean;
  17218. }>): void;
  17219. /**
  17220. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17221. * @param options Sets of optional options forcing the compilation with different modes
  17222. * @returns A promise that resolves when the compilation completes
  17223. */
  17224. forceCompilationAsync(options?: Partial<{
  17225. useInstances: boolean;
  17226. }>): Promise<void>;
  17227. /**
  17228. * Serializes the shadow generator setup to a json object.
  17229. * @returns The serialized JSON object
  17230. */
  17231. serialize(): any;
  17232. /**
  17233. * Disposes the Shadow map and related Textures and effects.
  17234. */
  17235. dispose(): void;
  17236. }
  17237. /**
  17238. * Default implementation IShadowGenerator.
  17239. * This is the main object responsible of generating shadows in the framework.
  17240. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17241. */
  17242. export class ShadowGenerator implements IShadowGenerator {
  17243. /**
  17244. * Name of the shadow generator class
  17245. */
  17246. static CLASSNAME: string;
  17247. /**
  17248. * Shadow generator mode None: no filtering applied.
  17249. */
  17250. static readonly FILTER_NONE: number;
  17251. /**
  17252. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17253. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17254. */
  17255. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17256. /**
  17257. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17258. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17259. */
  17260. static readonly FILTER_POISSONSAMPLING: number;
  17261. /**
  17262. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17263. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17264. */
  17265. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17266. /**
  17267. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17268. * edge artifacts on steep falloff.
  17269. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17270. */
  17271. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17272. /**
  17273. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17274. * edge artifacts on steep falloff.
  17275. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17276. */
  17277. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17278. /**
  17279. * Shadow generator mode PCF: Percentage Closer Filtering
  17280. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17281. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17282. */
  17283. static readonly FILTER_PCF: number;
  17284. /**
  17285. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17286. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17287. * Contact Hardening
  17288. */
  17289. static readonly FILTER_PCSS: number;
  17290. /**
  17291. * Reserved for PCF and PCSS
  17292. * Highest Quality.
  17293. *
  17294. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17295. *
  17296. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17297. */
  17298. static readonly QUALITY_HIGH: number;
  17299. /**
  17300. * Reserved for PCF and PCSS
  17301. * Good tradeoff for quality/perf cross devices
  17302. *
  17303. * Execute PCF on a 3*3 kernel.
  17304. *
  17305. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17306. */
  17307. static readonly QUALITY_MEDIUM: number;
  17308. /**
  17309. * Reserved for PCF and PCSS
  17310. * The lowest quality but the fastest.
  17311. *
  17312. * Execute PCF on a 1*1 kernel.
  17313. *
  17314. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17315. */
  17316. static readonly QUALITY_LOW: number;
  17317. /** Gets or sets the custom shader name to use */
  17318. customShaderOptions: ICustomShaderOptions;
  17319. /**
  17320. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17321. */
  17322. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17323. /**
  17324. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17325. */
  17326. onAfterShadowMapRenderObservable: Observable<Effect>;
  17327. /**
  17328. * Observable triggered before a mesh is rendered in the shadow map.
  17329. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17330. */
  17331. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17332. /**
  17333. * Observable triggered after a mesh is rendered in the shadow map.
  17334. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17335. */
  17336. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17337. protected _bias: number;
  17338. /**
  17339. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17340. */
  17341. get bias(): number;
  17342. /**
  17343. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17344. */
  17345. set bias(bias: number);
  17346. protected _normalBias: number;
  17347. /**
  17348. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17349. */
  17350. get normalBias(): number;
  17351. /**
  17352. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17353. */
  17354. set normalBias(normalBias: number);
  17355. protected _blurBoxOffset: number;
  17356. /**
  17357. * Gets the blur box offset: offset applied during the blur pass.
  17358. * Only useful if useKernelBlur = false
  17359. */
  17360. get blurBoxOffset(): number;
  17361. /**
  17362. * Sets the blur box offset: offset applied during the blur pass.
  17363. * Only useful if useKernelBlur = false
  17364. */
  17365. set blurBoxOffset(value: number);
  17366. protected _blurScale: number;
  17367. /**
  17368. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17369. * 2 means half of the size.
  17370. */
  17371. get blurScale(): number;
  17372. /**
  17373. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17374. * 2 means half of the size.
  17375. */
  17376. set blurScale(value: number);
  17377. protected _blurKernel: number;
  17378. /**
  17379. * Gets the blur kernel: kernel size of the blur pass.
  17380. * Only useful if useKernelBlur = true
  17381. */
  17382. get blurKernel(): number;
  17383. /**
  17384. * Sets the blur kernel: kernel size of the blur pass.
  17385. * Only useful if useKernelBlur = true
  17386. */
  17387. set blurKernel(value: number);
  17388. protected _useKernelBlur: boolean;
  17389. /**
  17390. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17391. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17392. */
  17393. get useKernelBlur(): boolean;
  17394. /**
  17395. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17396. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17397. */
  17398. set useKernelBlur(value: boolean);
  17399. protected _depthScale: number;
  17400. /**
  17401. * Gets the depth scale used in ESM mode.
  17402. */
  17403. get depthScale(): number;
  17404. /**
  17405. * Sets the depth scale used in ESM mode.
  17406. * This can override the scale stored on the light.
  17407. */
  17408. set depthScale(value: number);
  17409. protected _validateFilter(filter: number): number;
  17410. protected _filter: number;
  17411. /**
  17412. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17413. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17414. */
  17415. get filter(): number;
  17416. /**
  17417. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17418. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17419. */
  17420. set filter(value: number);
  17421. /**
  17422. * Gets if the current filter is set to Poisson Sampling.
  17423. */
  17424. get usePoissonSampling(): boolean;
  17425. /**
  17426. * Sets the current filter to Poisson Sampling.
  17427. */
  17428. set usePoissonSampling(value: boolean);
  17429. /**
  17430. * Gets if the current filter is set to ESM.
  17431. */
  17432. get useExponentialShadowMap(): boolean;
  17433. /**
  17434. * Sets the current filter is to ESM.
  17435. */
  17436. set useExponentialShadowMap(value: boolean);
  17437. /**
  17438. * Gets if the current filter is set to filtered ESM.
  17439. */
  17440. get useBlurExponentialShadowMap(): boolean;
  17441. /**
  17442. * Gets if the current filter is set to filtered ESM.
  17443. */
  17444. set useBlurExponentialShadowMap(value: boolean);
  17445. /**
  17446. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17447. * exponential to prevent steep falloff artifacts).
  17448. */
  17449. get useCloseExponentialShadowMap(): boolean;
  17450. /**
  17451. * Sets the current filter to "close ESM" (using the inverse of the
  17452. * exponential to prevent steep falloff artifacts).
  17453. */
  17454. set useCloseExponentialShadowMap(value: boolean);
  17455. /**
  17456. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17457. * exponential to prevent steep falloff artifacts).
  17458. */
  17459. get useBlurCloseExponentialShadowMap(): boolean;
  17460. /**
  17461. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17462. * exponential to prevent steep falloff artifacts).
  17463. */
  17464. set useBlurCloseExponentialShadowMap(value: boolean);
  17465. /**
  17466. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17467. */
  17468. get usePercentageCloserFiltering(): boolean;
  17469. /**
  17470. * Sets the current filter to "PCF" (percentage closer filtering).
  17471. */
  17472. set usePercentageCloserFiltering(value: boolean);
  17473. protected _filteringQuality: number;
  17474. /**
  17475. * Gets the PCF or PCSS Quality.
  17476. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17477. */
  17478. get filteringQuality(): number;
  17479. /**
  17480. * Sets the PCF or PCSS Quality.
  17481. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17482. */
  17483. set filteringQuality(filteringQuality: number);
  17484. /**
  17485. * Gets if the current filter is set to "PCSS" (contact hardening).
  17486. */
  17487. get useContactHardeningShadow(): boolean;
  17488. /**
  17489. * Sets the current filter to "PCSS" (contact hardening).
  17490. */
  17491. set useContactHardeningShadow(value: boolean);
  17492. protected _contactHardeningLightSizeUVRatio: number;
  17493. /**
  17494. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17495. * Using a ratio helps keeping shape stability independently of the map size.
  17496. *
  17497. * It does not account for the light projection as it was having too much
  17498. * instability during the light setup or during light position changes.
  17499. *
  17500. * Only valid if useContactHardeningShadow is true.
  17501. */
  17502. get contactHardeningLightSizeUVRatio(): number;
  17503. /**
  17504. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17505. * Using a ratio helps keeping shape stability independently of the map size.
  17506. *
  17507. * It does not account for the light projection as it was having too much
  17508. * instability during the light setup or during light position changes.
  17509. *
  17510. * Only valid if useContactHardeningShadow is true.
  17511. */
  17512. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17513. protected _darkness: number;
  17514. /** Gets or sets the actual darkness of a shadow */
  17515. get darkness(): number;
  17516. set darkness(value: number);
  17517. /**
  17518. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17519. * 0 means strongest and 1 would means no shadow.
  17520. * @returns the darkness.
  17521. */
  17522. getDarkness(): number;
  17523. /**
  17524. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17525. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17526. * @returns the shadow generator allowing fluent coding.
  17527. */
  17528. setDarkness(darkness: number): ShadowGenerator;
  17529. protected _transparencyShadow: boolean;
  17530. /** Gets or sets the ability to have transparent shadow */
  17531. get transparencyShadow(): boolean;
  17532. set transparencyShadow(value: boolean);
  17533. /**
  17534. * Sets the ability to have transparent shadow (boolean).
  17535. * @param transparent True if transparent else False
  17536. * @returns the shadow generator allowing fluent coding
  17537. */
  17538. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17539. /**
  17540. * Enables or disables shadows with varying strength based on the transparency
  17541. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17542. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17543. * mesh.visibility * alphaTexture.a
  17544. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17545. */
  17546. enableSoftTransparentShadow: boolean;
  17547. protected _shadowMap: Nullable<RenderTargetTexture>;
  17548. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17549. /**
  17550. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17551. * @returns The render target texture if present otherwise, null
  17552. */
  17553. getShadowMap(): Nullable<RenderTargetTexture>;
  17554. /**
  17555. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17556. * @returns The render target texture if the shadow map is present otherwise, null
  17557. */
  17558. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17559. /**
  17560. * Gets the class name of that object
  17561. * @returns "ShadowGenerator"
  17562. */
  17563. getClassName(): string;
  17564. /**
  17565. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17566. * @param mesh Mesh to add
  17567. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17568. * @returns the Shadow Generator itself
  17569. */
  17570. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17571. /**
  17572. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17573. * @param mesh Mesh to remove
  17574. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17575. * @returns the Shadow Generator itself
  17576. */
  17577. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17578. /**
  17579. * Controls the extent to which the shadows fade out at the edge of the frustum
  17580. */
  17581. frustumEdgeFalloff: number;
  17582. protected _light: IShadowLight;
  17583. /**
  17584. * Returns the associated light object.
  17585. * @returns the light generating the shadow
  17586. */
  17587. getLight(): IShadowLight;
  17588. /**
  17589. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17590. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17591. * It might on the other hand introduce peter panning.
  17592. */
  17593. forceBackFacesOnly: boolean;
  17594. protected _scene: Scene;
  17595. protected _lightDirection: Vector3;
  17596. protected _effect: Effect;
  17597. protected _viewMatrix: Matrix;
  17598. protected _projectionMatrix: Matrix;
  17599. protected _transformMatrix: Matrix;
  17600. protected _cachedPosition: Vector3;
  17601. protected _cachedDirection: Vector3;
  17602. protected _cachedDefines: string;
  17603. protected _currentRenderID: number;
  17604. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17605. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17606. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17607. protected _blurPostProcesses: PostProcess[];
  17608. protected _mapSize: number;
  17609. protected _currentFaceIndex: number;
  17610. protected _currentFaceIndexCache: number;
  17611. protected _textureType: number;
  17612. protected _defaultTextureMatrix: Matrix;
  17613. protected _storedUniqueId: Nullable<number>;
  17614. /** @hidden */
  17615. static _SceneComponentInitialization: (scene: Scene) => void;
  17616. /**
  17617. * Creates a ShadowGenerator object.
  17618. * A ShadowGenerator is the required tool to use the shadows.
  17619. * Each light casting shadows needs to use its own ShadowGenerator.
  17620. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17621. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17622. * @param light The light object generating the shadows.
  17623. * @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.
  17624. */
  17625. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17626. protected _initializeGenerator(): void;
  17627. protected _createTargetRenderTexture(): void;
  17628. protected _initializeShadowMap(): void;
  17629. protected _initializeBlurRTTAndPostProcesses(): void;
  17630. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17631. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17632. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17633. protected _applyFilterValues(): void;
  17634. /**
  17635. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17636. * @param onCompiled Callback triggered at the and of the effects compilation
  17637. * @param options Sets of optional options forcing the compilation with different modes
  17638. */
  17639. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17640. useInstances: boolean;
  17641. }>): void;
  17642. /**
  17643. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17644. * @param options Sets of optional options forcing the compilation with different modes
  17645. * @returns A promise that resolves when the compilation completes
  17646. */
  17647. forceCompilationAsync(options?: Partial<{
  17648. useInstances: boolean;
  17649. }>): Promise<void>;
  17650. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17651. private _prepareShadowDefines;
  17652. /**
  17653. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17654. * @param subMesh The submesh we want to render in the shadow map
  17655. * @param useInstances Defines wether will draw in the map using instances
  17656. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17657. * @returns true if ready otherwise, false
  17658. */
  17659. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17660. /**
  17661. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17662. * @param defines Defines of the material we want to update
  17663. * @param lightIndex Index of the light in the enabled light list of the material
  17664. */
  17665. prepareDefines(defines: any, lightIndex: number): void;
  17666. /**
  17667. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17668. * defined in the generator but impacting the effect).
  17669. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17670. * @param effect The effect we are binfing the information for
  17671. */
  17672. bindShadowLight(lightIndex: string, effect: Effect): void;
  17673. /**
  17674. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17675. * (eq to shadow prjection matrix * light transform matrix)
  17676. * @returns The transform matrix used to create the shadow map
  17677. */
  17678. getTransformMatrix(): Matrix;
  17679. /**
  17680. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17681. * Cube and 2D textures for instance.
  17682. */
  17683. recreateShadowMap(): void;
  17684. protected _disposeBlurPostProcesses(): void;
  17685. protected _disposeRTTandPostProcesses(): void;
  17686. /**
  17687. * Disposes the ShadowGenerator.
  17688. * Returns nothing.
  17689. */
  17690. dispose(): void;
  17691. /**
  17692. * Serializes the shadow generator setup to a json object.
  17693. * @returns The serialized JSON object
  17694. */
  17695. serialize(): any;
  17696. /**
  17697. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17698. * @param parsedShadowGenerator The JSON object to parse
  17699. * @param scene The scene to create the shadow map for
  17700. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17701. * @returns The parsed shadow generator
  17702. */
  17703. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17704. }
  17705. }
  17706. declare module BABYLON {
  17707. /**
  17708. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17709. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17710. * 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.
  17711. */
  17712. export abstract class Light extends Node {
  17713. /**
  17714. * Falloff Default: light is falling off following the material specification:
  17715. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17716. */
  17717. static readonly FALLOFF_DEFAULT: number;
  17718. /**
  17719. * Falloff Physical: light is falling off following the inverse squared distance law.
  17720. */
  17721. static readonly FALLOFF_PHYSICAL: number;
  17722. /**
  17723. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17724. * to enhance interoperability with other engines.
  17725. */
  17726. static readonly FALLOFF_GLTF: number;
  17727. /**
  17728. * Falloff Standard: light is falling off like in the standard material
  17729. * to enhance interoperability with other materials.
  17730. */
  17731. static readonly FALLOFF_STANDARD: number;
  17732. /**
  17733. * If every light affecting the material is in this lightmapMode,
  17734. * material.lightmapTexture adds or multiplies
  17735. * (depends on material.useLightmapAsShadowmap)
  17736. * after every other light calculations.
  17737. */
  17738. static readonly LIGHTMAP_DEFAULT: number;
  17739. /**
  17740. * material.lightmapTexture as only diffuse lighting from this light
  17741. * adds only specular lighting from this light
  17742. * adds dynamic shadows
  17743. */
  17744. static readonly LIGHTMAP_SPECULAR: number;
  17745. /**
  17746. * material.lightmapTexture as only lighting
  17747. * no light calculation from this light
  17748. * only adds dynamic shadows from this light
  17749. */
  17750. static readonly LIGHTMAP_SHADOWSONLY: number;
  17751. /**
  17752. * Each light type uses the default quantity according to its type:
  17753. * point/spot lights use luminous intensity
  17754. * directional lights use illuminance
  17755. */
  17756. static readonly INTENSITYMODE_AUTOMATIC: number;
  17757. /**
  17758. * lumen (lm)
  17759. */
  17760. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17761. /**
  17762. * candela (lm/sr)
  17763. */
  17764. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17765. /**
  17766. * lux (lm/m^2)
  17767. */
  17768. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17769. /**
  17770. * nit (cd/m^2)
  17771. */
  17772. static readonly INTENSITYMODE_LUMINANCE: number;
  17773. /**
  17774. * Light type const id of the point light.
  17775. */
  17776. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17777. /**
  17778. * Light type const id of the directional light.
  17779. */
  17780. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17781. /**
  17782. * Light type const id of the spot light.
  17783. */
  17784. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17785. /**
  17786. * Light type const id of the hemispheric light.
  17787. */
  17788. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17789. /**
  17790. * Diffuse gives the basic color to an object.
  17791. */
  17792. diffuse: Color3;
  17793. /**
  17794. * Specular produces a highlight color on an object.
  17795. * Note: This is note affecting PBR materials.
  17796. */
  17797. specular: Color3;
  17798. /**
  17799. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17800. * falling off base on range or angle.
  17801. * This can be set to any values in Light.FALLOFF_x.
  17802. *
  17803. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17804. * other types of materials.
  17805. */
  17806. falloffType: number;
  17807. /**
  17808. * Strength of the light.
  17809. * Note: By default it is define in the framework own unit.
  17810. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17811. */
  17812. intensity: number;
  17813. private _range;
  17814. protected _inverseSquaredRange: number;
  17815. /**
  17816. * Defines how far from the source the light is impacting in scene units.
  17817. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17818. */
  17819. get range(): number;
  17820. /**
  17821. * Defines how far from the source the light is impacting in scene units.
  17822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17823. */
  17824. set range(value: number);
  17825. /**
  17826. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17827. * of light.
  17828. */
  17829. private _photometricScale;
  17830. private _intensityMode;
  17831. /**
  17832. * Gets the photometric scale used to interpret the intensity.
  17833. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17834. */
  17835. get intensityMode(): number;
  17836. /**
  17837. * Sets the photometric scale used to interpret the intensity.
  17838. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17839. */
  17840. set intensityMode(value: number);
  17841. private _radius;
  17842. /**
  17843. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17844. */
  17845. get radius(): number;
  17846. /**
  17847. * sets the light radius used by PBR Materials to simulate soft area lights.
  17848. */
  17849. set radius(value: number);
  17850. private _renderPriority;
  17851. /**
  17852. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17853. * exceeding the number allowed of the materials.
  17854. */
  17855. renderPriority: number;
  17856. private _shadowEnabled;
  17857. /**
  17858. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17859. * the current shadow generator.
  17860. */
  17861. get shadowEnabled(): boolean;
  17862. /**
  17863. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17864. * the current shadow generator.
  17865. */
  17866. set shadowEnabled(value: boolean);
  17867. private _includedOnlyMeshes;
  17868. /**
  17869. * Gets the only meshes impacted by this light.
  17870. */
  17871. get includedOnlyMeshes(): AbstractMesh[];
  17872. /**
  17873. * Sets the only meshes impacted by this light.
  17874. */
  17875. set includedOnlyMeshes(value: AbstractMesh[]);
  17876. private _excludedMeshes;
  17877. /**
  17878. * Gets the meshes not impacted by this light.
  17879. */
  17880. get excludedMeshes(): AbstractMesh[];
  17881. /**
  17882. * Sets the meshes not impacted by this light.
  17883. */
  17884. set excludedMeshes(value: AbstractMesh[]);
  17885. private _excludeWithLayerMask;
  17886. /**
  17887. * Gets the layer id use to find what meshes are not impacted by the light.
  17888. * Inactive if 0
  17889. */
  17890. get excludeWithLayerMask(): number;
  17891. /**
  17892. * Sets the layer id use to find what meshes are not impacted by the light.
  17893. * Inactive if 0
  17894. */
  17895. set excludeWithLayerMask(value: number);
  17896. private _includeOnlyWithLayerMask;
  17897. /**
  17898. * Gets the layer id use to find what meshes are impacted by the light.
  17899. * Inactive if 0
  17900. */
  17901. get includeOnlyWithLayerMask(): number;
  17902. /**
  17903. * Sets the layer id use to find what meshes are impacted by the light.
  17904. * Inactive if 0
  17905. */
  17906. set includeOnlyWithLayerMask(value: number);
  17907. private _lightmapMode;
  17908. /**
  17909. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17910. */
  17911. get lightmapMode(): number;
  17912. /**
  17913. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17914. */
  17915. set lightmapMode(value: number);
  17916. /**
  17917. * Shadow generator associted to the light.
  17918. * @hidden Internal use only.
  17919. */
  17920. _shadowGenerator: Nullable<IShadowGenerator>;
  17921. /**
  17922. * @hidden Internal use only.
  17923. */
  17924. _excludedMeshesIds: string[];
  17925. /**
  17926. * @hidden Internal use only.
  17927. */
  17928. _includedOnlyMeshesIds: string[];
  17929. /**
  17930. * The current light unifom buffer.
  17931. * @hidden Internal use only.
  17932. */
  17933. _uniformBuffer: UniformBuffer;
  17934. /** @hidden */
  17935. _renderId: number;
  17936. /**
  17937. * Creates a Light object in the scene.
  17938. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17939. * @param name The firendly name of the light
  17940. * @param scene The scene the light belongs too
  17941. */
  17942. constructor(name: string, scene: Scene);
  17943. protected abstract _buildUniformLayout(): void;
  17944. /**
  17945. * Sets the passed Effect "effect" with the Light information.
  17946. * @param effect The effect to update
  17947. * @param lightIndex The index of the light in the effect to update
  17948. * @returns The light
  17949. */
  17950. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17951. /**
  17952. * Sets the passed Effect "effect" with the Light textures.
  17953. * @param effect The effect to update
  17954. * @param lightIndex The index of the light in the effect to update
  17955. * @returns The light
  17956. */
  17957. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17958. /**
  17959. * Binds the lights information from the scene to the effect for the given mesh.
  17960. * @param lightIndex Light index
  17961. * @param scene The scene where the light belongs to
  17962. * @param effect The effect we are binding the data to
  17963. * @param useSpecular Defines if specular is supported
  17964. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17965. */
  17966. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17967. /**
  17968. * Sets the passed Effect "effect" with the Light information.
  17969. * @param effect The effect to update
  17970. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17971. * @returns The light
  17972. */
  17973. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17974. /**
  17975. * Returns the string "Light".
  17976. * @returns the class name
  17977. */
  17978. getClassName(): string;
  17979. /** @hidden */
  17980. readonly _isLight: boolean;
  17981. /**
  17982. * Converts the light information to a readable string for debug purpose.
  17983. * @param fullDetails Supports for multiple levels of logging within scene loading
  17984. * @returns the human readable light info
  17985. */
  17986. toString(fullDetails?: boolean): string;
  17987. /** @hidden */
  17988. protected _syncParentEnabledState(): void;
  17989. /**
  17990. * Set the enabled state of this node.
  17991. * @param value - the new enabled state
  17992. */
  17993. setEnabled(value: boolean): void;
  17994. /**
  17995. * Returns the Light associated shadow generator if any.
  17996. * @return the associated shadow generator.
  17997. */
  17998. getShadowGenerator(): Nullable<IShadowGenerator>;
  17999. /**
  18000. * Returns a Vector3, the absolute light position in the World.
  18001. * @returns the world space position of the light
  18002. */
  18003. getAbsolutePosition(): Vector3;
  18004. /**
  18005. * Specifies if the light will affect the passed mesh.
  18006. * @param mesh The mesh to test against the light
  18007. * @return true the mesh is affected otherwise, false.
  18008. */
  18009. canAffectMesh(mesh: AbstractMesh): boolean;
  18010. /**
  18011. * Sort function to order lights for rendering.
  18012. * @param a First Light object to compare to second.
  18013. * @param b Second Light object to compare first.
  18014. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18015. */
  18016. static CompareLightsPriority(a: Light, b: Light): number;
  18017. /**
  18018. * Releases resources associated with this node.
  18019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18021. */
  18022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18023. /**
  18024. * Returns the light type ID (integer).
  18025. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18026. */
  18027. getTypeID(): number;
  18028. /**
  18029. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18030. * @returns the scaled intensity in intensity mode unit
  18031. */
  18032. getScaledIntensity(): number;
  18033. /**
  18034. * Returns a new Light object, named "name", from the current one.
  18035. * @param name The name of the cloned light
  18036. * @param newParent The parent of this light, if it has one
  18037. * @returns the new created light
  18038. */
  18039. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18040. /**
  18041. * Serializes the current light into a Serialization object.
  18042. * @returns the serialized object.
  18043. */
  18044. serialize(): any;
  18045. /**
  18046. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18047. * This new light is named "name" and added to the passed scene.
  18048. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18049. * @param name The friendly name of the light
  18050. * @param scene The scene the new light will belong to
  18051. * @returns the constructor function
  18052. */
  18053. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18054. /**
  18055. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18056. * @param parsedLight The JSON representation of the light
  18057. * @param scene The scene to create the parsed light in
  18058. * @returns the created light after parsing
  18059. */
  18060. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18061. private _hookArrayForExcluded;
  18062. private _hookArrayForIncludedOnly;
  18063. private _resyncMeshes;
  18064. /**
  18065. * Forces the meshes to update their light related information in their rendering used effects
  18066. * @hidden Internal Use Only
  18067. */
  18068. _markMeshesAsLightDirty(): void;
  18069. /**
  18070. * Recomputes the cached photometric scale if needed.
  18071. */
  18072. private _computePhotometricScale;
  18073. /**
  18074. * Returns the Photometric Scale according to the light type and intensity mode.
  18075. */
  18076. private _getPhotometricScale;
  18077. /**
  18078. * Reorder the light in the scene according to their defined priority.
  18079. * @hidden Internal Use Only
  18080. */
  18081. _reorderLightsInScene(): void;
  18082. /**
  18083. * Prepares the list of defines specific to the light type.
  18084. * @param defines the list of defines
  18085. * @param lightIndex defines the index of the light for the effect
  18086. */
  18087. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18088. }
  18089. }
  18090. declare module BABYLON {
  18091. /**
  18092. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18093. * This is the base of the follow, arc rotate cameras and Free camera
  18094. * @see https://doc.babylonjs.com/features/cameras
  18095. */
  18096. export class TargetCamera extends Camera {
  18097. private static _RigCamTransformMatrix;
  18098. private static _TargetTransformMatrix;
  18099. private static _TargetFocalPoint;
  18100. private _tmpUpVector;
  18101. private _tmpTargetVector;
  18102. /**
  18103. * Define the current direction the camera is moving to
  18104. */
  18105. cameraDirection: Vector3;
  18106. /**
  18107. * Define the current rotation the camera is rotating to
  18108. */
  18109. cameraRotation: Vector2;
  18110. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18111. ignoreParentScaling: boolean;
  18112. /**
  18113. * When set, the up vector of the camera will be updated by the rotation of the camera
  18114. */
  18115. updateUpVectorFromRotation: boolean;
  18116. private _tmpQuaternion;
  18117. /**
  18118. * Define the current rotation of the camera
  18119. */
  18120. rotation: Vector3;
  18121. /**
  18122. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18123. */
  18124. rotationQuaternion: Quaternion;
  18125. /**
  18126. * Define the current speed of the camera
  18127. */
  18128. speed: number;
  18129. /**
  18130. * Add constraint to the camera to prevent it to move freely in all directions and
  18131. * around all axis.
  18132. */
  18133. noRotationConstraint: boolean;
  18134. /**
  18135. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18136. * panning
  18137. */
  18138. invertRotation: boolean;
  18139. /**
  18140. * Speed multiplier for inverse camera panning
  18141. */
  18142. inverseRotationSpeed: number;
  18143. /**
  18144. * Define the current target of the camera as an object or a position.
  18145. */
  18146. lockedTarget: any;
  18147. /** @hidden */
  18148. _currentTarget: Vector3;
  18149. /** @hidden */
  18150. _initialFocalDistance: number;
  18151. /** @hidden */
  18152. _viewMatrix: Matrix;
  18153. /** @hidden */
  18154. _camMatrix: Matrix;
  18155. /** @hidden */
  18156. _cameraTransformMatrix: Matrix;
  18157. /** @hidden */
  18158. _cameraRotationMatrix: Matrix;
  18159. /** @hidden */
  18160. _referencePoint: Vector3;
  18161. /** @hidden */
  18162. _transformedReferencePoint: Vector3;
  18163. /** @hidden */
  18164. _reset: () => void;
  18165. private _defaultUp;
  18166. /**
  18167. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18168. * This is the base of the follow, arc rotate cameras and Free camera
  18169. * @see https://doc.babylonjs.com/features/cameras
  18170. * @param name Defines the name of the camera in the scene
  18171. * @param position Defines the start position of the camera in the scene
  18172. * @param scene Defines the scene the camera belongs to
  18173. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18174. */
  18175. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18176. /**
  18177. * Gets the position in front of the camera at a given distance.
  18178. * @param distance The distance from the camera we want the position to be
  18179. * @returns the position
  18180. */
  18181. getFrontPosition(distance: number): Vector3;
  18182. /** @hidden */
  18183. _getLockedTargetPosition(): Nullable<Vector3>;
  18184. private _storedPosition;
  18185. private _storedRotation;
  18186. private _storedRotationQuaternion;
  18187. /**
  18188. * Store current camera state of the camera (fov, position, rotation, etc..)
  18189. * @returns the camera
  18190. */
  18191. storeState(): Camera;
  18192. /**
  18193. * Restored camera state. You must call storeState() first
  18194. * @returns whether it was successful or not
  18195. * @hidden
  18196. */
  18197. _restoreStateValues(): boolean;
  18198. /** @hidden */
  18199. _initCache(): void;
  18200. /** @hidden */
  18201. _updateCache(ignoreParentClass?: boolean): void;
  18202. /** @hidden */
  18203. _isSynchronizedViewMatrix(): boolean;
  18204. /** @hidden */
  18205. _computeLocalCameraSpeed(): number;
  18206. /**
  18207. * Defines the target the camera should look at.
  18208. * @param target Defines the new target as a Vector or a mesh
  18209. */
  18210. setTarget(target: Vector3): void;
  18211. /**
  18212. * Return the current target position of the camera. This value is expressed in local space.
  18213. * @returns the target position
  18214. */
  18215. getTarget(): Vector3;
  18216. /** @hidden */
  18217. _decideIfNeedsToMove(): boolean;
  18218. /** @hidden */
  18219. _updatePosition(): void;
  18220. /** @hidden */
  18221. _checkInputs(): void;
  18222. protected _updateCameraRotationMatrix(): void;
  18223. /**
  18224. * 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)
  18225. * @returns the current camera
  18226. */
  18227. private _rotateUpVectorWithCameraRotationMatrix;
  18228. private _cachedRotationZ;
  18229. private _cachedQuaternionRotationZ;
  18230. /** @hidden */
  18231. _getViewMatrix(): Matrix;
  18232. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18233. /**
  18234. * @hidden
  18235. */
  18236. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18237. /**
  18238. * @hidden
  18239. */
  18240. _updateRigCameras(): void;
  18241. private _getRigCamPositionAndTarget;
  18242. /**
  18243. * Gets the current object class name.
  18244. * @return the class name
  18245. */
  18246. getClassName(): string;
  18247. }
  18248. }
  18249. declare module BABYLON {
  18250. /**
  18251. * Gather the list of keyboard event types as constants.
  18252. */
  18253. export class KeyboardEventTypes {
  18254. /**
  18255. * The keydown event is fired when a key becomes active (pressed).
  18256. */
  18257. static readonly KEYDOWN: number;
  18258. /**
  18259. * The keyup event is fired when a key has been released.
  18260. */
  18261. static readonly KEYUP: number;
  18262. }
  18263. /**
  18264. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18265. */
  18266. export class KeyboardInfo {
  18267. /**
  18268. * Defines the type of event (KeyboardEventTypes)
  18269. */
  18270. type: number;
  18271. /**
  18272. * Defines the related dom event
  18273. */
  18274. event: KeyboardEvent;
  18275. /**
  18276. * Instantiates a new keyboard info.
  18277. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18278. * @param type Defines the type of event (KeyboardEventTypes)
  18279. * @param event Defines the related dom event
  18280. */
  18281. constructor(
  18282. /**
  18283. * Defines the type of event (KeyboardEventTypes)
  18284. */
  18285. type: number,
  18286. /**
  18287. * Defines the related dom event
  18288. */
  18289. event: KeyboardEvent);
  18290. }
  18291. /**
  18292. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18293. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18294. */
  18295. export class KeyboardInfoPre extends KeyboardInfo {
  18296. /**
  18297. * Defines the type of event (KeyboardEventTypes)
  18298. */
  18299. type: number;
  18300. /**
  18301. * Defines the related dom event
  18302. */
  18303. event: KeyboardEvent;
  18304. /**
  18305. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18306. */
  18307. skipOnPointerObservable: boolean;
  18308. /**
  18309. * Instantiates a new keyboard pre info.
  18310. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18311. * @param type Defines the type of event (KeyboardEventTypes)
  18312. * @param event Defines the related dom event
  18313. */
  18314. constructor(
  18315. /**
  18316. * Defines the type of event (KeyboardEventTypes)
  18317. */
  18318. type: number,
  18319. /**
  18320. * Defines the related dom event
  18321. */
  18322. event: KeyboardEvent);
  18323. }
  18324. }
  18325. declare module BABYLON {
  18326. /**
  18327. * Manage the keyboard inputs to control the movement of a free camera.
  18328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18329. */
  18330. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18331. /**
  18332. * Defines the camera the input is attached to.
  18333. */
  18334. camera: FreeCamera;
  18335. /**
  18336. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18337. */
  18338. keysUp: number[];
  18339. /**
  18340. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18341. */
  18342. keysUpward: number[];
  18343. /**
  18344. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18345. */
  18346. keysDown: number[];
  18347. /**
  18348. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18349. */
  18350. keysDownward: number[];
  18351. /**
  18352. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18353. */
  18354. keysLeft: number[];
  18355. /**
  18356. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18357. */
  18358. keysRight: number[];
  18359. private _keys;
  18360. private _onCanvasBlurObserver;
  18361. private _onKeyboardObserver;
  18362. private _engine;
  18363. private _scene;
  18364. /**
  18365. * Attach the input controls to a specific dom element to get the input from.
  18366. * @param element Defines the element the controls should be listened from
  18367. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18368. */
  18369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18370. /**
  18371. * Detach the current controls from the specified dom element.
  18372. * @param element Defines the element to stop listening the inputs from
  18373. */
  18374. detachControl(element: Nullable<HTMLElement>): void;
  18375. /**
  18376. * Update the current camera state depending on the inputs that have been used this frame.
  18377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18378. */
  18379. checkInputs(): void;
  18380. /**
  18381. * Gets the class name of the current intput.
  18382. * @returns the class name
  18383. */
  18384. getClassName(): string;
  18385. /** @hidden */
  18386. _onLostFocus(): void;
  18387. /**
  18388. * Get the friendly name associated with the input class.
  18389. * @returns the input friendly name
  18390. */
  18391. getSimpleName(): string;
  18392. }
  18393. }
  18394. declare module BABYLON {
  18395. /**
  18396. * Gather the list of pointer event types as constants.
  18397. */
  18398. export class PointerEventTypes {
  18399. /**
  18400. * 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.
  18401. */
  18402. static readonly POINTERDOWN: number;
  18403. /**
  18404. * The pointerup event is fired when a pointer is no longer active.
  18405. */
  18406. static readonly POINTERUP: number;
  18407. /**
  18408. * The pointermove event is fired when a pointer changes coordinates.
  18409. */
  18410. static readonly POINTERMOVE: number;
  18411. /**
  18412. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18413. */
  18414. static readonly POINTERWHEEL: number;
  18415. /**
  18416. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18417. */
  18418. static readonly POINTERPICK: number;
  18419. /**
  18420. * The pointertap event is fired when a the object has been touched and released without drag.
  18421. */
  18422. static readonly POINTERTAP: number;
  18423. /**
  18424. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18425. */
  18426. static readonly POINTERDOUBLETAP: number;
  18427. }
  18428. /**
  18429. * Base class of pointer info types.
  18430. */
  18431. export class PointerInfoBase {
  18432. /**
  18433. * Defines the type of event (PointerEventTypes)
  18434. */
  18435. type: number;
  18436. /**
  18437. * Defines the related dom event
  18438. */
  18439. event: PointerEvent | MouseWheelEvent;
  18440. /**
  18441. * Instantiates the base class of pointers info.
  18442. * @param type Defines the type of event (PointerEventTypes)
  18443. * @param event Defines the related dom event
  18444. */
  18445. constructor(
  18446. /**
  18447. * Defines the type of event (PointerEventTypes)
  18448. */
  18449. type: number,
  18450. /**
  18451. * Defines the related dom event
  18452. */
  18453. event: PointerEvent | MouseWheelEvent);
  18454. }
  18455. /**
  18456. * This class is used to store pointer related info for the onPrePointerObservable event.
  18457. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18458. */
  18459. export class PointerInfoPre extends PointerInfoBase {
  18460. /**
  18461. * Ray from a pointer if availible (eg. 6dof controller)
  18462. */
  18463. ray: Nullable<Ray>;
  18464. /**
  18465. * Defines the local position of the pointer on the canvas.
  18466. */
  18467. localPosition: Vector2;
  18468. /**
  18469. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18470. */
  18471. skipOnPointerObservable: boolean;
  18472. /**
  18473. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18474. * @param type Defines the type of event (PointerEventTypes)
  18475. * @param event Defines the related dom event
  18476. * @param localX Defines the local x coordinates of the pointer when the event occured
  18477. * @param localY Defines the local y coordinates of the pointer when the event occured
  18478. */
  18479. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18480. }
  18481. /**
  18482. * This type contains all the data related to a pointer event in Babylon.js.
  18483. * 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.
  18484. */
  18485. export class PointerInfo extends PointerInfoBase {
  18486. /**
  18487. * Defines the picking info associated to the info (if any)\
  18488. */
  18489. pickInfo: Nullable<PickingInfo>;
  18490. /**
  18491. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18492. * @param type Defines the type of event (PointerEventTypes)
  18493. * @param event Defines the related dom event
  18494. * @param pickInfo Defines the picking info associated to the info (if any)\
  18495. */
  18496. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18497. /**
  18498. * Defines the picking info associated to the info (if any)\
  18499. */
  18500. pickInfo: Nullable<PickingInfo>);
  18501. }
  18502. /**
  18503. * Data relating to a touch event on the screen.
  18504. */
  18505. export interface PointerTouch {
  18506. /**
  18507. * X coordinate of touch.
  18508. */
  18509. x: number;
  18510. /**
  18511. * Y coordinate of touch.
  18512. */
  18513. y: number;
  18514. /**
  18515. * Id of touch. Unique for each finger.
  18516. */
  18517. pointerId: number;
  18518. /**
  18519. * Event type passed from DOM.
  18520. */
  18521. type: any;
  18522. }
  18523. }
  18524. declare module BABYLON {
  18525. /**
  18526. * Manage the mouse inputs to control the movement of a free camera.
  18527. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18528. */
  18529. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18530. /**
  18531. * Define if touch is enabled in the mouse input
  18532. */
  18533. touchEnabled: boolean;
  18534. /**
  18535. * Defines the camera the input is attached to.
  18536. */
  18537. camera: FreeCamera;
  18538. /**
  18539. * Defines the buttons associated with the input to handle camera move.
  18540. */
  18541. buttons: number[];
  18542. /**
  18543. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18544. */
  18545. angularSensibility: number;
  18546. private _pointerInput;
  18547. private _onMouseMove;
  18548. private _observer;
  18549. private previousPosition;
  18550. /**
  18551. * Observable for when a pointer move event occurs containing the move offset
  18552. */
  18553. onPointerMovedObservable: Observable<{
  18554. offsetX: number;
  18555. offsetY: number;
  18556. }>;
  18557. /**
  18558. * @hidden
  18559. * If the camera should be rotated automatically based on pointer movement
  18560. */
  18561. _allowCameraRotation: boolean;
  18562. /**
  18563. * Manage the mouse inputs to control the movement of a free camera.
  18564. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18565. * @param touchEnabled Defines if touch is enabled or not
  18566. */
  18567. constructor(
  18568. /**
  18569. * Define if touch is enabled in the mouse input
  18570. */
  18571. touchEnabled?: boolean);
  18572. /**
  18573. * Attach the input controls to a specific dom element to get the input from.
  18574. * @param element Defines the element the controls should be listened from
  18575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18576. */
  18577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18578. /**
  18579. * Called on JS contextmenu event.
  18580. * Override this method to provide functionality.
  18581. */
  18582. protected onContextMenu(evt: PointerEvent): void;
  18583. /**
  18584. * Detach the current controls from the specified dom element.
  18585. * @param element Defines the element to stop listening the inputs from
  18586. */
  18587. detachControl(element: Nullable<HTMLElement>): void;
  18588. /**
  18589. * Gets the class name of the current intput.
  18590. * @returns the class name
  18591. */
  18592. getClassName(): string;
  18593. /**
  18594. * Get the friendly name associated with the input class.
  18595. * @returns the input friendly name
  18596. */
  18597. getSimpleName(): string;
  18598. }
  18599. }
  18600. declare module BABYLON {
  18601. /**
  18602. * Manage the touch inputs to control the movement of a free camera.
  18603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18604. */
  18605. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18606. /**
  18607. * Defines the camera the input is attached to.
  18608. */
  18609. camera: FreeCamera;
  18610. /**
  18611. * Defines the touch sensibility for rotation.
  18612. * The higher the faster.
  18613. */
  18614. touchAngularSensibility: number;
  18615. /**
  18616. * Defines the touch sensibility for move.
  18617. * The higher the faster.
  18618. */
  18619. touchMoveSensibility: number;
  18620. private _offsetX;
  18621. private _offsetY;
  18622. private _pointerPressed;
  18623. private _pointerInput;
  18624. private _observer;
  18625. private _onLostFocus;
  18626. /**
  18627. * Attach the input controls to a specific dom element to get the input from.
  18628. * @param element Defines the element the controls should be listened from
  18629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18630. */
  18631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18632. /**
  18633. * Detach the current controls from the specified dom element.
  18634. * @param element Defines the element to stop listening the inputs from
  18635. */
  18636. detachControl(element: Nullable<HTMLElement>): void;
  18637. /**
  18638. * Update the current camera state depending on the inputs that have been used this frame.
  18639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18640. */
  18641. checkInputs(): void;
  18642. /**
  18643. * Gets the class name of the current intput.
  18644. * @returns the class name
  18645. */
  18646. getClassName(): string;
  18647. /**
  18648. * Get the friendly name associated with the input class.
  18649. * @returns the input friendly name
  18650. */
  18651. getSimpleName(): string;
  18652. }
  18653. }
  18654. declare module BABYLON {
  18655. /**
  18656. * Default Inputs manager for the FreeCamera.
  18657. * It groups all the default supported inputs for ease of use.
  18658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18659. */
  18660. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18661. /**
  18662. * @hidden
  18663. */
  18664. _mouseInput: Nullable<FreeCameraMouseInput>;
  18665. /**
  18666. * Instantiates a new FreeCameraInputsManager.
  18667. * @param camera Defines the camera the inputs belong to
  18668. */
  18669. constructor(camera: FreeCamera);
  18670. /**
  18671. * Add keyboard input support to the input manager.
  18672. * @returns the current input manager
  18673. */
  18674. addKeyboard(): FreeCameraInputsManager;
  18675. /**
  18676. * Add mouse input support to the input manager.
  18677. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18678. * @returns the current input manager
  18679. */
  18680. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18681. /**
  18682. * Removes the mouse input support from the manager
  18683. * @returns the current input manager
  18684. */
  18685. removeMouse(): FreeCameraInputsManager;
  18686. /**
  18687. * Add touch input support to the input manager.
  18688. * @returns the current input manager
  18689. */
  18690. addTouch(): FreeCameraInputsManager;
  18691. /**
  18692. * Remove all attached input methods from a camera
  18693. */
  18694. clear(): void;
  18695. }
  18696. }
  18697. declare module BABYLON {
  18698. /**
  18699. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18700. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18701. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18702. */
  18703. export class FreeCamera extends TargetCamera {
  18704. /**
  18705. * Define the collision ellipsoid of the camera.
  18706. * This is helpful to simulate a camera body like the player body around the camera
  18707. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18708. */
  18709. ellipsoid: Vector3;
  18710. /**
  18711. * Define an offset for the position of the ellipsoid around the camera.
  18712. * This can be helpful to determine the center of the body near the gravity center of the body
  18713. * instead of its head.
  18714. */
  18715. ellipsoidOffset: Vector3;
  18716. /**
  18717. * Enable or disable collisions of the camera with the rest of the scene objects.
  18718. */
  18719. checkCollisions: boolean;
  18720. /**
  18721. * Enable or disable gravity on the camera.
  18722. */
  18723. applyGravity: boolean;
  18724. /**
  18725. * Define the input manager associated to the camera.
  18726. */
  18727. inputs: FreeCameraInputsManager;
  18728. /**
  18729. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18730. * Higher values reduce sensitivity.
  18731. */
  18732. get angularSensibility(): number;
  18733. /**
  18734. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18735. * Higher values reduce sensitivity.
  18736. */
  18737. set angularSensibility(value: number);
  18738. /**
  18739. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18740. */
  18741. get keysUp(): number[];
  18742. set keysUp(value: number[]);
  18743. /**
  18744. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18745. */
  18746. get keysUpward(): number[];
  18747. set keysUpward(value: number[]);
  18748. /**
  18749. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18750. */
  18751. get keysDown(): number[];
  18752. set keysDown(value: number[]);
  18753. /**
  18754. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18755. */
  18756. get keysDownward(): number[];
  18757. set keysDownward(value: number[]);
  18758. /**
  18759. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18760. */
  18761. get keysLeft(): number[];
  18762. set keysLeft(value: number[]);
  18763. /**
  18764. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18765. */
  18766. get keysRight(): number[];
  18767. set keysRight(value: number[]);
  18768. /**
  18769. * Event raised when the camera collide with a mesh in the scene.
  18770. */
  18771. onCollide: (collidedMesh: AbstractMesh) => void;
  18772. private _collider;
  18773. private _needMoveForGravity;
  18774. private _oldPosition;
  18775. private _diffPosition;
  18776. private _newPosition;
  18777. /** @hidden */
  18778. _localDirection: Vector3;
  18779. /** @hidden */
  18780. _transformedDirection: Vector3;
  18781. /**
  18782. * Instantiates a Free Camera.
  18783. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18784. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18785. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18786. * @param name Define the name of the camera in the scene
  18787. * @param position Define the start position of the camera in the scene
  18788. * @param scene Define the scene the camera belongs to
  18789. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18790. */
  18791. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18792. /**
  18793. * Attached controls to the current camera.
  18794. * @param element Defines the element the controls should be listened from
  18795. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18796. */
  18797. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18798. /**
  18799. * Detach the current controls from the camera.
  18800. * The camera will stop reacting to inputs.
  18801. * @param element Defines the element to stop listening the inputs from
  18802. */
  18803. detachControl(element: HTMLElement): void;
  18804. private _collisionMask;
  18805. /**
  18806. * Define a collision mask to limit the list of object the camera can collide with
  18807. */
  18808. get collisionMask(): number;
  18809. set collisionMask(mask: number);
  18810. /** @hidden */
  18811. _collideWithWorld(displacement: Vector3): void;
  18812. private _onCollisionPositionChange;
  18813. /** @hidden */
  18814. _checkInputs(): void;
  18815. /** @hidden */
  18816. _decideIfNeedsToMove(): boolean;
  18817. /** @hidden */
  18818. _updatePosition(): void;
  18819. /**
  18820. * Destroy the camera and release the current resources hold by it.
  18821. */
  18822. dispose(): void;
  18823. /**
  18824. * Gets the current object class name.
  18825. * @return the class name
  18826. */
  18827. getClassName(): string;
  18828. }
  18829. }
  18830. declare module BABYLON {
  18831. /**
  18832. * Represents a gamepad control stick position
  18833. */
  18834. export class StickValues {
  18835. /**
  18836. * The x component of the control stick
  18837. */
  18838. x: number;
  18839. /**
  18840. * The y component of the control stick
  18841. */
  18842. y: number;
  18843. /**
  18844. * Initializes the gamepad x and y control stick values
  18845. * @param x The x component of the gamepad control stick value
  18846. * @param y The y component of the gamepad control stick value
  18847. */
  18848. constructor(
  18849. /**
  18850. * The x component of the control stick
  18851. */
  18852. x: number,
  18853. /**
  18854. * The y component of the control stick
  18855. */
  18856. y: number);
  18857. }
  18858. /**
  18859. * An interface which manages callbacks for gamepad button changes
  18860. */
  18861. export interface GamepadButtonChanges {
  18862. /**
  18863. * Called when a gamepad has been changed
  18864. */
  18865. changed: boolean;
  18866. /**
  18867. * Called when a gamepad press event has been triggered
  18868. */
  18869. pressChanged: boolean;
  18870. /**
  18871. * Called when a touch event has been triggered
  18872. */
  18873. touchChanged: boolean;
  18874. /**
  18875. * Called when a value has changed
  18876. */
  18877. valueChanged: boolean;
  18878. }
  18879. /**
  18880. * Represents a gamepad
  18881. */
  18882. export class Gamepad {
  18883. /**
  18884. * The id of the gamepad
  18885. */
  18886. id: string;
  18887. /**
  18888. * The index of the gamepad
  18889. */
  18890. index: number;
  18891. /**
  18892. * The browser gamepad
  18893. */
  18894. browserGamepad: any;
  18895. /**
  18896. * Specifies what type of gamepad this represents
  18897. */
  18898. type: number;
  18899. private _leftStick;
  18900. private _rightStick;
  18901. /** @hidden */
  18902. _isConnected: boolean;
  18903. private _leftStickAxisX;
  18904. private _leftStickAxisY;
  18905. private _rightStickAxisX;
  18906. private _rightStickAxisY;
  18907. /**
  18908. * Triggered when the left control stick has been changed
  18909. */
  18910. private _onleftstickchanged;
  18911. /**
  18912. * Triggered when the right control stick has been changed
  18913. */
  18914. private _onrightstickchanged;
  18915. /**
  18916. * Represents a gamepad controller
  18917. */
  18918. static GAMEPAD: number;
  18919. /**
  18920. * Represents a generic controller
  18921. */
  18922. static GENERIC: number;
  18923. /**
  18924. * Represents an XBox controller
  18925. */
  18926. static XBOX: number;
  18927. /**
  18928. * Represents a pose-enabled controller
  18929. */
  18930. static POSE_ENABLED: number;
  18931. /**
  18932. * Represents an Dual Shock controller
  18933. */
  18934. static DUALSHOCK: number;
  18935. /**
  18936. * Specifies whether the left control stick should be Y-inverted
  18937. */
  18938. protected _invertLeftStickY: boolean;
  18939. /**
  18940. * Specifies if the gamepad has been connected
  18941. */
  18942. get isConnected(): boolean;
  18943. /**
  18944. * Initializes the gamepad
  18945. * @param id The id of the gamepad
  18946. * @param index The index of the gamepad
  18947. * @param browserGamepad The browser gamepad
  18948. * @param leftStickX The x component of the left joystick
  18949. * @param leftStickY The y component of the left joystick
  18950. * @param rightStickX The x component of the right joystick
  18951. * @param rightStickY The y component of the right joystick
  18952. */
  18953. constructor(
  18954. /**
  18955. * The id of the gamepad
  18956. */
  18957. id: string,
  18958. /**
  18959. * The index of the gamepad
  18960. */
  18961. index: number,
  18962. /**
  18963. * The browser gamepad
  18964. */
  18965. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18966. /**
  18967. * Callback triggered when the left joystick has changed
  18968. * @param callback
  18969. */
  18970. onleftstickchanged(callback: (values: StickValues) => void): void;
  18971. /**
  18972. * Callback triggered when the right joystick has changed
  18973. * @param callback
  18974. */
  18975. onrightstickchanged(callback: (values: StickValues) => void): void;
  18976. /**
  18977. * Gets the left joystick
  18978. */
  18979. get leftStick(): StickValues;
  18980. /**
  18981. * Sets the left joystick values
  18982. */
  18983. set leftStick(newValues: StickValues);
  18984. /**
  18985. * Gets the right joystick
  18986. */
  18987. get rightStick(): StickValues;
  18988. /**
  18989. * Sets the right joystick value
  18990. */
  18991. set rightStick(newValues: StickValues);
  18992. /**
  18993. * Updates the gamepad joystick positions
  18994. */
  18995. update(): void;
  18996. /**
  18997. * Disposes the gamepad
  18998. */
  18999. dispose(): void;
  19000. }
  19001. /**
  19002. * Represents a generic gamepad
  19003. */
  19004. export class GenericPad extends Gamepad {
  19005. private _buttons;
  19006. private _onbuttondown;
  19007. private _onbuttonup;
  19008. /**
  19009. * Observable triggered when a button has been pressed
  19010. */
  19011. onButtonDownObservable: Observable<number>;
  19012. /**
  19013. * Observable triggered when a button has been released
  19014. */
  19015. onButtonUpObservable: Observable<number>;
  19016. /**
  19017. * Callback triggered when a button has been pressed
  19018. * @param callback Called when a button has been pressed
  19019. */
  19020. onbuttondown(callback: (buttonPressed: number) => void): void;
  19021. /**
  19022. * Callback triggered when a button has been released
  19023. * @param callback Called when a button has been released
  19024. */
  19025. onbuttonup(callback: (buttonReleased: number) => void): void;
  19026. /**
  19027. * Initializes the generic gamepad
  19028. * @param id The id of the generic gamepad
  19029. * @param index The index of the generic gamepad
  19030. * @param browserGamepad The browser gamepad
  19031. */
  19032. constructor(id: string, index: number, browserGamepad: any);
  19033. private _setButtonValue;
  19034. /**
  19035. * Updates the generic gamepad
  19036. */
  19037. update(): void;
  19038. /**
  19039. * Disposes the generic gamepad
  19040. */
  19041. dispose(): void;
  19042. }
  19043. }
  19044. declare module BABYLON {
  19045. /**
  19046. * Defines the types of pose enabled controllers that are supported
  19047. */
  19048. export enum PoseEnabledControllerType {
  19049. /**
  19050. * HTC Vive
  19051. */
  19052. VIVE = 0,
  19053. /**
  19054. * Oculus Rift
  19055. */
  19056. OCULUS = 1,
  19057. /**
  19058. * Windows mixed reality
  19059. */
  19060. WINDOWS = 2,
  19061. /**
  19062. * Samsung gear VR
  19063. */
  19064. GEAR_VR = 3,
  19065. /**
  19066. * Google Daydream
  19067. */
  19068. DAYDREAM = 4,
  19069. /**
  19070. * Generic
  19071. */
  19072. GENERIC = 5
  19073. }
  19074. /**
  19075. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19076. */
  19077. export interface MutableGamepadButton {
  19078. /**
  19079. * Value of the button/trigger
  19080. */
  19081. value: number;
  19082. /**
  19083. * If the button/trigger is currently touched
  19084. */
  19085. touched: boolean;
  19086. /**
  19087. * If the button/trigger is currently pressed
  19088. */
  19089. pressed: boolean;
  19090. }
  19091. /**
  19092. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19093. * @hidden
  19094. */
  19095. export interface ExtendedGamepadButton extends GamepadButton {
  19096. /**
  19097. * If the button/trigger is currently pressed
  19098. */
  19099. readonly pressed: boolean;
  19100. /**
  19101. * If the button/trigger is currently touched
  19102. */
  19103. readonly touched: boolean;
  19104. /**
  19105. * Value of the button/trigger
  19106. */
  19107. readonly value: number;
  19108. }
  19109. /** @hidden */
  19110. export interface _GamePadFactory {
  19111. /**
  19112. * Returns whether or not the current gamepad can be created for this type of controller.
  19113. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19114. * @returns true if it can be created, otherwise false
  19115. */
  19116. canCreate(gamepadInfo: any): boolean;
  19117. /**
  19118. * Creates a new instance of the Gamepad.
  19119. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19120. * @returns the new gamepad instance
  19121. */
  19122. create(gamepadInfo: any): Gamepad;
  19123. }
  19124. /**
  19125. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19126. */
  19127. export class PoseEnabledControllerHelper {
  19128. /** @hidden */
  19129. static _ControllerFactories: _GamePadFactory[];
  19130. /** @hidden */
  19131. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19132. /**
  19133. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19134. * @param vrGamepad the gamepad to initialized
  19135. * @returns a vr controller of the type the gamepad identified as
  19136. */
  19137. static InitiateController(vrGamepad: any): Gamepad;
  19138. }
  19139. /**
  19140. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19141. */
  19142. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19143. /**
  19144. * If the controller is used in a webXR session
  19145. */
  19146. isXR: boolean;
  19147. private _deviceRoomPosition;
  19148. private _deviceRoomRotationQuaternion;
  19149. /**
  19150. * The device position in babylon space
  19151. */
  19152. devicePosition: Vector3;
  19153. /**
  19154. * The device rotation in babylon space
  19155. */
  19156. deviceRotationQuaternion: Quaternion;
  19157. /**
  19158. * The scale factor of the device in babylon space
  19159. */
  19160. deviceScaleFactor: number;
  19161. /**
  19162. * (Likely devicePosition should be used instead) The device position in its room space
  19163. */
  19164. position: Vector3;
  19165. /**
  19166. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19167. */
  19168. rotationQuaternion: Quaternion;
  19169. /**
  19170. * The type of controller (Eg. Windows mixed reality)
  19171. */
  19172. controllerType: PoseEnabledControllerType;
  19173. protected _calculatedPosition: Vector3;
  19174. private _calculatedRotation;
  19175. /**
  19176. * The raw pose from the device
  19177. */
  19178. rawPose: DevicePose;
  19179. private _trackPosition;
  19180. private _maxRotationDistFromHeadset;
  19181. private _draggedRoomRotation;
  19182. /**
  19183. * @hidden
  19184. */
  19185. _disableTrackPosition(fixedPosition: Vector3): void;
  19186. /**
  19187. * Internal, the mesh attached to the controller
  19188. * @hidden
  19189. */
  19190. _mesh: Nullable<AbstractMesh>;
  19191. private _poseControlledCamera;
  19192. private _leftHandSystemQuaternion;
  19193. /**
  19194. * Internal, matrix used to convert room space to babylon space
  19195. * @hidden
  19196. */
  19197. _deviceToWorld: Matrix;
  19198. /**
  19199. * Node to be used when casting a ray from the controller
  19200. * @hidden
  19201. */
  19202. _pointingPoseNode: Nullable<TransformNode>;
  19203. /**
  19204. * Name of the child mesh that can be used to cast a ray from the controller
  19205. */
  19206. static readonly POINTING_POSE: string;
  19207. /**
  19208. * Creates a new PoseEnabledController from a gamepad
  19209. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19210. */
  19211. constructor(browserGamepad: any);
  19212. private _workingMatrix;
  19213. /**
  19214. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19215. */
  19216. update(): void;
  19217. /**
  19218. * Updates only the pose device and mesh without doing any button event checking
  19219. */
  19220. protected _updatePoseAndMesh(): void;
  19221. /**
  19222. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19223. * @param poseData raw pose fromthe device
  19224. */
  19225. updateFromDevice(poseData: DevicePose): void;
  19226. /**
  19227. * @hidden
  19228. */
  19229. _meshAttachedObservable: Observable<AbstractMesh>;
  19230. /**
  19231. * Attaches a mesh to the controller
  19232. * @param mesh the mesh to be attached
  19233. */
  19234. attachToMesh(mesh: AbstractMesh): void;
  19235. /**
  19236. * Attaches the controllers mesh to a camera
  19237. * @param camera the camera the mesh should be attached to
  19238. */
  19239. attachToPoseControlledCamera(camera: TargetCamera): void;
  19240. /**
  19241. * Disposes of the controller
  19242. */
  19243. dispose(): void;
  19244. /**
  19245. * The mesh that is attached to the controller
  19246. */
  19247. get mesh(): Nullable<AbstractMesh>;
  19248. /**
  19249. * Gets the ray of the controller in the direction the controller is pointing
  19250. * @param length the length the resulting ray should be
  19251. * @returns a ray in the direction the controller is pointing
  19252. */
  19253. getForwardRay(length?: number): Ray;
  19254. }
  19255. }
  19256. declare module BABYLON {
  19257. /**
  19258. * Defines the WebVRController object that represents controllers tracked in 3D space
  19259. */
  19260. export abstract class WebVRController extends PoseEnabledController {
  19261. /**
  19262. * Internal, the default controller model for the controller
  19263. */
  19264. protected _defaultModel: Nullable<AbstractMesh>;
  19265. /**
  19266. * Fired when the trigger state has changed
  19267. */
  19268. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19269. /**
  19270. * Fired when the main button state has changed
  19271. */
  19272. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19273. /**
  19274. * Fired when the secondary button state has changed
  19275. */
  19276. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19277. /**
  19278. * Fired when the pad state has changed
  19279. */
  19280. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19281. /**
  19282. * Fired when controllers stick values have changed
  19283. */
  19284. onPadValuesChangedObservable: Observable<StickValues>;
  19285. /**
  19286. * Array of button availible on the controller
  19287. */
  19288. protected _buttons: Array<MutableGamepadButton>;
  19289. private _onButtonStateChange;
  19290. /**
  19291. * Fired when a controller button's state has changed
  19292. * @param callback the callback containing the button that was modified
  19293. */
  19294. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19295. /**
  19296. * X and Y axis corresponding to the controllers joystick
  19297. */
  19298. pad: StickValues;
  19299. /**
  19300. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19301. */
  19302. hand: string;
  19303. /**
  19304. * The default controller model for the controller
  19305. */
  19306. get defaultModel(): Nullable<AbstractMesh>;
  19307. /**
  19308. * Creates a new WebVRController from a gamepad
  19309. * @param vrGamepad the gamepad that the WebVRController should be created from
  19310. */
  19311. constructor(vrGamepad: any);
  19312. /**
  19313. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19314. */
  19315. update(): void;
  19316. /**
  19317. * Function to be called when a button is modified
  19318. */
  19319. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19320. /**
  19321. * Loads a mesh and attaches it to the controller
  19322. * @param scene the scene the mesh should be added to
  19323. * @param meshLoaded callback for when the mesh has been loaded
  19324. */
  19325. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19326. private _setButtonValue;
  19327. private _changes;
  19328. private _checkChanges;
  19329. /**
  19330. * Disposes of th webVRCOntroller
  19331. */
  19332. dispose(): void;
  19333. }
  19334. }
  19335. declare module BABYLON {
  19336. /**
  19337. * The HemisphericLight simulates the ambient environment light,
  19338. * so the passed direction is the light reflection direction, not the incoming direction.
  19339. */
  19340. export class HemisphericLight extends Light {
  19341. /**
  19342. * The groundColor is the light in the opposite direction to the one specified during creation.
  19343. * 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.
  19344. */
  19345. groundColor: Color3;
  19346. /**
  19347. * The light reflection direction, not the incoming direction.
  19348. */
  19349. direction: Vector3;
  19350. /**
  19351. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19352. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19353. * The HemisphericLight can't cast shadows.
  19354. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19355. * @param name The friendly name of the light
  19356. * @param direction The direction of the light reflection
  19357. * @param scene The scene the light belongs to
  19358. */
  19359. constructor(name: string, direction: Vector3, scene: Scene);
  19360. protected _buildUniformLayout(): void;
  19361. /**
  19362. * Returns the string "HemisphericLight".
  19363. * @return The class name
  19364. */
  19365. getClassName(): string;
  19366. /**
  19367. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19368. * Returns the updated direction.
  19369. * @param target The target the direction should point to
  19370. * @return The computed direction
  19371. */
  19372. setDirectionToTarget(target: Vector3): Vector3;
  19373. /**
  19374. * Returns the shadow generator associated to the light.
  19375. * @returns Always null for hemispheric lights because it does not support shadows.
  19376. */
  19377. getShadowGenerator(): Nullable<IShadowGenerator>;
  19378. /**
  19379. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19380. * @param effect The effect to update
  19381. * @param lightIndex The index of the light in the effect to update
  19382. * @returns The hemispheric light
  19383. */
  19384. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19385. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19386. /**
  19387. * Computes the world matrix of the node
  19388. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19389. * @param useWasUpdatedFlag defines a reserved property
  19390. * @returns the world matrix
  19391. */
  19392. computeWorldMatrix(): Matrix;
  19393. /**
  19394. * Returns the integer 3.
  19395. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19396. */
  19397. getTypeID(): number;
  19398. /**
  19399. * Prepares the list of defines specific to the light type.
  19400. * @param defines the list of defines
  19401. * @param lightIndex defines the index of the light for the effect
  19402. */
  19403. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19404. }
  19405. }
  19406. declare module BABYLON {
  19407. /** @hidden */
  19408. export var vrMultiviewToSingleviewPixelShader: {
  19409. name: string;
  19410. shader: string;
  19411. };
  19412. }
  19413. declare module BABYLON {
  19414. /**
  19415. * Renders to multiple views with a single draw call
  19416. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19417. */
  19418. export class MultiviewRenderTarget extends RenderTargetTexture {
  19419. /**
  19420. * Creates a multiview render target
  19421. * @param scene scene used with the render target
  19422. * @param size the size of the render target (used for each view)
  19423. */
  19424. constructor(scene: Scene, size?: number | {
  19425. width: number;
  19426. height: number;
  19427. } | {
  19428. ratio: number;
  19429. });
  19430. /**
  19431. * @hidden
  19432. * @param faceIndex the face index, if its a cube texture
  19433. */
  19434. _bindFrameBuffer(faceIndex?: number): void;
  19435. /**
  19436. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19437. * @returns the view count
  19438. */
  19439. getViewCount(): number;
  19440. }
  19441. }
  19442. declare module BABYLON {
  19443. interface Engine {
  19444. /**
  19445. * Creates a new multiview render target
  19446. * @param width defines the width of the texture
  19447. * @param height defines the height of the texture
  19448. * @returns the created multiview texture
  19449. */
  19450. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19451. /**
  19452. * Binds a multiview framebuffer to be drawn to
  19453. * @param multiviewTexture texture to bind
  19454. */
  19455. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19456. }
  19457. interface Camera {
  19458. /**
  19459. * @hidden
  19460. * 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)
  19461. */
  19462. _useMultiviewToSingleView: boolean;
  19463. /**
  19464. * @hidden
  19465. * 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)
  19466. */
  19467. _multiviewTexture: Nullable<RenderTargetTexture>;
  19468. /**
  19469. * @hidden
  19470. * ensures the multiview texture of the camera exists and has the specified width/height
  19471. * @param width height to set on the multiview texture
  19472. * @param height width to set on the multiview texture
  19473. */
  19474. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19475. }
  19476. interface Scene {
  19477. /** @hidden */
  19478. _transformMatrixR: Matrix;
  19479. /** @hidden */
  19480. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19481. /** @hidden */
  19482. _createMultiviewUbo(): void;
  19483. /** @hidden */
  19484. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19485. /** @hidden */
  19486. _renderMultiviewToSingleView(camera: Camera): void;
  19487. }
  19488. }
  19489. declare module BABYLON {
  19490. /**
  19491. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19492. * This will not be used for webXR as it supports displaying texture arrays directly
  19493. */
  19494. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19495. /**
  19496. * Initializes a VRMultiviewToSingleview
  19497. * @param name name of the post process
  19498. * @param camera camera to be applied to
  19499. * @param scaleFactor scaling factor to the size of the output texture
  19500. */
  19501. constructor(name: string, camera: Camera, scaleFactor: number);
  19502. }
  19503. }
  19504. declare module BABYLON {
  19505. /**
  19506. * Interface used to define additional presentation attributes
  19507. */
  19508. export interface IVRPresentationAttributes {
  19509. /**
  19510. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19511. */
  19512. highRefreshRate: boolean;
  19513. /**
  19514. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19515. */
  19516. foveationLevel: number;
  19517. }
  19518. interface Engine {
  19519. /** @hidden */
  19520. _vrDisplay: any;
  19521. /** @hidden */
  19522. _vrSupported: boolean;
  19523. /** @hidden */
  19524. _oldSize: Size;
  19525. /** @hidden */
  19526. _oldHardwareScaleFactor: number;
  19527. /** @hidden */
  19528. _vrExclusivePointerMode: boolean;
  19529. /** @hidden */
  19530. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19531. /** @hidden */
  19532. _onVRDisplayPointerRestricted: () => void;
  19533. /** @hidden */
  19534. _onVRDisplayPointerUnrestricted: () => void;
  19535. /** @hidden */
  19536. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19537. /** @hidden */
  19538. _onVrDisplayDisconnect: Nullable<() => void>;
  19539. /** @hidden */
  19540. _onVrDisplayPresentChange: Nullable<() => void>;
  19541. /**
  19542. * Observable signaled when VR display mode changes
  19543. */
  19544. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19545. /**
  19546. * Observable signaled when VR request present is complete
  19547. */
  19548. onVRRequestPresentComplete: Observable<boolean>;
  19549. /**
  19550. * Observable signaled when VR request present starts
  19551. */
  19552. onVRRequestPresentStart: Observable<Engine>;
  19553. /**
  19554. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19555. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19556. */
  19557. isInVRExclusivePointerMode: boolean;
  19558. /**
  19559. * Gets a boolean indicating if a webVR device was detected
  19560. * @returns true if a webVR device was detected
  19561. */
  19562. isVRDevicePresent(): boolean;
  19563. /**
  19564. * Gets the current webVR device
  19565. * @returns the current webVR device (or null)
  19566. */
  19567. getVRDevice(): any;
  19568. /**
  19569. * Initializes a webVR display and starts listening to display change events
  19570. * The onVRDisplayChangedObservable will be notified upon these changes
  19571. * @returns A promise containing a VRDisplay and if vr is supported
  19572. */
  19573. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19574. /** @hidden */
  19575. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19576. /**
  19577. * Gets or sets the presentation attributes used to configure VR rendering
  19578. */
  19579. vrPresentationAttributes?: IVRPresentationAttributes;
  19580. /**
  19581. * Call this function to switch to webVR mode
  19582. * Will do nothing if webVR is not supported or if there is no webVR device
  19583. * @param options the webvr options provided to the camera. mainly used for multiview
  19584. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19585. */
  19586. enableVR(options: WebVROptions): void;
  19587. /** @hidden */
  19588. _onVRFullScreenTriggered(): void;
  19589. }
  19590. }
  19591. declare module BABYLON {
  19592. /**
  19593. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19594. * IMPORTANT!! The data is right-hand data.
  19595. * @export
  19596. * @interface DevicePose
  19597. */
  19598. export interface DevicePose {
  19599. /**
  19600. * The position of the device, values in array are [x,y,z].
  19601. */
  19602. readonly position: Nullable<Float32Array>;
  19603. /**
  19604. * The linearVelocity of the device, values in array are [x,y,z].
  19605. */
  19606. readonly linearVelocity: Nullable<Float32Array>;
  19607. /**
  19608. * The linearAcceleration of the device, values in array are [x,y,z].
  19609. */
  19610. readonly linearAcceleration: Nullable<Float32Array>;
  19611. /**
  19612. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19613. */
  19614. readonly orientation: Nullable<Float32Array>;
  19615. /**
  19616. * The angularVelocity of the device, values in array are [x,y,z].
  19617. */
  19618. readonly angularVelocity: Nullable<Float32Array>;
  19619. /**
  19620. * The angularAcceleration of the device, values in array are [x,y,z].
  19621. */
  19622. readonly angularAcceleration: Nullable<Float32Array>;
  19623. }
  19624. /**
  19625. * Interface representing a pose controlled object in Babylon.
  19626. * A pose controlled object has both regular pose values as well as pose values
  19627. * from an external device such as a VR head mounted display
  19628. */
  19629. export interface PoseControlled {
  19630. /**
  19631. * The position of the object in babylon space.
  19632. */
  19633. position: Vector3;
  19634. /**
  19635. * The rotation quaternion of the object in babylon space.
  19636. */
  19637. rotationQuaternion: Quaternion;
  19638. /**
  19639. * The position of the device in babylon space.
  19640. */
  19641. devicePosition?: Vector3;
  19642. /**
  19643. * The rotation quaternion of the device in babylon space.
  19644. */
  19645. deviceRotationQuaternion: Quaternion;
  19646. /**
  19647. * The raw pose coming from the device.
  19648. */
  19649. rawPose: Nullable<DevicePose>;
  19650. /**
  19651. * The scale of the device to be used when translating from device space to babylon space.
  19652. */
  19653. deviceScaleFactor: number;
  19654. /**
  19655. * Updates the poseControlled values based on the input device pose.
  19656. * @param poseData the pose data to update the object with
  19657. */
  19658. updateFromDevice(poseData: DevicePose): void;
  19659. }
  19660. /**
  19661. * Set of options to customize the webVRCamera
  19662. */
  19663. export interface WebVROptions {
  19664. /**
  19665. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19666. */
  19667. trackPosition?: boolean;
  19668. /**
  19669. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19670. */
  19671. positionScale?: number;
  19672. /**
  19673. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19674. */
  19675. displayName?: string;
  19676. /**
  19677. * Should the native controller meshes be initialized. (default: true)
  19678. */
  19679. controllerMeshes?: boolean;
  19680. /**
  19681. * Creating a default HemiLight only on controllers. (default: true)
  19682. */
  19683. defaultLightingOnControllers?: boolean;
  19684. /**
  19685. * If you don't want to use the default VR button of the helper. (default: false)
  19686. */
  19687. useCustomVRButton?: boolean;
  19688. /**
  19689. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19690. */
  19691. customVRButton?: HTMLButtonElement;
  19692. /**
  19693. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19694. */
  19695. rayLength?: number;
  19696. /**
  19697. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19698. */
  19699. defaultHeight?: number;
  19700. /**
  19701. * If multiview should be used if availible (default: false)
  19702. */
  19703. useMultiview?: boolean;
  19704. }
  19705. /**
  19706. * This represents a WebVR camera.
  19707. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19708. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19709. */
  19710. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19711. private webVROptions;
  19712. /**
  19713. * @hidden
  19714. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19715. */
  19716. _vrDevice: any;
  19717. /**
  19718. * The rawPose of the vrDevice.
  19719. */
  19720. rawPose: Nullable<DevicePose>;
  19721. private _onVREnabled;
  19722. private _specsVersion;
  19723. private _attached;
  19724. private _frameData;
  19725. protected _descendants: Array<Node>;
  19726. private _deviceRoomPosition;
  19727. /** @hidden */
  19728. _deviceRoomRotationQuaternion: Quaternion;
  19729. private _standingMatrix;
  19730. /**
  19731. * Represents device position in babylon space.
  19732. */
  19733. devicePosition: Vector3;
  19734. /**
  19735. * Represents device rotation in babylon space.
  19736. */
  19737. deviceRotationQuaternion: Quaternion;
  19738. /**
  19739. * The scale of the device to be used when translating from device space to babylon space.
  19740. */
  19741. deviceScaleFactor: number;
  19742. private _deviceToWorld;
  19743. private _worldToDevice;
  19744. /**
  19745. * References to the webVR controllers for the vrDevice.
  19746. */
  19747. controllers: Array<WebVRController>;
  19748. /**
  19749. * Emits an event when a controller is attached.
  19750. */
  19751. onControllersAttachedObservable: Observable<WebVRController[]>;
  19752. /**
  19753. * Emits an event when a controller's mesh has been loaded;
  19754. */
  19755. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19756. /**
  19757. * Emits an event when the HMD's pose has been updated.
  19758. */
  19759. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19760. private _poseSet;
  19761. /**
  19762. * If the rig cameras be used as parent instead of this camera.
  19763. */
  19764. rigParenting: boolean;
  19765. private _lightOnControllers;
  19766. private _defaultHeight?;
  19767. /**
  19768. * Instantiates a WebVRFreeCamera.
  19769. * @param name The name of the WebVRFreeCamera
  19770. * @param position The starting anchor position for the camera
  19771. * @param scene The scene the camera belongs to
  19772. * @param webVROptions a set of customizable options for the webVRCamera
  19773. */
  19774. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19775. /**
  19776. * Gets the device distance from the ground in meters.
  19777. * @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.
  19778. */
  19779. deviceDistanceToRoomGround(): number;
  19780. /**
  19781. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19782. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19783. */
  19784. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19785. /**
  19786. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19787. * @returns A promise with a boolean set to if the standing matrix is supported.
  19788. */
  19789. useStandingMatrixAsync(): Promise<boolean>;
  19790. /**
  19791. * Disposes the camera
  19792. */
  19793. dispose(): void;
  19794. /**
  19795. * Gets a vrController by name.
  19796. * @param name The name of the controller to retreive
  19797. * @returns the controller matching the name specified or null if not found
  19798. */
  19799. getControllerByName(name: string): Nullable<WebVRController>;
  19800. private _leftController;
  19801. /**
  19802. * The controller corresponding to the users left hand.
  19803. */
  19804. get leftController(): Nullable<WebVRController>;
  19805. private _rightController;
  19806. /**
  19807. * The controller corresponding to the users right hand.
  19808. */
  19809. get rightController(): Nullable<WebVRController>;
  19810. /**
  19811. * Casts a ray forward from the vrCamera's gaze.
  19812. * @param length Length of the ray (default: 100)
  19813. * @returns the ray corresponding to the gaze
  19814. */
  19815. getForwardRay(length?: number): Ray;
  19816. /**
  19817. * @hidden
  19818. * Updates the camera based on device's frame data
  19819. */
  19820. _checkInputs(): void;
  19821. /**
  19822. * Updates the poseControlled values based on the input device pose.
  19823. * @param poseData Pose coming from the device
  19824. */
  19825. updateFromDevice(poseData: DevicePose): void;
  19826. private _htmlElementAttached;
  19827. private _detachIfAttached;
  19828. /**
  19829. * WebVR's attach control will start broadcasting frames to the device.
  19830. * Note that in certain browsers (chrome for example) this function must be called
  19831. * within a user-interaction callback. Example:
  19832. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19833. *
  19834. * @param element html element to attach the vrDevice to
  19835. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19836. */
  19837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19838. /**
  19839. * Detaches the camera from the html element and disables VR
  19840. *
  19841. * @param element html element to detach from
  19842. */
  19843. detachControl(element: HTMLElement): void;
  19844. /**
  19845. * @returns the name of this class
  19846. */
  19847. getClassName(): string;
  19848. /**
  19849. * Calls resetPose on the vrDisplay
  19850. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19851. */
  19852. resetToCurrentRotation(): void;
  19853. /**
  19854. * @hidden
  19855. * Updates the rig cameras (left and right eye)
  19856. */
  19857. _updateRigCameras(): void;
  19858. private _workingVector;
  19859. private _oneVector;
  19860. private _workingMatrix;
  19861. private updateCacheCalled;
  19862. private _correctPositionIfNotTrackPosition;
  19863. /**
  19864. * @hidden
  19865. * Updates the cached values of the camera
  19866. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19867. */
  19868. _updateCache(ignoreParentClass?: boolean): void;
  19869. /**
  19870. * @hidden
  19871. * Get current device position in babylon world
  19872. */
  19873. _computeDevicePosition(): void;
  19874. /**
  19875. * Updates the current device position and rotation in the babylon world
  19876. */
  19877. update(): void;
  19878. /**
  19879. * @hidden
  19880. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19881. * @returns an identity matrix
  19882. */
  19883. _getViewMatrix(): Matrix;
  19884. private _tmpMatrix;
  19885. /**
  19886. * This function is called by the two RIG cameras.
  19887. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19888. * @hidden
  19889. */
  19890. _getWebVRViewMatrix(): Matrix;
  19891. /** @hidden */
  19892. _getWebVRProjectionMatrix(): Matrix;
  19893. private _onGamepadConnectedObserver;
  19894. private _onGamepadDisconnectedObserver;
  19895. private _updateCacheWhenTrackingDisabledObserver;
  19896. /**
  19897. * Initializes the controllers and their meshes
  19898. */
  19899. initControllers(): void;
  19900. }
  19901. }
  19902. declare module BABYLON {
  19903. /**
  19904. * "Static Class" containing the most commonly used helper while dealing with material for
  19905. * rendering purpose.
  19906. *
  19907. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19908. *
  19909. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19910. */
  19911. export class MaterialHelper {
  19912. /**
  19913. * Bind the current view position to an effect.
  19914. * @param effect The effect to be bound
  19915. * @param scene The scene the eyes position is used from
  19916. * @param variableName name of the shader variable that will hold the eye position
  19917. */
  19918. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19919. /**
  19920. * Helps preparing the defines values about the UVs in used in the effect.
  19921. * UVs are shared as much as we can accross channels in the shaders.
  19922. * @param texture The texture we are preparing the UVs for
  19923. * @param defines The defines to update
  19924. * @param key The channel key "diffuse", "specular"... used in the shader
  19925. */
  19926. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19927. /**
  19928. * Binds a texture matrix value to its corrsponding uniform
  19929. * @param texture The texture to bind the matrix for
  19930. * @param uniformBuffer The uniform buffer receivin the data
  19931. * @param key The channel key "diffuse", "specular"... used in the shader
  19932. */
  19933. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19934. /**
  19935. * Gets the current status of the fog (should it be enabled?)
  19936. * @param mesh defines the mesh to evaluate for fog support
  19937. * @param scene defines the hosting scene
  19938. * @returns true if fog must be enabled
  19939. */
  19940. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19941. /**
  19942. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19943. * @param mesh defines the current mesh
  19944. * @param scene defines the current scene
  19945. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19946. * @param pointsCloud defines if point cloud rendering has to be turned on
  19947. * @param fogEnabled defines if fog has to be turned on
  19948. * @param alphaTest defines if alpha testing has to be turned on
  19949. * @param defines defines the current list of defines
  19950. */
  19951. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19952. /**
  19953. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19954. * @param scene defines the current scene
  19955. * @param engine defines the current engine
  19956. * @param defines specifies the list of active defines
  19957. * @param useInstances defines if instances have to be turned on
  19958. * @param useClipPlane defines if clip plane have to be turned on
  19959. * @param useInstances defines if instances have to be turned on
  19960. * @param useThinInstances defines if thin instances have to be turned on
  19961. */
  19962. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  19963. /**
  19964. * Prepares the defines for bones
  19965. * @param mesh The mesh containing the geometry data we will draw
  19966. * @param defines The defines to update
  19967. */
  19968. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  19969. /**
  19970. * Prepares the defines for morph targets
  19971. * @param mesh The mesh containing the geometry data we will draw
  19972. * @param defines The defines to update
  19973. */
  19974. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  19975. /**
  19976. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  19977. * @param mesh The mesh containing the geometry data we will draw
  19978. * @param defines The defines to update
  19979. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  19980. * @param useBones Precise whether bones should be used or not (override mesh info)
  19981. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  19982. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  19983. * @returns false if defines are considered not dirty and have not been checked
  19984. */
  19985. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  19986. /**
  19987. * Prepares the defines related to multiview
  19988. * @param scene The scene we are intending to draw
  19989. * @param defines The defines to update
  19990. */
  19991. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  19992. /**
  19993. * Prepares the defines related to the prepass
  19994. * @param scene The scene we are intending to draw
  19995. * @param defines The defines to update
  19996. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  19997. */
  19998. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  19999. /**
  20000. * Prepares the defines related to the light information passed in parameter
  20001. * @param scene The scene we are intending to draw
  20002. * @param mesh The mesh the effect is compiling for
  20003. * @param light The light the effect is compiling for
  20004. * @param lightIndex The index of the light
  20005. * @param defines The defines to update
  20006. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20007. * @param state Defines the current state regarding what is needed (normals, etc...)
  20008. */
  20009. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20010. needNormals: boolean;
  20011. needRebuild: boolean;
  20012. shadowEnabled: boolean;
  20013. specularEnabled: boolean;
  20014. lightmapMode: boolean;
  20015. }): void;
  20016. /**
  20017. * Prepares the defines related to the light information passed in parameter
  20018. * @param scene The scene we are intending to draw
  20019. * @param mesh The mesh the effect is compiling for
  20020. * @param defines The defines to update
  20021. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20022. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20023. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20024. * @returns true if normals will be required for the rest of the effect
  20025. */
  20026. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20027. /**
  20028. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20029. * @param lightIndex defines the light index
  20030. * @param uniformsList The uniform list
  20031. * @param samplersList The sampler list
  20032. * @param projectedLightTexture defines if projected texture must be used
  20033. * @param uniformBuffersList defines an optional list of uniform buffers
  20034. */
  20035. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20036. /**
  20037. * Prepares the uniforms and samplers list to be used in the effect
  20038. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20039. * @param samplersList The sampler list
  20040. * @param defines The defines helping in the list generation
  20041. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20042. */
  20043. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20044. /**
  20045. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20046. * @param defines The defines to update while falling back
  20047. * @param fallbacks The authorized effect fallbacks
  20048. * @param maxSimultaneousLights The maximum number of lights allowed
  20049. * @param rank the current rank of the Effect
  20050. * @returns The newly affected rank
  20051. */
  20052. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20053. private static _TmpMorphInfluencers;
  20054. /**
  20055. * Prepares the list of attributes required for morph targets according to the effect defines.
  20056. * @param attribs The current list of supported attribs
  20057. * @param mesh The mesh to prepare the morph targets attributes for
  20058. * @param influencers The number of influencers
  20059. */
  20060. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20061. /**
  20062. * Prepares the list of attributes required for morph targets according to the effect defines.
  20063. * @param attribs The current list of supported attribs
  20064. * @param mesh The mesh to prepare the morph targets attributes for
  20065. * @param defines The current Defines of the effect
  20066. */
  20067. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20068. /**
  20069. * Prepares the list of attributes required for bones according to the effect defines.
  20070. * @param attribs The current list of supported attribs
  20071. * @param mesh The mesh to prepare the bones attributes for
  20072. * @param defines The current Defines of the effect
  20073. * @param fallbacks The current efffect fallback strategy
  20074. */
  20075. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20076. /**
  20077. * Check and prepare the list of attributes required for instances according to the effect defines.
  20078. * @param attribs The current list of supported attribs
  20079. * @param defines The current MaterialDefines of the effect
  20080. */
  20081. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20082. /**
  20083. * Add the list of attributes required for instances to the attribs array.
  20084. * @param attribs The current list of supported attribs
  20085. */
  20086. static PushAttributesForInstances(attribs: string[]): void;
  20087. /**
  20088. * Binds the light information to the effect.
  20089. * @param light The light containing the generator
  20090. * @param effect The effect we are binding the data to
  20091. * @param lightIndex The light index in the effect used to render
  20092. */
  20093. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20094. /**
  20095. * Binds the lights information from the scene to the effect for the given mesh.
  20096. * @param light Light to bind
  20097. * @param lightIndex Light index
  20098. * @param scene The scene where the light belongs to
  20099. * @param effect The effect we are binding the data to
  20100. * @param useSpecular Defines if specular is supported
  20101. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20102. */
  20103. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20104. /**
  20105. * Binds the lights information from the scene to the effect for the given mesh.
  20106. * @param scene The scene the lights belongs to
  20107. * @param mesh The mesh we are binding the information to render
  20108. * @param effect The effect we are binding the data to
  20109. * @param defines The generated defines for the effect
  20110. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20111. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20112. */
  20113. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20114. private static _tempFogColor;
  20115. /**
  20116. * Binds the fog information from the scene to the effect for the given mesh.
  20117. * @param scene The scene the lights belongs to
  20118. * @param mesh The mesh we are binding the information to render
  20119. * @param effect The effect we are binding the data to
  20120. * @param linearSpace Defines if the fog effect is applied in linear space
  20121. */
  20122. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20123. /**
  20124. * Binds the bones information from the mesh to the effect.
  20125. * @param mesh The mesh we are binding the information to render
  20126. * @param effect The effect we are binding the data to
  20127. */
  20128. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20129. /**
  20130. * Binds the morph targets information from the mesh to the effect.
  20131. * @param abstractMesh The mesh we are binding the information to render
  20132. * @param effect The effect we are binding the data to
  20133. */
  20134. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20135. /**
  20136. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20137. * @param defines The generated defines used in the effect
  20138. * @param effect The effect we are binding the data to
  20139. * @param scene The scene we are willing to render with logarithmic scale for
  20140. */
  20141. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20142. /**
  20143. * Binds the clip plane information from the scene to the effect.
  20144. * @param scene The scene the clip plane information are extracted from
  20145. * @param effect The effect we are binding the data to
  20146. */
  20147. static BindClipPlane(effect: Effect, scene: Scene): void;
  20148. }
  20149. }
  20150. declare module BABYLON {
  20151. /**
  20152. * Block used to expose an input value
  20153. */
  20154. export class InputBlock extends NodeMaterialBlock {
  20155. private _mode;
  20156. private _associatedVariableName;
  20157. private _storedValue;
  20158. private _valueCallback;
  20159. private _type;
  20160. private _animationType;
  20161. /** Gets or set a value used to limit the range of float values */
  20162. min: number;
  20163. /** Gets or set a value used to limit the range of float values */
  20164. max: number;
  20165. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20166. isBoolean: boolean;
  20167. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20168. matrixMode: number;
  20169. /** @hidden */
  20170. _systemValue: Nullable<NodeMaterialSystemValues>;
  20171. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20172. visibleInInspector: boolean;
  20173. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20174. isConstant: boolean;
  20175. /** Gets or sets the group to use to display this block in the Inspector */
  20176. groupInInspector: string;
  20177. /** Gets an observable raised when the value is changed */
  20178. onValueChangedObservable: Observable<InputBlock>;
  20179. /**
  20180. * Gets or sets the connection point type (default is float)
  20181. */
  20182. get type(): NodeMaterialBlockConnectionPointTypes;
  20183. /**
  20184. * Creates a new InputBlock
  20185. * @param name defines the block name
  20186. * @param target defines the target of that block (Vertex by default)
  20187. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20188. */
  20189. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20190. /**
  20191. * Gets the output component
  20192. */
  20193. get output(): NodeMaterialConnectionPoint;
  20194. /**
  20195. * Set the source of this connection point to a vertex attribute
  20196. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20197. * @returns the current connection point
  20198. */
  20199. setAsAttribute(attributeName?: string): InputBlock;
  20200. /**
  20201. * Set the source of this connection point to a system value
  20202. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20203. * @returns the current connection point
  20204. */
  20205. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20206. /**
  20207. * Gets or sets the value of that point.
  20208. * Please note that this value will be ignored if valueCallback is defined
  20209. */
  20210. get value(): any;
  20211. set value(value: any);
  20212. /**
  20213. * Gets or sets a callback used to get the value of that point.
  20214. * Please note that setting this value will force the connection point to ignore the value property
  20215. */
  20216. get valueCallback(): () => any;
  20217. set valueCallback(value: () => any);
  20218. /**
  20219. * Gets or sets the associated variable name in the shader
  20220. */
  20221. get associatedVariableName(): string;
  20222. set associatedVariableName(value: string);
  20223. /** Gets or sets the type of animation applied to the input */
  20224. get animationType(): AnimatedInputBlockTypes;
  20225. set animationType(value: AnimatedInputBlockTypes);
  20226. /**
  20227. * Gets a boolean indicating that this connection point not defined yet
  20228. */
  20229. get isUndefined(): boolean;
  20230. /**
  20231. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20232. * In this case the connection point name must be the name of the uniform to use.
  20233. * Can only be set on inputs
  20234. */
  20235. get isUniform(): boolean;
  20236. set isUniform(value: boolean);
  20237. /**
  20238. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20239. * In this case the connection point name must be the name of the attribute to use
  20240. * Can only be set on inputs
  20241. */
  20242. get isAttribute(): boolean;
  20243. set isAttribute(value: boolean);
  20244. /**
  20245. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20246. * Can only be set on exit points
  20247. */
  20248. get isVarying(): boolean;
  20249. set isVarying(value: boolean);
  20250. /**
  20251. * Gets a boolean indicating that the current connection point is a system value
  20252. */
  20253. get isSystemValue(): boolean;
  20254. /**
  20255. * Gets or sets the current well known value or null if not defined as a system value
  20256. */
  20257. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20258. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20259. /**
  20260. * Gets the current class name
  20261. * @returns the class name
  20262. */
  20263. getClassName(): string;
  20264. /**
  20265. * Animate the input if animationType !== None
  20266. * @param scene defines the rendering scene
  20267. */
  20268. animate(scene: Scene): void;
  20269. private _emitDefine;
  20270. initialize(state: NodeMaterialBuildState): void;
  20271. /**
  20272. * Set the input block to its default value (based on its type)
  20273. */
  20274. setDefaultValue(): void;
  20275. private _emitConstant;
  20276. /** @hidden */
  20277. get _noContextSwitch(): boolean;
  20278. private _emit;
  20279. /** @hidden */
  20280. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20281. /** @hidden */
  20282. _transmit(effect: Effect, scene: Scene): void;
  20283. protected _buildBlock(state: NodeMaterialBuildState): void;
  20284. protected _dumpPropertiesCode(): string;
  20285. dispose(): void;
  20286. serialize(): any;
  20287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20288. }
  20289. }
  20290. declare module BABYLON {
  20291. /**
  20292. * Enum used to define the compatibility state between two connection points
  20293. */
  20294. export enum NodeMaterialConnectionPointCompatibilityStates {
  20295. /** Points are compatibles */
  20296. Compatible = 0,
  20297. /** Points are incompatible because of their types */
  20298. TypeIncompatible = 1,
  20299. /** Points are incompatible because of their targets (vertex vs fragment) */
  20300. TargetIncompatible = 2
  20301. }
  20302. /**
  20303. * Defines the direction of a connection point
  20304. */
  20305. export enum NodeMaterialConnectionPointDirection {
  20306. /** Input */
  20307. Input = 0,
  20308. /** Output */
  20309. Output = 1
  20310. }
  20311. /**
  20312. * Defines a connection point for a block
  20313. */
  20314. export class NodeMaterialConnectionPoint {
  20315. /** @hidden */
  20316. _ownerBlock: NodeMaterialBlock;
  20317. /** @hidden */
  20318. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20319. private _endpoints;
  20320. private _associatedVariableName;
  20321. private _direction;
  20322. /** @hidden */
  20323. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20324. /** @hidden */
  20325. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20326. private _type;
  20327. /** @hidden */
  20328. _enforceAssociatedVariableName: boolean;
  20329. /** Gets the direction of the point */
  20330. get direction(): NodeMaterialConnectionPointDirection;
  20331. /** Indicates that this connection point needs dual validation before being connected to another point */
  20332. needDualDirectionValidation: boolean;
  20333. /**
  20334. * Gets or sets the additional types supported by this connection point
  20335. */
  20336. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20337. /**
  20338. * Gets or sets the additional types excluded by this connection point
  20339. */
  20340. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20341. /**
  20342. * Observable triggered when this point is connected
  20343. */
  20344. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20345. /**
  20346. * Gets or sets the associated variable name in the shader
  20347. */
  20348. get associatedVariableName(): string;
  20349. set associatedVariableName(value: string);
  20350. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20351. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20352. /**
  20353. * Gets or sets the connection point type (default is float)
  20354. */
  20355. get type(): NodeMaterialBlockConnectionPointTypes;
  20356. set type(value: NodeMaterialBlockConnectionPointTypes);
  20357. /**
  20358. * Gets or sets the connection point name
  20359. */
  20360. name: string;
  20361. /**
  20362. * Gets or sets the connection point name
  20363. */
  20364. displayName: string;
  20365. /**
  20366. * Gets or sets a boolean indicating that this connection point can be omitted
  20367. */
  20368. isOptional: boolean;
  20369. /**
  20370. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20371. */
  20372. isExposedOnFrame: boolean;
  20373. /**
  20374. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20375. */
  20376. define: string;
  20377. /** @hidden */
  20378. _prioritizeVertex: boolean;
  20379. private _target;
  20380. /** Gets or sets the target of that connection point */
  20381. get target(): NodeMaterialBlockTargets;
  20382. set target(value: NodeMaterialBlockTargets);
  20383. /**
  20384. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20385. */
  20386. get isConnected(): boolean;
  20387. /**
  20388. * Gets a boolean indicating that the current point is connected to an input block
  20389. */
  20390. get isConnectedToInputBlock(): boolean;
  20391. /**
  20392. * Gets a the connected input block (if any)
  20393. */
  20394. get connectInputBlock(): Nullable<InputBlock>;
  20395. /** Get the other side of the connection (if any) */
  20396. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20397. /** Get the block that owns this connection point */
  20398. get ownerBlock(): NodeMaterialBlock;
  20399. /** Get the block connected on the other side of this connection (if any) */
  20400. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20401. /** Get the block connected on the endpoints of this connection (if any) */
  20402. get connectedBlocks(): Array<NodeMaterialBlock>;
  20403. /** Gets the list of connected endpoints */
  20404. get endpoints(): NodeMaterialConnectionPoint[];
  20405. /** Gets a boolean indicating if that output point is connected to at least one input */
  20406. get hasEndpoints(): boolean;
  20407. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20408. get isConnectedInVertexShader(): boolean;
  20409. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20410. get isConnectedInFragmentShader(): boolean;
  20411. /**
  20412. * Creates a block suitable to be used as an input for this input point.
  20413. * If null is returned, a block based on the point type will be created.
  20414. * @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
  20415. */
  20416. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20417. /**
  20418. * Creates a new connection point
  20419. * @param name defines the connection point name
  20420. * @param ownerBlock defines the block hosting this connection point
  20421. * @param direction defines the direction of the connection point
  20422. */
  20423. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20424. /**
  20425. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20426. * @returns the class name
  20427. */
  20428. getClassName(): string;
  20429. /**
  20430. * Gets a boolean indicating if the current point can be connected to another point
  20431. * @param connectionPoint defines the other connection point
  20432. * @returns a boolean
  20433. */
  20434. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20435. /**
  20436. * Gets a number indicating if the current point can be connected to another point
  20437. * @param connectionPoint defines the other connection point
  20438. * @returns a number defining the compatibility state
  20439. */
  20440. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20441. /**
  20442. * Connect this point to another connection point
  20443. * @param connectionPoint defines the other connection point
  20444. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20445. * @returns the current connection point
  20446. */
  20447. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20448. /**
  20449. * Disconnect this point from one of his endpoint
  20450. * @param endpoint defines the other connection point
  20451. * @returns the current connection point
  20452. */
  20453. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20454. /**
  20455. * Serializes this point in a JSON representation
  20456. * @param isInput defines if the connection point is an input (default is true)
  20457. * @returns the serialized point object
  20458. */
  20459. serialize(isInput?: boolean): any;
  20460. /**
  20461. * Release resources
  20462. */
  20463. dispose(): void;
  20464. }
  20465. }
  20466. declare module BABYLON {
  20467. /**
  20468. * Enum used to define the material modes
  20469. */
  20470. export enum NodeMaterialModes {
  20471. /** Regular material */
  20472. Material = 0,
  20473. /** For post process */
  20474. PostProcess = 1,
  20475. /** For particle system */
  20476. Particle = 2
  20477. }
  20478. }
  20479. declare module BABYLON {
  20480. /**
  20481. * Block used to read a texture from a sampler
  20482. */
  20483. export class TextureBlock extends NodeMaterialBlock {
  20484. private _defineName;
  20485. private _linearDefineName;
  20486. private _gammaDefineName;
  20487. private _tempTextureRead;
  20488. private _samplerName;
  20489. private _transformedUVName;
  20490. private _textureTransformName;
  20491. private _textureInfoName;
  20492. private _mainUVName;
  20493. private _mainUVDefineName;
  20494. private _fragmentOnly;
  20495. /**
  20496. * Gets or sets the texture associated with the node
  20497. */
  20498. texture: Nullable<Texture>;
  20499. /**
  20500. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20501. */
  20502. convertToGammaSpace: boolean;
  20503. /**
  20504. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20505. */
  20506. convertToLinearSpace: boolean;
  20507. /**
  20508. * Create a new TextureBlock
  20509. * @param name defines the block name
  20510. */
  20511. constructor(name: string, fragmentOnly?: boolean);
  20512. /**
  20513. * Gets the current class name
  20514. * @returns the class name
  20515. */
  20516. getClassName(): string;
  20517. /**
  20518. * Gets the uv input component
  20519. */
  20520. get uv(): NodeMaterialConnectionPoint;
  20521. /**
  20522. * Gets the rgba output component
  20523. */
  20524. get rgba(): NodeMaterialConnectionPoint;
  20525. /**
  20526. * Gets the rgb output component
  20527. */
  20528. get rgb(): NodeMaterialConnectionPoint;
  20529. /**
  20530. * Gets the r output component
  20531. */
  20532. get r(): NodeMaterialConnectionPoint;
  20533. /**
  20534. * Gets the g output component
  20535. */
  20536. get g(): NodeMaterialConnectionPoint;
  20537. /**
  20538. * Gets the b output component
  20539. */
  20540. get b(): NodeMaterialConnectionPoint;
  20541. /**
  20542. * Gets the a output component
  20543. */
  20544. get a(): NodeMaterialConnectionPoint;
  20545. get target(): NodeMaterialBlockTargets;
  20546. autoConfigure(material: NodeMaterial): void;
  20547. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20549. isReady(): boolean;
  20550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20551. private get _isMixed();
  20552. private _injectVertexCode;
  20553. private _writeTextureRead;
  20554. private _writeOutput;
  20555. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20556. protected _dumpPropertiesCode(): string;
  20557. serialize(): any;
  20558. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20559. }
  20560. }
  20561. declare module BABYLON {
  20562. /** @hidden */
  20563. export var reflectionFunction: {
  20564. name: string;
  20565. shader: string;
  20566. };
  20567. }
  20568. declare module BABYLON {
  20569. /**
  20570. * Base block used to read a reflection texture from a sampler
  20571. */
  20572. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20573. /** @hidden */
  20574. _define3DName: string;
  20575. /** @hidden */
  20576. _defineCubicName: string;
  20577. /** @hidden */
  20578. _defineExplicitName: string;
  20579. /** @hidden */
  20580. _defineProjectionName: string;
  20581. /** @hidden */
  20582. _defineLocalCubicName: string;
  20583. /** @hidden */
  20584. _defineSphericalName: string;
  20585. /** @hidden */
  20586. _definePlanarName: string;
  20587. /** @hidden */
  20588. _defineEquirectangularName: string;
  20589. /** @hidden */
  20590. _defineMirroredEquirectangularFixedName: string;
  20591. /** @hidden */
  20592. _defineEquirectangularFixedName: string;
  20593. /** @hidden */
  20594. _defineSkyboxName: string;
  20595. /** @hidden */
  20596. _defineOppositeZ: string;
  20597. /** @hidden */
  20598. _cubeSamplerName: string;
  20599. /** @hidden */
  20600. _2DSamplerName: string;
  20601. protected _positionUVWName: string;
  20602. protected _directionWName: string;
  20603. protected _reflectionVectorName: string;
  20604. /** @hidden */
  20605. _reflectionCoordsName: string;
  20606. /** @hidden */
  20607. _reflectionMatrixName: string;
  20608. protected _reflectionColorName: string;
  20609. /**
  20610. * Gets or sets the texture associated with the node
  20611. */
  20612. texture: Nullable<BaseTexture>;
  20613. /**
  20614. * Create a new ReflectionTextureBaseBlock
  20615. * @param name defines the block name
  20616. */
  20617. constructor(name: string);
  20618. /**
  20619. * Gets the current class name
  20620. * @returns the class name
  20621. */
  20622. getClassName(): string;
  20623. /**
  20624. * Gets the world position input component
  20625. */
  20626. abstract get position(): NodeMaterialConnectionPoint;
  20627. /**
  20628. * Gets the world position input component
  20629. */
  20630. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20631. /**
  20632. * Gets the world normal input component
  20633. */
  20634. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20635. /**
  20636. * Gets the world input component
  20637. */
  20638. abstract get world(): NodeMaterialConnectionPoint;
  20639. /**
  20640. * Gets the camera (or eye) position component
  20641. */
  20642. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20643. /**
  20644. * Gets the view input component
  20645. */
  20646. abstract get view(): NodeMaterialConnectionPoint;
  20647. protected _getTexture(): Nullable<BaseTexture>;
  20648. autoConfigure(material: NodeMaterial): void;
  20649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20650. isReady(): boolean;
  20651. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20652. /**
  20653. * Gets the code to inject in the vertex shader
  20654. * @param state current state of the node material building
  20655. * @returns the shader code
  20656. */
  20657. handleVertexSide(state: NodeMaterialBuildState): string;
  20658. /**
  20659. * Handles the inits for the fragment code path
  20660. * @param state node material build state
  20661. */
  20662. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20663. /**
  20664. * Generates the reflection coords code for the fragment code path
  20665. * @param worldNormalVarName name of the world normal variable
  20666. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20667. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20668. * @returns the shader code
  20669. */
  20670. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20671. /**
  20672. * Generates the reflection color code for the fragment code path
  20673. * @param lodVarName name of the lod variable
  20674. * @param swizzleLookupTexture swizzle to use for the final color variable
  20675. * @returns the shader code
  20676. */
  20677. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20678. /**
  20679. * Generates the code corresponding to the connected output points
  20680. * @param state node material build state
  20681. * @param varName name of the variable to output
  20682. * @returns the shader code
  20683. */
  20684. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20685. protected _buildBlock(state: NodeMaterialBuildState): this;
  20686. protected _dumpPropertiesCode(): string;
  20687. serialize(): any;
  20688. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20689. }
  20690. }
  20691. declare module BABYLON {
  20692. /**
  20693. * Defines a connection point to be used for points with a custom object type
  20694. */
  20695. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20696. private _blockType;
  20697. private _blockName;
  20698. private _nameForCheking?;
  20699. /**
  20700. * Creates a new connection point
  20701. * @param name defines the connection point name
  20702. * @param ownerBlock defines the block hosting this connection point
  20703. * @param direction defines the direction of the connection point
  20704. */
  20705. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20706. /**
  20707. * Gets a number indicating if the current point can be connected to another point
  20708. * @param connectionPoint defines the other connection point
  20709. * @returns a number defining the compatibility state
  20710. */
  20711. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20712. /**
  20713. * Creates a block suitable to be used as an input for this input point.
  20714. * If null is returned, a block based on the point type will be created.
  20715. * @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
  20716. */
  20717. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20718. }
  20719. }
  20720. declare module BABYLON {
  20721. /**
  20722. * Enum defining the type of properties that can be edited in the property pages in the NME
  20723. */
  20724. export enum PropertyTypeForEdition {
  20725. /** property is a boolean */
  20726. Boolean = 0,
  20727. /** property is a float */
  20728. Float = 1,
  20729. /** property is a Vector2 */
  20730. Vector2 = 2,
  20731. /** property is a list of values */
  20732. List = 3
  20733. }
  20734. /**
  20735. * Interface that defines an option in a variable of type list
  20736. */
  20737. export interface IEditablePropertyListOption {
  20738. /** label of the option */
  20739. "label": string;
  20740. /** value of the option */
  20741. "value": number;
  20742. }
  20743. /**
  20744. * Interface that defines the options available for an editable property
  20745. */
  20746. export interface IEditablePropertyOption {
  20747. /** min value */
  20748. "min"?: number;
  20749. /** max value */
  20750. "max"?: number;
  20751. /** notifiers: indicates which actions to take when the property is changed */
  20752. "notifiers"?: {
  20753. /** the material should be rebuilt */
  20754. "rebuild"?: boolean;
  20755. /** the preview should be updated */
  20756. "update"?: boolean;
  20757. };
  20758. /** list of the options for a variable of type list */
  20759. "options"?: IEditablePropertyListOption[];
  20760. }
  20761. /**
  20762. * Interface that describes an editable property
  20763. */
  20764. export interface IPropertyDescriptionForEdition {
  20765. /** name of the property */
  20766. "propertyName": string;
  20767. /** display name of the property */
  20768. "displayName": string;
  20769. /** type of the property */
  20770. "type": PropertyTypeForEdition;
  20771. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20772. "groupName": string;
  20773. /** options for the property */
  20774. "options": IEditablePropertyOption;
  20775. }
  20776. /**
  20777. * Decorator that flags a property in a node material block as being editable
  20778. */
  20779. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20780. }
  20781. declare module BABYLON {
  20782. /**
  20783. * Block used to implement the refraction part of the sub surface module of the PBR material
  20784. */
  20785. export class RefractionBlock extends NodeMaterialBlock {
  20786. /** @hidden */
  20787. _define3DName: string;
  20788. /** @hidden */
  20789. _refractionMatrixName: string;
  20790. /** @hidden */
  20791. _defineLODRefractionAlpha: string;
  20792. /** @hidden */
  20793. _defineLinearSpecularRefraction: string;
  20794. /** @hidden */
  20795. _defineOppositeZ: string;
  20796. /** @hidden */
  20797. _cubeSamplerName: string;
  20798. /** @hidden */
  20799. _2DSamplerName: string;
  20800. /** @hidden */
  20801. _vRefractionMicrosurfaceInfosName: string;
  20802. /** @hidden */
  20803. _vRefractionInfosName: string;
  20804. private _scene;
  20805. /**
  20806. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20807. * Materials half opaque for instance using refraction could benefit from this control.
  20808. */
  20809. linkRefractionWithTransparency: boolean;
  20810. /**
  20811. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20812. */
  20813. invertRefractionY: boolean;
  20814. /**
  20815. * Gets or sets the texture associated with the node
  20816. */
  20817. texture: Nullable<BaseTexture>;
  20818. /**
  20819. * Create a new RefractionBlock
  20820. * @param name defines the block name
  20821. */
  20822. constructor(name: string);
  20823. /**
  20824. * Gets the current class name
  20825. * @returns the class name
  20826. */
  20827. getClassName(): string;
  20828. /**
  20829. * Gets the intensity input component
  20830. */
  20831. get intensity(): NodeMaterialConnectionPoint;
  20832. /**
  20833. * Gets the index of refraction input component
  20834. */
  20835. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20836. /**
  20837. * Gets the tint at distance input component
  20838. */
  20839. get tintAtDistance(): NodeMaterialConnectionPoint;
  20840. /**
  20841. * Gets the view input component
  20842. */
  20843. get view(): NodeMaterialConnectionPoint;
  20844. /**
  20845. * Gets the refraction object output component
  20846. */
  20847. get refraction(): NodeMaterialConnectionPoint;
  20848. /**
  20849. * Returns true if the block has a texture
  20850. */
  20851. get hasTexture(): boolean;
  20852. protected _getTexture(): Nullable<BaseTexture>;
  20853. autoConfigure(material: NodeMaterial): void;
  20854. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20855. isReady(): boolean;
  20856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20857. /**
  20858. * Gets the main code of the block (fragment side)
  20859. * @param state current state of the node material building
  20860. * @returns the shader code
  20861. */
  20862. getCode(state: NodeMaterialBuildState): string;
  20863. protected _buildBlock(state: NodeMaterialBuildState): this;
  20864. protected _dumpPropertiesCode(): string;
  20865. serialize(): any;
  20866. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20867. }
  20868. }
  20869. declare module BABYLON {
  20870. /**
  20871. * Base block used as input for post process
  20872. */
  20873. export class CurrentScreenBlock extends NodeMaterialBlock {
  20874. private _samplerName;
  20875. private _linearDefineName;
  20876. private _gammaDefineName;
  20877. private _mainUVName;
  20878. private _tempTextureRead;
  20879. /**
  20880. * Gets or sets the texture associated with the node
  20881. */
  20882. texture: Nullable<BaseTexture>;
  20883. /**
  20884. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20885. */
  20886. convertToGammaSpace: boolean;
  20887. /**
  20888. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20889. */
  20890. convertToLinearSpace: boolean;
  20891. /**
  20892. * Create a new CurrentScreenBlock
  20893. * @param name defines the block name
  20894. */
  20895. constructor(name: string);
  20896. /**
  20897. * Gets the current class name
  20898. * @returns the class name
  20899. */
  20900. getClassName(): string;
  20901. /**
  20902. * Gets the uv input component
  20903. */
  20904. get uv(): NodeMaterialConnectionPoint;
  20905. /**
  20906. * Gets the rgba output component
  20907. */
  20908. get rgba(): NodeMaterialConnectionPoint;
  20909. /**
  20910. * Gets the rgb output component
  20911. */
  20912. get rgb(): NodeMaterialConnectionPoint;
  20913. /**
  20914. * Gets the r output component
  20915. */
  20916. get r(): NodeMaterialConnectionPoint;
  20917. /**
  20918. * Gets the g output component
  20919. */
  20920. get g(): NodeMaterialConnectionPoint;
  20921. /**
  20922. * Gets the b output component
  20923. */
  20924. get b(): NodeMaterialConnectionPoint;
  20925. /**
  20926. * Gets the a output component
  20927. */
  20928. get a(): NodeMaterialConnectionPoint;
  20929. /**
  20930. * Initialize the block and prepare the context for build
  20931. * @param state defines the state that will be used for the build
  20932. */
  20933. initialize(state: NodeMaterialBuildState): void;
  20934. get target(): NodeMaterialBlockTargets;
  20935. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20936. isReady(): boolean;
  20937. private _injectVertexCode;
  20938. private _writeTextureRead;
  20939. private _writeOutput;
  20940. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20941. serialize(): any;
  20942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20943. }
  20944. }
  20945. declare module BABYLON {
  20946. /**
  20947. * Base block used for the particle texture
  20948. */
  20949. export class ParticleTextureBlock extends NodeMaterialBlock {
  20950. private _samplerName;
  20951. private _linearDefineName;
  20952. private _gammaDefineName;
  20953. private _tempTextureRead;
  20954. /**
  20955. * Gets or sets the texture associated with the node
  20956. */
  20957. texture: Nullable<BaseTexture>;
  20958. /**
  20959. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20960. */
  20961. convertToGammaSpace: boolean;
  20962. /**
  20963. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20964. */
  20965. convertToLinearSpace: boolean;
  20966. /**
  20967. * Create a new ParticleTextureBlock
  20968. * @param name defines the block name
  20969. */
  20970. constructor(name: string);
  20971. /**
  20972. * Gets the current class name
  20973. * @returns the class name
  20974. */
  20975. getClassName(): string;
  20976. /**
  20977. * Gets the uv input component
  20978. */
  20979. get uv(): NodeMaterialConnectionPoint;
  20980. /**
  20981. * Gets the rgba output component
  20982. */
  20983. get rgba(): NodeMaterialConnectionPoint;
  20984. /**
  20985. * Gets the rgb output component
  20986. */
  20987. get rgb(): NodeMaterialConnectionPoint;
  20988. /**
  20989. * Gets the r output component
  20990. */
  20991. get r(): NodeMaterialConnectionPoint;
  20992. /**
  20993. * Gets the g output component
  20994. */
  20995. get g(): NodeMaterialConnectionPoint;
  20996. /**
  20997. * Gets the b output component
  20998. */
  20999. get b(): NodeMaterialConnectionPoint;
  21000. /**
  21001. * Gets the a output component
  21002. */
  21003. get a(): NodeMaterialConnectionPoint;
  21004. /**
  21005. * Initialize the block and prepare the context for build
  21006. * @param state defines the state that will be used for the build
  21007. */
  21008. initialize(state: NodeMaterialBuildState): void;
  21009. autoConfigure(material: NodeMaterial): void;
  21010. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21011. isReady(): boolean;
  21012. private _writeOutput;
  21013. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21014. serialize(): any;
  21015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21016. }
  21017. }
  21018. declare module BABYLON {
  21019. /**
  21020. * Class used to store shared data between 2 NodeMaterialBuildState
  21021. */
  21022. export class NodeMaterialBuildStateSharedData {
  21023. /**
  21024. * Gets the list of emitted varyings
  21025. */
  21026. temps: string[];
  21027. /**
  21028. * Gets the list of emitted varyings
  21029. */
  21030. varyings: string[];
  21031. /**
  21032. * Gets the varying declaration string
  21033. */
  21034. varyingDeclaration: string;
  21035. /**
  21036. * Input blocks
  21037. */
  21038. inputBlocks: InputBlock[];
  21039. /**
  21040. * Input blocks
  21041. */
  21042. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21043. /**
  21044. * Bindable blocks (Blocks that need to set data to the effect)
  21045. */
  21046. bindableBlocks: NodeMaterialBlock[];
  21047. /**
  21048. * List of blocks that can provide a compilation fallback
  21049. */
  21050. blocksWithFallbacks: NodeMaterialBlock[];
  21051. /**
  21052. * List of blocks that can provide a define update
  21053. */
  21054. blocksWithDefines: NodeMaterialBlock[];
  21055. /**
  21056. * List of blocks that can provide a repeatable content
  21057. */
  21058. repeatableContentBlocks: NodeMaterialBlock[];
  21059. /**
  21060. * List of blocks that can provide a dynamic list of uniforms
  21061. */
  21062. dynamicUniformBlocks: NodeMaterialBlock[];
  21063. /**
  21064. * List of blocks that can block the isReady function for the material
  21065. */
  21066. blockingBlocks: NodeMaterialBlock[];
  21067. /**
  21068. * Gets the list of animated inputs
  21069. */
  21070. animatedInputs: InputBlock[];
  21071. /**
  21072. * Build Id used to avoid multiple recompilations
  21073. */
  21074. buildId: number;
  21075. /** List of emitted variables */
  21076. variableNames: {
  21077. [key: string]: number;
  21078. };
  21079. /** List of emitted defines */
  21080. defineNames: {
  21081. [key: string]: number;
  21082. };
  21083. /** Should emit comments? */
  21084. emitComments: boolean;
  21085. /** Emit build activity */
  21086. verbose: boolean;
  21087. /** Gets or sets the hosting scene */
  21088. scene: Scene;
  21089. /**
  21090. * Gets the compilation hints emitted at compilation time
  21091. */
  21092. hints: {
  21093. needWorldViewMatrix: boolean;
  21094. needWorldViewProjectionMatrix: boolean;
  21095. needAlphaBlending: boolean;
  21096. needAlphaTesting: boolean;
  21097. };
  21098. /**
  21099. * List of compilation checks
  21100. */
  21101. checks: {
  21102. emitVertex: boolean;
  21103. emitFragment: boolean;
  21104. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21105. };
  21106. /**
  21107. * Is vertex program allowed to be empty?
  21108. */
  21109. allowEmptyVertexProgram: boolean;
  21110. /** Creates a new shared data */
  21111. constructor();
  21112. /**
  21113. * Emits console errors and exceptions if there is a failing check
  21114. */
  21115. emitErrors(): void;
  21116. }
  21117. }
  21118. declare module BABYLON {
  21119. /**
  21120. * Class used to store node based material build state
  21121. */
  21122. export class NodeMaterialBuildState {
  21123. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21124. supportUniformBuffers: boolean;
  21125. /**
  21126. * Gets the list of emitted attributes
  21127. */
  21128. attributes: string[];
  21129. /**
  21130. * Gets the list of emitted uniforms
  21131. */
  21132. uniforms: string[];
  21133. /**
  21134. * Gets the list of emitted constants
  21135. */
  21136. constants: string[];
  21137. /**
  21138. * Gets the list of emitted samplers
  21139. */
  21140. samplers: string[];
  21141. /**
  21142. * Gets the list of emitted functions
  21143. */
  21144. functions: {
  21145. [key: string]: string;
  21146. };
  21147. /**
  21148. * Gets the list of emitted extensions
  21149. */
  21150. extensions: {
  21151. [key: string]: string;
  21152. };
  21153. /**
  21154. * Gets the target of the compilation state
  21155. */
  21156. target: NodeMaterialBlockTargets;
  21157. /**
  21158. * Gets the list of emitted counters
  21159. */
  21160. counters: {
  21161. [key: string]: number;
  21162. };
  21163. /**
  21164. * Shared data between multiple NodeMaterialBuildState instances
  21165. */
  21166. sharedData: NodeMaterialBuildStateSharedData;
  21167. /** @hidden */
  21168. _vertexState: NodeMaterialBuildState;
  21169. /** @hidden */
  21170. _attributeDeclaration: string;
  21171. /** @hidden */
  21172. _uniformDeclaration: string;
  21173. /** @hidden */
  21174. _constantDeclaration: string;
  21175. /** @hidden */
  21176. _samplerDeclaration: string;
  21177. /** @hidden */
  21178. _varyingTransfer: string;
  21179. /** @hidden */
  21180. _injectAtEnd: string;
  21181. private _repeatableContentAnchorIndex;
  21182. /** @hidden */
  21183. _builtCompilationString: string;
  21184. /**
  21185. * Gets the emitted compilation strings
  21186. */
  21187. compilationString: string;
  21188. /**
  21189. * Finalize the compilation strings
  21190. * @param state defines the current compilation state
  21191. */
  21192. finalize(state: NodeMaterialBuildState): void;
  21193. /** @hidden */
  21194. get _repeatableContentAnchor(): string;
  21195. /** @hidden */
  21196. _getFreeVariableName(prefix: string): string;
  21197. /** @hidden */
  21198. _getFreeDefineName(prefix: string): string;
  21199. /** @hidden */
  21200. _excludeVariableName(name: string): void;
  21201. /** @hidden */
  21202. _emit2DSampler(name: string): void;
  21203. /** @hidden */
  21204. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21205. /** @hidden */
  21206. _emitExtension(name: string, extension: string, define?: string): void;
  21207. /** @hidden */
  21208. _emitFunction(name: string, code: string, comments: string): void;
  21209. /** @hidden */
  21210. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21211. replaceStrings?: {
  21212. search: RegExp;
  21213. replace: string;
  21214. }[];
  21215. repeatKey?: string;
  21216. }): string;
  21217. /** @hidden */
  21218. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21219. repeatKey?: string;
  21220. removeAttributes?: boolean;
  21221. removeUniforms?: boolean;
  21222. removeVaryings?: boolean;
  21223. removeIfDef?: boolean;
  21224. replaceStrings?: {
  21225. search: RegExp;
  21226. replace: string;
  21227. }[];
  21228. }, storeKey?: string): void;
  21229. /** @hidden */
  21230. _registerTempVariable(name: string): boolean;
  21231. /** @hidden */
  21232. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21233. /** @hidden */
  21234. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21235. /** @hidden */
  21236. _emitFloat(value: number): string;
  21237. }
  21238. }
  21239. declare module BABYLON {
  21240. /**
  21241. * Helper class used to generate session unique ID
  21242. */
  21243. export class UniqueIdGenerator {
  21244. private static _UniqueIdCounter;
  21245. /**
  21246. * Gets an unique (relatively to the current scene) Id
  21247. */
  21248. static get UniqueId(): number;
  21249. }
  21250. }
  21251. declare module BABYLON {
  21252. /**
  21253. * Defines a block that can be used inside a node based material
  21254. */
  21255. export class NodeMaterialBlock {
  21256. private _buildId;
  21257. private _buildTarget;
  21258. private _target;
  21259. private _isFinalMerger;
  21260. private _isInput;
  21261. protected _isUnique: boolean;
  21262. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21263. inputsAreExclusive: boolean;
  21264. /** @hidden */
  21265. _codeVariableName: string;
  21266. /** @hidden */
  21267. _inputs: NodeMaterialConnectionPoint[];
  21268. /** @hidden */
  21269. _outputs: NodeMaterialConnectionPoint[];
  21270. /** @hidden */
  21271. _preparationId: number;
  21272. /**
  21273. * Gets or sets the name of the block
  21274. */
  21275. name: string;
  21276. /**
  21277. * Gets or sets the unique id of the node
  21278. */
  21279. uniqueId: number;
  21280. /**
  21281. * Gets or sets the comments associated with this block
  21282. */
  21283. comments: string;
  21284. /**
  21285. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21286. */
  21287. get isUnique(): boolean;
  21288. /**
  21289. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21290. */
  21291. get isFinalMerger(): boolean;
  21292. /**
  21293. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21294. */
  21295. get isInput(): boolean;
  21296. /**
  21297. * Gets or sets the build Id
  21298. */
  21299. get buildId(): number;
  21300. set buildId(value: number);
  21301. /**
  21302. * Gets or sets the target of the block
  21303. */
  21304. get target(): NodeMaterialBlockTargets;
  21305. set target(value: NodeMaterialBlockTargets);
  21306. /**
  21307. * Gets the list of input points
  21308. */
  21309. get inputs(): NodeMaterialConnectionPoint[];
  21310. /** Gets the list of output points */
  21311. get outputs(): NodeMaterialConnectionPoint[];
  21312. /**
  21313. * Find an input by its name
  21314. * @param name defines the name of the input to look for
  21315. * @returns the input or null if not found
  21316. */
  21317. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21318. /**
  21319. * Find an output by its name
  21320. * @param name defines the name of the outputto look for
  21321. * @returns the output or null if not found
  21322. */
  21323. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21324. /**
  21325. * Creates a new NodeMaterialBlock
  21326. * @param name defines the block name
  21327. * @param target defines the target of that block (Vertex by default)
  21328. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21329. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21330. */
  21331. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21332. /**
  21333. * Initialize the block and prepare the context for build
  21334. * @param state defines the state that will be used for the build
  21335. */
  21336. initialize(state: NodeMaterialBuildState): void;
  21337. /**
  21338. * Bind data to effect. Will only be called for blocks with isBindable === true
  21339. * @param effect defines the effect to bind data to
  21340. * @param nodeMaterial defines the hosting NodeMaterial
  21341. * @param mesh defines the mesh that will be rendered
  21342. * @param subMesh defines the submesh that will be rendered
  21343. */
  21344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21345. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21346. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21347. protected _writeFloat(value: number): string;
  21348. /**
  21349. * Gets the current class name e.g. "NodeMaterialBlock"
  21350. * @returns the class name
  21351. */
  21352. getClassName(): string;
  21353. /**
  21354. * Register a new input. Must be called inside a block constructor
  21355. * @param name defines the connection point name
  21356. * @param type defines the connection point type
  21357. * @param isOptional defines a boolean indicating that this input can be omitted
  21358. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21359. * @param point an already created connection point. If not provided, create a new one
  21360. * @returns the current block
  21361. */
  21362. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21363. /**
  21364. * Register a new output. Must be called inside a block constructor
  21365. * @param name defines the connection point name
  21366. * @param type defines the connection point type
  21367. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21368. * @param point an already created connection point. If not provided, create a new one
  21369. * @returns the current block
  21370. */
  21371. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21372. /**
  21373. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21374. * @param forOutput defines an optional connection point to check compatibility with
  21375. * @returns the first available input or null
  21376. */
  21377. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21378. /**
  21379. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21380. * @param forBlock defines an optional block to check compatibility with
  21381. * @returns the first available input or null
  21382. */
  21383. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21384. /**
  21385. * Gets the sibling of the given output
  21386. * @param current defines the current output
  21387. * @returns the next output in the list or null
  21388. */
  21389. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21390. /**
  21391. * Connect current block with another block
  21392. * @param other defines the block to connect with
  21393. * @param options define the various options to help pick the right connections
  21394. * @returns the current block
  21395. */
  21396. connectTo(other: NodeMaterialBlock, options?: {
  21397. input?: string;
  21398. output?: string;
  21399. outputSwizzle?: string;
  21400. }): this | undefined;
  21401. protected _buildBlock(state: NodeMaterialBuildState): void;
  21402. /**
  21403. * Add uniforms, samplers and uniform buffers at compilation time
  21404. * @param state defines the state to update
  21405. * @param nodeMaterial defines the node material requesting the update
  21406. * @param defines defines the material defines to update
  21407. * @param uniformBuffers defines the list of uniform buffer names
  21408. */
  21409. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21410. /**
  21411. * Add potential fallbacks if shader compilation fails
  21412. * @param mesh defines the mesh to be rendered
  21413. * @param fallbacks defines the current prioritized list of fallbacks
  21414. */
  21415. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21416. /**
  21417. * Initialize defines for shader compilation
  21418. * @param mesh defines the mesh to be rendered
  21419. * @param nodeMaterial defines the node material requesting the update
  21420. * @param defines defines the material defines to update
  21421. * @param useInstances specifies that instances should be used
  21422. */
  21423. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21424. /**
  21425. * Update defines for shader compilation
  21426. * @param mesh defines the mesh to be rendered
  21427. * @param nodeMaterial defines the node material requesting the update
  21428. * @param defines defines the material defines to update
  21429. * @param useInstances specifies that instances should be used
  21430. * @param subMesh defines which submesh to render
  21431. */
  21432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21433. /**
  21434. * Lets the block try to connect some inputs automatically
  21435. * @param material defines the hosting NodeMaterial
  21436. */
  21437. autoConfigure(material: NodeMaterial): void;
  21438. /**
  21439. * Function called when a block is declared as repeatable content generator
  21440. * @param vertexShaderState defines the current compilation state for the vertex shader
  21441. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21442. * @param mesh defines the mesh to be rendered
  21443. * @param defines defines the material defines to update
  21444. */
  21445. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21446. /**
  21447. * Checks if the block is ready
  21448. * @param mesh defines the mesh to be rendered
  21449. * @param nodeMaterial defines the node material requesting the update
  21450. * @param defines defines the material defines to update
  21451. * @param useInstances specifies that instances should be used
  21452. * @returns true if the block is ready
  21453. */
  21454. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21455. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21456. private _processBuild;
  21457. /**
  21458. * Compile the current node and generate the shader code
  21459. * @param state defines the current compilation state (uniforms, samplers, current string)
  21460. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21461. * @returns true if already built
  21462. */
  21463. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21464. protected _inputRename(name: string): string;
  21465. protected _outputRename(name: string): string;
  21466. protected _dumpPropertiesCode(): string;
  21467. /** @hidden */
  21468. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21469. /** @hidden */
  21470. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21471. /**
  21472. * Clone the current block to a new identical block
  21473. * @param scene defines the hosting scene
  21474. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21475. * @returns a copy of the current block
  21476. */
  21477. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21478. /**
  21479. * Serializes this block in a JSON representation
  21480. * @returns the serialized block object
  21481. */
  21482. serialize(): any;
  21483. /** @hidden */
  21484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21485. private _deserializePortDisplayNamesAndExposedOnFrame;
  21486. /**
  21487. * Release resources
  21488. */
  21489. dispose(): void;
  21490. }
  21491. }
  21492. declare module BABYLON {
  21493. /**
  21494. * Base class of materials working in push mode in babylon JS
  21495. * @hidden
  21496. */
  21497. export class PushMaterial extends Material {
  21498. protected _activeEffect: Effect;
  21499. protected _normalMatrix: Matrix;
  21500. constructor(name: string, scene: Scene);
  21501. getEffect(): Effect;
  21502. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21503. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21504. /**
  21505. * Binds the given world matrix to the active effect
  21506. *
  21507. * @param world the matrix to bind
  21508. */
  21509. bindOnlyWorldMatrix(world: Matrix): void;
  21510. /**
  21511. * Binds the given normal matrix to the active effect
  21512. *
  21513. * @param normalMatrix the matrix to bind
  21514. */
  21515. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21516. bind(world: Matrix, mesh?: Mesh): void;
  21517. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21518. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21519. }
  21520. }
  21521. declare module BABYLON {
  21522. /**
  21523. * Root class for all node material optimizers
  21524. */
  21525. export class NodeMaterialOptimizer {
  21526. /**
  21527. * Function used to optimize a NodeMaterial graph
  21528. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21529. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21530. */
  21531. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21537. */
  21538. export class TransformBlock extends NodeMaterialBlock {
  21539. /**
  21540. * Defines the value to use to complement W value to transform it to a Vector4
  21541. */
  21542. complementW: number;
  21543. /**
  21544. * Defines the value to use to complement z value to transform it to a Vector4
  21545. */
  21546. complementZ: number;
  21547. /**
  21548. * Creates a new TransformBlock
  21549. * @param name defines the block name
  21550. */
  21551. constructor(name: string);
  21552. /**
  21553. * Gets the current class name
  21554. * @returns the class name
  21555. */
  21556. getClassName(): string;
  21557. /**
  21558. * Gets the vector input
  21559. */
  21560. get vector(): NodeMaterialConnectionPoint;
  21561. /**
  21562. * Gets the output component
  21563. */
  21564. get output(): NodeMaterialConnectionPoint;
  21565. /**
  21566. * Gets the xyz output component
  21567. */
  21568. get xyz(): NodeMaterialConnectionPoint;
  21569. /**
  21570. * Gets the matrix transform input
  21571. */
  21572. get transform(): NodeMaterialConnectionPoint;
  21573. protected _buildBlock(state: NodeMaterialBuildState): this;
  21574. /**
  21575. * Update defines for shader compilation
  21576. * @param mesh defines the mesh to be rendered
  21577. * @param nodeMaterial defines the node material requesting the update
  21578. * @param defines defines the material defines to update
  21579. * @param useInstances specifies that instances should be used
  21580. * @param subMesh defines which submesh to render
  21581. */
  21582. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21583. serialize(): any;
  21584. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21585. protected _dumpPropertiesCode(): string;
  21586. }
  21587. }
  21588. declare module BABYLON {
  21589. /**
  21590. * Block used to output the vertex position
  21591. */
  21592. export class VertexOutputBlock extends NodeMaterialBlock {
  21593. /**
  21594. * Creates a new VertexOutputBlock
  21595. * @param name defines the block name
  21596. */
  21597. constructor(name: string);
  21598. /**
  21599. * Gets the current class name
  21600. * @returns the class name
  21601. */
  21602. getClassName(): string;
  21603. /**
  21604. * Gets the vector input component
  21605. */
  21606. get vector(): NodeMaterialConnectionPoint;
  21607. protected _buildBlock(state: NodeMaterialBuildState): this;
  21608. }
  21609. }
  21610. declare module BABYLON {
  21611. /**
  21612. * Block used to output the final color
  21613. */
  21614. export class FragmentOutputBlock extends NodeMaterialBlock {
  21615. /**
  21616. * Create a new FragmentOutputBlock
  21617. * @param name defines the block name
  21618. */
  21619. constructor(name: string);
  21620. /**
  21621. * Gets the current class name
  21622. * @returns the class name
  21623. */
  21624. getClassName(): string;
  21625. /**
  21626. * Gets the rgba input component
  21627. */
  21628. get rgba(): NodeMaterialConnectionPoint;
  21629. /**
  21630. * Gets the rgb input component
  21631. */
  21632. get rgb(): NodeMaterialConnectionPoint;
  21633. /**
  21634. * Gets the a input component
  21635. */
  21636. get a(): NodeMaterialConnectionPoint;
  21637. protected _buildBlock(state: NodeMaterialBuildState): this;
  21638. }
  21639. }
  21640. declare module BABYLON {
  21641. /**
  21642. * Block used for the particle ramp gradient section
  21643. */
  21644. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21645. /**
  21646. * Create a new ParticleRampGradientBlock
  21647. * @param name defines the block name
  21648. */
  21649. constructor(name: string);
  21650. /**
  21651. * Gets the current class name
  21652. * @returns the class name
  21653. */
  21654. getClassName(): string;
  21655. /**
  21656. * Gets the color input component
  21657. */
  21658. get color(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the rampColor output component
  21661. */
  21662. get rampColor(): NodeMaterialConnectionPoint;
  21663. /**
  21664. * Initialize the block and prepare the context for build
  21665. * @param state defines the state that will be used for the build
  21666. */
  21667. initialize(state: NodeMaterialBuildState): void;
  21668. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21669. }
  21670. }
  21671. declare module BABYLON {
  21672. /**
  21673. * Block used for the particle blend multiply section
  21674. */
  21675. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21676. /**
  21677. * Create a new ParticleBlendMultiplyBlock
  21678. * @param name defines the block name
  21679. */
  21680. constructor(name: string);
  21681. /**
  21682. * Gets the current class name
  21683. * @returns the class name
  21684. */
  21685. getClassName(): string;
  21686. /**
  21687. * Gets the color input component
  21688. */
  21689. get color(): NodeMaterialConnectionPoint;
  21690. /**
  21691. * Gets the alphaTexture input component
  21692. */
  21693. get alphaTexture(): NodeMaterialConnectionPoint;
  21694. /**
  21695. * Gets the alphaColor input component
  21696. */
  21697. get alphaColor(): NodeMaterialConnectionPoint;
  21698. /**
  21699. * Gets the blendColor output component
  21700. */
  21701. get blendColor(): NodeMaterialConnectionPoint;
  21702. /**
  21703. * Initialize the block and prepare the context for build
  21704. * @param state defines the state that will be used for the build
  21705. */
  21706. initialize(state: NodeMaterialBuildState): void;
  21707. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21708. }
  21709. }
  21710. declare module BABYLON {
  21711. /**
  21712. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21713. */
  21714. export class VectorMergerBlock extends NodeMaterialBlock {
  21715. /**
  21716. * Create a new VectorMergerBlock
  21717. * @param name defines the block name
  21718. */
  21719. constructor(name: string);
  21720. /**
  21721. * Gets the current class name
  21722. * @returns the class name
  21723. */
  21724. getClassName(): string;
  21725. /**
  21726. * Gets the xyz component (input)
  21727. */
  21728. get xyzIn(): NodeMaterialConnectionPoint;
  21729. /**
  21730. * Gets the xy component (input)
  21731. */
  21732. get xyIn(): NodeMaterialConnectionPoint;
  21733. /**
  21734. * Gets the x component (input)
  21735. */
  21736. get x(): NodeMaterialConnectionPoint;
  21737. /**
  21738. * Gets the y component (input)
  21739. */
  21740. get y(): NodeMaterialConnectionPoint;
  21741. /**
  21742. * Gets the z component (input)
  21743. */
  21744. get z(): NodeMaterialConnectionPoint;
  21745. /**
  21746. * Gets the w component (input)
  21747. */
  21748. get w(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the xyzw component (output)
  21751. */
  21752. get xyzw(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Gets the xyz component (output)
  21755. */
  21756. get xyzOut(): NodeMaterialConnectionPoint;
  21757. /**
  21758. * Gets the xy component (output)
  21759. */
  21760. get xyOut(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the xy component (output)
  21763. * @deprecated Please use xyOut instead.
  21764. */
  21765. get xy(): NodeMaterialConnectionPoint;
  21766. /**
  21767. * Gets the xyz component (output)
  21768. * @deprecated Please use xyzOut instead.
  21769. */
  21770. get xyz(): NodeMaterialConnectionPoint;
  21771. protected _buildBlock(state: NodeMaterialBuildState): this;
  21772. }
  21773. }
  21774. declare module BABYLON {
  21775. /**
  21776. * Block used to remap a float from a range to a new one
  21777. */
  21778. export class RemapBlock extends NodeMaterialBlock {
  21779. /**
  21780. * Gets or sets the source range
  21781. */
  21782. sourceRange: Vector2;
  21783. /**
  21784. * Gets or sets the target range
  21785. */
  21786. targetRange: Vector2;
  21787. /**
  21788. * Creates a new RemapBlock
  21789. * @param name defines the block name
  21790. */
  21791. constructor(name: string);
  21792. /**
  21793. * Gets the current class name
  21794. * @returns the class name
  21795. */
  21796. getClassName(): string;
  21797. /**
  21798. * Gets the input component
  21799. */
  21800. get input(): NodeMaterialConnectionPoint;
  21801. /**
  21802. * Gets the source min input component
  21803. */
  21804. get sourceMin(): NodeMaterialConnectionPoint;
  21805. /**
  21806. * Gets the source max input component
  21807. */
  21808. get sourceMax(): NodeMaterialConnectionPoint;
  21809. /**
  21810. * Gets the target min input component
  21811. */
  21812. get targetMin(): NodeMaterialConnectionPoint;
  21813. /**
  21814. * Gets the target max input component
  21815. */
  21816. get targetMax(): NodeMaterialConnectionPoint;
  21817. /**
  21818. * Gets the output component
  21819. */
  21820. get output(): NodeMaterialConnectionPoint;
  21821. protected _buildBlock(state: NodeMaterialBuildState): this;
  21822. protected _dumpPropertiesCode(): string;
  21823. serialize(): any;
  21824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21825. }
  21826. }
  21827. declare module BABYLON {
  21828. /**
  21829. * Block used to multiply 2 values
  21830. */
  21831. export class MultiplyBlock extends NodeMaterialBlock {
  21832. /**
  21833. * Creates a new MultiplyBlock
  21834. * @param name defines the block name
  21835. */
  21836. constructor(name: string);
  21837. /**
  21838. * Gets the current class name
  21839. * @returns the class name
  21840. */
  21841. getClassName(): string;
  21842. /**
  21843. * Gets the left operand input component
  21844. */
  21845. get left(): NodeMaterialConnectionPoint;
  21846. /**
  21847. * Gets the right operand input component
  21848. */
  21849. get right(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the output component
  21852. */
  21853. get output(): NodeMaterialConnectionPoint;
  21854. protected _buildBlock(state: NodeMaterialBuildState): this;
  21855. }
  21856. }
  21857. declare module BABYLON {
  21858. /**
  21859. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21860. */
  21861. export class ColorSplitterBlock extends NodeMaterialBlock {
  21862. /**
  21863. * Create a new ColorSplitterBlock
  21864. * @param name defines the block name
  21865. */
  21866. constructor(name: string);
  21867. /**
  21868. * Gets the current class name
  21869. * @returns the class name
  21870. */
  21871. getClassName(): string;
  21872. /**
  21873. * Gets the rgba component (input)
  21874. */
  21875. get rgba(): NodeMaterialConnectionPoint;
  21876. /**
  21877. * Gets the rgb component (input)
  21878. */
  21879. get rgbIn(): NodeMaterialConnectionPoint;
  21880. /**
  21881. * Gets the rgb component (output)
  21882. */
  21883. get rgbOut(): NodeMaterialConnectionPoint;
  21884. /**
  21885. * Gets the r component (output)
  21886. */
  21887. get r(): NodeMaterialConnectionPoint;
  21888. /**
  21889. * Gets the g component (output)
  21890. */
  21891. get g(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the b component (output)
  21894. */
  21895. get b(): NodeMaterialConnectionPoint;
  21896. /**
  21897. * Gets the a component (output)
  21898. */
  21899. get a(): NodeMaterialConnectionPoint;
  21900. protected _inputRename(name: string): string;
  21901. protected _outputRename(name: string): string;
  21902. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21903. }
  21904. }
  21905. declare module BABYLON {
  21906. /**
  21907. * Interface used to configure the node material editor
  21908. */
  21909. export interface INodeMaterialEditorOptions {
  21910. /** Define the URl to load node editor script */
  21911. editorURL?: string;
  21912. }
  21913. /** @hidden */
  21914. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21915. NORMAL: boolean;
  21916. TANGENT: boolean;
  21917. UV1: boolean;
  21918. /** BONES */
  21919. NUM_BONE_INFLUENCERS: number;
  21920. BonesPerMesh: number;
  21921. BONETEXTURE: boolean;
  21922. /** MORPH TARGETS */
  21923. MORPHTARGETS: boolean;
  21924. MORPHTARGETS_NORMAL: boolean;
  21925. MORPHTARGETS_TANGENT: boolean;
  21926. MORPHTARGETS_UV: boolean;
  21927. NUM_MORPH_INFLUENCERS: number;
  21928. /** IMAGE PROCESSING */
  21929. IMAGEPROCESSING: boolean;
  21930. VIGNETTE: boolean;
  21931. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21932. VIGNETTEBLENDMODEOPAQUE: boolean;
  21933. TONEMAPPING: boolean;
  21934. TONEMAPPING_ACES: boolean;
  21935. CONTRAST: boolean;
  21936. EXPOSURE: boolean;
  21937. COLORCURVES: boolean;
  21938. COLORGRADING: boolean;
  21939. COLORGRADING3D: boolean;
  21940. SAMPLER3DGREENDEPTH: boolean;
  21941. SAMPLER3DBGRMAP: boolean;
  21942. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21943. /** MISC. */
  21944. BUMPDIRECTUV: number;
  21945. constructor();
  21946. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21947. }
  21948. /**
  21949. * Class used to configure NodeMaterial
  21950. */
  21951. export interface INodeMaterialOptions {
  21952. /**
  21953. * Defines if blocks should emit comments
  21954. */
  21955. emitComments: boolean;
  21956. }
  21957. /**
  21958. * Class used to create a node based material built by assembling shader blocks
  21959. */
  21960. export class NodeMaterial extends PushMaterial {
  21961. private static _BuildIdGenerator;
  21962. private _options;
  21963. private _vertexCompilationState;
  21964. private _fragmentCompilationState;
  21965. private _sharedData;
  21966. private _buildId;
  21967. private _buildWasSuccessful;
  21968. private _cachedWorldViewMatrix;
  21969. private _cachedWorldViewProjectionMatrix;
  21970. private _optimizers;
  21971. private _animationFrame;
  21972. /** Define the Url to load node editor script */
  21973. static EditorURL: string;
  21974. /** Define the Url to load snippets */
  21975. static SnippetUrl: string;
  21976. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  21977. static IgnoreTexturesAtLoadTime: boolean;
  21978. private BJSNODEMATERIALEDITOR;
  21979. /** Get the inspector from bundle or global */
  21980. private _getGlobalNodeMaterialEditor;
  21981. /**
  21982. * Snippet ID if the material was created from the snippet server
  21983. */
  21984. snippetId: string;
  21985. /**
  21986. * Gets or sets data used by visual editor
  21987. * @see https://nme.babylonjs.com
  21988. */
  21989. editorData: any;
  21990. /**
  21991. * 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)
  21992. */
  21993. ignoreAlpha: boolean;
  21994. /**
  21995. * Defines the maximum number of lights that can be used in the material
  21996. */
  21997. maxSimultaneousLights: number;
  21998. /**
  21999. * Observable raised when the material is built
  22000. */
  22001. onBuildObservable: Observable<NodeMaterial>;
  22002. /**
  22003. * Gets or sets the root nodes of the material vertex shader
  22004. */
  22005. _vertexOutputNodes: NodeMaterialBlock[];
  22006. /**
  22007. * Gets or sets the root nodes of the material fragment (pixel) shader
  22008. */
  22009. _fragmentOutputNodes: NodeMaterialBlock[];
  22010. /** Gets or sets options to control the node material overall behavior */
  22011. get options(): INodeMaterialOptions;
  22012. set options(options: INodeMaterialOptions);
  22013. /**
  22014. * Default configuration related to image processing available in the standard Material.
  22015. */
  22016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22017. /**
  22018. * Gets the image processing configuration used either in this material.
  22019. */
  22020. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22021. /**
  22022. * Sets the Default image processing configuration used either in the this material.
  22023. *
  22024. * If sets to null, the scene one is in use.
  22025. */
  22026. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22027. /**
  22028. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22029. */
  22030. attachedBlocks: NodeMaterialBlock[];
  22031. /**
  22032. * Specifies the mode of the node material
  22033. * @hidden
  22034. */
  22035. _mode: NodeMaterialModes;
  22036. /**
  22037. * Gets the mode property
  22038. */
  22039. get mode(): NodeMaterialModes;
  22040. /**
  22041. * Create a new node based material
  22042. * @param name defines the material name
  22043. * @param scene defines the hosting scene
  22044. * @param options defines creation option
  22045. */
  22046. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22047. /**
  22048. * Gets the current class name of the material e.g. "NodeMaterial"
  22049. * @returns the class name
  22050. */
  22051. getClassName(): string;
  22052. /**
  22053. * Keep track of the image processing observer to allow dispose and replace.
  22054. */
  22055. private _imageProcessingObserver;
  22056. /**
  22057. * Attaches a new image processing configuration to the Standard Material.
  22058. * @param configuration
  22059. */
  22060. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22061. /**
  22062. * Get a block by its name
  22063. * @param name defines the name of the block to retrieve
  22064. * @returns the required block or null if not found
  22065. */
  22066. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22067. /**
  22068. * Get a block by its name
  22069. * @param predicate defines the predicate used to find the good candidate
  22070. * @returns the required block or null if not found
  22071. */
  22072. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22073. /**
  22074. * Get an input block by its name
  22075. * @param predicate defines the predicate used to find the good candidate
  22076. * @returns the required input block or null if not found
  22077. */
  22078. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22079. /**
  22080. * Gets the list of input blocks attached to this material
  22081. * @returns an array of InputBlocks
  22082. */
  22083. getInputBlocks(): InputBlock[];
  22084. /**
  22085. * Adds a new optimizer to the list of optimizers
  22086. * @param optimizer defines the optimizers to add
  22087. * @returns the current material
  22088. */
  22089. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22090. /**
  22091. * Remove an optimizer from the list of optimizers
  22092. * @param optimizer defines the optimizers to remove
  22093. * @returns the current material
  22094. */
  22095. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22096. /**
  22097. * Add a new block to the list of output nodes
  22098. * @param node defines the node to add
  22099. * @returns the current material
  22100. */
  22101. addOutputNode(node: NodeMaterialBlock): this;
  22102. /**
  22103. * Remove a block from the list of root nodes
  22104. * @param node defines the node to remove
  22105. * @returns the current material
  22106. */
  22107. removeOutputNode(node: NodeMaterialBlock): this;
  22108. private _addVertexOutputNode;
  22109. private _removeVertexOutputNode;
  22110. private _addFragmentOutputNode;
  22111. private _removeFragmentOutputNode;
  22112. /**
  22113. * Specifies if the material will require alpha blending
  22114. * @returns a boolean specifying if alpha blending is needed
  22115. */
  22116. needAlphaBlending(): boolean;
  22117. /**
  22118. * Specifies if this material should be rendered in alpha test mode
  22119. * @returns a boolean specifying if an alpha test is needed.
  22120. */
  22121. needAlphaTesting(): boolean;
  22122. private _initializeBlock;
  22123. private _resetDualBlocks;
  22124. /**
  22125. * Remove a block from the current node material
  22126. * @param block defines the block to remove
  22127. */
  22128. removeBlock(block: NodeMaterialBlock): void;
  22129. /**
  22130. * Build the material and generates the inner effect
  22131. * @param verbose defines if the build should log activity
  22132. */
  22133. build(verbose?: boolean): void;
  22134. /**
  22135. * Runs an otpimization phase to try to improve the shader code
  22136. */
  22137. optimize(): void;
  22138. private _prepareDefinesForAttributes;
  22139. /**
  22140. * Create a post process from the material
  22141. * @param camera The camera to apply the render pass to.
  22142. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22143. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22144. * @param engine The engine which the post process will be applied. (default: current engine)
  22145. * @param reusable If the post process can be reused on the same frame. (default: false)
  22146. * @param textureType Type of textures used when performing the post process. (default: 0)
  22147. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22148. * @returns the post process created
  22149. */
  22150. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22151. /**
  22152. * Create the post process effect from the material
  22153. * @param postProcess The post process to create the effect for
  22154. */
  22155. createEffectForPostProcess(postProcess: PostProcess): void;
  22156. private _createEffectOrPostProcess;
  22157. private _createEffectForParticles;
  22158. /**
  22159. * Create the effect to be used as the custom effect for a particle system
  22160. * @param particleSystem Particle system to create the effect for
  22161. * @param onCompiled defines a function to call when the effect creation is successful
  22162. * @param onError defines a function to call when the effect creation has failed
  22163. */
  22164. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22165. private _processDefines;
  22166. /**
  22167. * Get if the submesh is ready to be used and all its information available.
  22168. * Child classes can use it to update shaders
  22169. * @param mesh defines the mesh to check
  22170. * @param subMesh defines which submesh to check
  22171. * @param useInstances specifies that instances should be used
  22172. * @returns a boolean indicating that the submesh is ready or not
  22173. */
  22174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22175. /**
  22176. * Get a string representing the shaders built by the current node graph
  22177. */
  22178. get compiledShaders(): string;
  22179. /**
  22180. * Binds the world matrix to the material
  22181. * @param world defines the world transformation matrix
  22182. */
  22183. bindOnlyWorldMatrix(world: Matrix): void;
  22184. /**
  22185. * Binds the submesh to this material by preparing the effect and shader to draw
  22186. * @param world defines the world transformation matrix
  22187. * @param mesh defines the mesh containing the submesh
  22188. * @param subMesh defines the submesh to bind the material to
  22189. */
  22190. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22191. /**
  22192. * Gets the active textures from the material
  22193. * @returns an array of textures
  22194. */
  22195. getActiveTextures(): BaseTexture[];
  22196. /**
  22197. * Gets the list of texture blocks
  22198. * @returns an array of texture blocks
  22199. */
  22200. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22201. /**
  22202. * Specifies if the material uses a texture
  22203. * @param texture defines the texture to check against the material
  22204. * @returns a boolean specifying if the material uses the texture
  22205. */
  22206. hasTexture(texture: BaseTexture): boolean;
  22207. /**
  22208. * Disposes the material
  22209. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22210. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22211. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22212. */
  22213. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22214. /** Creates the node editor window. */
  22215. private _createNodeEditor;
  22216. /**
  22217. * Launch the node material editor
  22218. * @param config Define the configuration of the editor
  22219. * @return a promise fulfilled when the node editor is visible
  22220. */
  22221. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22222. /**
  22223. * Clear the current material
  22224. */
  22225. clear(): void;
  22226. /**
  22227. * Clear the current material and set it to a default state
  22228. */
  22229. setToDefault(): void;
  22230. /**
  22231. * Clear the current material and set it to a default state for post process
  22232. */
  22233. setToDefaultPostProcess(): void;
  22234. /**
  22235. * Clear the current material and set it to a default state for particle
  22236. */
  22237. setToDefaultParticle(): void;
  22238. /**
  22239. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22240. * @param url defines the url to load from
  22241. * @returns a promise that will fullfil when the material is fully loaded
  22242. */
  22243. loadAsync(url: string): Promise<void>;
  22244. private _gatherBlocks;
  22245. /**
  22246. * Generate a string containing the code declaration required to create an equivalent of this material
  22247. * @returns a string
  22248. */
  22249. generateCode(): string;
  22250. /**
  22251. * Serializes this material in a JSON representation
  22252. * @returns the serialized material object
  22253. */
  22254. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22255. private _restoreConnections;
  22256. /**
  22257. * Clear the current graph and load a new one from a serialization object
  22258. * @param source defines the JSON representation of the material
  22259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22260. * @param merge defines whether or not the source must be merged or replace the current content
  22261. */
  22262. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22263. /**
  22264. * Makes a duplicate of the current material.
  22265. * @param name - name to use for the new material.
  22266. */
  22267. clone(name: string): NodeMaterial;
  22268. /**
  22269. * Creates a node material from parsed material data
  22270. * @param source defines the JSON representation of the material
  22271. * @param scene defines the hosting scene
  22272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22273. * @returns a new node material
  22274. */
  22275. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22276. /**
  22277. * Creates a node material from a snippet saved in a remote file
  22278. * @param name defines the name of the material to create
  22279. * @param url defines the url to load from
  22280. * @param scene defines the hosting scene
  22281. * @returns a promise that will resolve to the new node material
  22282. */
  22283. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22284. /**
  22285. * Creates a node material from a snippet saved by the node material editor
  22286. * @param snippetId defines the snippet to load
  22287. * @param scene defines the hosting scene
  22288. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22289. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22290. * @returns a promise that will resolve to the new node material
  22291. */
  22292. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22293. /**
  22294. * Creates a new node material set to default basic configuration
  22295. * @param name defines the name of the material
  22296. * @param scene defines the hosting scene
  22297. * @returns a new NodeMaterial
  22298. */
  22299. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22300. }
  22301. }
  22302. declare module BABYLON {
  22303. /**
  22304. * Size options for a post process
  22305. */
  22306. export type PostProcessOptions = {
  22307. width: number;
  22308. height: number;
  22309. };
  22310. /**
  22311. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22312. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22313. */
  22314. export class PostProcess {
  22315. /** Name of the PostProcess. */
  22316. name: string;
  22317. /**
  22318. * Gets or sets the unique id of the post process
  22319. */
  22320. uniqueId: number;
  22321. /**
  22322. * Width of the texture to apply the post process on
  22323. */
  22324. width: number;
  22325. /**
  22326. * Height of the texture to apply the post process on
  22327. */
  22328. height: number;
  22329. /**
  22330. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22331. */
  22332. nodeMaterialSource: Nullable<NodeMaterial>;
  22333. /**
  22334. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22335. * @hidden
  22336. */
  22337. _outputTexture: Nullable<InternalTexture>;
  22338. /**
  22339. * Sampling mode used by the shader
  22340. * See https://doc.babylonjs.com/classes/3.1/texture
  22341. */
  22342. renderTargetSamplingMode: number;
  22343. /**
  22344. * Clear color to use when screen clearing
  22345. */
  22346. clearColor: Color4;
  22347. /**
  22348. * If the buffer needs to be cleared before applying the post process. (default: true)
  22349. * Should be set to false if shader will overwrite all previous pixels.
  22350. */
  22351. autoClear: boolean;
  22352. /**
  22353. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22354. */
  22355. alphaMode: number;
  22356. /**
  22357. * Sets the setAlphaBlendConstants of the babylon engine
  22358. */
  22359. alphaConstants: Color4;
  22360. /**
  22361. * Animations to be used for the post processing
  22362. */
  22363. animations: Animation[];
  22364. /**
  22365. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22366. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22367. */
  22368. enablePixelPerfectMode: boolean;
  22369. /**
  22370. * Force the postprocess to be applied without taking in account viewport
  22371. */
  22372. forceFullscreenViewport: boolean;
  22373. /**
  22374. * List of inspectable custom properties (used by the Inspector)
  22375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22376. */
  22377. inspectableCustomProperties: IInspectable[];
  22378. /**
  22379. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22380. *
  22381. * | Value | Type | Description |
  22382. * | ----- | ----------------------------------- | ----------- |
  22383. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22384. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22385. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22386. *
  22387. */
  22388. scaleMode: number;
  22389. /**
  22390. * Force textures to be a power of two (default: false)
  22391. */
  22392. alwaysForcePOT: boolean;
  22393. private _samples;
  22394. /**
  22395. * Number of sample textures (default: 1)
  22396. */
  22397. get samples(): number;
  22398. set samples(n: number);
  22399. /**
  22400. * Modify the scale of the post process to be the same as the viewport (default: false)
  22401. */
  22402. adaptScaleToCurrentViewport: boolean;
  22403. private _camera;
  22404. protected _scene: Scene;
  22405. private _engine;
  22406. private _options;
  22407. private _reusable;
  22408. private _textureType;
  22409. private _textureFormat;
  22410. /**
  22411. * Smart array of input and output textures for the post process.
  22412. * @hidden
  22413. */
  22414. _textures: SmartArray<InternalTexture>;
  22415. /**
  22416. * The index in _textures that corresponds to the output texture.
  22417. * @hidden
  22418. */
  22419. _currentRenderTextureInd: number;
  22420. private _effect;
  22421. private _samplers;
  22422. private _fragmentUrl;
  22423. private _vertexUrl;
  22424. private _parameters;
  22425. private _scaleRatio;
  22426. protected _indexParameters: any;
  22427. private _shareOutputWithPostProcess;
  22428. private _texelSize;
  22429. private _forcedOutputTexture;
  22430. /**
  22431. * Returns the fragment url or shader name used in the post process.
  22432. * @returns the fragment url or name in the shader store.
  22433. */
  22434. getEffectName(): string;
  22435. /**
  22436. * An event triggered when the postprocess is activated.
  22437. */
  22438. onActivateObservable: Observable<Camera>;
  22439. private _onActivateObserver;
  22440. /**
  22441. * A function that is added to the onActivateObservable
  22442. */
  22443. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22444. /**
  22445. * An event triggered when the postprocess changes its size.
  22446. */
  22447. onSizeChangedObservable: Observable<PostProcess>;
  22448. private _onSizeChangedObserver;
  22449. /**
  22450. * A function that is added to the onSizeChangedObservable
  22451. */
  22452. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22453. /**
  22454. * An event triggered when the postprocess applies its effect.
  22455. */
  22456. onApplyObservable: Observable<Effect>;
  22457. private _onApplyObserver;
  22458. /**
  22459. * A function that is added to the onApplyObservable
  22460. */
  22461. set onApply(callback: (effect: Effect) => void);
  22462. /**
  22463. * An event triggered before rendering the postprocess
  22464. */
  22465. onBeforeRenderObservable: Observable<Effect>;
  22466. private _onBeforeRenderObserver;
  22467. /**
  22468. * A function that is added to the onBeforeRenderObservable
  22469. */
  22470. set onBeforeRender(callback: (effect: Effect) => void);
  22471. /**
  22472. * An event triggered after rendering the postprocess
  22473. */
  22474. onAfterRenderObservable: Observable<Effect>;
  22475. private _onAfterRenderObserver;
  22476. /**
  22477. * A function that is added to the onAfterRenderObservable
  22478. */
  22479. set onAfterRender(callback: (efect: Effect) => void);
  22480. /**
  22481. * 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
  22482. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22483. */
  22484. get inputTexture(): InternalTexture;
  22485. set inputTexture(value: InternalTexture);
  22486. /**
  22487. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22488. * the only way to unset it is to use this function to restore its internal state
  22489. */
  22490. restoreDefaultInputTexture(): void;
  22491. /**
  22492. * Gets the camera which post process is applied to.
  22493. * @returns The camera the post process is applied to.
  22494. */
  22495. getCamera(): Camera;
  22496. /**
  22497. * Gets the texel size of the postprocess.
  22498. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22499. */
  22500. get texelSize(): Vector2;
  22501. /**
  22502. * Creates a new instance PostProcess
  22503. * @param name The name of the PostProcess.
  22504. * @param fragmentUrl The url of the fragment shader to be used.
  22505. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22506. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22507. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22508. * @param camera The camera to apply the render pass to.
  22509. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22510. * @param engine The engine which the post process will be applied. (default: current engine)
  22511. * @param reusable If the post process can be reused on the same frame. (default: false)
  22512. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22513. * @param textureType Type of textures used when performing the post process. (default: 0)
  22514. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22515. * @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
  22516. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22517. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22518. */
  22519. constructor(
  22520. /** Name of the PostProcess. */
  22521. 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);
  22522. /**
  22523. * Gets a string idenfifying the name of the class
  22524. * @returns "PostProcess" string
  22525. */
  22526. getClassName(): string;
  22527. /**
  22528. * Gets the engine which this post process belongs to.
  22529. * @returns The engine the post process was enabled with.
  22530. */
  22531. getEngine(): Engine;
  22532. /**
  22533. * The effect that is created when initializing the post process.
  22534. * @returns The created effect corresponding the the postprocess.
  22535. */
  22536. getEffect(): Effect;
  22537. /**
  22538. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22539. * @param postProcess The post process to share the output with.
  22540. * @returns This post process.
  22541. */
  22542. shareOutputWith(postProcess: PostProcess): PostProcess;
  22543. /**
  22544. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22545. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22546. */
  22547. useOwnOutput(): void;
  22548. /**
  22549. * Updates the effect with the current post process compile time values and recompiles the shader.
  22550. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22551. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22552. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22553. * @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
  22554. * @param onCompiled Called when the shader has been compiled.
  22555. * @param onError Called if there is an error when compiling a shader.
  22556. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22557. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22558. */
  22559. 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;
  22560. /**
  22561. * The post process is reusable if it can be used multiple times within one frame.
  22562. * @returns If the post process is reusable
  22563. */
  22564. isReusable(): boolean;
  22565. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22566. markTextureDirty(): void;
  22567. /**
  22568. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22569. * 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.
  22570. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22571. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22572. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22573. * @returns The target texture that was bound to be written to.
  22574. */
  22575. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22576. /**
  22577. * If the post process is supported.
  22578. */
  22579. get isSupported(): boolean;
  22580. /**
  22581. * The aspect ratio of the output texture.
  22582. */
  22583. get aspectRatio(): number;
  22584. /**
  22585. * Get a value indicating if the post-process is ready to be used
  22586. * @returns true if the post-process is ready (shader is compiled)
  22587. */
  22588. isReady(): boolean;
  22589. /**
  22590. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22591. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22592. */
  22593. apply(): Nullable<Effect>;
  22594. private _disposeTextures;
  22595. /**
  22596. * Disposes the post process.
  22597. * @param camera The camera to dispose the post process on.
  22598. */
  22599. dispose(camera?: Camera): void;
  22600. }
  22601. }
  22602. declare module BABYLON {
  22603. /** @hidden */
  22604. export var kernelBlurVaryingDeclaration: {
  22605. name: string;
  22606. shader: string;
  22607. };
  22608. }
  22609. declare module BABYLON {
  22610. /** @hidden */
  22611. export var kernelBlurFragment: {
  22612. name: string;
  22613. shader: string;
  22614. };
  22615. }
  22616. declare module BABYLON {
  22617. /** @hidden */
  22618. export var kernelBlurFragment2: {
  22619. name: string;
  22620. shader: string;
  22621. };
  22622. }
  22623. declare module BABYLON {
  22624. /** @hidden */
  22625. export var kernelBlurPixelShader: {
  22626. name: string;
  22627. shader: string;
  22628. };
  22629. }
  22630. declare module BABYLON {
  22631. /** @hidden */
  22632. export var kernelBlurVertex: {
  22633. name: string;
  22634. shader: string;
  22635. };
  22636. }
  22637. declare module BABYLON {
  22638. /** @hidden */
  22639. export var kernelBlurVertexShader: {
  22640. name: string;
  22641. shader: string;
  22642. };
  22643. }
  22644. declare module BABYLON {
  22645. /**
  22646. * The Blur Post Process which blurs an image based on a kernel and direction.
  22647. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22648. */
  22649. export class BlurPostProcess extends PostProcess {
  22650. /** The direction in which to blur the image. */
  22651. direction: Vector2;
  22652. private blockCompilation;
  22653. protected _kernel: number;
  22654. protected _idealKernel: number;
  22655. protected _packedFloat: boolean;
  22656. private _staticDefines;
  22657. /**
  22658. * Sets the length in pixels of the blur sample region
  22659. */
  22660. set kernel(v: number);
  22661. /**
  22662. * Gets the length in pixels of the blur sample region
  22663. */
  22664. get kernel(): number;
  22665. /**
  22666. * Sets wether or not the blur needs to unpack/repack floats
  22667. */
  22668. set packedFloat(v: boolean);
  22669. /**
  22670. * Gets wether or not the blur is unpacking/repacking floats
  22671. */
  22672. get packedFloat(): boolean;
  22673. /**
  22674. * Creates a new instance BlurPostProcess
  22675. * @param name The name of the effect.
  22676. * @param direction The direction in which to blur the image.
  22677. * @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.
  22678. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22679. * @param camera The camera to apply the render pass to.
  22680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22681. * @param engine The engine which the post process will be applied. (default: current engine)
  22682. * @param reusable If the post process can be reused on the same frame. (default: false)
  22683. * @param textureType Type of textures used when performing the post process. (default: 0)
  22684. * @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)
  22685. */
  22686. constructor(name: string,
  22687. /** The direction in which to blur the image. */
  22688. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22689. /**
  22690. * Updates the effect with the current post process compile time values and recompiles the shader.
  22691. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22692. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22693. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22694. * @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
  22695. * @param onCompiled Called when the shader has been compiled.
  22696. * @param onError Called if there is an error when compiling a shader.
  22697. */
  22698. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22699. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22700. /**
  22701. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22702. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22703. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22704. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22705. * The gaps between physical kernels are compensated for in the weighting of the samples
  22706. * @param idealKernel Ideal blur kernel.
  22707. * @return Nearest best kernel.
  22708. */
  22709. protected _nearestBestKernel(idealKernel: number): number;
  22710. /**
  22711. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22712. * @param x The point on the Gaussian distribution to sample.
  22713. * @return the value of the Gaussian function at x.
  22714. */
  22715. protected _gaussianWeight(x: number): number;
  22716. /**
  22717. * Generates a string that can be used as a floating point number in GLSL.
  22718. * @param x Value to print.
  22719. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22720. * @return GLSL float string.
  22721. */
  22722. protected _glslFloat(x: number, decimalFigures?: number): string;
  22723. }
  22724. }
  22725. declare module BABYLON {
  22726. /**
  22727. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22728. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22729. * You can then easily use it as a reflectionTexture on a flat surface.
  22730. * In case the surface is not a plane, please consider relying on reflection probes.
  22731. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22732. */
  22733. export class MirrorTexture extends RenderTargetTexture {
  22734. private scene;
  22735. /**
  22736. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22737. * 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.
  22738. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22739. */
  22740. mirrorPlane: Plane;
  22741. /**
  22742. * Define the blur ratio used to blur the reflection if needed.
  22743. */
  22744. set blurRatio(value: number);
  22745. get blurRatio(): number;
  22746. /**
  22747. * Define the adaptive blur kernel used to blur the reflection if needed.
  22748. * This will autocompute the closest best match for the `blurKernel`
  22749. */
  22750. set adaptiveBlurKernel(value: number);
  22751. /**
  22752. * Define the blur kernel used to blur the reflection if needed.
  22753. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22754. */
  22755. set blurKernel(value: number);
  22756. /**
  22757. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22758. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22759. */
  22760. set blurKernelX(value: number);
  22761. get blurKernelX(): number;
  22762. /**
  22763. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22764. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22765. */
  22766. set blurKernelY(value: number);
  22767. get blurKernelY(): number;
  22768. private _autoComputeBlurKernel;
  22769. protected _onRatioRescale(): void;
  22770. private _updateGammaSpace;
  22771. private _imageProcessingConfigChangeObserver;
  22772. private _transformMatrix;
  22773. private _mirrorMatrix;
  22774. private _savedViewMatrix;
  22775. private _blurX;
  22776. private _blurY;
  22777. private _adaptiveBlurKernel;
  22778. private _blurKernelX;
  22779. private _blurKernelY;
  22780. private _blurRatio;
  22781. /**
  22782. * Instantiates a Mirror Texture.
  22783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22785. * You can then easily use it as a reflectionTexture on a flat surface.
  22786. * In case the surface is not a plane, please consider relying on reflection probes.
  22787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22788. * @param name
  22789. * @param size
  22790. * @param scene
  22791. * @param generateMipMaps
  22792. * @param type
  22793. * @param samplingMode
  22794. * @param generateDepthBuffer
  22795. */
  22796. constructor(name: string, size: number | {
  22797. width: number;
  22798. height: number;
  22799. } | {
  22800. ratio: number;
  22801. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22802. private _preparePostProcesses;
  22803. /**
  22804. * Clone the mirror texture.
  22805. * @returns the cloned texture
  22806. */
  22807. clone(): MirrorTexture;
  22808. /**
  22809. * Serialize the texture to a JSON representation you could use in Parse later on
  22810. * @returns the serialized JSON representation
  22811. */
  22812. serialize(): any;
  22813. /**
  22814. * Dispose the texture and release its associated resources.
  22815. */
  22816. dispose(): void;
  22817. }
  22818. }
  22819. declare module BABYLON {
  22820. /**
  22821. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22822. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22823. */
  22824. export class Texture extends BaseTexture {
  22825. /**
  22826. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22827. */
  22828. static SerializeBuffers: boolean;
  22829. /** @hidden */
  22830. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22831. /** @hidden */
  22832. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22833. /** @hidden */
  22834. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22835. /** nearest is mag = nearest and min = nearest and mip = linear */
  22836. static readonly NEAREST_SAMPLINGMODE: number;
  22837. /** nearest is mag = nearest and min = nearest and mip = linear */
  22838. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22839. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22840. static readonly BILINEAR_SAMPLINGMODE: number;
  22841. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22842. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22843. /** Trilinear is mag = linear and min = linear and mip = linear */
  22844. static readonly TRILINEAR_SAMPLINGMODE: number;
  22845. /** Trilinear is mag = linear and min = linear and mip = linear */
  22846. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22847. /** mag = nearest and min = nearest and mip = nearest */
  22848. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22849. /** mag = nearest and min = linear and mip = nearest */
  22850. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22851. /** mag = nearest and min = linear and mip = linear */
  22852. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22853. /** mag = nearest and min = linear and mip = none */
  22854. static readonly NEAREST_LINEAR: number;
  22855. /** mag = nearest and min = nearest and mip = none */
  22856. static readonly NEAREST_NEAREST: number;
  22857. /** mag = linear and min = nearest and mip = nearest */
  22858. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22859. /** mag = linear and min = nearest and mip = linear */
  22860. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22861. /** mag = linear and min = linear and mip = none */
  22862. static readonly LINEAR_LINEAR: number;
  22863. /** mag = linear and min = nearest and mip = none */
  22864. static readonly LINEAR_NEAREST: number;
  22865. /** Explicit coordinates mode */
  22866. static readonly EXPLICIT_MODE: number;
  22867. /** Spherical coordinates mode */
  22868. static readonly SPHERICAL_MODE: number;
  22869. /** Planar coordinates mode */
  22870. static readonly PLANAR_MODE: number;
  22871. /** Cubic coordinates mode */
  22872. static readonly CUBIC_MODE: number;
  22873. /** Projection coordinates mode */
  22874. static readonly PROJECTION_MODE: number;
  22875. /** Inverse Cubic coordinates mode */
  22876. static readonly SKYBOX_MODE: number;
  22877. /** Inverse Cubic coordinates mode */
  22878. static readonly INVCUBIC_MODE: number;
  22879. /** Equirectangular coordinates mode */
  22880. static readonly EQUIRECTANGULAR_MODE: number;
  22881. /** Equirectangular Fixed coordinates mode */
  22882. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22883. /** Equirectangular Fixed Mirrored coordinates mode */
  22884. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22885. /** Texture is not repeating outside of 0..1 UVs */
  22886. static readonly CLAMP_ADDRESSMODE: number;
  22887. /** Texture is repeating outside of 0..1 UVs */
  22888. static readonly WRAP_ADDRESSMODE: number;
  22889. /** Texture is repeating and mirrored */
  22890. static readonly MIRROR_ADDRESSMODE: number;
  22891. /**
  22892. * 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
  22893. */
  22894. static UseSerializedUrlIfAny: boolean;
  22895. /**
  22896. * Define the url of the texture.
  22897. */
  22898. url: Nullable<string>;
  22899. /**
  22900. * Define an offset on the texture to offset the u coordinates of the UVs
  22901. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22902. */
  22903. uOffset: number;
  22904. /**
  22905. * Define an offset on the texture to offset the v coordinates of the UVs
  22906. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22907. */
  22908. vOffset: number;
  22909. /**
  22910. * Define an offset on the texture to scale the u coordinates of the UVs
  22911. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22912. */
  22913. uScale: number;
  22914. /**
  22915. * Define an offset on the texture to scale the v coordinates of the UVs
  22916. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22917. */
  22918. vScale: number;
  22919. /**
  22920. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22921. * @see https://doc.babylonjs.com/how_to/more_materials
  22922. */
  22923. uAng: number;
  22924. /**
  22925. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22926. * @see https://doc.babylonjs.com/how_to/more_materials
  22927. */
  22928. vAng: number;
  22929. /**
  22930. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22931. * @see https://doc.babylonjs.com/how_to/more_materials
  22932. */
  22933. wAng: number;
  22934. /**
  22935. * Defines the center of rotation (U)
  22936. */
  22937. uRotationCenter: number;
  22938. /**
  22939. * Defines the center of rotation (V)
  22940. */
  22941. vRotationCenter: number;
  22942. /**
  22943. * Defines the center of rotation (W)
  22944. */
  22945. wRotationCenter: number;
  22946. /**
  22947. * Are mip maps generated for this texture or not.
  22948. */
  22949. get noMipmap(): boolean;
  22950. /**
  22951. * List of inspectable custom properties (used by the Inspector)
  22952. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22953. */
  22954. inspectableCustomProperties: Nullable<IInspectable[]>;
  22955. private _noMipmap;
  22956. /** @hidden */
  22957. _invertY: boolean;
  22958. private _rowGenerationMatrix;
  22959. private _cachedTextureMatrix;
  22960. private _projectionModeMatrix;
  22961. private _t0;
  22962. private _t1;
  22963. private _t2;
  22964. private _cachedUOffset;
  22965. private _cachedVOffset;
  22966. private _cachedUScale;
  22967. private _cachedVScale;
  22968. private _cachedUAng;
  22969. private _cachedVAng;
  22970. private _cachedWAng;
  22971. private _cachedProjectionMatrixId;
  22972. private _cachedCoordinatesMode;
  22973. /** @hidden */
  22974. protected _initialSamplingMode: number;
  22975. /** @hidden */
  22976. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  22977. private _deleteBuffer;
  22978. protected _format: Nullable<number>;
  22979. private _delayedOnLoad;
  22980. private _delayedOnError;
  22981. private _mimeType?;
  22982. /**
  22983. * Observable triggered once the texture has been loaded.
  22984. */
  22985. onLoadObservable: Observable<Texture>;
  22986. protected _isBlocking: boolean;
  22987. /**
  22988. * Is the texture preventing material to render while loading.
  22989. * If false, a default texture will be used instead of the loading one during the preparation step.
  22990. */
  22991. set isBlocking(value: boolean);
  22992. get isBlocking(): boolean;
  22993. /**
  22994. * Get the current sampling mode associated with the texture.
  22995. */
  22996. get samplingMode(): number;
  22997. /**
  22998. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  22999. */
  23000. get invertY(): boolean;
  23001. /**
  23002. * Instantiates a new texture.
  23003. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23004. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23005. * @param url defines the url of the picture to load as a texture
  23006. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23007. * @param noMipmap defines if the texture will require mip maps or not
  23008. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23009. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23010. * @param onLoad defines a callback triggered when the texture has been loaded
  23011. * @param onError defines a callback triggered when an error occurred during the loading session
  23012. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23013. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23014. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23015. * @param mimeType defines an optional mime type information
  23016. */
  23017. 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);
  23018. /**
  23019. * Update the url (and optional buffer) of this texture if url was null during construction.
  23020. * @param url the url of the texture
  23021. * @param buffer the buffer of the texture (defaults to null)
  23022. * @param onLoad callback called when the texture is loaded (defaults to null)
  23023. */
  23024. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23025. /**
  23026. * Finish the loading sequence of a texture flagged as delayed load.
  23027. * @hidden
  23028. */
  23029. delayLoad(): void;
  23030. private _prepareRowForTextureGeneration;
  23031. /**
  23032. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23033. * @returns the transform matrix of the texture.
  23034. */
  23035. getTextureMatrix(uBase?: number): Matrix;
  23036. /**
  23037. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23038. * @returns The reflection texture transform
  23039. */
  23040. getReflectionTextureMatrix(): Matrix;
  23041. /**
  23042. * Clones the texture.
  23043. * @returns the cloned texture
  23044. */
  23045. clone(): Texture;
  23046. /**
  23047. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23048. * @returns The JSON representation of the texture
  23049. */
  23050. serialize(): any;
  23051. /**
  23052. * Get the current class name of the texture useful for serialization or dynamic coding.
  23053. * @returns "Texture"
  23054. */
  23055. getClassName(): string;
  23056. /**
  23057. * Dispose the texture and release its associated resources.
  23058. */
  23059. dispose(): void;
  23060. /**
  23061. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23062. * @param parsedTexture Define the JSON representation of the texture
  23063. * @param scene Define the scene the parsed texture should be instantiated in
  23064. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23065. * @returns The parsed texture if successful
  23066. */
  23067. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23068. /**
  23069. * Creates a texture from its base 64 representation.
  23070. * @param data Define the base64 payload without the data: prefix
  23071. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23072. * @param scene Define the scene the texture should belong to
  23073. * @param noMipmap Forces the texture to not create mip map information if true
  23074. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23075. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23076. * @param onLoad define a callback triggered when the texture has been loaded
  23077. * @param onError define a callback triggered when an error occurred during the loading session
  23078. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23079. * @returns the created texture
  23080. */
  23081. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23082. /**
  23083. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23084. * @param data Define the base64 payload without the data: prefix
  23085. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23086. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23087. * @param scene Define the scene the texture should belong to
  23088. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23089. * @param noMipmap Forces the texture to not create mip map information if true
  23090. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23091. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23092. * @param onLoad define a callback triggered when the texture has been loaded
  23093. * @param onError define a callback triggered when an error occurred during the loading session
  23094. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23095. * @returns the created texture
  23096. */
  23097. 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;
  23098. }
  23099. }
  23100. declare module BABYLON {
  23101. /**
  23102. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23103. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23104. */
  23105. export class PostProcessManager {
  23106. private _scene;
  23107. private _indexBuffer;
  23108. private _vertexBuffers;
  23109. /**
  23110. * Creates a new instance PostProcess
  23111. * @param scene The scene that the post process is associated with.
  23112. */
  23113. constructor(scene: Scene);
  23114. private _prepareBuffers;
  23115. private _buildIndexBuffer;
  23116. /**
  23117. * Rebuilds the vertex buffers of the manager.
  23118. * @hidden
  23119. */
  23120. _rebuild(): void;
  23121. /**
  23122. * Prepares a frame to be run through a post process.
  23123. * @param sourceTexture The input texture to the post procesess. (default: null)
  23124. * @param postProcesses An array of post processes to be run. (default: null)
  23125. * @returns True if the post processes were able to be run.
  23126. * @hidden
  23127. */
  23128. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23129. /**
  23130. * Manually render a set of post processes to a texture.
  23131. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23132. * @param postProcesses An array of post processes to be run.
  23133. * @param targetTexture The target texture to render to.
  23134. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23135. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23136. * @param lodLevel defines which lod of the texture to render to
  23137. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23138. */
  23139. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23140. /**
  23141. * Finalize the result of the output of the postprocesses.
  23142. * @param doNotPresent If true the result will not be displayed to the screen.
  23143. * @param targetTexture The target texture to render to.
  23144. * @param faceIndex The index of the face to bind the target texture to.
  23145. * @param postProcesses The array of post processes to render.
  23146. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23147. * @hidden
  23148. */
  23149. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23150. /**
  23151. * Disposes of the post process manager.
  23152. */
  23153. dispose(): void;
  23154. }
  23155. }
  23156. declare module BABYLON {
  23157. /**
  23158. * This Helps creating a texture that will be created from a camera in your scene.
  23159. * It is basically a dynamic texture that could be used to create special effects for instance.
  23160. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23161. */
  23162. export class RenderTargetTexture extends Texture {
  23163. isCube: boolean;
  23164. /**
  23165. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23166. */
  23167. static readonly REFRESHRATE_RENDER_ONCE: number;
  23168. /**
  23169. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23170. */
  23171. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23172. /**
  23173. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23174. * the central point of your effect and can save a lot of performances.
  23175. */
  23176. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23177. /**
  23178. * Use this predicate to dynamically define the list of mesh you want to render.
  23179. * If set, the renderList property will be overwritten.
  23180. */
  23181. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23182. private _renderList;
  23183. /**
  23184. * Use this list to define the list of mesh you want to render.
  23185. */
  23186. get renderList(): Nullable<Array<AbstractMesh>>;
  23187. set renderList(value: Nullable<Array<AbstractMesh>>);
  23188. /**
  23189. * Use this function to overload the renderList array at rendering time.
  23190. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23191. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23192. * the cube (if the RTT is a cube, else layerOrFace=0).
  23193. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23194. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23195. * hold dummy elements!
  23196. */
  23197. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23198. private _hookArray;
  23199. /**
  23200. * Define if particles should be rendered in your texture.
  23201. */
  23202. renderParticles: boolean;
  23203. /**
  23204. * Define if sprites should be rendered in your texture.
  23205. */
  23206. renderSprites: boolean;
  23207. /**
  23208. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23209. */
  23210. coordinatesMode: number;
  23211. /**
  23212. * Define the camera used to render the texture.
  23213. */
  23214. activeCamera: Nullable<Camera>;
  23215. /**
  23216. * Override the mesh isReady function with your own one.
  23217. */
  23218. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23219. /**
  23220. * Override the render function of the texture with your own one.
  23221. */
  23222. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23223. /**
  23224. * Define if camera post processes should be use while rendering the texture.
  23225. */
  23226. useCameraPostProcesses: boolean;
  23227. /**
  23228. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23229. */
  23230. ignoreCameraViewport: boolean;
  23231. private _postProcessManager;
  23232. private _postProcesses;
  23233. private _resizeObserver;
  23234. /**
  23235. * An event triggered when the texture is unbind.
  23236. */
  23237. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23238. /**
  23239. * An event triggered when the texture is unbind.
  23240. */
  23241. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23242. private _onAfterUnbindObserver;
  23243. /**
  23244. * Set a after unbind callback in the texture.
  23245. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23246. */
  23247. set onAfterUnbind(callback: () => void);
  23248. /**
  23249. * An event triggered before rendering the texture
  23250. */
  23251. onBeforeRenderObservable: Observable<number>;
  23252. private _onBeforeRenderObserver;
  23253. /**
  23254. * Set a before render callback in the texture.
  23255. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23256. */
  23257. set onBeforeRender(callback: (faceIndex: number) => void);
  23258. /**
  23259. * An event triggered after rendering the texture
  23260. */
  23261. onAfterRenderObservable: Observable<number>;
  23262. private _onAfterRenderObserver;
  23263. /**
  23264. * Set a after render callback in the texture.
  23265. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23266. */
  23267. set onAfterRender(callback: (faceIndex: number) => void);
  23268. /**
  23269. * An event triggered after the texture clear
  23270. */
  23271. onClearObservable: Observable<Engine>;
  23272. private _onClearObserver;
  23273. /**
  23274. * Set a clear callback in the texture.
  23275. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23276. */
  23277. set onClear(callback: (Engine: Engine) => void);
  23278. /**
  23279. * An event triggered when the texture is resized.
  23280. */
  23281. onResizeObservable: Observable<RenderTargetTexture>;
  23282. /**
  23283. * Define the clear color of the Render Target if it should be different from the scene.
  23284. */
  23285. clearColor: Color4;
  23286. protected _size: number | {
  23287. width: number;
  23288. height: number;
  23289. layers?: number;
  23290. };
  23291. protected _initialSizeParameter: number | {
  23292. width: number;
  23293. height: number;
  23294. } | {
  23295. ratio: number;
  23296. };
  23297. protected _sizeRatio: Nullable<number>;
  23298. /** @hidden */
  23299. _generateMipMaps: boolean;
  23300. protected _renderingManager: RenderingManager;
  23301. /** @hidden */
  23302. _waitingRenderList: string[];
  23303. protected _doNotChangeAspectRatio: boolean;
  23304. protected _currentRefreshId: number;
  23305. protected _refreshRate: number;
  23306. protected _textureMatrix: Matrix;
  23307. protected _samples: number;
  23308. protected _renderTargetOptions: RenderTargetCreationOptions;
  23309. /**
  23310. * Gets render target creation options that were used.
  23311. */
  23312. get renderTargetOptions(): RenderTargetCreationOptions;
  23313. protected _onRatioRescale(): void;
  23314. /**
  23315. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23316. * It must define where the camera used to render the texture is set
  23317. */
  23318. boundingBoxPosition: Vector3;
  23319. private _boundingBoxSize;
  23320. /**
  23321. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23322. * When defined, the cubemap will switch to local mode
  23323. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23324. * @example https://www.babylonjs-playground.com/#RNASML
  23325. */
  23326. set boundingBoxSize(value: Vector3);
  23327. get boundingBoxSize(): Vector3;
  23328. /**
  23329. * In case the RTT has been created with a depth texture, get the associated
  23330. * depth texture.
  23331. * Otherwise, return null.
  23332. */
  23333. get depthStencilTexture(): Nullable<InternalTexture>;
  23334. /**
  23335. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23336. * or used a shadow, depth texture...
  23337. * @param name The friendly name of the texture
  23338. * @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)
  23339. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23340. * @param generateMipMaps True if mip maps need to be generated after render.
  23341. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23342. * @param type The type of the buffer in the RTT (int, half float, float...)
  23343. * @param isCube True if a cube texture needs to be created
  23344. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23345. * @param generateDepthBuffer True to generate a depth buffer
  23346. * @param generateStencilBuffer True to generate a stencil buffer
  23347. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23348. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23349. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23350. */
  23351. constructor(name: string, size: number | {
  23352. width: number;
  23353. height: number;
  23354. layers?: number;
  23355. } | {
  23356. ratio: number;
  23357. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23358. /**
  23359. * Creates a depth stencil texture.
  23360. * This is only available in WebGL 2 or with the depth texture extension available.
  23361. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23362. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23363. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23364. */
  23365. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23366. private _processSizeParameter;
  23367. /**
  23368. * Define the number of samples to use in case of MSAA.
  23369. * It defaults to one meaning no MSAA has been enabled.
  23370. */
  23371. get samples(): number;
  23372. set samples(value: number);
  23373. /**
  23374. * Resets the refresh counter of the texture and start bak from scratch.
  23375. * Could be useful to regenerate the texture if it is setup to render only once.
  23376. */
  23377. resetRefreshCounter(): void;
  23378. /**
  23379. * Define the refresh rate of the texture or the rendering frequency.
  23380. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23381. */
  23382. get refreshRate(): number;
  23383. set refreshRate(value: number);
  23384. /**
  23385. * Adds a post process to the render target rendering passes.
  23386. * @param postProcess define the post process to add
  23387. */
  23388. addPostProcess(postProcess: PostProcess): void;
  23389. /**
  23390. * Clear all the post processes attached to the render target
  23391. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23392. */
  23393. clearPostProcesses(dispose?: boolean): void;
  23394. /**
  23395. * Remove one of the post process from the list of attached post processes to the texture
  23396. * @param postProcess define the post process to remove from the list
  23397. */
  23398. removePostProcess(postProcess: PostProcess): void;
  23399. /** @hidden */
  23400. _shouldRender(): boolean;
  23401. /**
  23402. * Gets the actual render size of the texture.
  23403. * @returns the width of the render size
  23404. */
  23405. getRenderSize(): number;
  23406. /**
  23407. * Gets the actual render width of the texture.
  23408. * @returns the width of the render size
  23409. */
  23410. getRenderWidth(): number;
  23411. /**
  23412. * Gets the actual render height of the texture.
  23413. * @returns the height of the render size
  23414. */
  23415. getRenderHeight(): number;
  23416. /**
  23417. * Gets the actual number of layers of the texture.
  23418. * @returns the number of layers
  23419. */
  23420. getRenderLayers(): number;
  23421. /**
  23422. * Get if the texture can be rescaled or not.
  23423. */
  23424. get canRescale(): boolean;
  23425. /**
  23426. * Resize the texture using a ratio.
  23427. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23428. */
  23429. scale(ratio: number): void;
  23430. /**
  23431. * Get the texture reflection matrix used to rotate/transform the reflection.
  23432. * @returns the reflection matrix
  23433. */
  23434. getReflectionTextureMatrix(): Matrix;
  23435. /**
  23436. * Resize the texture to a new desired size.
  23437. * Be carrefull as it will recreate all the data in the new texture.
  23438. * @param size Define the new size. It can be:
  23439. * - a number for squared texture,
  23440. * - an object containing { width: number, height: number }
  23441. * - or an object containing a ratio { ratio: number }
  23442. */
  23443. resize(size: number | {
  23444. width: number;
  23445. height: number;
  23446. } | {
  23447. ratio: number;
  23448. }): void;
  23449. private _defaultRenderListPrepared;
  23450. /**
  23451. * Renders all the objects from the render list into the texture.
  23452. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23453. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23454. */
  23455. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23456. private _bestReflectionRenderTargetDimension;
  23457. private _prepareRenderingManager;
  23458. /**
  23459. * @hidden
  23460. * @param faceIndex face index to bind to if this is a cubetexture
  23461. * @param layer defines the index of the texture to bind in the array
  23462. */
  23463. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23464. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23465. private renderToTarget;
  23466. /**
  23467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23468. * This allowed control for front to back rendering or reversly depending of the special needs.
  23469. *
  23470. * @param renderingGroupId The rendering group id corresponding to its index
  23471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23474. */
  23475. 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;
  23476. /**
  23477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23478. *
  23479. * @param renderingGroupId The rendering group id corresponding to its index
  23480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23481. */
  23482. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23483. /**
  23484. * Clones the texture.
  23485. * @returns the cloned texture
  23486. */
  23487. clone(): RenderTargetTexture;
  23488. /**
  23489. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23490. * @returns The JSON representation of the texture
  23491. */
  23492. serialize(): any;
  23493. /**
  23494. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23495. */
  23496. disposeFramebufferObjects(): void;
  23497. /**
  23498. * Dispose the texture and release its associated resources.
  23499. */
  23500. dispose(): void;
  23501. /** @hidden */
  23502. _rebuild(): void;
  23503. /**
  23504. * Clear the info related to rendering groups preventing retention point in material dispose.
  23505. */
  23506. freeRenderingGroups(): void;
  23507. /**
  23508. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23509. * @returns the view count
  23510. */
  23511. getViewCount(): number;
  23512. }
  23513. }
  23514. declare module BABYLON {
  23515. /**
  23516. * Class used to manipulate GUIDs
  23517. */
  23518. export class GUID {
  23519. /**
  23520. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23521. * Be aware Math.random() could cause collisions, but:
  23522. * "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"
  23523. * @returns a pseudo random id
  23524. */
  23525. static RandomId(): string;
  23526. }
  23527. }
  23528. declare module BABYLON {
  23529. /**
  23530. * Options to be used when creating a shadow depth material
  23531. */
  23532. export interface IIOptionShadowDepthMaterial {
  23533. /** Variables in the vertex shader code that need to have their names remapped.
  23534. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23535. * "var_name" should be either: worldPos or vNormalW
  23536. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23537. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23538. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23539. */
  23540. remappedVariables?: string[];
  23541. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23542. standalone?: boolean;
  23543. }
  23544. /**
  23545. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23546. */
  23547. export class ShadowDepthWrapper {
  23548. private _scene;
  23549. private _options?;
  23550. private _baseMaterial;
  23551. private _onEffectCreatedObserver;
  23552. private _subMeshToEffect;
  23553. private _subMeshToDepthEffect;
  23554. private _meshes;
  23555. /** @hidden */
  23556. _matriceNames: any;
  23557. /** Gets the standalone status of the wrapper */
  23558. get standalone(): boolean;
  23559. /** Gets the base material the wrapper is built upon */
  23560. get baseMaterial(): Material;
  23561. /**
  23562. * Instantiate a new shadow depth wrapper.
  23563. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23564. * generate the shadow depth map. For more information, please refer to the documentation:
  23565. * https://doc.babylonjs.com/babylon101/shadows
  23566. * @param baseMaterial Material to wrap
  23567. * @param scene Define the scene the material belongs to
  23568. * @param options Options used to create the wrapper
  23569. */
  23570. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23571. /**
  23572. * Gets the effect to use to generate the depth map
  23573. * @param subMesh subMesh to get the effect for
  23574. * @param shadowGenerator shadow generator to get the effect for
  23575. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23576. */
  23577. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23578. /**
  23579. * Specifies that the submesh is ready to be used for depth rendering
  23580. * @param subMesh submesh to check
  23581. * @param defines the list of defines to take into account when checking the effect
  23582. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23583. * @param useInstances specifies that instances should be used
  23584. * @returns a boolean indicating that the submesh is ready or not
  23585. */
  23586. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23587. /**
  23588. * Disposes the resources
  23589. */
  23590. dispose(): void;
  23591. private _makeEffect;
  23592. }
  23593. }
  23594. declare module BABYLON {
  23595. /**
  23596. * Options for compiling materials.
  23597. */
  23598. export interface IMaterialCompilationOptions {
  23599. /**
  23600. * Defines whether clip planes are enabled.
  23601. */
  23602. clipPlane: boolean;
  23603. /**
  23604. * Defines whether instances are enabled.
  23605. */
  23606. useInstances: boolean;
  23607. }
  23608. /**
  23609. * Options passed when calling customShaderNameResolve
  23610. */
  23611. export interface ICustomShaderNameResolveOptions {
  23612. /**
  23613. * 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
  23614. */
  23615. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23616. }
  23617. /**
  23618. * Base class for the main features of a material in Babylon.js
  23619. */
  23620. export class Material implements IAnimatable {
  23621. /**
  23622. * Returns the triangle fill mode
  23623. */
  23624. static readonly TriangleFillMode: number;
  23625. /**
  23626. * Returns the wireframe mode
  23627. */
  23628. static readonly WireFrameFillMode: number;
  23629. /**
  23630. * Returns the point fill mode
  23631. */
  23632. static readonly PointFillMode: number;
  23633. /**
  23634. * Returns the point list draw mode
  23635. */
  23636. static readonly PointListDrawMode: number;
  23637. /**
  23638. * Returns the line list draw mode
  23639. */
  23640. static readonly LineListDrawMode: number;
  23641. /**
  23642. * Returns the line loop draw mode
  23643. */
  23644. static readonly LineLoopDrawMode: number;
  23645. /**
  23646. * Returns the line strip draw mode
  23647. */
  23648. static readonly LineStripDrawMode: number;
  23649. /**
  23650. * Returns the triangle strip draw mode
  23651. */
  23652. static readonly TriangleStripDrawMode: number;
  23653. /**
  23654. * Returns the triangle fan draw mode
  23655. */
  23656. static readonly TriangleFanDrawMode: number;
  23657. /**
  23658. * Stores the clock-wise side orientation
  23659. */
  23660. static readonly ClockWiseSideOrientation: number;
  23661. /**
  23662. * Stores the counter clock-wise side orientation
  23663. */
  23664. static readonly CounterClockWiseSideOrientation: number;
  23665. /**
  23666. * The dirty texture flag value
  23667. */
  23668. static readonly TextureDirtyFlag: number;
  23669. /**
  23670. * The dirty light flag value
  23671. */
  23672. static readonly LightDirtyFlag: number;
  23673. /**
  23674. * The dirty fresnel flag value
  23675. */
  23676. static readonly FresnelDirtyFlag: number;
  23677. /**
  23678. * The dirty attribute flag value
  23679. */
  23680. static readonly AttributesDirtyFlag: number;
  23681. /**
  23682. * The dirty misc flag value
  23683. */
  23684. static readonly MiscDirtyFlag: number;
  23685. /**
  23686. * The all dirty flag value
  23687. */
  23688. static readonly AllDirtyFlag: number;
  23689. /**
  23690. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23691. */
  23692. static readonly MATERIAL_OPAQUE: number;
  23693. /**
  23694. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23695. */
  23696. static readonly MATERIAL_ALPHATEST: number;
  23697. /**
  23698. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23699. */
  23700. static readonly MATERIAL_ALPHABLEND: number;
  23701. /**
  23702. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23703. * They are also discarded below the alpha cutoff threshold to improve performances.
  23704. */
  23705. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23706. /**
  23707. * The Whiteout method is used to blend normals.
  23708. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23709. */
  23710. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23711. /**
  23712. * The Reoriented Normal Mapping method is used to blend normals.
  23713. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23714. */
  23715. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23716. /**
  23717. * Custom callback helping to override the default shader used in the material.
  23718. */
  23719. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23720. /**
  23721. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23722. */
  23723. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23724. /**
  23725. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23726. * This means that the material can keep using a previous shader while a new one is being compiled.
  23727. * This is mostly used when shader parallel compilation is supported (true by default)
  23728. */
  23729. allowShaderHotSwapping: boolean;
  23730. /**
  23731. * The ID of the material
  23732. */
  23733. id: string;
  23734. /**
  23735. * Gets or sets the unique id of the material
  23736. */
  23737. uniqueId: number;
  23738. /**
  23739. * The name of the material
  23740. */
  23741. name: string;
  23742. /**
  23743. * Gets or sets user defined metadata
  23744. */
  23745. metadata: any;
  23746. /**
  23747. * For internal use only. Please do not use.
  23748. */
  23749. reservedDataStore: any;
  23750. /**
  23751. * Specifies if the ready state should be checked on each call
  23752. */
  23753. checkReadyOnEveryCall: boolean;
  23754. /**
  23755. * Specifies if the ready state should be checked once
  23756. */
  23757. checkReadyOnlyOnce: boolean;
  23758. /**
  23759. * The state of the material
  23760. */
  23761. state: string;
  23762. /**
  23763. * If the material should be rendered to several textures with MRT extension
  23764. */
  23765. get shouldRenderToMRT(): boolean;
  23766. /**
  23767. * The alpha value of the material
  23768. */
  23769. protected _alpha: number;
  23770. /**
  23771. * List of inspectable custom properties (used by the Inspector)
  23772. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23773. */
  23774. inspectableCustomProperties: IInspectable[];
  23775. /**
  23776. * Sets the alpha value of the material
  23777. */
  23778. set alpha(value: number);
  23779. /**
  23780. * Gets the alpha value of the material
  23781. */
  23782. get alpha(): number;
  23783. /**
  23784. * Specifies if back face culling is enabled
  23785. */
  23786. protected _backFaceCulling: boolean;
  23787. /**
  23788. * Sets the back-face culling state
  23789. */
  23790. set backFaceCulling(value: boolean);
  23791. /**
  23792. * Gets the back-face culling state
  23793. */
  23794. get backFaceCulling(): boolean;
  23795. /**
  23796. * Stores the value for side orientation
  23797. */
  23798. sideOrientation: number;
  23799. /**
  23800. * Callback triggered when the material is compiled
  23801. */
  23802. onCompiled: Nullable<(effect: Effect) => void>;
  23803. /**
  23804. * Callback triggered when an error occurs
  23805. */
  23806. onError: Nullable<(effect: Effect, errors: string) => void>;
  23807. /**
  23808. * Callback triggered to get the render target textures
  23809. */
  23810. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23811. /**
  23812. * Gets a boolean indicating that current material needs to register RTT
  23813. */
  23814. get hasRenderTargetTextures(): boolean;
  23815. /**
  23816. * Specifies if the material should be serialized
  23817. */
  23818. doNotSerialize: boolean;
  23819. /**
  23820. * @hidden
  23821. */
  23822. _storeEffectOnSubMeshes: boolean;
  23823. /**
  23824. * Stores the animations for the material
  23825. */
  23826. animations: Nullable<Array<Animation>>;
  23827. /**
  23828. * An event triggered when the material is disposed
  23829. */
  23830. onDisposeObservable: Observable<Material>;
  23831. /**
  23832. * An observer which watches for dispose events
  23833. */
  23834. private _onDisposeObserver;
  23835. private _onUnBindObservable;
  23836. /**
  23837. * Called during a dispose event
  23838. */
  23839. set onDispose(callback: () => void);
  23840. private _onBindObservable;
  23841. /**
  23842. * An event triggered when the material is bound
  23843. */
  23844. get onBindObservable(): Observable<AbstractMesh>;
  23845. /**
  23846. * An observer which watches for bind events
  23847. */
  23848. private _onBindObserver;
  23849. /**
  23850. * Called during a bind event
  23851. */
  23852. set onBind(callback: (Mesh: AbstractMesh) => void);
  23853. /**
  23854. * An event triggered when the material is unbound
  23855. */
  23856. get onUnBindObservable(): Observable<Material>;
  23857. protected _onEffectCreatedObservable: Nullable<Observable<{
  23858. effect: Effect;
  23859. subMesh: Nullable<SubMesh>;
  23860. }>>;
  23861. /**
  23862. * An event triggered when the effect is (re)created
  23863. */
  23864. get onEffectCreatedObservable(): Observable<{
  23865. effect: Effect;
  23866. subMesh: Nullable<SubMesh>;
  23867. }>;
  23868. /**
  23869. * Stores the value of the alpha mode
  23870. */
  23871. private _alphaMode;
  23872. /**
  23873. * Sets the value of the alpha mode.
  23874. *
  23875. * | Value | Type | Description |
  23876. * | --- | --- | --- |
  23877. * | 0 | ALPHA_DISABLE | |
  23878. * | 1 | ALPHA_ADD | |
  23879. * | 2 | ALPHA_COMBINE | |
  23880. * | 3 | ALPHA_SUBTRACT | |
  23881. * | 4 | ALPHA_MULTIPLY | |
  23882. * | 5 | ALPHA_MAXIMIZED | |
  23883. * | 6 | ALPHA_ONEONE | |
  23884. * | 7 | ALPHA_PREMULTIPLIED | |
  23885. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23886. * | 9 | ALPHA_INTERPOLATE | |
  23887. * | 10 | ALPHA_SCREENMODE | |
  23888. *
  23889. */
  23890. set alphaMode(value: number);
  23891. /**
  23892. * Gets the value of the alpha mode
  23893. */
  23894. get alphaMode(): number;
  23895. /**
  23896. * Stores the state of the need depth pre-pass value
  23897. */
  23898. private _needDepthPrePass;
  23899. /**
  23900. * Sets the need depth pre-pass value
  23901. */
  23902. set needDepthPrePass(value: boolean);
  23903. /**
  23904. * Gets the depth pre-pass value
  23905. */
  23906. get needDepthPrePass(): boolean;
  23907. /**
  23908. * Specifies if depth writing should be disabled
  23909. */
  23910. disableDepthWrite: boolean;
  23911. /**
  23912. * Specifies if color writing should be disabled
  23913. */
  23914. disableColorWrite: boolean;
  23915. /**
  23916. * Specifies if depth writing should be forced
  23917. */
  23918. forceDepthWrite: boolean;
  23919. /**
  23920. * Specifies the depth function that should be used. 0 means the default engine function
  23921. */
  23922. depthFunction: number;
  23923. /**
  23924. * Specifies if there should be a separate pass for culling
  23925. */
  23926. separateCullingPass: boolean;
  23927. /**
  23928. * Stores the state specifing if fog should be enabled
  23929. */
  23930. private _fogEnabled;
  23931. /**
  23932. * Sets the state for enabling fog
  23933. */
  23934. set fogEnabled(value: boolean);
  23935. /**
  23936. * Gets the value of the fog enabled state
  23937. */
  23938. get fogEnabled(): boolean;
  23939. /**
  23940. * Stores the size of points
  23941. */
  23942. pointSize: number;
  23943. /**
  23944. * Stores the z offset value
  23945. */
  23946. zOffset: number;
  23947. get wireframe(): boolean;
  23948. /**
  23949. * Sets the state of wireframe mode
  23950. */
  23951. set wireframe(value: boolean);
  23952. /**
  23953. * Gets the value specifying if point clouds are enabled
  23954. */
  23955. get pointsCloud(): boolean;
  23956. /**
  23957. * Sets the state of point cloud mode
  23958. */
  23959. set pointsCloud(value: boolean);
  23960. /**
  23961. * Gets the material fill mode
  23962. */
  23963. get fillMode(): number;
  23964. /**
  23965. * Sets the material fill mode
  23966. */
  23967. set fillMode(value: number);
  23968. /**
  23969. * @hidden
  23970. * Stores the effects for the material
  23971. */
  23972. _effect: Nullable<Effect>;
  23973. /**
  23974. * Specifies if uniform buffers should be used
  23975. */
  23976. private _useUBO;
  23977. /**
  23978. * Stores a reference to the scene
  23979. */
  23980. private _scene;
  23981. /**
  23982. * Stores the fill mode state
  23983. */
  23984. private _fillMode;
  23985. /**
  23986. * Specifies if the depth write state should be cached
  23987. */
  23988. private _cachedDepthWriteState;
  23989. /**
  23990. * Specifies if the color write state should be cached
  23991. */
  23992. private _cachedColorWriteState;
  23993. /**
  23994. * Specifies if the depth function state should be cached
  23995. */
  23996. private _cachedDepthFunctionState;
  23997. /**
  23998. * Stores the uniform buffer
  23999. */
  24000. protected _uniformBuffer: UniformBuffer;
  24001. /** @hidden */
  24002. _indexInSceneMaterialArray: number;
  24003. /** @hidden */
  24004. meshMap: Nullable<{
  24005. [id: string]: AbstractMesh | undefined;
  24006. }>;
  24007. /**
  24008. * Creates a material instance
  24009. * @param name defines the name of the material
  24010. * @param scene defines the scene to reference
  24011. * @param doNotAdd specifies if the material should be added to the scene
  24012. */
  24013. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24014. /**
  24015. * Returns a string representation of the current material
  24016. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24017. * @returns a string with material information
  24018. */
  24019. toString(fullDetails?: boolean): string;
  24020. /**
  24021. * Gets the class name of the material
  24022. * @returns a string with the class name of the material
  24023. */
  24024. getClassName(): string;
  24025. /**
  24026. * Specifies if updates for the material been locked
  24027. */
  24028. get isFrozen(): boolean;
  24029. /**
  24030. * Locks updates for the material
  24031. */
  24032. freeze(): void;
  24033. /**
  24034. * Unlocks updates for the material
  24035. */
  24036. unfreeze(): void;
  24037. /**
  24038. * Specifies if the material is ready to be used
  24039. * @param mesh defines the mesh to check
  24040. * @param useInstances specifies if instances should be used
  24041. * @returns a boolean indicating if the material is ready to be used
  24042. */
  24043. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24044. /**
  24045. * Specifies that the submesh is ready to be used
  24046. * @param mesh defines the mesh to check
  24047. * @param subMesh defines which submesh to check
  24048. * @param useInstances specifies that instances should be used
  24049. * @returns a boolean indicating that the submesh is ready or not
  24050. */
  24051. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24052. /**
  24053. * Returns the material effect
  24054. * @returns the effect associated with the material
  24055. */
  24056. getEffect(): Nullable<Effect>;
  24057. /**
  24058. * Returns the current scene
  24059. * @returns a Scene
  24060. */
  24061. getScene(): Scene;
  24062. /**
  24063. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24064. */
  24065. protected _forceAlphaTest: boolean;
  24066. /**
  24067. * The transparency mode of the material.
  24068. */
  24069. protected _transparencyMode: Nullable<number>;
  24070. /**
  24071. * Gets the current transparency mode.
  24072. */
  24073. get transparencyMode(): Nullable<number>;
  24074. /**
  24075. * Sets the transparency mode of the material.
  24076. *
  24077. * | Value | Type | Description |
  24078. * | ----- | ----------------------------------- | ----------- |
  24079. * | 0 | OPAQUE | |
  24080. * | 1 | ALPHATEST | |
  24081. * | 2 | ALPHABLEND | |
  24082. * | 3 | ALPHATESTANDBLEND | |
  24083. *
  24084. */
  24085. set transparencyMode(value: Nullable<number>);
  24086. /**
  24087. * Returns true if alpha blending should be disabled.
  24088. */
  24089. protected get _disableAlphaBlending(): boolean;
  24090. /**
  24091. * Specifies whether or not this material should be rendered in alpha blend mode.
  24092. * @returns a boolean specifying if alpha blending is needed
  24093. */
  24094. needAlphaBlending(): boolean;
  24095. /**
  24096. * Specifies if the mesh will require alpha blending
  24097. * @param mesh defines the mesh to check
  24098. * @returns a boolean specifying if alpha blending is needed for the mesh
  24099. */
  24100. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24101. /**
  24102. * Specifies whether or not this material should be rendered in alpha test mode.
  24103. * @returns a boolean specifying if an alpha test is needed.
  24104. */
  24105. needAlphaTesting(): boolean;
  24106. /**
  24107. * Specifies if material alpha testing should be turned on for the mesh
  24108. * @param mesh defines the mesh to check
  24109. */
  24110. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24111. /**
  24112. * Gets the texture used for the alpha test
  24113. * @returns the texture to use for alpha testing
  24114. */
  24115. getAlphaTestTexture(): Nullable<BaseTexture>;
  24116. /**
  24117. * Marks the material to indicate that it needs to be re-calculated
  24118. */
  24119. markDirty(): void;
  24120. /** @hidden */
  24121. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24122. /**
  24123. * Binds the material to the mesh
  24124. * @param world defines the world transformation matrix
  24125. * @param mesh defines the mesh to bind the material to
  24126. */
  24127. bind(world: Matrix, mesh?: Mesh): void;
  24128. /**
  24129. * Binds the submesh to the material
  24130. * @param world defines the world transformation matrix
  24131. * @param mesh defines the mesh containing the submesh
  24132. * @param subMesh defines the submesh to bind the material to
  24133. */
  24134. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24135. /**
  24136. * Binds the world matrix to the material
  24137. * @param world defines the world transformation matrix
  24138. */
  24139. bindOnlyWorldMatrix(world: Matrix): void;
  24140. /**
  24141. * Binds the scene's uniform buffer to the effect.
  24142. * @param effect defines the effect to bind to the scene uniform buffer
  24143. * @param sceneUbo defines the uniform buffer storing scene data
  24144. */
  24145. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24146. /**
  24147. * Binds the view matrix to the effect
  24148. * @param effect defines the effect to bind the view matrix to
  24149. */
  24150. bindView(effect: Effect): void;
  24151. /**
  24152. * Binds the view projection matrix to the effect
  24153. * @param effect defines the effect to bind the view projection matrix to
  24154. */
  24155. bindViewProjection(effect: Effect): void;
  24156. /**
  24157. * Processes to execute after binding the material to a mesh
  24158. * @param mesh defines the rendered mesh
  24159. */
  24160. protected _afterBind(mesh?: Mesh): void;
  24161. /**
  24162. * Unbinds the material from the mesh
  24163. */
  24164. unbind(): void;
  24165. /**
  24166. * Gets the active textures from the material
  24167. * @returns an array of textures
  24168. */
  24169. getActiveTextures(): BaseTexture[];
  24170. /**
  24171. * Specifies if the material uses a texture
  24172. * @param texture defines the texture to check against the material
  24173. * @returns a boolean specifying if the material uses the texture
  24174. */
  24175. hasTexture(texture: BaseTexture): boolean;
  24176. /**
  24177. * Makes a duplicate of the material, and gives it a new name
  24178. * @param name defines the new name for the duplicated material
  24179. * @returns the cloned material
  24180. */
  24181. clone(name: string): Nullable<Material>;
  24182. /**
  24183. * Gets the meshes bound to the material
  24184. * @returns an array of meshes bound to the material
  24185. */
  24186. getBindedMeshes(): AbstractMesh[];
  24187. /**
  24188. * Force shader compilation
  24189. * @param mesh defines the mesh associated with this material
  24190. * @param onCompiled defines a function to execute once the material is compiled
  24191. * @param options defines the options to configure the compilation
  24192. * @param onError defines a function to execute if the material fails compiling
  24193. */
  24194. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24195. /**
  24196. * Force shader compilation
  24197. * @param mesh defines the mesh that will use this material
  24198. * @param options defines additional options for compiling the shaders
  24199. * @returns a promise that resolves when the compilation completes
  24200. */
  24201. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24202. private static readonly _AllDirtyCallBack;
  24203. private static readonly _ImageProcessingDirtyCallBack;
  24204. private static readonly _TextureDirtyCallBack;
  24205. private static readonly _FresnelDirtyCallBack;
  24206. private static readonly _MiscDirtyCallBack;
  24207. private static readonly _LightsDirtyCallBack;
  24208. private static readonly _AttributeDirtyCallBack;
  24209. private static _FresnelAndMiscDirtyCallBack;
  24210. private static _TextureAndMiscDirtyCallBack;
  24211. private static readonly _DirtyCallbackArray;
  24212. private static readonly _RunDirtyCallBacks;
  24213. /**
  24214. * Marks a define in the material to indicate that it needs to be re-computed
  24215. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24216. */
  24217. markAsDirty(flag: number): void;
  24218. /**
  24219. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24220. * @param func defines a function which checks material defines against the submeshes
  24221. */
  24222. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24223. /**
  24224. * Indicates that the scene should check if the rendering now needs a prepass
  24225. */
  24226. protected _markScenePrePassDirty(): void;
  24227. /**
  24228. * Indicates that we need to re-calculated for all submeshes
  24229. */
  24230. protected _markAllSubMeshesAsAllDirty(): void;
  24231. /**
  24232. * Indicates that image processing needs to be re-calculated for all submeshes
  24233. */
  24234. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24235. /**
  24236. * Indicates that textures need to be re-calculated for all submeshes
  24237. */
  24238. protected _markAllSubMeshesAsTexturesDirty(): void;
  24239. /**
  24240. * Indicates that fresnel needs to be re-calculated for all submeshes
  24241. */
  24242. protected _markAllSubMeshesAsFresnelDirty(): void;
  24243. /**
  24244. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24245. */
  24246. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24247. /**
  24248. * Indicates that lights need to be re-calculated for all submeshes
  24249. */
  24250. protected _markAllSubMeshesAsLightsDirty(): void;
  24251. /**
  24252. * Indicates that attributes need to be re-calculated for all submeshes
  24253. */
  24254. protected _markAllSubMeshesAsAttributesDirty(): void;
  24255. /**
  24256. * Indicates that misc needs to be re-calculated for all submeshes
  24257. */
  24258. protected _markAllSubMeshesAsMiscDirty(): void;
  24259. /**
  24260. * Indicates that textures and misc need to be re-calculated for all submeshes
  24261. */
  24262. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24263. /**
  24264. * Disposes the material
  24265. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24266. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24267. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24268. */
  24269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24270. /** @hidden */
  24271. private releaseVertexArrayObject;
  24272. /**
  24273. * Serializes this material
  24274. * @returns the serialized material object
  24275. */
  24276. serialize(): any;
  24277. /**
  24278. * Creates a material from parsed material data
  24279. * @param parsedMaterial defines parsed material data
  24280. * @param scene defines the hosting scene
  24281. * @param rootUrl defines the root URL to use to load textures
  24282. * @returns a new material
  24283. */
  24284. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24285. }
  24286. }
  24287. declare module BABYLON {
  24288. /**
  24289. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24290. * separate meshes. This can be use to improve performances.
  24291. * @see https://doc.babylonjs.com/how_to/multi_materials
  24292. */
  24293. export class MultiMaterial extends Material {
  24294. private _subMaterials;
  24295. /**
  24296. * Gets or Sets the list of Materials used within the multi material.
  24297. * They need to be ordered according to the submeshes order in the associated mesh
  24298. */
  24299. get subMaterials(): Nullable<Material>[];
  24300. set subMaterials(value: Nullable<Material>[]);
  24301. /**
  24302. * Function used to align with Node.getChildren()
  24303. * @returns the list of Materials used within the multi material
  24304. */
  24305. getChildren(): Nullable<Material>[];
  24306. /**
  24307. * Instantiates a new Multi Material
  24308. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24309. * separate meshes. This can be use to improve performances.
  24310. * @see https://doc.babylonjs.com/how_to/multi_materials
  24311. * @param name Define the name in the scene
  24312. * @param scene Define the scene the material belongs to
  24313. */
  24314. constructor(name: string, scene: Scene);
  24315. private _hookArray;
  24316. /**
  24317. * Get one of the submaterial by its index in the submaterials array
  24318. * @param index The index to look the sub material at
  24319. * @returns The Material if the index has been defined
  24320. */
  24321. getSubMaterial(index: number): Nullable<Material>;
  24322. /**
  24323. * Get the list of active textures for the whole sub materials list.
  24324. * @returns All the textures that will be used during the rendering
  24325. */
  24326. getActiveTextures(): BaseTexture[];
  24327. /**
  24328. * Gets the current class name of the material e.g. "MultiMaterial"
  24329. * Mainly use in serialization.
  24330. * @returns the class name
  24331. */
  24332. getClassName(): string;
  24333. /**
  24334. * Checks if the material is ready to render the requested sub mesh
  24335. * @param mesh Define the mesh the submesh belongs to
  24336. * @param subMesh Define the sub mesh to look readyness for
  24337. * @param useInstances Define whether or not the material is used with instances
  24338. * @returns true if ready, otherwise false
  24339. */
  24340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24341. /**
  24342. * Clones the current material and its related sub materials
  24343. * @param name Define the name of the newly cloned material
  24344. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24345. * @returns the cloned material
  24346. */
  24347. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24348. /**
  24349. * Serializes the materials into a JSON representation.
  24350. * @returns the JSON representation
  24351. */
  24352. serialize(): any;
  24353. /**
  24354. * Dispose the material and release its associated resources
  24355. * @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)
  24356. * @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)
  24357. * @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)
  24358. */
  24359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24360. /**
  24361. * Creates a MultiMaterial from parsed MultiMaterial data.
  24362. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24363. * @param scene defines the hosting scene
  24364. * @returns a new MultiMaterial
  24365. */
  24366. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24367. }
  24368. }
  24369. declare module BABYLON {
  24370. /**
  24371. * Defines a subdivision inside a mesh
  24372. */
  24373. export class SubMesh implements ICullable {
  24374. /** the material index to use */
  24375. materialIndex: number;
  24376. /** vertex index start */
  24377. verticesStart: number;
  24378. /** vertices count */
  24379. verticesCount: number;
  24380. /** index start */
  24381. indexStart: number;
  24382. /** indices count */
  24383. indexCount: number;
  24384. /** @hidden */
  24385. _materialDefines: Nullable<MaterialDefines>;
  24386. /** @hidden */
  24387. _materialEffect: Nullable<Effect>;
  24388. /** @hidden */
  24389. _effectOverride: Nullable<Effect>;
  24390. /**
  24391. * Gets material defines used by the effect associated to the sub mesh
  24392. */
  24393. get materialDefines(): Nullable<MaterialDefines>;
  24394. /**
  24395. * Sets material defines used by the effect associated to the sub mesh
  24396. */
  24397. set materialDefines(defines: Nullable<MaterialDefines>);
  24398. /**
  24399. * Gets associated effect
  24400. */
  24401. get effect(): Nullable<Effect>;
  24402. /**
  24403. * Sets associated effect (effect used to render this submesh)
  24404. * @param effect defines the effect to associate with
  24405. * @param defines defines the set of defines used to compile this effect
  24406. */
  24407. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24408. /** @hidden */
  24409. _linesIndexCount: number;
  24410. private _mesh;
  24411. private _renderingMesh;
  24412. private _boundingInfo;
  24413. private _linesIndexBuffer;
  24414. /** @hidden */
  24415. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24416. /** @hidden */
  24417. _trianglePlanes: Plane[];
  24418. /** @hidden */
  24419. _lastColliderTransformMatrix: Nullable<Matrix>;
  24420. /** @hidden */
  24421. _renderId: number;
  24422. /** @hidden */
  24423. _alphaIndex: number;
  24424. /** @hidden */
  24425. _distanceToCamera: number;
  24426. /** @hidden */
  24427. _id: number;
  24428. private _currentMaterial;
  24429. /**
  24430. * Add a new submesh to a mesh
  24431. * @param materialIndex defines the material index to use
  24432. * @param verticesStart defines vertex index start
  24433. * @param verticesCount defines vertices count
  24434. * @param indexStart defines index start
  24435. * @param indexCount defines indices count
  24436. * @param mesh defines the parent mesh
  24437. * @param renderingMesh defines an optional rendering mesh
  24438. * @param createBoundingBox defines if bounding box should be created for this submesh
  24439. * @returns the new submesh
  24440. */
  24441. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24442. /**
  24443. * Creates a new submesh
  24444. * @param materialIndex defines the material index to use
  24445. * @param verticesStart defines vertex index start
  24446. * @param verticesCount defines vertices count
  24447. * @param indexStart defines index start
  24448. * @param indexCount defines indices count
  24449. * @param mesh defines the parent mesh
  24450. * @param renderingMesh defines an optional rendering mesh
  24451. * @param createBoundingBox defines if bounding box should be created for this submesh
  24452. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24453. */
  24454. constructor(
  24455. /** the material index to use */
  24456. materialIndex: number,
  24457. /** vertex index start */
  24458. verticesStart: number,
  24459. /** vertices count */
  24460. verticesCount: number,
  24461. /** index start */
  24462. indexStart: number,
  24463. /** indices count */
  24464. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24465. /**
  24466. * Returns true if this submesh covers the entire parent mesh
  24467. * @ignorenaming
  24468. */
  24469. get IsGlobal(): boolean;
  24470. /**
  24471. * Returns the submesh BoudingInfo object
  24472. * @returns current bounding info (or mesh's one if the submesh is global)
  24473. */
  24474. getBoundingInfo(): BoundingInfo;
  24475. /**
  24476. * Sets the submesh BoundingInfo
  24477. * @param boundingInfo defines the new bounding info to use
  24478. * @returns the SubMesh
  24479. */
  24480. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24481. /**
  24482. * Returns the mesh of the current submesh
  24483. * @return the parent mesh
  24484. */
  24485. getMesh(): AbstractMesh;
  24486. /**
  24487. * Returns the rendering mesh of the submesh
  24488. * @returns the rendering mesh (could be different from parent mesh)
  24489. */
  24490. getRenderingMesh(): Mesh;
  24491. /**
  24492. * Returns the replacement mesh of the submesh
  24493. * @returns the replacement mesh (could be different from parent mesh)
  24494. */
  24495. getReplacementMesh(): Nullable<AbstractMesh>;
  24496. /**
  24497. * Returns the effective mesh of the submesh
  24498. * @returns the effective mesh (could be different from parent mesh)
  24499. */
  24500. getEffectiveMesh(): AbstractMesh;
  24501. /**
  24502. * Returns the submesh material
  24503. * @returns null or the current material
  24504. */
  24505. getMaterial(): Nullable<Material>;
  24506. private _IsMultiMaterial;
  24507. /**
  24508. * Sets a new updated BoundingInfo object to the submesh
  24509. * @param data defines an optional position array to use to determine the bounding info
  24510. * @returns the SubMesh
  24511. */
  24512. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24513. /** @hidden */
  24514. _checkCollision(collider: Collider): boolean;
  24515. /**
  24516. * Updates the submesh BoundingInfo
  24517. * @param world defines the world matrix to use to update the bounding info
  24518. * @returns the submesh
  24519. */
  24520. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24521. /**
  24522. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24523. * @param frustumPlanes defines the frustum planes
  24524. * @returns true if the submesh is intersecting with the frustum
  24525. */
  24526. isInFrustum(frustumPlanes: Plane[]): boolean;
  24527. /**
  24528. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24529. * @param frustumPlanes defines the frustum planes
  24530. * @returns true if the submesh is inside the frustum
  24531. */
  24532. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24533. /**
  24534. * Renders the submesh
  24535. * @param enableAlphaMode defines if alpha needs to be used
  24536. * @returns the submesh
  24537. */
  24538. render(enableAlphaMode: boolean): SubMesh;
  24539. /**
  24540. * @hidden
  24541. */
  24542. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24543. /**
  24544. * Checks if the submesh intersects with a ray
  24545. * @param ray defines the ray to test
  24546. * @returns true is the passed ray intersects the submesh bounding box
  24547. */
  24548. canIntersects(ray: Ray): boolean;
  24549. /**
  24550. * Intersects current submesh with a ray
  24551. * @param ray defines the ray to test
  24552. * @param positions defines mesh's positions array
  24553. * @param indices defines mesh's indices array
  24554. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24555. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24556. * @returns intersection info or null if no intersection
  24557. */
  24558. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24559. /** @hidden */
  24560. private _intersectLines;
  24561. /** @hidden */
  24562. private _intersectUnIndexedLines;
  24563. /** @hidden */
  24564. private _intersectTriangles;
  24565. /** @hidden */
  24566. private _intersectUnIndexedTriangles;
  24567. /** @hidden */
  24568. _rebuild(): void;
  24569. /**
  24570. * Creates a new submesh from the passed mesh
  24571. * @param newMesh defines the new hosting mesh
  24572. * @param newRenderingMesh defines an optional rendering mesh
  24573. * @returns the new submesh
  24574. */
  24575. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24576. /**
  24577. * Release associated resources
  24578. */
  24579. dispose(): void;
  24580. /**
  24581. * Gets the class name
  24582. * @returns the string "SubMesh".
  24583. */
  24584. getClassName(): string;
  24585. /**
  24586. * Creates a new submesh from indices data
  24587. * @param materialIndex the index of the main mesh material
  24588. * @param startIndex the index where to start the copy in the mesh indices array
  24589. * @param indexCount the number of indices to copy then from the startIndex
  24590. * @param mesh the main mesh to create the submesh from
  24591. * @param renderingMesh the optional rendering mesh
  24592. * @returns a new submesh
  24593. */
  24594. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24595. }
  24596. }
  24597. declare module BABYLON {
  24598. /**
  24599. * Class used to represent data loading progression
  24600. */
  24601. export class SceneLoaderFlags {
  24602. private static _ForceFullSceneLoadingForIncremental;
  24603. private static _ShowLoadingScreen;
  24604. private static _CleanBoneMatrixWeights;
  24605. private static _loggingLevel;
  24606. /**
  24607. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24608. */
  24609. static get ForceFullSceneLoadingForIncremental(): boolean;
  24610. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24611. /**
  24612. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24613. */
  24614. static get ShowLoadingScreen(): boolean;
  24615. static set ShowLoadingScreen(value: boolean);
  24616. /**
  24617. * Defines the current logging level (while loading the scene)
  24618. * @ignorenaming
  24619. */
  24620. static get loggingLevel(): number;
  24621. static set loggingLevel(value: number);
  24622. /**
  24623. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24624. */
  24625. static get CleanBoneMatrixWeights(): boolean;
  24626. static set CleanBoneMatrixWeights(value: boolean);
  24627. }
  24628. }
  24629. declare module BABYLON {
  24630. /**
  24631. * Class used to store geometry data (vertex buffers + index buffer)
  24632. */
  24633. export class Geometry implements IGetSetVerticesData {
  24634. /**
  24635. * Gets or sets the ID of the geometry
  24636. */
  24637. id: string;
  24638. /**
  24639. * Gets or sets the unique ID of the geometry
  24640. */
  24641. uniqueId: number;
  24642. /**
  24643. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24644. */
  24645. delayLoadState: number;
  24646. /**
  24647. * Gets the file containing the data to load when running in delay load state
  24648. */
  24649. delayLoadingFile: Nullable<string>;
  24650. /**
  24651. * Callback called when the geometry is updated
  24652. */
  24653. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24654. private _scene;
  24655. private _engine;
  24656. private _meshes;
  24657. private _totalVertices;
  24658. /** @hidden */
  24659. _indices: IndicesArray;
  24660. /** @hidden */
  24661. _vertexBuffers: {
  24662. [key: string]: VertexBuffer;
  24663. };
  24664. private _isDisposed;
  24665. private _extend;
  24666. private _boundingBias;
  24667. /** @hidden */
  24668. _delayInfo: Array<string>;
  24669. private _indexBuffer;
  24670. private _indexBufferIsUpdatable;
  24671. /** @hidden */
  24672. _boundingInfo: Nullable<BoundingInfo>;
  24673. /** @hidden */
  24674. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24675. /** @hidden */
  24676. _softwareSkinningFrameId: number;
  24677. private _vertexArrayObjects;
  24678. private _updatable;
  24679. /** @hidden */
  24680. _positions: Nullable<Vector3[]>;
  24681. /**
  24682. * 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
  24683. */
  24684. get boundingBias(): Vector2;
  24685. /**
  24686. * 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
  24687. */
  24688. set boundingBias(value: Vector2);
  24689. /**
  24690. * Static function used to attach a new empty geometry to a mesh
  24691. * @param mesh defines the mesh to attach the geometry to
  24692. * @returns the new Geometry
  24693. */
  24694. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24695. /** Get the list of meshes using this geometry */
  24696. get meshes(): Mesh[];
  24697. /**
  24698. * 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
  24699. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  24700. */
  24701. useBoundingInfoFromGeometry: boolean;
  24702. /**
  24703. * Creates a new geometry
  24704. * @param id defines the unique ID
  24705. * @param scene defines the hosting scene
  24706. * @param vertexData defines the VertexData used to get geometry data
  24707. * @param updatable defines if geometry must be updatable (false by default)
  24708. * @param mesh defines the mesh that will be associated with the geometry
  24709. */
  24710. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24711. /**
  24712. * Gets the current extend of the geometry
  24713. */
  24714. get extend(): {
  24715. minimum: Vector3;
  24716. maximum: Vector3;
  24717. };
  24718. /**
  24719. * Gets the hosting scene
  24720. * @returns the hosting Scene
  24721. */
  24722. getScene(): Scene;
  24723. /**
  24724. * Gets the hosting engine
  24725. * @returns the hosting Engine
  24726. */
  24727. getEngine(): Engine;
  24728. /**
  24729. * Defines if the geometry is ready to use
  24730. * @returns true if the geometry is ready to be used
  24731. */
  24732. isReady(): boolean;
  24733. /**
  24734. * Gets a value indicating that the geometry should not be serialized
  24735. */
  24736. get doNotSerialize(): boolean;
  24737. /** @hidden */
  24738. _rebuild(): void;
  24739. /**
  24740. * Affects all geometry data in one call
  24741. * @param vertexData defines the geometry data
  24742. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24743. */
  24744. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24745. /**
  24746. * Set specific vertex data
  24747. * @param kind defines the data kind (Position, normal, etc...)
  24748. * @param data defines the vertex data to use
  24749. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24750. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24751. */
  24752. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24753. /**
  24754. * Removes a specific vertex data
  24755. * @param kind defines the data kind (Position, normal, etc...)
  24756. */
  24757. removeVerticesData(kind: string): void;
  24758. /**
  24759. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24760. * @param buffer defines the vertex buffer to use
  24761. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24762. */
  24763. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24764. /**
  24765. * Update a specific vertex buffer
  24766. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24767. * It will do nothing if the buffer is not updatable
  24768. * @param kind defines the data kind (Position, normal, etc...)
  24769. * @param data defines the data to use
  24770. * @param offset defines the offset in the target buffer where to store the data
  24771. * @param useBytes set to true if the offset is in bytes
  24772. */
  24773. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24774. /**
  24775. * Update a specific vertex buffer
  24776. * This function will create a new buffer if the current one is not updatable
  24777. * @param kind defines the data kind (Position, normal, etc...)
  24778. * @param data defines the data to use
  24779. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24780. */
  24781. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24782. private _updateBoundingInfo;
  24783. /** @hidden */
  24784. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24785. /**
  24786. * Gets total number of vertices
  24787. * @returns the total number of vertices
  24788. */
  24789. getTotalVertices(): number;
  24790. /**
  24791. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24792. * @param kind defines the data kind (Position, normal, etc...)
  24793. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24794. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24795. * @returns a float array containing vertex data
  24796. */
  24797. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24798. /**
  24799. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24800. * @param kind defines the data kind (Position, normal, etc...)
  24801. * @returns true if the vertex buffer with the specified kind is updatable
  24802. */
  24803. isVertexBufferUpdatable(kind: string): boolean;
  24804. /**
  24805. * Gets a specific vertex buffer
  24806. * @param kind defines the data kind (Position, normal, etc...)
  24807. * @returns a VertexBuffer
  24808. */
  24809. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24810. /**
  24811. * Returns all vertex buffers
  24812. * @return an object holding all vertex buffers indexed by kind
  24813. */
  24814. getVertexBuffers(): Nullable<{
  24815. [key: string]: VertexBuffer;
  24816. }>;
  24817. /**
  24818. * Gets a boolean indicating if specific vertex buffer is present
  24819. * @param kind defines the data kind (Position, normal, etc...)
  24820. * @returns true if data is present
  24821. */
  24822. isVerticesDataPresent(kind: string): boolean;
  24823. /**
  24824. * Gets a list of all attached data kinds (Position, normal, etc...)
  24825. * @returns a list of string containing all kinds
  24826. */
  24827. getVerticesDataKinds(): string[];
  24828. /**
  24829. * Update index buffer
  24830. * @param indices defines the indices to store in the index buffer
  24831. * @param offset defines the offset in the target buffer where to store the data
  24832. * @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)
  24833. */
  24834. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24835. /**
  24836. * Creates a new index buffer
  24837. * @param indices defines the indices to store in the index buffer
  24838. * @param totalVertices defines the total number of vertices (could be null)
  24839. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24840. */
  24841. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24842. /**
  24843. * Return the total number of indices
  24844. * @returns the total number of indices
  24845. */
  24846. getTotalIndices(): number;
  24847. /**
  24848. * Gets the index buffer array
  24849. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24850. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24851. * @returns the index buffer array
  24852. */
  24853. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24854. /**
  24855. * Gets the index buffer
  24856. * @return the index buffer
  24857. */
  24858. getIndexBuffer(): Nullable<DataBuffer>;
  24859. /** @hidden */
  24860. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24861. /**
  24862. * Release the associated resources for a specific mesh
  24863. * @param mesh defines the source mesh
  24864. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24865. */
  24866. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24867. /**
  24868. * Apply current geometry to a given mesh
  24869. * @param mesh defines the mesh to apply geometry to
  24870. */
  24871. applyToMesh(mesh: Mesh): void;
  24872. private _updateExtend;
  24873. private _applyToMesh;
  24874. private notifyUpdate;
  24875. /**
  24876. * Load the geometry if it was flagged as delay loaded
  24877. * @param scene defines the hosting scene
  24878. * @param onLoaded defines a callback called when the geometry is loaded
  24879. */
  24880. load(scene: Scene, onLoaded?: () => void): void;
  24881. private _queueLoad;
  24882. /**
  24883. * Invert the geometry to move from a right handed system to a left handed one.
  24884. */
  24885. toLeftHanded(): void;
  24886. /** @hidden */
  24887. _resetPointsArrayCache(): void;
  24888. /** @hidden */
  24889. _generatePointsArray(): boolean;
  24890. /**
  24891. * Gets a value indicating if the geometry is disposed
  24892. * @returns true if the geometry was disposed
  24893. */
  24894. isDisposed(): boolean;
  24895. private _disposeVertexArrayObjects;
  24896. /**
  24897. * Free all associated resources
  24898. */
  24899. dispose(): void;
  24900. /**
  24901. * Clone the current geometry into a new geometry
  24902. * @param id defines the unique ID of the new geometry
  24903. * @returns a new geometry object
  24904. */
  24905. copy(id: string): Geometry;
  24906. /**
  24907. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24908. * @return a JSON representation of the current geometry data (without the vertices data)
  24909. */
  24910. serialize(): any;
  24911. private toNumberArray;
  24912. /**
  24913. * Serialize all vertices data into a JSON oject
  24914. * @returns a JSON representation of the current geometry data
  24915. */
  24916. serializeVerticeData(): any;
  24917. /**
  24918. * Extracts a clone of a mesh geometry
  24919. * @param mesh defines the source mesh
  24920. * @param id defines the unique ID of the new geometry object
  24921. * @returns the new geometry object
  24922. */
  24923. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24924. /**
  24925. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24926. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24927. * Be aware Math.random() could cause collisions, but:
  24928. * "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"
  24929. * @returns a string containing a new GUID
  24930. */
  24931. static RandomId(): string;
  24932. /** @hidden */
  24933. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24934. private static _CleanMatricesWeights;
  24935. /**
  24936. * Create a new geometry from persisted data (Using .babylon file format)
  24937. * @param parsedVertexData defines the persisted data
  24938. * @param scene defines the hosting scene
  24939. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24940. * @returns the new geometry object
  24941. */
  24942. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24943. }
  24944. }
  24945. declare module BABYLON {
  24946. /**
  24947. * Define an interface for all classes that will get and set the data on vertices
  24948. */
  24949. export interface IGetSetVerticesData {
  24950. /**
  24951. * Gets a boolean indicating if specific vertex data is present
  24952. * @param kind defines the vertex data kind to use
  24953. * @returns true is data kind is present
  24954. */
  24955. isVerticesDataPresent(kind: string): boolean;
  24956. /**
  24957. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24958. * @param kind defines the data kind (Position, normal, etc...)
  24959. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24960. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24961. * @returns a float array containing vertex data
  24962. */
  24963. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24964. /**
  24965. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24966. * @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.
  24967. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24968. * @returns the indices array or an empty array if the mesh has no geometry
  24969. */
  24970. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24971. /**
  24972. * Set specific vertex data
  24973. * @param kind defines the data kind (Position, normal, etc...)
  24974. * @param data defines the vertex data to use
  24975. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24976. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24977. */
  24978. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  24979. /**
  24980. * Update a specific associated vertex buffer
  24981. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24982. * - VertexBuffer.PositionKind
  24983. * - VertexBuffer.UVKind
  24984. * - VertexBuffer.UV2Kind
  24985. * - VertexBuffer.UV3Kind
  24986. * - VertexBuffer.UV4Kind
  24987. * - VertexBuffer.UV5Kind
  24988. * - VertexBuffer.UV6Kind
  24989. * - VertexBuffer.ColorKind
  24990. * - VertexBuffer.MatricesIndicesKind
  24991. * - VertexBuffer.MatricesIndicesExtraKind
  24992. * - VertexBuffer.MatricesWeightsKind
  24993. * - VertexBuffer.MatricesWeightsExtraKind
  24994. * @param data defines the data source
  24995. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24996. * @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)
  24997. */
  24998. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  24999. /**
  25000. * Creates a new index buffer
  25001. * @param indices defines the indices to store in the index buffer
  25002. * @param totalVertices defines the total number of vertices (could be null)
  25003. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25004. */
  25005. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25006. }
  25007. /**
  25008. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25009. */
  25010. export class VertexData {
  25011. /**
  25012. * Mesh side orientation : usually the external or front surface
  25013. */
  25014. static readonly FRONTSIDE: number;
  25015. /**
  25016. * Mesh side orientation : usually the internal or back surface
  25017. */
  25018. static readonly BACKSIDE: number;
  25019. /**
  25020. * Mesh side orientation : both internal and external or front and back surfaces
  25021. */
  25022. static readonly DOUBLESIDE: number;
  25023. /**
  25024. * Mesh side orientation : by default, `FRONTSIDE`
  25025. */
  25026. static readonly DEFAULTSIDE: number;
  25027. /**
  25028. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25029. */
  25030. positions: Nullable<FloatArray>;
  25031. /**
  25032. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25033. */
  25034. normals: Nullable<FloatArray>;
  25035. /**
  25036. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25037. */
  25038. tangents: Nullable<FloatArray>;
  25039. /**
  25040. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25041. */
  25042. uvs: Nullable<FloatArray>;
  25043. /**
  25044. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25045. */
  25046. uvs2: Nullable<FloatArray>;
  25047. /**
  25048. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25049. */
  25050. uvs3: Nullable<FloatArray>;
  25051. /**
  25052. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25053. */
  25054. uvs4: Nullable<FloatArray>;
  25055. /**
  25056. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25057. */
  25058. uvs5: Nullable<FloatArray>;
  25059. /**
  25060. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25061. */
  25062. uvs6: Nullable<FloatArray>;
  25063. /**
  25064. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25065. */
  25066. colors: Nullable<FloatArray>;
  25067. /**
  25068. * 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).
  25069. */
  25070. matricesIndices: Nullable<FloatArray>;
  25071. /**
  25072. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25073. */
  25074. matricesWeights: Nullable<FloatArray>;
  25075. /**
  25076. * An array extending the number of possible indices
  25077. */
  25078. matricesIndicesExtra: Nullable<FloatArray>;
  25079. /**
  25080. * An array extending the number of possible weights when the number of indices is extended
  25081. */
  25082. matricesWeightsExtra: Nullable<FloatArray>;
  25083. /**
  25084. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25085. */
  25086. indices: Nullable<IndicesArray>;
  25087. /**
  25088. * Uses the passed data array to set the set the values for the specified kind of data
  25089. * @param data a linear array of floating numbers
  25090. * @param kind the type of data that is being set, eg positions, colors etc
  25091. */
  25092. set(data: FloatArray, kind: string): void;
  25093. /**
  25094. * Associates the vertexData to the passed Mesh.
  25095. * Sets it as updatable or not (default `false`)
  25096. * @param mesh the mesh the vertexData is applied to
  25097. * @param updatable when used and having the value true allows new data to update the vertexData
  25098. * @returns the VertexData
  25099. */
  25100. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25101. /**
  25102. * Associates the vertexData to the passed Geometry.
  25103. * Sets it as updatable or not (default `false`)
  25104. * @param geometry the geometry the vertexData is applied to
  25105. * @param updatable when used and having the value true allows new data to update the vertexData
  25106. * @returns VertexData
  25107. */
  25108. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25109. /**
  25110. * Updates the associated mesh
  25111. * @param mesh the mesh to be updated
  25112. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25113. * @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
  25114. * @returns VertexData
  25115. */
  25116. updateMesh(mesh: Mesh): VertexData;
  25117. /**
  25118. * Updates the associated geometry
  25119. * @param geometry the geometry to be updated
  25120. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25121. * @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
  25122. * @returns VertexData.
  25123. */
  25124. updateGeometry(geometry: Geometry): VertexData;
  25125. private _applyTo;
  25126. private _update;
  25127. /**
  25128. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25129. * @param matrix the transforming matrix
  25130. * @returns the VertexData
  25131. */
  25132. transform(matrix: Matrix): VertexData;
  25133. /**
  25134. * Merges the passed VertexData into the current one
  25135. * @param other the VertexData to be merged into the current one
  25136. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25137. * @returns the modified VertexData
  25138. */
  25139. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25140. private _mergeElement;
  25141. private _validate;
  25142. /**
  25143. * Serializes the VertexData
  25144. * @returns a serialized object
  25145. */
  25146. serialize(): any;
  25147. /**
  25148. * Extracts the vertexData from a mesh
  25149. * @param mesh the mesh from which to extract the VertexData
  25150. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25151. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25152. * @returns the object VertexData associated to the passed mesh
  25153. */
  25154. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25155. /**
  25156. * Extracts the vertexData from the geometry
  25157. * @param geometry the geometry from which to extract the VertexData
  25158. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25159. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25160. * @returns the object VertexData associated to the passed mesh
  25161. */
  25162. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25163. private static _ExtractFrom;
  25164. /**
  25165. * Creates the VertexData for a Ribbon
  25166. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25167. * * pathArray array of paths, each of which an array of successive Vector3
  25168. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25169. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25170. * * 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
  25171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25172. * * 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)
  25173. * * 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)
  25174. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25175. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25176. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25177. * @returns the VertexData of the ribbon
  25178. */
  25179. static CreateRibbon(options: {
  25180. pathArray: Vector3[][];
  25181. closeArray?: boolean;
  25182. closePath?: boolean;
  25183. offset?: number;
  25184. sideOrientation?: number;
  25185. frontUVs?: Vector4;
  25186. backUVs?: Vector4;
  25187. invertUV?: boolean;
  25188. uvs?: Vector2[];
  25189. colors?: Color4[];
  25190. }): VertexData;
  25191. /**
  25192. * Creates the VertexData for a box
  25193. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25194. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25195. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25196. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25197. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25198. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25199. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25201. * * 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)
  25202. * * 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)
  25203. * @returns the VertexData of the box
  25204. */
  25205. static CreateBox(options: {
  25206. size?: number;
  25207. width?: number;
  25208. height?: number;
  25209. depth?: number;
  25210. faceUV?: Vector4[];
  25211. faceColors?: Color4[];
  25212. sideOrientation?: number;
  25213. frontUVs?: Vector4;
  25214. backUVs?: Vector4;
  25215. }): VertexData;
  25216. /**
  25217. * Creates the VertexData for a tiled box
  25218. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25219. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25223. * @returns the VertexData of the box
  25224. */
  25225. static CreateTiledBox(options: {
  25226. pattern?: number;
  25227. width?: number;
  25228. height?: number;
  25229. depth?: number;
  25230. tileSize?: number;
  25231. tileWidth?: number;
  25232. tileHeight?: number;
  25233. alignHorizontal?: number;
  25234. alignVertical?: number;
  25235. faceUV?: Vector4[];
  25236. faceColors?: Color4[];
  25237. sideOrientation?: number;
  25238. }): VertexData;
  25239. /**
  25240. * Creates the VertexData for a tiled plane
  25241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25242. * * pattern a limited pattern arrangement depending on the number
  25243. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25244. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25245. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25246. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25247. * * 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)
  25248. * * 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)
  25249. * @returns the VertexData of the tiled plane
  25250. */
  25251. static CreateTiledPlane(options: {
  25252. pattern?: number;
  25253. tileSize?: number;
  25254. tileWidth?: number;
  25255. tileHeight?: number;
  25256. size?: number;
  25257. width?: number;
  25258. height?: number;
  25259. alignHorizontal?: number;
  25260. alignVertical?: number;
  25261. sideOrientation?: number;
  25262. frontUVs?: Vector4;
  25263. backUVs?: Vector4;
  25264. }): VertexData;
  25265. /**
  25266. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25268. * * segments sets the number of horizontal strips optional, default 32
  25269. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25270. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25271. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25272. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25273. * * 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
  25274. * * 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
  25275. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25276. * * 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)
  25277. * * 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)
  25278. * @returns the VertexData of the ellipsoid
  25279. */
  25280. static CreateSphere(options: {
  25281. segments?: number;
  25282. diameter?: number;
  25283. diameterX?: number;
  25284. diameterY?: number;
  25285. diameterZ?: number;
  25286. arc?: number;
  25287. slice?: number;
  25288. sideOrientation?: number;
  25289. frontUVs?: Vector4;
  25290. backUVs?: Vector4;
  25291. }): VertexData;
  25292. /**
  25293. * Creates the VertexData for a cylinder, cone or prism
  25294. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25295. * * height sets the height (y direction) of the cylinder, optional, default 2
  25296. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25297. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25298. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25299. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25300. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25301. * * 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
  25302. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25303. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25304. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25305. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25306. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25307. * * 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)
  25308. * * 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)
  25309. * @returns the VertexData of the cylinder, cone or prism
  25310. */
  25311. static CreateCylinder(options: {
  25312. height?: number;
  25313. diameterTop?: number;
  25314. diameterBottom?: number;
  25315. diameter?: number;
  25316. tessellation?: number;
  25317. subdivisions?: number;
  25318. arc?: number;
  25319. faceColors?: Color4[];
  25320. faceUV?: Vector4[];
  25321. hasRings?: boolean;
  25322. enclose?: boolean;
  25323. sideOrientation?: number;
  25324. frontUVs?: Vector4;
  25325. backUVs?: Vector4;
  25326. }): VertexData;
  25327. /**
  25328. * Creates the VertexData for a torus
  25329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25330. * * diameter the diameter of the torus, optional default 1
  25331. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25332. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25334. * * 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)
  25335. * * 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)
  25336. * @returns the VertexData of the torus
  25337. */
  25338. static CreateTorus(options: {
  25339. diameter?: number;
  25340. thickness?: number;
  25341. tessellation?: number;
  25342. sideOrientation?: number;
  25343. frontUVs?: Vector4;
  25344. backUVs?: Vector4;
  25345. }): VertexData;
  25346. /**
  25347. * Creates the VertexData of the LineSystem
  25348. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25349. * - lines an array of lines, each line being an array of successive Vector3
  25350. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25351. * @returns the VertexData of the LineSystem
  25352. */
  25353. static CreateLineSystem(options: {
  25354. lines: Vector3[][];
  25355. colors?: Nullable<Color4[][]>;
  25356. }): VertexData;
  25357. /**
  25358. * Create the VertexData for a DashedLines
  25359. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25360. * - points an array successive Vector3
  25361. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25362. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25363. * - dashNb the intended total number of dashes, optional, default 200
  25364. * @returns the VertexData for the DashedLines
  25365. */
  25366. static CreateDashedLines(options: {
  25367. points: Vector3[];
  25368. dashSize?: number;
  25369. gapSize?: number;
  25370. dashNb?: number;
  25371. }): VertexData;
  25372. /**
  25373. * Creates the VertexData for a Ground
  25374. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25375. * - width the width (x direction) of the ground, optional, default 1
  25376. * - height the height (z direction) of the ground, optional, default 1
  25377. * - subdivisions the number of subdivisions per side, optional, default 1
  25378. * @returns the VertexData of the Ground
  25379. */
  25380. static CreateGround(options: {
  25381. width?: number;
  25382. height?: number;
  25383. subdivisions?: number;
  25384. subdivisionsX?: number;
  25385. subdivisionsY?: number;
  25386. }): VertexData;
  25387. /**
  25388. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25389. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25390. * * xmin the ground minimum X coordinate, optional, default -1
  25391. * * zmin the ground minimum Z coordinate, optional, default -1
  25392. * * xmax the ground maximum X coordinate, optional, default 1
  25393. * * zmax the ground maximum Z coordinate, optional, default 1
  25394. * * 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}
  25395. * * 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}
  25396. * @returns the VertexData of the TiledGround
  25397. */
  25398. static CreateTiledGround(options: {
  25399. xmin: number;
  25400. zmin: number;
  25401. xmax: number;
  25402. zmax: number;
  25403. subdivisions?: {
  25404. w: number;
  25405. h: number;
  25406. };
  25407. precision?: {
  25408. w: number;
  25409. h: number;
  25410. };
  25411. }): VertexData;
  25412. /**
  25413. * Creates the VertexData of the Ground designed from a heightmap
  25414. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25415. * * width the width (x direction) of the ground
  25416. * * height the height (z direction) of the ground
  25417. * * subdivisions the number of subdivisions per side
  25418. * * minHeight the minimum altitude on the ground, optional, default 0
  25419. * * maxHeight the maximum altitude on the ground, optional default 1
  25420. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25421. * * buffer the array holding the image color data
  25422. * * bufferWidth the width of image
  25423. * * bufferHeight the height of image
  25424. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25425. * @returns the VertexData of the Ground designed from a heightmap
  25426. */
  25427. static CreateGroundFromHeightMap(options: {
  25428. width: number;
  25429. height: number;
  25430. subdivisions: number;
  25431. minHeight: number;
  25432. maxHeight: number;
  25433. colorFilter: Color3;
  25434. buffer: Uint8Array;
  25435. bufferWidth: number;
  25436. bufferHeight: number;
  25437. alphaFilter: number;
  25438. }): VertexData;
  25439. /**
  25440. * Creates the VertexData for a Plane
  25441. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25442. * * size sets the width and height of the plane to the value of size, optional default 1
  25443. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25444. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25446. * * 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)
  25447. * * 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)
  25448. * @returns the VertexData of the box
  25449. */
  25450. static CreatePlane(options: {
  25451. size?: number;
  25452. width?: number;
  25453. height?: number;
  25454. sideOrientation?: number;
  25455. frontUVs?: Vector4;
  25456. backUVs?: Vector4;
  25457. }): VertexData;
  25458. /**
  25459. * Creates the VertexData of the Disc or regular Polygon
  25460. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25461. * * radius the radius of the disc, optional default 0.5
  25462. * * tessellation the number of polygon sides, optional, default 64
  25463. * * 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
  25464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25465. * * 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)
  25466. * * 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)
  25467. * @returns the VertexData of the box
  25468. */
  25469. static CreateDisc(options: {
  25470. radius?: number;
  25471. tessellation?: number;
  25472. arc?: number;
  25473. sideOrientation?: number;
  25474. frontUVs?: Vector4;
  25475. backUVs?: Vector4;
  25476. }): VertexData;
  25477. /**
  25478. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25479. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25480. * @param polygon a mesh built from polygonTriangulation.build()
  25481. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25482. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25483. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25484. * @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)
  25485. * @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)
  25486. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25487. * @returns the VertexData of the Polygon
  25488. */
  25489. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25490. /**
  25491. * Creates the VertexData of the IcoSphere
  25492. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25493. * * radius the radius of the IcoSphere, optional default 1
  25494. * * radiusX allows stretching in the x direction, optional, default radius
  25495. * * radiusY allows stretching in the y direction, optional, default radius
  25496. * * radiusZ allows stretching in the z direction, optional, default radius
  25497. * * flat when true creates a flat shaded mesh, optional, default true
  25498. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25500. * * 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)
  25501. * * 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)
  25502. * @returns the VertexData of the IcoSphere
  25503. */
  25504. static CreateIcoSphere(options: {
  25505. radius?: number;
  25506. radiusX?: number;
  25507. radiusY?: number;
  25508. radiusZ?: number;
  25509. flat?: boolean;
  25510. subdivisions?: number;
  25511. sideOrientation?: number;
  25512. frontUVs?: Vector4;
  25513. backUVs?: Vector4;
  25514. }): VertexData;
  25515. /**
  25516. * Creates the VertexData for a Polyhedron
  25517. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25518. * * type provided types are:
  25519. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25520. * * 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)
  25521. * * size the size of the IcoSphere, optional default 1
  25522. * * sizeX allows stretching in the x direction, optional, default size
  25523. * * sizeY allows stretching in the y direction, optional, default size
  25524. * * sizeZ allows stretching in the z direction, optional, default size
  25525. * * 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
  25526. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25527. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25528. * * flat when true creates a flat shaded mesh, optional, default true
  25529. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25530. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25531. * * 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)
  25532. * * 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)
  25533. * @returns the VertexData of the Polyhedron
  25534. */
  25535. static CreatePolyhedron(options: {
  25536. type?: number;
  25537. size?: number;
  25538. sizeX?: number;
  25539. sizeY?: number;
  25540. sizeZ?: number;
  25541. custom?: any;
  25542. faceUV?: Vector4[];
  25543. faceColors?: Color4[];
  25544. flat?: boolean;
  25545. sideOrientation?: number;
  25546. frontUVs?: Vector4;
  25547. backUVs?: Vector4;
  25548. }): VertexData;
  25549. /**
  25550. * Creates the VertexData for a TorusKnot
  25551. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25552. * * radius the radius of the torus knot, optional, default 2
  25553. * * tube the thickness of the tube, optional, default 0.5
  25554. * * radialSegments the number of sides on each tube segments, optional, default 32
  25555. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25556. * * p the number of windings around the z axis, optional, default 2
  25557. * * q the number of windings around the x axis, optional, default 3
  25558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25559. * * 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)
  25560. * * 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)
  25561. * @returns the VertexData of the Torus Knot
  25562. */
  25563. static CreateTorusKnot(options: {
  25564. radius?: number;
  25565. tube?: number;
  25566. radialSegments?: number;
  25567. tubularSegments?: number;
  25568. p?: number;
  25569. q?: number;
  25570. sideOrientation?: number;
  25571. frontUVs?: Vector4;
  25572. backUVs?: Vector4;
  25573. }): VertexData;
  25574. /**
  25575. * Compute normals for given positions and indices
  25576. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25577. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25578. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25579. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25580. * * facetNormals : optional array of facet normals (vector3)
  25581. * * facetPositions : optional array of facet positions (vector3)
  25582. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25583. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25584. * * bInfo : optional bounding info, required for facetPartitioning computation
  25585. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25586. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25587. * * useRightHandedSystem: optional boolean to for right handed system computation
  25588. * * depthSort : optional boolean to enable the facet depth sort computation
  25589. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25590. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25591. */
  25592. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25593. facetNormals?: any;
  25594. facetPositions?: any;
  25595. facetPartitioning?: any;
  25596. ratio?: number;
  25597. bInfo?: any;
  25598. bbSize?: Vector3;
  25599. subDiv?: any;
  25600. useRightHandedSystem?: boolean;
  25601. depthSort?: boolean;
  25602. distanceTo?: Vector3;
  25603. depthSortedFacets?: any;
  25604. }): void;
  25605. /** @hidden */
  25606. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25607. /**
  25608. * Applies VertexData created from the imported parameters to the geometry
  25609. * @param parsedVertexData the parsed data from an imported file
  25610. * @param geometry the geometry to apply the VertexData to
  25611. */
  25612. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25613. }
  25614. }
  25615. declare module BABYLON {
  25616. /**
  25617. * Defines a target to use with MorphTargetManager
  25618. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25619. */
  25620. export class MorphTarget implements IAnimatable {
  25621. /** defines the name of the target */
  25622. name: string;
  25623. /**
  25624. * Gets or sets the list of animations
  25625. */
  25626. animations: Animation[];
  25627. private _scene;
  25628. private _positions;
  25629. private _normals;
  25630. private _tangents;
  25631. private _uvs;
  25632. private _influence;
  25633. private _uniqueId;
  25634. /**
  25635. * Observable raised when the influence changes
  25636. */
  25637. onInfluenceChanged: Observable<boolean>;
  25638. /** @hidden */
  25639. _onDataLayoutChanged: Observable<void>;
  25640. /**
  25641. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25642. */
  25643. get influence(): number;
  25644. set influence(influence: number);
  25645. /**
  25646. * Gets or sets the id of the morph Target
  25647. */
  25648. id: string;
  25649. private _animationPropertiesOverride;
  25650. /**
  25651. * Gets or sets the animation properties override
  25652. */
  25653. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25654. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25655. /**
  25656. * Creates a new MorphTarget
  25657. * @param name defines the name of the target
  25658. * @param influence defines the influence to use
  25659. * @param scene defines the scene the morphtarget belongs to
  25660. */
  25661. constructor(
  25662. /** defines the name of the target */
  25663. name: string, influence?: number, scene?: Nullable<Scene>);
  25664. /**
  25665. * Gets the unique ID of this manager
  25666. */
  25667. get uniqueId(): number;
  25668. /**
  25669. * Gets a boolean defining if the target contains position data
  25670. */
  25671. get hasPositions(): boolean;
  25672. /**
  25673. * Gets a boolean defining if the target contains normal data
  25674. */
  25675. get hasNormals(): boolean;
  25676. /**
  25677. * Gets a boolean defining if the target contains tangent data
  25678. */
  25679. get hasTangents(): boolean;
  25680. /**
  25681. * Gets a boolean defining if the target contains texture coordinates data
  25682. */
  25683. get hasUVs(): boolean;
  25684. /**
  25685. * Affects position data to this target
  25686. * @param data defines the position data to use
  25687. */
  25688. setPositions(data: Nullable<FloatArray>): void;
  25689. /**
  25690. * Gets the position data stored in this target
  25691. * @returns a FloatArray containing the position data (or null if not present)
  25692. */
  25693. getPositions(): Nullable<FloatArray>;
  25694. /**
  25695. * Affects normal data to this target
  25696. * @param data defines the normal data to use
  25697. */
  25698. setNormals(data: Nullable<FloatArray>): void;
  25699. /**
  25700. * Gets the normal data stored in this target
  25701. * @returns a FloatArray containing the normal data (or null if not present)
  25702. */
  25703. getNormals(): Nullable<FloatArray>;
  25704. /**
  25705. * Affects tangent data to this target
  25706. * @param data defines the tangent data to use
  25707. */
  25708. setTangents(data: Nullable<FloatArray>): void;
  25709. /**
  25710. * Gets the tangent data stored in this target
  25711. * @returns a FloatArray containing the tangent data (or null if not present)
  25712. */
  25713. getTangents(): Nullable<FloatArray>;
  25714. /**
  25715. * Affects texture coordinates data to this target
  25716. * @param data defines the texture coordinates data to use
  25717. */
  25718. setUVs(data: Nullable<FloatArray>): void;
  25719. /**
  25720. * Gets the texture coordinates data stored in this target
  25721. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25722. */
  25723. getUVs(): Nullable<FloatArray>;
  25724. /**
  25725. * Clone the current target
  25726. * @returns a new MorphTarget
  25727. */
  25728. clone(): MorphTarget;
  25729. /**
  25730. * Serializes the current target into a Serialization object
  25731. * @returns the serialized object
  25732. */
  25733. serialize(): any;
  25734. /**
  25735. * Returns the string "MorphTarget"
  25736. * @returns "MorphTarget"
  25737. */
  25738. getClassName(): string;
  25739. /**
  25740. * Creates a new target from serialized data
  25741. * @param serializationObject defines the serialized data to use
  25742. * @returns a new MorphTarget
  25743. */
  25744. static Parse(serializationObject: any): MorphTarget;
  25745. /**
  25746. * Creates a MorphTarget from mesh data
  25747. * @param mesh defines the source mesh
  25748. * @param name defines the name to use for the new target
  25749. * @param influence defines the influence to attach to the target
  25750. * @returns a new MorphTarget
  25751. */
  25752. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25753. }
  25754. }
  25755. declare module BABYLON {
  25756. /**
  25757. * This class is used to deform meshes using morphing between different targets
  25758. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25759. */
  25760. export class MorphTargetManager {
  25761. private _targets;
  25762. private _targetInfluenceChangedObservers;
  25763. private _targetDataLayoutChangedObservers;
  25764. private _activeTargets;
  25765. private _scene;
  25766. private _influences;
  25767. private _supportsNormals;
  25768. private _supportsTangents;
  25769. private _supportsUVs;
  25770. private _vertexCount;
  25771. private _uniqueId;
  25772. private _tempInfluences;
  25773. /**
  25774. * Gets or sets a boolean indicating if normals must be morphed
  25775. */
  25776. enableNormalMorphing: boolean;
  25777. /**
  25778. * Gets or sets a boolean indicating if tangents must be morphed
  25779. */
  25780. enableTangentMorphing: boolean;
  25781. /**
  25782. * Gets or sets a boolean indicating if UV must be morphed
  25783. */
  25784. enableUVMorphing: boolean;
  25785. /**
  25786. * Creates a new MorphTargetManager
  25787. * @param scene defines the current scene
  25788. */
  25789. constructor(scene?: Nullable<Scene>);
  25790. /**
  25791. * Gets the unique ID of this manager
  25792. */
  25793. get uniqueId(): number;
  25794. /**
  25795. * Gets the number of vertices handled by this manager
  25796. */
  25797. get vertexCount(): number;
  25798. /**
  25799. * Gets a boolean indicating if this manager supports morphing of normals
  25800. */
  25801. get supportsNormals(): boolean;
  25802. /**
  25803. * Gets a boolean indicating if this manager supports morphing of tangents
  25804. */
  25805. get supportsTangents(): boolean;
  25806. /**
  25807. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25808. */
  25809. get supportsUVs(): boolean;
  25810. /**
  25811. * Gets the number of targets stored in this manager
  25812. */
  25813. get numTargets(): number;
  25814. /**
  25815. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25816. */
  25817. get numInfluencers(): number;
  25818. /**
  25819. * Gets the list of influences (one per target)
  25820. */
  25821. get influences(): Float32Array;
  25822. /**
  25823. * Gets the active target at specified index. An active target is a target with an influence > 0
  25824. * @param index defines the index to check
  25825. * @returns the requested target
  25826. */
  25827. getActiveTarget(index: number): MorphTarget;
  25828. /**
  25829. * Gets the target at specified index
  25830. * @param index defines the index to check
  25831. * @returns the requested target
  25832. */
  25833. getTarget(index: number): MorphTarget;
  25834. /**
  25835. * Add a new target to this manager
  25836. * @param target defines the target to add
  25837. */
  25838. addTarget(target: MorphTarget): void;
  25839. /**
  25840. * Removes a target from the manager
  25841. * @param target defines the target to remove
  25842. */
  25843. removeTarget(target: MorphTarget): void;
  25844. /**
  25845. * Clone the current manager
  25846. * @returns a new MorphTargetManager
  25847. */
  25848. clone(): MorphTargetManager;
  25849. /**
  25850. * Serializes the current manager into a Serialization object
  25851. * @returns the serialized object
  25852. */
  25853. serialize(): any;
  25854. private _syncActiveTargets;
  25855. /**
  25856. * Syncrhonize the targets with all the meshes using this morph target manager
  25857. */
  25858. synchronize(): void;
  25859. /**
  25860. * Creates a new MorphTargetManager from serialized data
  25861. * @param serializationObject defines the serialized data
  25862. * @param scene defines the hosting scene
  25863. * @returns the new MorphTargetManager
  25864. */
  25865. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25866. }
  25867. }
  25868. declare module BABYLON {
  25869. /**
  25870. * Class used to represent a specific level of detail of a mesh
  25871. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25872. */
  25873. export class MeshLODLevel {
  25874. /** Defines the distance where this level should start being displayed */
  25875. distance: number;
  25876. /** Defines the mesh to use to render this level */
  25877. mesh: Nullable<Mesh>;
  25878. /**
  25879. * Creates a new LOD level
  25880. * @param distance defines the distance where this level should star being displayed
  25881. * @param mesh defines the mesh to use to render this level
  25882. */
  25883. constructor(
  25884. /** Defines the distance where this level should start being displayed */
  25885. distance: number,
  25886. /** Defines the mesh to use to render this level */
  25887. mesh: Nullable<Mesh>);
  25888. }
  25889. }
  25890. declare module BABYLON {
  25891. /**
  25892. * Helper class used to generate a canvas to manipulate images
  25893. */
  25894. export class CanvasGenerator {
  25895. /**
  25896. * Create a new canvas (or offscreen canvas depending on the context)
  25897. * @param width defines the expected width
  25898. * @param height defines the expected height
  25899. * @return a new canvas or offscreen canvas
  25900. */
  25901. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25902. }
  25903. }
  25904. declare module BABYLON {
  25905. /**
  25906. * Mesh representing the gorund
  25907. */
  25908. export class GroundMesh extends Mesh {
  25909. /** If octree should be generated */
  25910. generateOctree: boolean;
  25911. private _heightQuads;
  25912. /** @hidden */
  25913. _subdivisionsX: number;
  25914. /** @hidden */
  25915. _subdivisionsY: number;
  25916. /** @hidden */
  25917. _width: number;
  25918. /** @hidden */
  25919. _height: number;
  25920. /** @hidden */
  25921. _minX: number;
  25922. /** @hidden */
  25923. _maxX: number;
  25924. /** @hidden */
  25925. _minZ: number;
  25926. /** @hidden */
  25927. _maxZ: number;
  25928. constructor(name: string, scene: Scene);
  25929. /**
  25930. * "GroundMesh"
  25931. * @returns "GroundMesh"
  25932. */
  25933. getClassName(): string;
  25934. /**
  25935. * The minimum of x and y subdivisions
  25936. */
  25937. get subdivisions(): number;
  25938. /**
  25939. * X subdivisions
  25940. */
  25941. get subdivisionsX(): number;
  25942. /**
  25943. * Y subdivisions
  25944. */
  25945. get subdivisionsY(): number;
  25946. /**
  25947. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25948. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25949. * @param chunksCount the number of subdivisions for x and y
  25950. * @param octreeBlocksSize (Default: 32)
  25951. */
  25952. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25953. /**
  25954. * Returns a height (y) value in the Worl system :
  25955. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25956. * @param x x coordinate
  25957. * @param z z coordinate
  25958. * @returns the ground y position if (x, z) are outside the ground surface.
  25959. */
  25960. getHeightAtCoordinates(x: number, z: number): number;
  25961. /**
  25962. * Returns a normalized vector (Vector3) orthogonal to the ground
  25963. * at the ground coordinates (x, z) expressed in the World system.
  25964. * @param x x coordinate
  25965. * @param z z coordinate
  25966. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  25967. */
  25968. getNormalAtCoordinates(x: number, z: number): Vector3;
  25969. /**
  25970. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  25971. * at the ground coordinates (x, z) expressed in the World system.
  25972. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  25973. * @param x x coordinate
  25974. * @param z z coordinate
  25975. * @param ref vector to store the result
  25976. * @returns the GroundMesh.
  25977. */
  25978. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  25979. /**
  25980. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  25981. * if the ground has been updated.
  25982. * This can be used in the render loop.
  25983. * @returns the GroundMesh.
  25984. */
  25985. updateCoordinateHeights(): GroundMesh;
  25986. private _getFacetAt;
  25987. private _initHeightQuads;
  25988. private _computeHeightQuads;
  25989. /**
  25990. * Serializes this ground mesh
  25991. * @param serializationObject object to write serialization to
  25992. */
  25993. serialize(serializationObject: any): void;
  25994. /**
  25995. * Parses a serialized ground mesh
  25996. * @param parsedMesh the serialized mesh
  25997. * @param scene the scene to create the ground mesh in
  25998. * @returns the created ground mesh
  25999. */
  26000. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26001. }
  26002. }
  26003. declare module BABYLON {
  26004. /**
  26005. * Interface for Physics-Joint data
  26006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26007. */
  26008. export interface PhysicsJointData {
  26009. /**
  26010. * The main pivot of the joint
  26011. */
  26012. mainPivot?: Vector3;
  26013. /**
  26014. * The connected pivot of the joint
  26015. */
  26016. connectedPivot?: Vector3;
  26017. /**
  26018. * The main axis of the joint
  26019. */
  26020. mainAxis?: Vector3;
  26021. /**
  26022. * The connected axis of the joint
  26023. */
  26024. connectedAxis?: Vector3;
  26025. /**
  26026. * The collision of the joint
  26027. */
  26028. collision?: boolean;
  26029. /**
  26030. * Native Oimo/Cannon/Energy data
  26031. */
  26032. nativeParams?: any;
  26033. }
  26034. /**
  26035. * This is a holder class for the physics joint created by the physics plugin
  26036. * It holds a set of functions to control the underlying joint
  26037. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26038. */
  26039. export class PhysicsJoint {
  26040. /**
  26041. * The type of the physics joint
  26042. */
  26043. type: number;
  26044. /**
  26045. * The data for the physics joint
  26046. */
  26047. jointData: PhysicsJointData;
  26048. private _physicsJoint;
  26049. protected _physicsPlugin: IPhysicsEnginePlugin;
  26050. /**
  26051. * Initializes the physics joint
  26052. * @param type The type of the physics joint
  26053. * @param jointData The data for the physics joint
  26054. */
  26055. constructor(
  26056. /**
  26057. * The type of the physics joint
  26058. */
  26059. type: number,
  26060. /**
  26061. * The data for the physics joint
  26062. */
  26063. jointData: PhysicsJointData);
  26064. /**
  26065. * Gets the physics joint
  26066. */
  26067. get physicsJoint(): any;
  26068. /**
  26069. * Sets the physics joint
  26070. */
  26071. set physicsJoint(newJoint: any);
  26072. /**
  26073. * Sets the physics plugin
  26074. */
  26075. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26076. /**
  26077. * Execute a function that is physics-plugin specific.
  26078. * @param {Function} func the function that will be executed.
  26079. * It accepts two parameters: the physics world and the physics joint
  26080. */
  26081. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26082. /**
  26083. * Distance-Joint type
  26084. */
  26085. static DistanceJoint: number;
  26086. /**
  26087. * Hinge-Joint type
  26088. */
  26089. static HingeJoint: number;
  26090. /**
  26091. * Ball-and-Socket joint type
  26092. */
  26093. static BallAndSocketJoint: number;
  26094. /**
  26095. * Wheel-Joint type
  26096. */
  26097. static WheelJoint: number;
  26098. /**
  26099. * Slider-Joint type
  26100. */
  26101. static SliderJoint: number;
  26102. /**
  26103. * Prismatic-Joint type
  26104. */
  26105. static PrismaticJoint: number;
  26106. /**
  26107. * Universal-Joint type
  26108. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26109. */
  26110. static UniversalJoint: number;
  26111. /**
  26112. * Hinge-Joint 2 type
  26113. */
  26114. static Hinge2Joint: number;
  26115. /**
  26116. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26117. */
  26118. static PointToPointJoint: number;
  26119. /**
  26120. * Spring-Joint type
  26121. */
  26122. static SpringJoint: number;
  26123. /**
  26124. * Lock-Joint type
  26125. */
  26126. static LockJoint: number;
  26127. }
  26128. /**
  26129. * A class representing a physics distance joint
  26130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26131. */
  26132. export class DistanceJoint extends PhysicsJoint {
  26133. /**
  26134. *
  26135. * @param jointData The data for the Distance-Joint
  26136. */
  26137. constructor(jointData: DistanceJointData);
  26138. /**
  26139. * Update the predefined distance.
  26140. * @param maxDistance The maximum preferred distance
  26141. * @param minDistance The minimum preferred distance
  26142. */
  26143. updateDistance(maxDistance: number, minDistance?: number): void;
  26144. }
  26145. /**
  26146. * Represents a Motor-Enabled Joint
  26147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26148. */
  26149. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26150. /**
  26151. * Initializes the Motor-Enabled Joint
  26152. * @param type The type of the joint
  26153. * @param jointData The physica joint data for the joint
  26154. */
  26155. constructor(type: number, jointData: PhysicsJointData);
  26156. /**
  26157. * Set the motor values.
  26158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26159. * @param force the force to apply
  26160. * @param maxForce max force for this motor.
  26161. */
  26162. setMotor(force?: number, maxForce?: number): void;
  26163. /**
  26164. * Set the motor's limits.
  26165. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26166. * @param upperLimit The upper limit of the motor
  26167. * @param lowerLimit The lower limit of the motor
  26168. */
  26169. setLimit(upperLimit: number, lowerLimit?: number): void;
  26170. }
  26171. /**
  26172. * This class represents a single physics Hinge-Joint
  26173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26174. */
  26175. export class HingeJoint extends MotorEnabledJoint {
  26176. /**
  26177. * Initializes the Hinge-Joint
  26178. * @param jointData The joint data for the Hinge-Joint
  26179. */
  26180. constructor(jointData: PhysicsJointData);
  26181. /**
  26182. * Set the motor values.
  26183. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26184. * @param {number} force the force to apply
  26185. * @param {number} maxForce max force for this motor.
  26186. */
  26187. setMotor(force?: number, maxForce?: number): void;
  26188. /**
  26189. * Set the motor's limits.
  26190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26191. * @param upperLimit The upper limit of the motor
  26192. * @param lowerLimit The lower limit of the motor
  26193. */
  26194. setLimit(upperLimit: number, lowerLimit?: number): void;
  26195. }
  26196. /**
  26197. * This class represents a dual hinge physics joint (same as wheel joint)
  26198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26199. */
  26200. export class Hinge2Joint extends MotorEnabledJoint {
  26201. /**
  26202. * Initializes the Hinge2-Joint
  26203. * @param jointData The joint data for the Hinge2-Joint
  26204. */
  26205. constructor(jointData: PhysicsJointData);
  26206. /**
  26207. * Set the motor values.
  26208. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26209. * @param {number} targetSpeed the speed the motor is to reach
  26210. * @param {number} maxForce max force for this motor.
  26211. * @param {motorIndex} the motor's index, 0 or 1.
  26212. */
  26213. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26214. /**
  26215. * Set the motor limits.
  26216. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26217. * @param {number} upperLimit the upper limit
  26218. * @param {number} lowerLimit lower limit
  26219. * @param {motorIndex} the motor's index, 0 or 1.
  26220. */
  26221. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26222. }
  26223. /**
  26224. * Interface for a motor enabled joint
  26225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26226. */
  26227. export interface IMotorEnabledJoint {
  26228. /**
  26229. * Physics joint
  26230. */
  26231. physicsJoint: any;
  26232. /**
  26233. * Sets the motor of the motor-enabled joint
  26234. * @param force The force of the motor
  26235. * @param maxForce The maximum force of the motor
  26236. * @param motorIndex The index of the motor
  26237. */
  26238. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26239. /**
  26240. * Sets the limit of the motor
  26241. * @param upperLimit The upper limit of the motor
  26242. * @param lowerLimit The lower limit of the motor
  26243. * @param motorIndex The index of the motor
  26244. */
  26245. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26246. }
  26247. /**
  26248. * Joint data for a Distance-Joint
  26249. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26250. */
  26251. export interface DistanceJointData extends PhysicsJointData {
  26252. /**
  26253. * Max distance the 2 joint objects can be apart
  26254. */
  26255. maxDistance: number;
  26256. }
  26257. /**
  26258. * Joint data from a spring joint
  26259. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26260. */
  26261. export interface SpringJointData extends PhysicsJointData {
  26262. /**
  26263. * Length of the spring
  26264. */
  26265. length: number;
  26266. /**
  26267. * Stiffness of the spring
  26268. */
  26269. stiffness: number;
  26270. /**
  26271. * Damping of the spring
  26272. */
  26273. damping: number;
  26274. /** this callback will be called when applying the force to the impostors. */
  26275. forceApplicationCallback: () => void;
  26276. }
  26277. }
  26278. declare module BABYLON {
  26279. /**
  26280. * Holds the data for the raycast result
  26281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26282. */
  26283. export class PhysicsRaycastResult {
  26284. private _hasHit;
  26285. private _hitDistance;
  26286. private _hitNormalWorld;
  26287. private _hitPointWorld;
  26288. private _rayFromWorld;
  26289. private _rayToWorld;
  26290. /**
  26291. * Gets if there was a hit
  26292. */
  26293. get hasHit(): boolean;
  26294. /**
  26295. * Gets the distance from the hit
  26296. */
  26297. get hitDistance(): number;
  26298. /**
  26299. * Gets the hit normal/direction in the world
  26300. */
  26301. get hitNormalWorld(): Vector3;
  26302. /**
  26303. * Gets the hit point in the world
  26304. */
  26305. get hitPointWorld(): Vector3;
  26306. /**
  26307. * Gets the ray "start point" of the ray in the world
  26308. */
  26309. get rayFromWorld(): Vector3;
  26310. /**
  26311. * Gets the ray "end point" of the ray in the world
  26312. */
  26313. get rayToWorld(): Vector3;
  26314. /**
  26315. * Sets the hit data (normal & point in world space)
  26316. * @param hitNormalWorld defines the normal in world space
  26317. * @param hitPointWorld defines the point in world space
  26318. */
  26319. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26320. /**
  26321. * Sets the distance from the start point to the hit point
  26322. * @param distance
  26323. */
  26324. setHitDistance(distance: number): void;
  26325. /**
  26326. * Calculates the distance manually
  26327. */
  26328. calculateHitDistance(): void;
  26329. /**
  26330. * Resets all the values to default
  26331. * @param from The from point on world space
  26332. * @param to The to point on world space
  26333. */
  26334. reset(from?: Vector3, to?: Vector3): void;
  26335. }
  26336. /**
  26337. * Interface for the size containing width and height
  26338. */
  26339. interface IXYZ {
  26340. /**
  26341. * X
  26342. */
  26343. x: number;
  26344. /**
  26345. * Y
  26346. */
  26347. y: number;
  26348. /**
  26349. * Z
  26350. */
  26351. z: number;
  26352. }
  26353. }
  26354. declare module BABYLON {
  26355. /**
  26356. * Interface used to describe a physics joint
  26357. */
  26358. export interface PhysicsImpostorJoint {
  26359. /** Defines the main impostor to which the joint is linked */
  26360. mainImpostor: PhysicsImpostor;
  26361. /** Defines the impostor that is connected to the main impostor using this joint */
  26362. connectedImpostor: PhysicsImpostor;
  26363. /** Defines the joint itself */
  26364. joint: PhysicsJoint;
  26365. }
  26366. /** @hidden */
  26367. export interface IPhysicsEnginePlugin {
  26368. world: any;
  26369. name: string;
  26370. setGravity(gravity: Vector3): void;
  26371. setTimeStep(timeStep: number): void;
  26372. getTimeStep(): number;
  26373. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26374. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26375. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26376. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26377. removePhysicsBody(impostor: PhysicsImpostor): void;
  26378. generateJoint(joint: PhysicsImpostorJoint): void;
  26379. removeJoint(joint: PhysicsImpostorJoint): void;
  26380. isSupported(): boolean;
  26381. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26382. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26383. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26384. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26385. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26386. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26387. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26388. getBodyMass(impostor: PhysicsImpostor): number;
  26389. getBodyFriction(impostor: PhysicsImpostor): number;
  26390. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26391. getBodyRestitution(impostor: PhysicsImpostor): number;
  26392. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26393. getBodyPressure?(impostor: PhysicsImpostor): number;
  26394. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26395. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26396. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26397. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26398. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26399. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26400. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26401. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26402. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26403. sleepBody(impostor: PhysicsImpostor): void;
  26404. wakeUpBody(impostor: PhysicsImpostor): void;
  26405. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26406. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26407. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26408. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26409. getRadius(impostor: PhysicsImpostor): number;
  26410. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26411. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26412. dispose(): void;
  26413. }
  26414. /**
  26415. * Interface used to define a physics engine
  26416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26417. */
  26418. export interface IPhysicsEngine {
  26419. /**
  26420. * Gets the gravity vector used by the simulation
  26421. */
  26422. gravity: Vector3;
  26423. /**
  26424. * Sets the gravity vector used by the simulation
  26425. * @param gravity defines the gravity vector to use
  26426. */
  26427. setGravity(gravity: Vector3): void;
  26428. /**
  26429. * Set the time step of the physics engine.
  26430. * Default is 1/60.
  26431. * To slow it down, enter 1/600 for example.
  26432. * To speed it up, 1/30
  26433. * @param newTimeStep the new timestep to apply to this world.
  26434. */
  26435. setTimeStep(newTimeStep: number): void;
  26436. /**
  26437. * Get the time step of the physics engine.
  26438. * @returns the current time step
  26439. */
  26440. getTimeStep(): number;
  26441. /**
  26442. * Set the sub time step of the physics engine.
  26443. * Default is 0 meaning there is no sub steps
  26444. * To increase physics resolution precision, set a small value (like 1 ms)
  26445. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26446. */
  26447. setSubTimeStep(subTimeStep: number): void;
  26448. /**
  26449. * Get the sub time step of the physics engine.
  26450. * @returns the current sub time step
  26451. */
  26452. getSubTimeStep(): number;
  26453. /**
  26454. * Release all resources
  26455. */
  26456. dispose(): void;
  26457. /**
  26458. * Gets the name of the current physics plugin
  26459. * @returns the name of the plugin
  26460. */
  26461. getPhysicsPluginName(): string;
  26462. /**
  26463. * Adding a new impostor for the impostor tracking.
  26464. * This will be done by the impostor itself.
  26465. * @param impostor the impostor to add
  26466. */
  26467. addImpostor(impostor: PhysicsImpostor): void;
  26468. /**
  26469. * Remove an impostor from the engine.
  26470. * This impostor and its mesh will not longer be updated by the physics engine.
  26471. * @param impostor the impostor to remove
  26472. */
  26473. removeImpostor(impostor: PhysicsImpostor): void;
  26474. /**
  26475. * Add a joint to the physics engine
  26476. * @param mainImpostor defines the main impostor to which the joint is added.
  26477. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26478. * @param joint defines the joint that will connect both impostors.
  26479. */
  26480. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26481. /**
  26482. * Removes a joint from the simulation
  26483. * @param mainImpostor defines the impostor used with the joint
  26484. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26485. * @param joint defines the joint to remove
  26486. */
  26487. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26488. /**
  26489. * Gets the current plugin used to run the simulation
  26490. * @returns current plugin
  26491. */
  26492. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26493. /**
  26494. * Gets the list of physic impostors
  26495. * @returns an array of PhysicsImpostor
  26496. */
  26497. getImpostors(): Array<PhysicsImpostor>;
  26498. /**
  26499. * Gets the impostor for a physics enabled object
  26500. * @param object defines the object impersonated by the impostor
  26501. * @returns the PhysicsImpostor or null if not found
  26502. */
  26503. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26504. /**
  26505. * Gets the impostor for a physics body object
  26506. * @param body defines physics body used by the impostor
  26507. * @returns the PhysicsImpostor or null if not found
  26508. */
  26509. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26510. /**
  26511. * Does a raycast in the physics world
  26512. * @param from when should the ray start?
  26513. * @param to when should the ray end?
  26514. * @returns PhysicsRaycastResult
  26515. */
  26516. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26517. /**
  26518. * Called by the scene. No need to call it.
  26519. * @param delta defines the timespam between frames
  26520. */
  26521. _step(delta: number): void;
  26522. }
  26523. }
  26524. declare module BABYLON {
  26525. /**
  26526. * The interface for the physics imposter parameters
  26527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26528. */
  26529. export interface PhysicsImpostorParameters {
  26530. /**
  26531. * The mass of the physics imposter
  26532. */
  26533. mass: number;
  26534. /**
  26535. * The friction of the physics imposter
  26536. */
  26537. friction?: number;
  26538. /**
  26539. * The coefficient of restitution of the physics imposter
  26540. */
  26541. restitution?: number;
  26542. /**
  26543. * The native options of the physics imposter
  26544. */
  26545. nativeOptions?: any;
  26546. /**
  26547. * Specifies if the parent should be ignored
  26548. */
  26549. ignoreParent?: boolean;
  26550. /**
  26551. * Specifies if bi-directional transformations should be disabled
  26552. */
  26553. disableBidirectionalTransformation?: boolean;
  26554. /**
  26555. * The pressure inside the physics imposter, soft object only
  26556. */
  26557. pressure?: number;
  26558. /**
  26559. * The stiffness the physics imposter, soft object only
  26560. */
  26561. stiffness?: number;
  26562. /**
  26563. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26564. */
  26565. velocityIterations?: number;
  26566. /**
  26567. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26568. */
  26569. positionIterations?: number;
  26570. /**
  26571. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26572. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26573. * Add to fix multiple points
  26574. */
  26575. fixedPoints?: number;
  26576. /**
  26577. * The collision margin around a soft object
  26578. */
  26579. margin?: number;
  26580. /**
  26581. * The collision margin around a soft object
  26582. */
  26583. damping?: number;
  26584. /**
  26585. * The path for a rope based on an extrusion
  26586. */
  26587. path?: any;
  26588. /**
  26589. * The shape of an extrusion used for a rope based on an extrusion
  26590. */
  26591. shape?: any;
  26592. }
  26593. /**
  26594. * Interface for a physics-enabled object
  26595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26596. */
  26597. export interface IPhysicsEnabledObject {
  26598. /**
  26599. * The position of the physics-enabled object
  26600. */
  26601. position: Vector3;
  26602. /**
  26603. * The rotation of the physics-enabled object
  26604. */
  26605. rotationQuaternion: Nullable<Quaternion>;
  26606. /**
  26607. * The scale of the physics-enabled object
  26608. */
  26609. scaling: Vector3;
  26610. /**
  26611. * The rotation of the physics-enabled object
  26612. */
  26613. rotation?: Vector3;
  26614. /**
  26615. * The parent of the physics-enabled object
  26616. */
  26617. parent?: any;
  26618. /**
  26619. * The bounding info of the physics-enabled object
  26620. * @returns The bounding info of the physics-enabled object
  26621. */
  26622. getBoundingInfo(): BoundingInfo;
  26623. /**
  26624. * Computes the world matrix
  26625. * @param force Specifies if the world matrix should be computed by force
  26626. * @returns A world matrix
  26627. */
  26628. computeWorldMatrix(force: boolean): Matrix;
  26629. /**
  26630. * Gets the world matrix
  26631. * @returns A world matrix
  26632. */
  26633. getWorldMatrix?(): Matrix;
  26634. /**
  26635. * Gets the child meshes
  26636. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26637. * @returns An array of abstract meshes
  26638. */
  26639. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26640. /**
  26641. * Gets the vertex data
  26642. * @param kind The type of vertex data
  26643. * @returns A nullable array of numbers, or a float32 array
  26644. */
  26645. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26646. /**
  26647. * Gets the indices from the mesh
  26648. * @returns A nullable array of index arrays
  26649. */
  26650. getIndices?(): Nullable<IndicesArray>;
  26651. /**
  26652. * Gets the scene from the mesh
  26653. * @returns the indices array or null
  26654. */
  26655. getScene?(): Scene;
  26656. /**
  26657. * Gets the absolute position from the mesh
  26658. * @returns the absolute position
  26659. */
  26660. getAbsolutePosition(): Vector3;
  26661. /**
  26662. * Gets the absolute pivot point from the mesh
  26663. * @returns the absolute pivot point
  26664. */
  26665. getAbsolutePivotPoint(): Vector3;
  26666. /**
  26667. * Rotates the mesh
  26668. * @param axis The axis of rotation
  26669. * @param amount The amount of rotation
  26670. * @param space The space of the rotation
  26671. * @returns The rotation transform node
  26672. */
  26673. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26674. /**
  26675. * Translates the mesh
  26676. * @param axis The axis of translation
  26677. * @param distance The distance of translation
  26678. * @param space The space of the translation
  26679. * @returns The transform node
  26680. */
  26681. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26682. /**
  26683. * Sets the absolute position of the mesh
  26684. * @param absolutePosition The absolute position of the mesh
  26685. * @returns The transform node
  26686. */
  26687. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26688. /**
  26689. * Gets the class name of the mesh
  26690. * @returns The class name
  26691. */
  26692. getClassName(): string;
  26693. }
  26694. /**
  26695. * Represents a physics imposter
  26696. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26697. */
  26698. export class PhysicsImpostor {
  26699. /**
  26700. * The physics-enabled object used as the physics imposter
  26701. */
  26702. object: IPhysicsEnabledObject;
  26703. /**
  26704. * The type of the physics imposter
  26705. */
  26706. type: number;
  26707. private _options;
  26708. private _scene?;
  26709. /**
  26710. * The default object size of the imposter
  26711. */
  26712. static DEFAULT_OBJECT_SIZE: Vector3;
  26713. /**
  26714. * The identity quaternion of the imposter
  26715. */
  26716. static IDENTITY_QUATERNION: Quaternion;
  26717. /** @hidden */
  26718. _pluginData: any;
  26719. private _physicsEngine;
  26720. private _physicsBody;
  26721. private _bodyUpdateRequired;
  26722. private _onBeforePhysicsStepCallbacks;
  26723. private _onAfterPhysicsStepCallbacks;
  26724. /** @hidden */
  26725. _onPhysicsCollideCallbacks: Array<{
  26726. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26727. otherImpostors: Array<PhysicsImpostor>;
  26728. }>;
  26729. private _deltaPosition;
  26730. private _deltaRotation;
  26731. private _deltaRotationConjugated;
  26732. /** @hidden */
  26733. _isFromLine: boolean;
  26734. private _parent;
  26735. private _isDisposed;
  26736. private static _tmpVecs;
  26737. private static _tmpQuat;
  26738. /**
  26739. * Specifies if the physics imposter is disposed
  26740. */
  26741. get isDisposed(): boolean;
  26742. /**
  26743. * Gets the mass of the physics imposter
  26744. */
  26745. get mass(): number;
  26746. set mass(value: number);
  26747. /**
  26748. * Gets the coefficient of friction
  26749. */
  26750. get friction(): number;
  26751. /**
  26752. * Sets the coefficient of friction
  26753. */
  26754. set friction(value: number);
  26755. /**
  26756. * Gets the coefficient of restitution
  26757. */
  26758. get restitution(): number;
  26759. /**
  26760. * Sets the coefficient of restitution
  26761. */
  26762. set restitution(value: number);
  26763. /**
  26764. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26765. */
  26766. get pressure(): number;
  26767. /**
  26768. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26769. */
  26770. set pressure(value: number);
  26771. /**
  26772. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26773. */
  26774. get stiffness(): number;
  26775. /**
  26776. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26777. */
  26778. set stiffness(value: number);
  26779. /**
  26780. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26781. */
  26782. get velocityIterations(): number;
  26783. /**
  26784. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26785. */
  26786. set velocityIterations(value: number);
  26787. /**
  26788. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26789. */
  26790. get positionIterations(): number;
  26791. /**
  26792. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26793. */
  26794. set positionIterations(value: number);
  26795. /**
  26796. * The unique id of the physics imposter
  26797. * set by the physics engine when adding this impostor to the array
  26798. */
  26799. uniqueId: number;
  26800. /**
  26801. * @hidden
  26802. */
  26803. soft: boolean;
  26804. /**
  26805. * @hidden
  26806. */
  26807. segments: number;
  26808. private _joints;
  26809. /**
  26810. * Initializes the physics imposter
  26811. * @param object The physics-enabled object used as the physics imposter
  26812. * @param type The type of the physics imposter
  26813. * @param _options The options for the physics imposter
  26814. * @param _scene The Babylon scene
  26815. */
  26816. constructor(
  26817. /**
  26818. * The physics-enabled object used as the physics imposter
  26819. */
  26820. object: IPhysicsEnabledObject,
  26821. /**
  26822. * The type of the physics imposter
  26823. */
  26824. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26825. /**
  26826. * This function will completly initialize this impostor.
  26827. * It will create a new body - but only if this mesh has no parent.
  26828. * If it has, this impostor will not be used other than to define the impostor
  26829. * of the child mesh.
  26830. * @hidden
  26831. */
  26832. _init(): void;
  26833. private _getPhysicsParent;
  26834. /**
  26835. * Should a new body be generated.
  26836. * @returns boolean specifying if body initialization is required
  26837. */
  26838. isBodyInitRequired(): boolean;
  26839. /**
  26840. * Sets the updated scaling
  26841. * @param updated Specifies if the scaling is updated
  26842. */
  26843. setScalingUpdated(): void;
  26844. /**
  26845. * Force a regeneration of this or the parent's impostor's body.
  26846. * Use under cautious - This will remove all joints already implemented.
  26847. */
  26848. forceUpdate(): void;
  26849. /**
  26850. * Gets the body that holds this impostor. Either its own, or its parent.
  26851. */
  26852. get physicsBody(): any;
  26853. /**
  26854. * Get the parent of the physics imposter
  26855. * @returns Physics imposter or null
  26856. */
  26857. get parent(): Nullable<PhysicsImpostor>;
  26858. /**
  26859. * Sets the parent of the physics imposter
  26860. */
  26861. set parent(value: Nullable<PhysicsImpostor>);
  26862. /**
  26863. * Set the physics body. Used mainly by the physics engine/plugin
  26864. */
  26865. set physicsBody(physicsBody: any);
  26866. /**
  26867. * Resets the update flags
  26868. */
  26869. resetUpdateFlags(): void;
  26870. /**
  26871. * Gets the object extend size
  26872. * @returns the object extend size
  26873. */
  26874. getObjectExtendSize(): Vector3;
  26875. /**
  26876. * Gets the object center
  26877. * @returns The object center
  26878. */
  26879. getObjectCenter(): Vector3;
  26880. /**
  26881. * Get a specific parameter from the options parameters
  26882. * @param paramName The object parameter name
  26883. * @returns The object parameter
  26884. */
  26885. getParam(paramName: string): any;
  26886. /**
  26887. * Sets a specific parameter in the options given to the physics plugin
  26888. * @param paramName The parameter name
  26889. * @param value The value of the parameter
  26890. */
  26891. setParam(paramName: string, value: number): void;
  26892. /**
  26893. * Specifically change the body's mass option. Won't recreate the physics body object
  26894. * @param mass The mass of the physics imposter
  26895. */
  26896. setMass(mass: number): void;
  26897. /**
  26898. * Gets the linear velocity
  26899. * @returns linear velocity or null
  26900. */
  26901. getLinearVelocity(): Nullable<Vector3>;
  26902. /**
  26903. * Sets the linear velocity
  26904. * @param velocity linear velocity or null
  26905. */
  26906. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26907. /**
  26908. * Gets the angular velocity
  26909. * @returns angular velocity or null
  26910. */
  26911. getAngularVelocity(): Nullable<Vector3>;
  26912. /**
  26913. * Sets the angular velocity
  26914. * @param velocity The velocity or null
  26915. */
  26916. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26917. /**
  26918. * Execute a function with the physics plugin native code
  26919. * Provide a function the will have two variables - the world object and the physics body object
  26920. * @param func The function to execute with the physics plugin native code
  26921. */
  26922. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26923. /**
  26924. * Register a function that will be executed before the physics world is stepping forward
  26925. * @param func The function to execute before the physics world is stepped forward
  26926. */
  26927. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26928. /**
  26929. * Unregister a function that will be executed before the physics world is stepping forward
  26930. * @param func The function to execute before the physics world is stepped forward
  26931. */
  26932. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26933. /**
  26934. * Register a function that will be executed after the physics step
  26935. * @param func The function to execute after physics step
  26936. */
  26937. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26938. /**
  26939. * Unregisters a function that will be executed after the physics step
  26940. * @param func The function to execute after physics step
  26941. */
  26942. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26943. /**
  26944. * register a function that will be executed when this impostor collides against a different body
  26945. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26946. * @param func Callback that is executed on collision
  26947. */
  26948. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26949. /**
  26950. * Unregisters the physics imposter on contact
  26951. * @param collideAgainst The physics object to collide against
  26952. * @param func Callback to execute on collision
  26953. */
  26954. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26955. private _tmpQuat;
  26956. private _tmpQuat2;
  26957. /**
  26958. * Get the parent rotation
  26959. * @returns The parent rotation
  26960. */
  26961. getParentsRotation(): Quaternion;
  26962. /**
  26963. * this function is executed by the physics engine.
  26964. */
  26965. beforeStep: () => void;
  26966. /**
  26967. * this function is executed by the physics engine
  26968. */
  26969. afterStep: () => void;
  26970. /**
  26971. * Legacy collision detection event support
  26972. */
  26973. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  26974. /**
  26975. * event and body object due to cannon's event-based architecture.
  26976. */
  26977. onCollide: (e: {
  26978. body: any;
  26979. }) => void;
  26980. /**
  26981. * Apply a force
  26982. * @param force The force to apply
  26983. * @param contactPoint The contact point for the force
  26984. * @returns The physics imposter
  26985. */
  26986. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26987. /**
  26988. * Apply an impulse
  26989. * @param force The impulse force
  26990. * @param contactPoint The contact point for the impulse force
  26991. * @returns The physics imposter
  26992. */
  26993. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  26994. /**
  26995. * A help function to create a joint
  26996. * @param otherImpostor A physics imposter used to create a joint
  26997. * @param jointType The type of joint
  26998. * @param jointData The data for the joint
  26999. * @returns The physics imposter
  27000. */
  27001. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27002. /**
  27003. * Add a joint to this impostor with a different impostor
  27004. * @param otherImpostor A physics imposter used to add a joint
  27005. * @param joint The joint to add
  27006. * @returns The physics imposter
  27007. */
  27008. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27009. /**
  27010. * Add an anchor to a cloth impostor
  27011. * @param otherImpostor rigid impostor to anchor to
  27012. * @param width ratio across width from 0 to 1
  27013. * @param height ratio up height from 0 to 1
  27014. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27015. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27016. * @returns impostor the soft imposter
  27017. */
  27018. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27019. /**
  27020. * Add a hook to a rope impostor
  27021. * @param otherImpostor rigid impostor to anchor to
  27022. * @param length ratio across rope from 0 to 1
  27023. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27024. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27025. * @returns impostor the rope imposter
  27026. */
  27027. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27028. /**
  27029. * Will keep this body still, in a sleep mode.
  27030. * @returns the physics imposter
  27031. */
  27032. sleep(): PhysicsImpostor;
  27033. /**
  27034. * Wake the body up.
  27035. * @returns The physics imposter
  27036. */
  27037. wakeUp(): PhysicsImpostor;
  27038. /**
  27039. * Clones the physics imposter
  27040. * @param newObject The physics imposter clones to this physics-enabled object
  27041. * @returns A nullable physics imposter
  27042. */
  27043. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27044. /**
  27045. * Disposes the physics imposter
  27046. */
  27047. dispose(): void;
  27048. /**
  27049. * Sets the delta position
  27050. * @param position The delta position amount
  27051. */
  27052. setDeltaPosition(position: Vector3): void;
  27053. /**
  27054. * Sets the delta rotation
  27055. * @param rotation The delta rotation amount
  27056. */
  27057. setDeltaRotation(rotation: Quaternion): void;
  27058. /**
  27059. * Gets the box size of the physics imposter and stores the result in the input parameter
  27060. * @param result Stores the box size
  27061. * @returns The physics imposter
  27062. */
  27063. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27064. /**
  27065. * Gets the radius of the physics imposter
  27066. * @returns Radius of the physics imposter
  27067. */
  27068. getRadius(): number;
  27069. /**
  27070. * Sync a bone with this impostor
  27071. * @param bone The bone to sync to the impostor.
  27072. * @param boneMesh The mesh that the bone is influencing.
  27073. * @param jointPivot The pivot of the joint / bone in local space.
  27074. * @param distToJoint Optional distance from the impostor to the joint.
  27075. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27076. */
  27077. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27078. /**
  27079. * Sync impostor to a bone
  27080. * @param bone The bone that the impostor will be synced to.
  27081. * @param boneMesh The mesh that the bone is influencing.
  27082. * @param jointPivot The pivot of the joint / bone in local space.
  27083. * @param distToJoint Optional distance from the impostor to the joint.
  27084. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27085. * @param boneAxis Optional vector3 axis the bone is aligned with
  27086. */
  27087. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27088. /**
  27089. * No-Imposter type
  27090. */
  27091. static NoImpostor: number;
  27092. /**
  27093. * Sphere-Imposter type
  27094. */
  27095. static SphereImpostor: number;
  27096. /**
  27097. * Box-Imposter type
  27098. */
  27099. static BoxImpostor: number;
  27100. /**
  27101. * Plane-Imposter type
  27102. */
  27103. static PlaneImpostor: number;
  27104. /**
  27105. * Mesh-imposter type
  27106. */
  27107. static MeshImpostor: number;
  27108. /**
  27109. * Capsule-Impostor type (Ammo.js plugin only)
  27110. */
  27111. static CapsuleImpostor: number;
  27112. /**
  27113. * Cylinder-Imposter type
  27114. */
  27115. static CylinderImpostor: number;
  27116. /**
  27117. * Particle-Imposter type
  27118. */
  27119. static ParticleImpostor: number;
  27120. /**
  27121. * Heightmap-Imposter type
  27122. */
  27123. static HeightmapImpostor: number;
  27124. /**
  27125. * ConvexHull-Impostor type (Ammo.js plugin only)
  27126. */
  27127. static ConvexHullImpostor: number;
  27128. /**
  27129. * Custom-Imposter type (Ammo.js plugin only)
  27130. */
  27131. static CustomImpostor: number;
  27132. /**
  27133. * Rope-Imposter type
  27134. */
  27135. static RopeImpostor: number;
  27136. /**
  27137. * Cloth-Imposter type
  27138. */
  27139. static ClothImpostor: number;
  27140. /**
  27141. * Softbody-Imposter type
  27142. */
  27143. static SoftbodyImpostor: number;
  27144. }
  27145. }
  27146. declare module BABYLON {
  27147. /**
  27148. * @hidden
  27149. **/
  27150. export class _CreationDataStorage {
  27151. closePath?: boolean;
  27152. closeArray?: boolean;
  27153. idx: number[];
  27154. dashSize: number;
  27155. gapSize: number;
  27156. path3D: Path3D;
  27157. pathArray: Vector3[][];
  27158. arc: number;
  27159. radius: number;
  27160. cap: number;
  27161. tessellation: number;
  27162. }
  27163. /**
  27164. * @hidden
  27165. **/
  27166. class _InstanceDataStorage {
  27167. visibleInstances: any;
  27168. batchCache: _InstancesBatch;
  27169. instancesBufferSize: number;
  27170. instancesBuffer: Nullable<Buffer>;
  27171. instancesData: Float32Array;
  27172. overridenInstanceCount: number;
  27173. isFrozen: boolean;
  27174. previousBatch: Nullable<_InstancesBatch>;
  27175. hardwareInstancedRendering: boolean;
  27176. sideOrientation: number;
  27177. manualUpdate: boolean;
  27178. }
  27179. /**
  27180. * @hidden
  27181. **/
  27182. export class _InstancesBatch {
  27183. mustReturn: boolean;
  27184. visibleInstances: Nullable<InstancedMesh[]>[];
  27185. renderSelf: boolean[];
  27186. hardwareInstancedRendering: boolean[];
  27187. }
  27188. /**
  27189. * @hidden
  27190. **/
  27191. class _ThinInstanceDataStorage {
  27192. instancesCount: number;
  27193. matrixBuffer: Nullable<Buffer>;
  27194. matrixBufferSize: number;
  27195. matrixData: Nullable<Float32Array>;
  27196. boundingVectors: Array<Vector3>;
  27197. }
  27198. /**
  27199. * Class used to represent renderable models
  27200. */
  27201. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27202. /**
  27203. * Mesh side orientation : usually the external or front surface
  27204. */
  27205. static readonly FRONTSIDE: number;
  27206. /**
  27207. * Mesh side orientation : usually the internal or back surface
  27208. */
  27209. static readonly BACKSIDE: number;
  27210. /**
  27211. * Mesh side orientation : both internal and external or front and back surfaces
  27212. */
  27213. static readonly DOUBLESIDE: number;
  27214. /**
  27215. * Mesh side orientation : by default, `FRONTSIDE`
  27216. */
  27217. static readonly DEFAULTSIDE: number;
  27218. /**
  27219. * Mesh cap setting : no cap
  27220. */
  27221. static readonly NO_CAP: number;
  27222. /**
  27223. * Mesh cap setting : one cap at the beginning of the mesh
  27224. */
  27225. static readonly CAP_START: number;
  27226. /**
  27227. * Mesh cap setting : one cap at the end of the mesh
  27228. */
  27229. static readonly CAP_END: number;
  27230. /**
  27231. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27232. */
  27233. static readonly CAP_ALL: number;
  27234. /**
  27235. * Mesh pattern setting : no flip or rotate
  27236. */
  27237. static readonly NO_FLIP: number;
  27238. /**
  27239. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27240. */
  27241. static readonly FLIP_TILE: number;
  27242. /**
  27243. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27244. */
  27245. static readonly ROTATE_TILE: number;
  27246. /**
  27247. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27248. */
  27249. static readonly FLIP_ROW: number;
  27250. /**
  27251. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27252. */
  27253. static readonly ROTATE_ROW: number;
  27254. /**
  27255. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27256. */
  27257. static readonly FLIP_N_ROTATE_TILE: number;
  27258. /**
  27259. * Mesh pattern setting : rotate pattern and rotate
  27260. */
  27261. static readonly FLIP_N_ROTATE_ROW: number;
  27262. /**
  27263. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27264. */
  27265. static readonly CENTER: number;
  27266. /**
  27267. * Mesh tile positioning : part tiles on left
  27268. */
  27269. static readonly LEFT: number;
  27270. /**
  27271. * Mesh tile positioning : part tiles on right
  27272. */
  27273. static readonly RIGHT: number;
  27274. /**
  27275. * Mesh tile positioning : part tiles on top
  27276. */
  27277. static readonly TOP: number;
  27278. /**
  27279. * Mesh tile positioning : part tiles on bottom
  27280. */
  27281. static readonly BOTTOM: number;
  27282. /**
  27283. * Gets the default side orientation.
  27284. * @param orientation the orientation to value to attempt to get
  27285. * @returns the default orientation
  27286. * @hidden
  27287. */
  27288. static _GetDefaultSideOrientation(orientation?: number): number;
  27289. private _internalMeshDataInfo;
  27290. /**
  27291. * An event triggered before rendering the mesh
  27292. */
  27293. get onBeforeRenderObservable(): Observable<Mesh>;
  27294. /**
  27295. * An event triggered before binding the mesh
  27296. */
  27297. get onBeforeBindObservable(): Observable<Mesh>;
  27298. /**
  27299. * An event triggered after rendering the mesh
  27300. */
  27301. get onAfterRenderObservable(): Observable<Mesh>;
  27302. /**
  27303. * An event triggered before drawing the mesh
  27304. */
  27305. get onBeforeDrawObservable(): Observable<Mesh>;
  27306. private _onBeforeDrawObserver;
  27307. /**
  27308. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27309. */
  27310. set onBeforeDraw(callback: () => void);
  27311. get hasInstances(): boolean;
  27312. get hasThinInstances(): boolean;
  27313. /**
  27314. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27315. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27316. */
  27317. delayLoadState: number;
  27318. /**
  27319. * Gets the list of instances created from this mesh
  27320. * it is not supposed to be modified manually.
  27321. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27322. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27323. */
  27324. instances: InstancedMesh[];
  27325. /**
  27326. * Gets the file containing delay loading data for this mesh
  27327. */
  27328. delayLoadingFile: string;
  27329. /** @hidden */
  27330. _binaryInfo: any;
  27331. /**
  27332. * User defined function used to change how LOD level selection is done
  27333. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27334. */
  27335. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27336. /**
  27337. * Gets or sets the morph target manager
  27338. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27339. */
  27340. get morphTargetManager(): Nullable<MorphTargetManager>;
  27341. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27342. /** @hidden */
  27343. _creationDataStorage: Nullable<_CreationDataStorage>;
  27344. /** @hidden */
  27345. _geometry: Nullable<Geometry>;
  27346. /** @hidden */
  27347. _delayInfo: Array<string>;
  27348. /** @hidden */
  27349. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27350. /** @hidden */
  27351. _instanceDataStorage: _InstanceDataStorage;
  27352. /** @hidden */
  27353. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27354. private _effectiveMaterial;
  27355. /** @hidden */
  27356. _shouldGenerateFlatShading: boolean;
  27357. /** @hidden */
  27358. _originalBuilderSideOrientation: number;
  27359. /**
  27360. * Use this property to change the original side orientation defined at construction time
  27361. */
  27362. overrideMaterialSideOrientation: Nullable<number>;
  27363. /**
  27364. * Gets the source mesh (the one used to clone this one from)
  27365. */
  27366. get source(): Nullable<Mesh>;
  27367. /**
  27368. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27369. */
  27370. get isUnIndexed(): boolean;
  27371. set isUnIndexed(value: boolean);
  27372. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27373. get worldMatrixInstancedBuffer(): Float32Array;
  27374. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27375. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27376. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27377. /**
  27378. * @constructor
  27379. * @param name The value used by scene.getMeshByName() to do a lookup.
  27380. * @param scene The scene to add this mesh to.
  27381. * @param parent The parent of this mesh, if it has one
  27382. * @param source An optional Mesh from which geometry is shared, cloned.
  27383. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27384. * When false, achieved by calling a clone(), also passing False.
  27385. * This will make creation of children, recursive.
  27386. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27387. */
  27388. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27389. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27390. doNotInstantiate: boolean;
  27391. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27392. /**
  27393. * Gets the class name
  27394. * @returns the string "Mesh".
  27395. */
  27396. getClassName(): string;
  27397. /** @hidden */
  27398. get _isMesh(): boolean;
  27399. /**
  27400. * Returns a description of this mesh
  27401. * @param fullDetails define if full details about this mesh must be used
  27402. * @returns a descriptive string representing this mesh
  27403. */
  27404. toString(fullDetails?: boolean): string;
  27405. /** @hidden */
  27406. _unBindEffect(): void;
  27407. /**
  27408. * Gets a boolean indicating if this mesh has LOD
  27409. */
  27410. get hasLODLevels(): boolean;
  27411. /**
  27412. * Gets the list of MeshLODLevel associated with the current mesh
  27413. * @returns an array of MeshLODLevel
  27414. */
  27415. getLODLevels(): MeshLODLevel[];
  27416. private _sortLODLevels;
  27417. /**
  27418. * Add a mesh as LOD level triggered at the given distance.
  27419. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27420. * @param distance The distance from the center of the object to show this level
  27421. * @param mesh The mesh to be added as LOD level (can be null)
  27422. * @return This mesh (for chaining)
  27423. */
  27424. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27425. /**
  27426. * Returns the LOD level mesh at the passed distance or null if not found.
  27427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27428. * @param distance The distance from the center of the object to show this level
  27429. * @returns a Mesh or `null`
  27430. */
  27431. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27432. /**
  27433. * Remove a mesh from the LOD array
  27434. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27435. * @param mesh defines the mesh to be removed
  27436. * @return This mesh (for chaining)
  27437. */
  27438. removeLODLevel(mesh: Mesh): Mesh;
  27439. /**
  27440. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27441. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27442. * @param camera defines the camera to use to compute distance
  27443. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27444. * @return This mesh (for chaining)
  27445. */
  27446. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27447. /**
  27448. * Gets the mesh internal Geometry object
  27449. */
  27450. get geometry(): Nullable<Geometry>;
  27451. /**
  27452. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27453. * @returns the total number of vertices
  27454. */
  27455. getTotalVertices(): number;
  27456. /**
  27457. * Returns the content of an associated vertex buffer
  27458. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27459. * - VertexBuffer.PositionKind
  27460. * - VertexBuffer.UVKind
  27461. * - VertexBuffer.UV2Kind
  27462. * - VertexBuffer.UV3Kind
  27463. * - VertexBuffer.UV4Kind
  27464. * - VertexBuffer.UV5Kind
  27465. * - VertexBuffer.UV6Kind
  27466. * - VertexBuffer.ColorKind
  27467. * - VertexBuffer.MatricesIndicesKind
  27468. * - VertexBuffer.MatricesIndicesExtraKind
  27469. * - VertexBuffer.MatricesWeightsKind
  27470. * - VertexBuffer.MatricesWeightsExtraKind
  27471. * @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
  27472. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27473. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27474. */
  27475. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27476. /**
  27477. * Returns the mesh VertexBuffer object from the requested `kind`
  27478. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27479. * - VertexBuffer.PositionKind
  27480. * - VertexBuffer.NormalKind
  27481. * - VertexBuffer.UVKind
  27482. * - VertexBuffer.UV2Kind
  27483. * - VertexBuffer.UV3Kind
  27484. * - VertexBuffer.UV4Kind
  27485. * - VertexBuffer.UV5Kind
  27486. * - VertexBuffer.UV6Kind
  27487. * - VertexBuffer.ColorKind
  27488. * - VertexBuffer.MatricesIndicesKind
  27489. * - VertexBuffer.MatricesIndicesExtraKind
  27490. * - VertexBuffer.MatricesWeightsKind
  27491. * - VertexBuffer.MatricesWeightsExtraKind
  27492. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27493. */
  27494. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27495. /**
  27496. * Tests if a specific vertex buffer is associated with this mesh
  27497. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27498. * - VertexBuffer.PositionKind
  27499. * - VertexBuffer.NormalKind
  27500. * - VertexBuffer.UVKind
  27501. * - VertexBuffer.UV2Kind
  27502. * - VertexBuffer.UV3Kind
  27503. * - VertexBuffer.UV4Kind
  27504. * - VertexBuffer.UV5Kind
  27505. * - VertexBuffer.UV6Kind
  27506. * - VertexBuffer.ColorKind
  27507. * - VertexBuffer.MatricesIndicesKind
  27508. * - VertexBuffer.MatricesIndicesExtraKind
  27509. * - VertexBuffer.MatricesWeightsKind
  27510. * - VertexBuffer.MatricesWeightsExtraKind
  27511. * @returns a boolean
  27512. */
  27513. isVerticesDataPresent(kind: string): boolean;
  27514. /**
  27515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27516. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27517. * - VertexBuffer.PositionKind
  27518. * - VertexBuffer.UVKind
  27519. * - VertexBuffer.UV2Kind
  27520. * - VertexBuffer.UV3Kind
  27521. * - VertexBuffer.UV4Kind
  27522. * - VertexBuffer.UV5Kind
  27523. * - VertexBuffer.UV6Kind
  27524. * - VertexBuffer.ColorKind
  27525. * - VertexBuffer.MatricesIndicesKind
  27526. * - VertexBuffer.MatricesIndicesExtraKind
  27527. * - VertexBuffer.MatricesWeightsKind
  27528. * - VertexBuffer.MatricesWeightsExtraKind
  27529. * @returns a boolean
  27530. */
  27531. isVertexBufferUpdatable(kind: string): boolean;
  27532. /**
  27533. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27534. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27535. * - VertexBuffer.PositionKind
  27536. * - VertexBuffer.NormalKind
  27537. * - VertexBuffer.UVKind
  27538. * - VertexBuffer.UV2Kind
  27539. * - VertexBuffer.UV3Kind
  27540. * - VertexBuffer.UV4Kind
  27541. * - VertexBuffer.UV5Kind
  27542. * - VertexBuffer.UV6Kind
  27543. * - VertexBuffer.ColorKind
  27544. * - VertexBuffer.MatricesIndicesKind
  27545. * - VertexBuffer.MatricesIndicesExtraKind
  27546. * - VertexBuffer.MatricesWeightsKind
  27547. * - VertexBuffer.MatricesWeightsExtraKind
  27548. * @returns an array of strings
  27549. */
  27550. getVerticesDataKinds(): string[];
  27551. /**
  27552. * Returns a positive integer : the total number of indices in this mesh geometry.
  27553. * @returns the numner of indices or zero if the mesh has no geometry.
  27554. */
  27555. getTotalIndices(): number;
  27556. /**
  27557. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27558. * @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.
  27559. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27560. * @returns the indices array or an empty array if the mesh has no geometry
  27561. */
  27562. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27563. get isBlocked(): boolean;
  27564. /**
  27565. * Determine if the current mesh is ready to be rendered
  27566. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27567. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27568. * @returns true if all associated assets are ready (material, textures, shaders)
  27569. */
  27570. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27571. /**
  27572. * 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.
  27573. */
  27574. get areNormalsFrozen(): boolean;
  27575. /**
  27576. * 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.
  27577. * @returns the current mesh
  27578. */
  27579. freezeNormals(): Mesh;
  27580. /**
  27581. * 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
  27582. * @returns the current mesh
  27583. */
  27584. unfreezeNormals(): Mesh;
  27585. /**
  27586. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27587. */
  27588. set overridenInstanceCount(count: number);
  27589. /** @hidden */
  27590. _preActivate(): Mesh;
  27591. /** @hidden */
  27592. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27593. /** @hidden */
  27594. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27595. protected _afterComputeWorldMatrix(): void;
  27596. /** @hidden */
  27597. _postActivate(): void;
  27598. /**
  27599. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27600. * This means the mesh underlying bounding box and sphere are recomputed.
  27601. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27602. * @returns the current mesh
  27603. */
  27604. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27605. /** @hidden */
  27606. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27607. /**
  27608. * This function will subdivide the mesh into multiple submeshes
  27609. * @param count defines the expected number of submeshes
  27610. */
  27611. subdivide(count: number): void;
  27612. /**
  27613. * Copy a FloatArray into a specific associated vertex buffer
  27614. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27615. * - VertexBuffer.PositionKind
  27616. * - VertexBuffer.UVKind
  27617. * - VertexBuffer.UV2Kind
  27618. * - VertexBuffer.UV3Kind
  27619. * - VertexBuffer.UV4Kind
  27620. * - VertexBuffer.UV5Kind
  27621. * - VertexBuffer.UV6Kind
  27622. * - VertexBuffer.ColorKind
  27623. * - VertexBuffer.MatricesIndicesKind
  27624. * - VertexBuffer.MatricesIndicesExtraKind
  27625. * - VertexBuffer.MatricesWeightsKind
  27626. * - VertexBuffer.MatricesWeightsExtraKind
  27627. * @param data defines the data source
  27628. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27629. * @param stride defines the data stride size (can be null)
  27630. * @returns the current mesh
  27631. */
  27632. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27633. /**
  27634. * Delete a vertex buffer associated with this mesh
  27635. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27636. * - VertexBuffer.PositionKind
  27637. * - VertexBuffer.UVKind
  27638. * - VertexBuffer.UV2Kind
  27639. * - VertexBuffer.UV3Kind
  27640. * - VertexBuffer.UV4Kind
  27641. * - VertexBuffer.UV5Kind
  27642. * - VertexBuffer.UV6Kind
  27643. * - VertexBuffer.ColorKind
  27644. * - VertexBuffer.MatricesIndicesKind
  27645. * - VertexBuffer.MatricesIndicesExtraKind
  27646. * - VertexBuffer.MatricesWeightsKind
  27647. * - VertexBuffer.MatricesWeightsExtraKind
  27648. */
  27649. removeVerticesData(kind: string): void;
  27650. /**
  27651. * Flags an associated vertex buffer as updatable
  27652. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27653. * - VertexBuffer.PositionKind
  27654. * - VertexBuffer.UVKind
  27655. * - VertexBuffer.UV2Kind
  27656. * - VertexBuffer.UV3Kind
  27657. * - VertexBuffer.UV4Kind
  27658. * - VertexBuffer.UV5Kind
  27659. * - VertexBuffer.UV6Kind
  27660. * - VertexBuffer.ColorKind
  27661. * - VertexBuffer.MatricesIndicesKind
  27662. * - VertexBuffer.MatricesIndicesExtraKind
  27663. * - VertexBuffer.MatricesWeightsKind
  27664. * - VertexBuffer.MatricesWeightsExtraKind
  27665. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27666. */
  27667. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27668. /**
  27669. * Sets the mesh global Vertex Buffer
  27670. * @param buffer defines the buffer to use
  27671. * @returns the current mesh
  27672. */
  27673. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27674. /**
  27675. * Update a specific associated vertex buffer
  27676. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27677. * - VertexBuffer.PositionKind
  27678. * - VertexBuffer.UVKind
  27679. * - VertexBuffer.UV2Kind
  27680. * - VertexBuffer.UV3Kind
  27681. * - VertexBuffer.UV4Kind
  27682. * - VertexBuffer.UV5Kind
  27683. * - VertexBuffer.UV6Kind
  27684. * - VertexBuffer.ColorKind
  27685. * - VertexBuffer.MatricesIndicesKind
  27686. * - VertexBuffer.MatricesIndicesExtraKind
  27687. * - VertexBuffer.MatricesWeightsKind
  27688. * - VertexBuffer.MatricesWeightsExtraKind
  27689. * @param data defines the data source
  27690. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27691. * @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)
  27692. * @returns the current mesh
  27693. */
  27694. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27695. /**
  27696. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27697. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27698. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27699. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27700. * @returns the current mesh
  27701. */
  27702. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27703. /**
  27704. * Creates a un-shared specific occurence of the geometry for the mesh.
  27705. * @returns the current mesh
  27706. */
  27707. makeGeometryUnique(): Mesh;
  27708. /**
  27709. * Set the index buffer of this mesh
  27710. * @param indices defines the source data
  27711. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27712. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27713. * @returns the current mesh
  27714. */
  27715. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27716. /**
  27717. * Update the current index buffer
  27718. * @param indices defines the source data
  27719. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27720. * @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)
  27721. * @returns the current mesh
  27722. */
  27723. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27724. /**
  27725. * Invert the geometry to move from a right handed system to a left handed one.
  27726. * @returns the current mesh
  27727. */
  27728. toLeftHanded(): Mesh;
  27729. /** @hidden */
  27730. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27731. /** @hidden */
  27732. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27733. /**
  27734. * Registers for this mesh a javascript function called just before the rendering process
  27735. * @param func defines the function to call before rendering this mesh
  27736. * @returns the current mesh
  27737. */
  27738. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27739. /**
  27740. * Disposes a previously registered javascript function called before the rendering
  27741. * @param func defines the function to remove
  27742. * @returns the current mesh
  27743. */
  27744. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27745. /**
  27746. * Registers for this mesh a javascript function called just after the rendering is complete
  27747. * @param func defines the function to call after rendering this mesh
  27748. * @returns the current mesh
  27749. */
  27750. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27751. /**
  27752. * Disposes a previously registered javascript function called after the rendering.
  27753. * @param func defines the function to remove
  27754. * @returns the current mesh
  27755. */
  27756. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27757. /** @hidden */
  27758. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27759. /** @hidden */
  27760. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27761. /** @hidden */
  27762. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27763. /** @hidden */
  27764. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27765. /** @hidden */
  27766. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27767. /** @hidden */
  27768. _rebuild(): void;
  27769. /** @hidden */
  27770. _freeze(): void;
  27771. /** @hidden */
  27772. _unFreeze(): void;
  27773. /**
  27774. * 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
  27775. * @param subMesh defines the subMesh to render
  27776. * @param enableAlphaMode defines if alpha mode can be changed
  27777. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27778. * @returns the current mesh
  27779. */
  27780. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27781. private _onBeforeDraw;
  27782. /**
  27783. * Renormalize the mesh and patch it up if there are no weights
  27784. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27785. * However in the case of zero weights then we set just a single influence to 1.
  27786. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27787. */
  27788. cleanMatrixWeights(): void;
  27789. private normalizeSkinFourWeights;
  27790. private normalizeSkinWeightsAndExtra;
  27791. /**
  27792. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27793. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27794. * the user know there was an issue with importing the mesh
  27795. * @returns a validation object with skinned, valid and report string
  27796. */
  27797. validateSkinning(): {
  27798. skinned: boolean;
  27799. valid: boolean;
  27800. report: string;
  27801. };
  27802. /** @hidden */
  27803. _checkDelayState(): Mesh;
  27804. private _queueLoad;
  27805. /**
  27806. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27807. * A mesh is in the frustum if its bounding box intersects the frustum
  27808. * @param frustumPlanes defines the frustum to test
  27809. * @returns true if the mesh is in the frustum planes
  27810. */
  27811. isInFrustum(frustumPlanes: Plane[]): boolean;
  27812. /**
  27813. * Sets the mesh material by the material or multiMaterial `id` property
  27814. * @param id is a string identifying the material or the multiMaterial
  27815. * @returns the current mesh
  27816. */
  27817. setMaterialByID(id: string): Mesh;
  27818. /**
  27819. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27820. * @returns an array of IAnimatable
  27821. */
  27822. getAnimatables(): IAnimatable[];
  27823. /**
  27824. * Modifies the mesh geometry according to the passed transformation matrix.
  27825. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27826. * The mesh normals are modified using the same transformation.
  27827. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27828. * @param transform defines the transform matrix to use
  27829. * @see https://doc.babylonjs.com/resources/baking_transformations
  27830. * @returns the current mesh
  27831. */
  27832. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27833. /**
  27834. * Modifies the mesh geometry according to its own current World Matrix.
  27835. * The mesh World Matrix is then reset.
  27836. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27837. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27838. * @see https://doc.babylonjs.com/resources/baking_transformations
  27839. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27840. * @returns the current mesh
  27841. */
  27842. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27843. /** @hidden */
  27844. get _positions(): Nullable<Vector3[]>;
  27845. /** @hidden */
  27846. _resetPointsArrayCache(): Mesh;
  27847. /** @hidden */
  27848. _generatePointsArray(): boolean;
  27849. /**
  27850. * Returns a new Mesh object generated from the current mesh properties.
  27851. * This method must not get confused with createInstance()
  27852. * @param name is a string, the name given to the new mesh
  27853. * @param newParent can be any Node object (default `null`)
  27854. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27855. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27856. * @returns a new mesh
  27857. */
  27858. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27859. /**
  27860. * Releases resources associated with this mesh.
  27861. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27862. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27863. */
  27864. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27865. /** @hidden */
  27866. _disposeInstanceSpecificData(): void;
  27867. /** @hidden */
  27868. _disposeThinInstanceSpecificData(): void;
  27869. /**
  27870. * Modifies the mesh geometry according to a displacement map.
  27871. * 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.
  27872. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27873. * @param url is a string, the URL from the image file is to be downloaded.
  27874. * @param minHeight is the lower limit of the displacement.
  27875. * @param maxHeight is the upper limit of the displacement.
  27876. * @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.
  27877. * @param uvOffset is an optional vector2 used to offset UV.
  27878. * @param uvScale is an optional vector2 used to scale UV.
  27879. * @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.
  27880. * @returns the Mesh.
  27881. */
  27882. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27883. /**
  27884. * Modifies the mesh geometry according to a displacementMap buffer.
  27885. * 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.
  27886. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27887. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27888. * @param heightMapWidth is the width of the buffer image.
  27889. * @param heightMapHeight is the height of the buffer image.
  27890. * @param minHeight is the lower limit of the displacement.
  27891. * @param maxHeight is the upper limit of the displacement.
  27892. * @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.
  27893. * @param uvOffset is an optional vector2 used to offset UV.
  27894. * @param uvScale is an optional vector2 used to scale UV.
  27895. * @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.
  27896. * @returns the Mesh.
  27897. */
  27898. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27899. /**
  27900. * Modify the mesh to get a flat shading rendering.
  27901. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27902. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27903. * @returns current mesh
  27904. */
  27905. convertToFlatShadedMesh(): Mesh;
  27906. /**
  27907. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27908. * In other words, more vertices, no more indices and a single bigger VBO.
  27909. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27910. * @returns current mesh
  27911. */
  27912. convertToUnIndexedMesh(): Mesh;
  27913. /**
  27914. * Inverses facet orientations.
  27915. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27916. * @param flipNormals will also inverts the normals
  27917. * @returns current mesh
  27918. */
  27919. flipFaces(flipNormals?: boolean): Mesh;
  27920. /**
  27921. * Increase the number of facets and hence vertices in a mesh
  27922. * Vertex normals are interpolated from existing vertex normals
  27923. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27924. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27925. */
  27926. increaseVertices(numberPerEdge: number): void;
  27927. /**
  27928. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27929. * This will undo any application of covertToFlatShadedMesh
  27930. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27931. */
  27932. forceSharedVertices(): void;
  27933. /** @hidden */
  27934. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27935. /** @hidden */
  27936. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27937. /**
  27938. * Creates a new InstancedMesh object from the mesh model.
  27939. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27940. * @param name defines the name of the new instance
  27941. * @returns a new InstancedMesh
  27942. */
  27943. createInstance(name: string): InstancedMesh;
  27944. /**
  27945. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27946. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27947. * @returns the current mesh
  27948. */
  27949. synchronizeInstances(): Mesh;
  27950. /**
  27951. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27952. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27953. * This should be used together with the simplification to avoid disappearing triangles.
  27954. * @param successCallback an optional success callback to be called after the optimization finished.
  27955. * @returns the current mesh
  27956. */
  27957. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27958. /**
  27959. * Serialize current mesh
  27960. * @param serializationObject defines the object which will receive the serialization data
  27961. */
  27962. serialize(serializationObject: any): void;
  27963. /** @hidden */
  27964. _syncGeometryWithMorphTargetManager(): void;
  27965. /** @hidden */
  27966. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  27967. /**
  27968. * Returns a new Mesh object parsed from the source provided.
  27969. * @param parsedMesh is the source
  27970. * @param scene defines the hosting scene
  27971. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27972. * @returns a new Mesh
  27973. */
  27974. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27975. /**
  27976. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  27978. * @param name defines the name of the mesh to create
  27979. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27980. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27981. * @param closePath creates a seam between the first and the last points of each path of the path array
  27982. * @param offset is taken in account only if the `pathArray` is containing a single path
  27983. * @param scene defines the hosting scene
  27984. * @param updatable defines if the mesh must be flagged as updatable
  27985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27986. * @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)
  27987. * @returns a new Mesh
  27988. */
  27989. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27990. /**
  27991. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27992. * @param name defines the name of the mesh to create
  27993. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27994. * @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
  27995. * @param scene defines the hosting scene
  27996. * @param updatable defines if the mesh must be flagged as updatable
  27997. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27998. * @returns a new Mesh
  27999. */
  28000. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28001. /**
  28002. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28003. * @param name defines the name of the mesh to create
  28004. * @param size sets the size (float) of each box side (default 1)
  28005. * @param scene defines the hosting scene
  28006. * @param updatable defines if the mesh must be flagged as updatable
  28007. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28008. * @returns a new Mesh
  28009. */
  28010. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28011. /**
  28012. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28013. * @param name defines the name of the mesh to create
  28014. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28015. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28016. * @param scene defines the hosting scene
  28017. * @param updatable defines if the mesh must be flagged as updatable
  28018. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28019. * @returns a new Mesh
  28020. */
  28021. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28022. /**
  28023. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28024. * @param name defines the name of the mesh to create
  28025. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28026. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28027. * @param scene defines the hosting scene
  28028. * @returns a new Mesh
  28029. */
  28030. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28031. /**
  28032. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28033. * @param name defines the name of the mesh to create
  28034. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28035. * @param diameterTop set the top cap diameter (floats, default 1)
  28036. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28037. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28038. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28039. * @param scene defines the hosting scene
  28040. * @param updatable defines if the mesh must be flagged as updatable
  28041. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28042. * @returns a new Mesh
  28043. */
  28044. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28045. /**
  28046. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28047. * @param name defines the name of the mesh to create
  28048. * @param diameter sets the diameter size (float) of the torus (default 1)
  28049. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28050. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28051. * @param scene defines the hosting scene
  28052. * @param updatable defines if the mesh must be flagged as updatable
  28053. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28054. * @returns a new Mesh
  28055. */
  28056. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28057. /**
  28058. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28059. * @param name defines the name of the mesh to create
  28060. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28061. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28062. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28063. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28064. * @param p the number of windings on X axis (positive integers, default 2)
  28065. * @param q the number of windings on Y axis (positive integers, default 3)
  28066. * @param scene defines the hosting scene
  28067. * @param updatable defines if the mesh must be flagged as updatable
  28068. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28069. * @returns a new Mesh
  28070. */
  28071. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28072. /**
  28073. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28074. * @param name defines the name of the mesh to create
  28075. * @param points is an array successive Vector3
  28076. * @param scene defines the hosting scene
  28077. * @param updatable defines if the mesh must be flagged as updatable
  28078. * @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).
  28079. * @returns a new Mesh
  28080. */
  28081. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28082. /**
  28083. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28084. * @param name defines the name of the mesh to create
  28085. * @param points is an array successive Vector3
  28086. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28087. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28088. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28089. * @param scene defines the hosting scene
  28090. * @param updatable defines if the mesh must be flagged as updatable
  28091. * @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)
  28092. * @returns a new Mesh
  28093. */
  28094. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28095. /**
  28096. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28097. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28098. * 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.
  28099. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28100. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28101. * Remember you can only change the shape positions, not their number when updating a polygon.
  28102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28103. * @param name defines the name of the mesh to create
  28104. * @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
  28105. * @param scene defines the hosting scene
  28106. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28107. * @param updatable defines if the mesh must be flagged as updatable
  28108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28109. * @param earcutInjection can be used to inject your own earcut reference
  28110. * @returns a new Mesh
  28111. */
  28112. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28113. /**
  28114. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28116. * @param name defines the name of the mesh to create
  28117. * @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
  28118. * @param depth defines the height of extrusion
  28119. * @param scene defines the hosting scene
  28120. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28121. * @param updatable defines if the mesh must be flagged as updatable
  28122. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28123. * @param earcutInjection can be used to inject your own earcut reference
  28124. * @returns a new Mesh
  28125. */
  28126. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28127. /**
  28128. * Creates an extruded shape mesh.
  28129. * 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
  28130. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28132. * @param name defines the name of the mesh to create
  28133. * @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
  28134. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28135. * @param scale is the value to scale the shape
  28136. * @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
  28137. * @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
  28138. * @param scene defines the hosting scene
  28139. * @param updatable defines if the mesh must be flagged as updatable
  28140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28141. * @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)
  28142. * @returns a new Mesh
  28143. */
  28144. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28145. /**
  28146. * Creates an custom extruded shape mesh.
  28147. * The custom extrusion is a parametric shape.
  28148. * It has no predefined shape. Its final shape will depend on the input parameters.
  28149. * Please consider using the same method from the MeshBuilder class instead
  28150. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28151. * @param name defines the name of the mesh to create
  28152. * @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
  28153. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28154. * @param scaleFunction is a custom Javascript function called on each path point
  28155. * @param rotationFunction is a custom Javascript function called on each path point
  28156. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28157. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28158. * @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
  28159. * @param scene defines the hosting scene
  28160. * @param updatable defines if the mesh must be flagged as updatable
  28161. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28162. * @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)
  28163. * @returns a new Mesh
  28164. */
  28165. 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;
  28166. /**
  28167. * Creates lathe mesh.
  28168. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28169. * Please consider using the same method from the MeshBuilder class instead
  28170. * @param name defines the name of the mesh to create
  28171. * @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
  28172. * @param radius is the radius value of the lathe
  28173. * @param tessellation is the side number of the lathe.
  28174. * @param scene defines the hosting scene
  28175. * @param updatable defines if the mesh must be flagged as updatable
  28176. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28177. * @returns a new Mesh
  28178. */
  28179. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28180. /**
  28181. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28182. * @param name defines the name of the mesh to create
  28183. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28184. * @param scene defines the hosting scene
  28185. * @param updatable defines if the mesh must be flagged as updatable
  28186. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28187. * @returns a new Mesh
  28188. */
  28189. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28190. /**
  28191. * Creates a ground mesh.
  28192. * Please consider using the same method from the MeshBuilder class instead
  28193. * @param name defines the name of the mesh to create
  28194. * @param width set the width of the ground
  28195. * @param height set the height of the ground
  28196. * @param subdivisions sets the number of subdivisions per side
  28197. * @param scene defines the hosting scene
  28198. * @param updatable defines if the mesh must be flagged as updatable
  28199. * @returns a new Mesh
  28200. */
  28201. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28202. /**
  28203. * Creates a tiled ground mesh.
  28204. * Please consider using the same method from the MeshBuilder class instead
  28205. * @param name defines the name of the mesh to create
  28206. * @param xmin set the ground minimum X coordinate
  28207. * @param zmin set the ground minimum Y coordinate
  28208. * @param xmax set the ground maximum X coordinate
  28209. * @param zmax set the ground maximum Z coordinate
  28210. * @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
  28211. * @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
  28212. * @param scene defines the hosting scene
  28213. * @param updatable defines if the mesh must be flagged as updatable
  28214. * @returns a new Mesh
  28215. */
  28216. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28217. w: number;
  28218. h: number;
  28219. }, precision: {
  28220. w: number;
  28221. h: number;
  28222. }, scene: Scene, updatable?: boolean): Mesh;
  28223. /**
  28224. * Creates a ground mesh from a height map.
  28225. * Please consider using the same method from the MeshBuilder class instead
  28226. * @see https://doc.babylonjs.com/babylon101/height_map
  28227. * @param name defines the name of the mesh to create
  28228. * @param url sets the URL of the height map image resource
  28229. * @param width set the ground width size
  28230. * @param height set the ground height size
  28231. * @param subdivisions sets the number of subdivision per side
  28232. * @param minHeight is the minimum altitude on the ground
  28233. * @param maxHeight is the maximum altitude on the ground
  28234. * @param scene defines the hosting scene
  28235. * @param updatable defines if the mesh must be flagged as updatable
  28236. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28237. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28238. * @returns a new Mesh
  28239. */
  28240. 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;
  28241. /**
  28242. * Creates a tube mesh.
  28243. * The tube is a parametric shape.
  28244. * It has no predefined shape. Its final shape will depend on the input parameters.
  28245. * Please consider using the same method from the MeshBuilder class instead
  28246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28247. * @param name defines the name of the mesh to create
  28248. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28249. * @param radius sets the tube radius size
  28250. * @param tessellation is the number of sides on the tubular surface
  28251. * @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
  28252. * @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
  28253. * @param scene defines the hosting scene
  28254. * @param updatable defines if the mesh must be flagged as updatable
  28255. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28256. * @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)
  28257. * @returns a new Mesh
  28258. */
  28259. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28260. (i: number, distance: number): number;
  28261. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28262. /**
  28263. * Creates a polyhedron mesh.
  28264. * Please consider using the same method from the MeshBuilder class instead.
  28265. * * 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
  28266. * * The parameter `size` (positive float, default 1) sets the polygon size
  28267. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28268. * * 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`
  28269. * * 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
  28270. * * 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)`)
  28271. * * 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
  28272. * * 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
  28273. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28274. * * 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
  28275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28276. * @param name defines the name of the mesh to create
  28277. * @param options defines the options used to create the mesh
  28278. * @param scene defines the hosting scene
  28279. * @returns a new Mesh
  28280. */
  28281. static CreatePolyhedron(name: string, options: {
  28282. type?: number;
  28283. size?: number;
  28284. sizeX?: number;
  28285. sizeY?: number;
  28286. sizeZ?: number;
  28287. custom?: any;
  28288. faceUV?: Vector4[];
  28289. faceColors?: Color4[];
  28290. updatable?: boolean;
  28291. sideOrientation?: number;
  28292. }, scene: Scene): Mesh;
  28293. /**
  28294. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28295. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28296. * * 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`)
  28297. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28298. * * 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
  28299. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28300. * * 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
  28301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28302. * @param name defines the name of the mesh
  28303. * @param options defines the options used to create the mesh
  28304. * @param scene defines the hosting scene
  28305. * @returns a new Mesh
  28306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28307. */
  28308. static CreateIcoSphere(name: string, options: {
  28309. radius?: number;
  28310. flat?: boolean;
  28311. subdivisions?: number;
  28312. sideOrientation?: number;
  28313. updatable?: boolean;
  28314. }, scene: Scene): Mesh;
  28315. /**
  28316. * Creates a decal mesh.
  28317. * Please consider using the same method from the MeshBuilder class instead.
  28318. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28319. * @param name defines the name of the mesh
  28320. * @param sourceMesh defines the mesh receiving the decal
  28321. * @param position sets the position of the decal in world coordinates
  28322. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28323. * @param size sets the decal scaling
  28324. * @param angle sets the angle to rotate the decal
  28325. * @returns a new Mesh
  28326. */
  28327. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28328. /**
  28329. * Prepare internal position array for software CPU skinning
  28330. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28331. */
  28332. setPositionsForCPUSkinning(): Float32Array;
  28333. /**
  28334. * Prepare internal normal array for software CPU skinning
  28335. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28336. */
  28337. setNormalsForCPUSkinning(): Float32Array;
  28338. /**
  28339. * Updates the vertex buffer by applying transformation from the bones
  28340. * @param skeleton defines the skeleton to apply to current mesh
  28341. * @returns the current mesh
  28342. */
  28343. applySkeleton(skeleton: Skeleton): Mesh;
  28344. /**
  28345. * 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
  28346. * @param meshes defines the list of meshes to scan
  28347. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28348. */
  28349. static MinMax(meshes: AbstractMesh[]): {
  28350. min: Vector3;
  28351. max: Vector3;
  28352. };
  28353. /**
  28354. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28355. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28356. * @returns a vector3
  28357. */
  28358. static Center(meshesOrMinMaxVector: {
  28359. min: Vector3;
  28360. max: Vector3;
  28361. } | AbstractMesh[]): Vector3;
  28362. /**
  28363. * Merge the array of meshes into a single mesh for performance reasons.
  28364. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28365. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28366. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28367. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28368. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28369. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28370. * @returns a new mesh
  28371. */
  28372. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28373. /** @hidden */
  28374. addInstance(instance: InstancedMesh): void;
  28375. /** @hidden */
  28376. removeInstance(instance: InstancedMesh): void;
  28377. }
  28378. }
  28379. declare module BABYLON {
  28380. /**
  28381. * This is the base class of all the camera used in the application.
  28382. * @see https://doc.babylonjs.com/features/cameras
  28383. */
  28384. export class Camera extends Node {
  28385. /** @hidden */
  28386. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28387. /**
  28388. * This is the default projection mode used by the cameras.
  28389. * It helps recreating a feeling of perspective and better appreciate depth.
  28390. * This is the best way to simulate real life cameras.
  28391. */
  28392. static readonly PERSPECTIVE_CAMERA: number;
  28393. /**
  28394. * This helps creating camera with an orthographic mode.
  28395. * 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.
  28396. */
  28397. static readonly ORTHOGRAPHIC_CAMERA: number;
  28398. /**
  28399. * This is the default FOV mode for perspective cameras.
  28400. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28401. */
  28402. static readonly FOVMODE_VERTICAL_FIXED: number;
  28403. /**
  28404. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28405. */
  28406. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28407. /**
  28408. * This specifies ther is no need for a camera rig.
  28409. * Basically only one eye is rendered corresponding to the camera.
  28410. */
  28411. static readonly RIG_MODE_NONE: number;
  28412. /**
  28413. * Simulates a camera Rig with one blue eye and one red eye.
  28414. * This can be use with 3d blue and red glasses.
  28415. */
  28416. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28417. /**
  28418. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28419. */
  28420. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28421. /**
  28422. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28423. */
  28424. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28425. /**
  28426. * Defines that both eyes of the camera will be rendered over under each other.
  28427. */
  28428. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28429. /**
  28430. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28431. */
  28432. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28433. /**
  28434. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28435. */
  28436. static readonly RIG_MODE_VR: number;
  28437. /**
  28438. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28439. */
  28440. static readonly RIG_MODE_WEBVR: number;
  28441. /**
  28442. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28443. */
  28444. static readonly RIG_MODE_CUSTOM: number;
  28445. /**
  28446. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28447. */
  28448. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28449. /**
  28450. * Define the input manager associated with the camera.
  28451. */
  28452. inputs: CameraInputsManager<Camera>;
  28453. /** @hidden */
  28454. _position: Vector3;
  28455. /**
  28456. * Define the current local position of the camera in the scene
  28457. */
  28458. get position(): Vector3;
  28459. set position(newPosition: Vector3);
  28460. /**
  28461. * The vector the camera should consider as up.
  28462. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28463. */
  28464. upVector: Vector3;
  28465. /**
  28466. * Define the current limit on the left side for an orthographic camera
  28467. * In scene unit
  28468. */
  28469. orthoLeft: Nullable<number>;
  28470. /**
  28471. * Define the current limit on the right side for an orthographic camera
  28472. * In scene unit
  28473. */
  28474. orthoRight: Nullable<number>;
  28475. /**
  28476. * Define the current limit on the bottom side for an orthographic camera
  28477. * In scene unit
  28478. */
  28479. orthoBottom: Nullable<number>;
  28480. /**
  28481. * Define the current limit on the top side for an orthographic camera
  28482. * In scene unit
  28483. */
  28484. orthoTop: Nullable<number>;
  28485. /**
  28486. * Field Of View is set in Radians. (default is 0.8)
  28487. */
  28488. fov: number;
  28489. /**
  28490. * Define the minimum distance the camera can see from.
  28491. * This is important to note that the depth buffer are not infinite and the closer it starts
  28492. * the more your scene might encounter depth fighting issue.
  28493. */
  28494. minZ: number;
  28495. /**
  28496. * Define the maximum distance the camera can see to.
  28497. * This is important to note that the depth buffer are not infinite and the further it end
  28498. * the more your scene might encounter depth fighting issue.
  28499. */
  28500. maxZ: number;
  28501. /**
  28502. * Define the default inertia of the camera.
  28503. * This helps giving a smooth feeling to the camera movement.
  28504. */
  28505. inertia: number;
  28506. /**
  28507. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28508. */
  28509. mode: number;
  28510. /**
  28511. * Define whether the camera is intermediate.
  28512. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28513. */
  28514. isIntermediate: boolean;
  28515. /**
  28516. * Define the viewport of the camera.
  28517. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28518. */
  28519. viewport: Viewport;
  28520. /**
  28521. * Restricts the camera to viewing objects with the same layerMask.
  28522. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28523. */
  28524. layerMask: number;
  28525. /**
  28526. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28527. */
  28528. fovMode: number;
  28529. /**
  28530. * Rig mode of the camera.
  28531. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28532. * This is normally controlled byt the camera themselves as internal use.
  28533. */
  28534. cameraRigMode: number;
  28535. /**
  28536. * Defines the distance between both "eyes" in case of a RIG
  28537. */
  28538. interaxialDistance: number;
  28539. /**
  28540. * Defines if stereoscopic rendering is done side by side or over under.
  28541. */
  28542. isStereoscopicSideBySide: boolean;
  28543. /**
  28544. * 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
  28545. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28546. * else in the scene. (Eg. security camera)
  28547. *
  28548. * 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)
  28549. */
  28550. customRenderTargets: RenderTargetTexture[];
  28551. /**
  28552. * When set, the camera will render to this render target instead of the default canvas
  28553. *
  28554. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28555. */
  28556. outputRenderTarget: Nullable<RenderTargetTexture>;
  28557. /**
  28558. * Observable triggered when the camera view matrix has changed.
  28559. */
  28560. onViewMatrixChangedObservable: Observable<Camera>;
  28561. /**
  28562. * Observable triggered when the camera Projection matrix has changed.
  28563. */
  28564. onProjectionMatrixChangedObservable: Observable<Camera>;
  28565. /**
  28566. * Observable triggered when the inputs have been processed.
  28567. */
  28568. onAfterCheckInputsObservable: Observable<Camera>;
  28569. /**
  28570. * Observable triggered when reset has been called and applied to the camera.
  28571. */
  28572. onRestoreStateObservable: Observable<Camera>;
  28573. /**
  28574. * Is this camera a part of a rig system?
  28575. */
  28576. isRigCamera: boolean;
  28577. /**
  28578. * If isRigCamera set to true this will be set with the parent camera.
  28579. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28580. */
  28581. rigParent?: Camera;
  28582. /** @hidden */
  28583. _cameraRigParams: any;
  28584. /** @hidden */
  28585. _rigCameras: Camera[];
  28586. /** @hidden */
  28587. _rigPostProcess: Nullable<PostProcess>;
  28588. protected _webvrViewMatrix: Matrix;
  28589. /** @hidden */
  28590. _skipRendering: boolean;
  28591. /** @hidden */
  28592. _projectionMatrix: Matrix;
  28593. /** @hidden */
  28594. _postProcesses: Nullable<PostProcess>[];
  28595. /** @hidden */
  28596. _activeMeshes: SmartArray<AbstractMesh>;
  28597. protected _globalPosition: Vector3;
  28598. /** @hidden */
  28599. _computedViewMatrix: Matrix;
  28600. private _doNotComputeProjectionMatrix;
  28601. private _transformMatrix;
  28602. private _frustumPlanes;
  28603. private _refreshFrustumPlanes;
  28604. private _storedFov;
  28605. private _stateStored;
  28606. /**
  28607. * Instantiates a new camera object.
  28608. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28609. * @see https://doc.babylonjs.com/features/cameras
  28610. * @param name Defines the name of the camera in the scene
  28611. * @param position Defines the position of the camera
  28612. * @param scene Defines the scene the camera belongs too
  28613. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28614. */
  28615. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28616. /**
  28617. * Store current camera state (fov, position, etc..)
  28618. * @returns the camera
  28619. */
  28620. storeState(): Camera;
  28621. /**
  28622. * Restores the camera state values if it has been stored. You must call storeState() first
  28623. */
  28624. protected _restoreStateValues(): boolean;
  28625. /**
  28626. * Restored camera state. You must call storeState() first.
  28627. * @returns true if restored and false otherwise
  28628. */
  28629. restoreState(): boolean;
  28630. /**
  28631. * Gets the class name of the camera.
  28632. * @returns the class name
  28633. */
  28634. getClassName(): string;
  28635. /** @hidden */
  28636. readonly _isCamera: boolean;
  28637. /**
  28638. * Gets a string representation of the camera useful for debug purpose.
  28639. * @param fullDetails Defines that a more verboe level of logging is required
  28640. * @returns the string representation
  28641. */
  28642. toString(fullDetails?: boolean): string;
  28643. /**
  28644. * Gets the current world space position of the camera.
  28645. */
  28646. get globalPosition(): Vector3;
  28647. /**
  28648. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28649. * @returns the active meshe list
  28650. */
  28651. getActiveMeshes(): SmartArray<AbstractMesh>;
  28652. /**
  28653. * Check whether a mesh is part of the current active mesh list of the camera
  28654. * @param mesh Defines the mesh to check
  28655. * @returns true if active, false otherwise
  28656. */
  28657. isActiveMesh(mesh: Mesh): boolean;
  28658. /**
  28659. * Is this camera ready to be used/rendered
  28660. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28661. * @return true if the camera is ready
  28662. */
  28663. isReady(completeCheck?: boolean): boolean;
  28664. /** @hidden */
  28665. _initCache(): void;
  28666. /** @hidden */
  28667. _updateCache(ignoreParentClass?: boolean): void;
  28668. /** @hidden */
  28669. _isSynchronized(): boolean;
  28670. /** @hidden */
  28671. _isSynchronizedViewMatrix(): boolean;
  28672. /** @hidden */
  28673. _isSynchronizedProjectionMatrix(): boolean;
  28674. /**
  28675. * Attach the input controls to a specific dom element to get the input from.
  28676. * @param element Defines the element the controls should be listened from
  28677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28678. */
  28679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28680. /**
  28681. * Detach the current controls from the specified dom element.
  28682. * @param element Defines the element to stop listening the inputs from
  28683. */
  28684. detachControl(element: HTMLElement): void;
  28685. /**
  28686. * Update the camera state according to the different inputs gathered during the frame.
  28687. */
  28688. update(): void;
  28689. /** @hidden */
  28690. _checkInputs(): void;
  28691. /** @hidden */
  28692. get rigCameras(): Camera[];
  28693. /**
  28694. * Gets the post process used by the rig cameras
  28695. */
  28696. get rigPostProcess(): Nullable<PostProcess>;
  28697. /**
  28698. * Internal, gets the first post proces.
  28699. * @returns the first post process to be run on this camera.
  28700. */
  28701. _getFirstPostProcess(): Nullable<PostProcess>;
  28702. private _cascadePostProcessesToRigCams;
  28703. /**
  28704. * Attach a post process to the camera.
  28705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28706. * @param postProcess The post process to attach to the camera
  28707. * @param insertAt The position of the post process in case several of them are in use in the scene
  28708. * @returns the position the post process has been inserted at
  28709. */
  28710. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28711. /**
  28712. * Detach a post process to the camera.
  28713. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28714. * @param postProcess The post process to detach from the camera
  28715. */
  28716. detachPostProcess(postProcess: PostProcess): void;
  28717. /**
  28718. * Gets the current world matrix of the camera
  28719. */
  28720. getWorldMatrix(): Matrix;
  28721. /** @hidden */
  28722. _getViewMatrix(): Matrix;
  28723. /**
  28724. * Gets the current view matrix of the camera.
  28725. * @param force forces the camera to recompute the matrix without looking at the cached state
  28726. * @returns the view matrix
  28727. */
  28728. getViewMatrix(force?: boolean): Matrix;
  28729. /**
  28730. * Freeze the projection matrix.
  28731. * It will prevent the cache check of the camera projection compute and can speed up perf
  28732. * if no parameter of the camera are meant to change
  28733. * @param projection Defines manually a projection if necessary
  28734. */
  28735. freezeProjectionMatrix(projection?: Matrix): void;
  28736. /**
  28737. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28738. */
  28739. unfreezeProjectionMatrix(): void;
  28740. /**
  28741. * Gets the current projection matrix of the camera.
  28742. * @param force forces the camera to recompute the matrix without looking at the cached state
  28743. * @returns the projection matrix
  28744. */
  28745. getProjectionMatrix(force?: boolean): Matrix;
  28746. /**
  28747. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28748. * @returns a Matrix
  28749. */
  28750. getTransformationMatrix(): Matrix;
  28751. private _updateFrustumPlanes;
  28752. /**
  28753. * Checks if a cullable object (mesh...) is in the camera frustum
  28754. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28755. * @param target The object to check
  28756. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28757. * @returns true if the object is in frustum otherwise false
  28758. */
  28759. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28760. /**
  28761. * Checks if a cullable object (mesh...) is in the camera frustum
  28762. * Unlike isInFrustum this cheks the full bounding box
  28763. * @param target The object to check
  28764. * @returns true if the object is in frustum otherwise false
  28765. */
  28766. isCompletelyInFrustum(target: ICullable): boolean;
  28767. /**
  28768. * Gets a ray in the forward direction from the camera.
  28769. * @param length Defines the length of the ray to create
  28770. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28771. * @param origin Defines the start point of the ray which defaults to the camera position
  28772. * @returns the forward ray
  28773. */
  28774. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28775. /**
  28776. * Releases resources associated with this node.
  28777. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28778. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28779. */
  28780. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28781. /** @hidden */
  28782. _isLeftCamera: boolean;
  28783. /**
  28784. * Gets the left camera of a rig setup in case of Rigged Camera
  28785. */
  28786. get isLeftCamera(): boolean;
  28787. /** @hidden */
  28788. _isRightCamera: boolean;
  28789. /**
  28790. * Gets the right camera of a rig setup in case of Rigged Camera
  28791. */
  28792. get isRightCamera(): boolean;
  28793. /**
  28794. * Gets the left camera of a rig setup in case of Rigged Camera
  28795. */
  28796. get leftCamera(): Nullable<FreeCamera>;
  28797. /**
  28798. * Gets the right camera of a rig setup in case of Rigged Camera
  28799. */
  28800. get rightCamera(): Nullable<FreeCamera>;
  28801. /**
  28802. * Gets the left camera target of a rig setup in case of Rigged Camera
  28803. * @returns the target position
  28804. */
  28805. getLeftTarget(): Nullable<Vector3>;
  28806. /**
  28807. * Gets the right camera target of a rig setup in case of Rigged Camera
  28808. * @returns the target position
  28809. */
  28810. getRightTarget(): Nullable<Vector3>;
  28811. /**
  28812. * @hidden
  28813. */
  28814. setCameraRigMode(mode: number, rigParams: any): void;
  28815. /** @hidden */
  28816. static _setStereoscopicRigMode(camera: Camera): void;
  28817. /** @hidden */
  28818. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28819. /** @hidden */
  28820. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28821. /** @hidden */
  28822. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28823. /** @hidden */
  28824. _getVRProjectionMatrix(): Matrix;
  28825. protected _updateCameraRotationMatrix(): void;
  28826. protected _updateWebVRCameraRotationMatrix(): void;
  28827. /**
  28828. * This function MUST be overwritten by the different WebVR cameras available.
  28829. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28830. * @hidden
  28831. */
  28832. _getWebVRProjectionMatrix(): Matrix;
  28833. /**
  28834. * This function MUST be overwritten by the different WebVR cameras available.
  28835. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28836. * @hidden
  28837. */
  28838. _getWebVRViewMatrix(): Matrix;
  28839. /** @hidden */
  28840. setCameraRigParameter(name: string, value: any): void;
  28841. /**
  28842. * needs to be overridden by children so sub has required properties to be copied
  28843. * @hidden
  28844. */
  28845. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28846. /**
  28847. * May need to be overridden by children
  28848. * @hidden
  28849. */
  28850. _updateRigCameras(): void;
  28851. /** @hidden */
  28852. _setupInputs(): void;
  28853. /**
  28854. * Serialiaze the camera setup to a json represention
  28855. * @returns the JSON representation
  28856. */
  28857. serialize(): any;
  28858. /**
  28859. * Clones the current camera.
  28860. * @param name The cloned camera name
  28861. * @returns the cloned camera
  28862. */
  28863. clone(name: string): Camera;
  28864. /**
  28865. * Gets the direction of the camera relative to a given local axis.
  28866. * @param localAxis Defines the reference axis to provide a relative direction.
  28867. * @return the direction
  28868. */
  28869. getDirection(localAxis: Vector3): Vector3;
  28870. /**
  28871. * Returns the current camera absolute rotation
  28872. */
  28873. get absoluteRotation(): Quaternion;
  28874. /**
  28875. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28876. * @param localAxis Defines the reference axis to provide a relative direction.
  28877. * @param result Defines the vector to store the result in
  28878. */
  28879. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28880. /**
  28881. * Gets a camera constructor for a given camera type
  28882. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28883. * @param name The name of the camera the result will be able to instantiate
  28884. * @param scene The scene the result will construct the camera in
  28885. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28886. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28887. * @returns a factory method to construc the camera
  28888. */
  28889. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28890. /**
  28891. * Compute the world matrix of the camera.
  28892. * @returns the camera world matrix
  28893. */
  28894. computeWorldMatrix(): Matrix;
  28895. /**
  28896. * Parse a JSON and creates the camera from the parsed information
  28897. * @param parsedCamera The JSON to parse
  28898. * @param scene The scene to instantiate the camera in
  28899. * @returns the newly constructed camera
  28900. */
  28901. static Parse(parsedCamera: any, scene: Scene): Camera;
  28902. }
  28903. }
  28904. declare module BABYLON {
  28905. /**
  28906. * Class containing static functions to help procedurally build meshes
  28907. */
  28908. export class DiscBuilder {
  28909. /**
  28910. * Creates a plane polygonal mesh. By default, this is a disc
  28911. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28912. * * 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
  28913. * * 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
  28914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28915. * * 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
  28916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28917. * @param name defines the name of the mesh
  28918. * @param options defines the options used to create the mesh
  28919. * @param scene defines the hosting scene
  28920. * @returns the plane polygonal mesh
  28921. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28922. */
  28923. static CreateDisc(name: string, options: {
  28924. radius?: number;
  28925. tessellation?: number;
  28926. arc?: number;
  28927. updatable?: boolean;
  28928. sideOrientation?: number;
  28929. frontUVs?: Vector4;
  28930. backUVs?: Vector4;
  28931. }, scene?: Nullable<Scene>): Mesh;
  28932. }
  28933. }
  28934. declare module BABYLON {
  28935. /**
  28936. * Options to be used when creating a FresnelParameters.
  28937. */
  28938. export type IFresnelParametersCreationOptions = {
  28939. /**
  28940. * Define the color used on edges (grazing angle)
  28941. */
  28942. leftColor?: Color3;
  28943. /**
  28944. * Define the color used on center
  28945. */
  28946. rightColor?: Color3;
  28947. /**
  28948. * Define bias applied to computed fresnel term
  28949. */
  28950. bias?: number;
  28951. /**
  28952. * Defined the power exponent applied to fresnel term
  28953. */
  28954. power?: number;
  28955. /**
  28956. * Define if the fresnel effect is enable or not.
  28957. */
  28958. isEnabled?: boolean;
  28959. };
  28960. /**
  28961. * Serialized format for FresnelParameters.
  28962. */
  28963. export type IFresnelParametersSerialized = {
  28964. /**
  28965. * Define the color used on edges (grazing angle) [as an array]
  28966. */
  28967. leftColor: number[];
  28968. /**
  28969. * Define the color used on center [as an array]
  28970. */
  28971. rightColor: number[];
  28972. /**
  28973. * Define bias applied to computed fresnel term
  28974. */
  28975. bias: number;
  28976. /**
  28977. * Defined the power exponent applied to fresnel term
  28978. */
  28979. power?: number;
  28980. /**
  28981. * Define if the fresnel effect is enable or not.
  28982. */
  28983. isEnabled: boolean;
  28984. };
  28985. /**
  28986. * This represents all the required information to add a fresnel effect on a material:
  28987. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28988. */
  28989. export class FresnelParameters {
  28990. private _isEnabled;
  28991. /**
  28992. * Define if the fresnel effect is enable or not.
  28993. */
  28994. get isEnabled(): boolean;
  28995. set isEnabled(value: boolean);
  28996. /**
  28997. * Define the color used on edges (grazing angle)
  28998. */
  28999. leftColor: Color3;
  29000. /**
  29001. * Define the color used on center
  29002. */
  29003. rightColor: Color3;
  29004. /**
  29005. * Define bias applied to computed fresnel term
  29006. */
  29007. bias: number;
  29008. /**
  29009. * Defined the power exponent applied to fresnel term
  29010. */
  29011. power: number;
  29012. /**
  29013. * Creates a new FresnelParameters object.
  29014. *
  29015. * @param options provide your own settings to optionally to override defaults
  29016. */
  29017. constructor(options?: IFresnelParametersCreationOptions);
  29018. /**
  29019. * Clones the current fresnel and its valuues
  29020. * @returns a clone fresnel configuration
  29021. */
  29022. clone(): FresnelParameters;
  29023. /**
  29024. * Determines equality between FresnelParameters objects
  29025. * @param otherFresnelParameters defines the second operand
  29026. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29027. */
  29028. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29029. /**
  29030. * Serializes the current fresnel parameters to a JSON representation.
  29031. * @return the JSON serialization
  29032. */
  29033. serialize(): IFresnelParametersSerialized;
  29034. /**
  29035. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29036. * @param parsedFresnelParameters Define the JSON representation
  29037. * @returns the parsed parameters
  29038. */
  29039. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29040. }
  29041. }
  29042. declare module BABYLON {
  29043. /**
  29044. * This groups all the flags used to control the materials channel.
  29045. */
  29046. export class MaterialFlags {
  29047. private static _DiffuseTextureEnabled;
  29048. /**
  29049. * Are diffuse textures enabled in the application.
  29050. */
  29051. static get DiffuseTextureEnabled(): boolean;
  29052. static set DiffuseTextureEnabled(value: boolean);
  29053. private static _DetailTextureEnabled;
  29054. /**
  29055. * Are detail textures enabled in the application.
  29056. */
  29057. static get DetailTextureEnabled(): boolean;
  29058. static set DetailTextureEnabled(value: boolean);
  29059. private static _AmbientTextureEnabled;
  29060. /**
  29061. * Are ambient textures enabled in the application.
  29062. */
  29063. static get AmbientTextureEnabled(): boolean;
  29064. static set AmbientTextureEnabled(value: boolean);
  29065. private static _OpacityTextureEnabled;
  29066. /**
  29067. * Are opacity textures enabled in the application.
  29068. */
  29069. static get OpacityTextureEnabled(): boolean;
  29070. static set OpacityTextureEnabled(value: boolean);
  29071. private static _ReflectionTextureEnabled;
  29072. /**
  29073. * Are reflection textures enabled in the application.
  29074. */
  29075. static get ReflectionTextureEnabled(): boolean;
  29076. static set ReflectionTextureEnabled(value: boolean);
  29077. private static _EmissiveTextureEnabled;
  29078. /**
  29079. * Are emissive textures enabled in the application.
  29080. */
  29081. static get EmissiveTextureEnabled(): boolean;
  29082. static set EmissiveTextureEnabled(value: boolean);
  29083. private static _SpecularTextureEnabled;
  29084. /**
  29085. * Are specular textures enabled in the application.
  29086. */
  29087. static get SpecularTextureEnabled(): boolean;
  29088. static set SpecularTextureEnabled(value: boolean);
  29089. private static _BumpTextureEnabled;
  29090. /**
  29091. * Are bump textures enabled in the application.
  29092. */
  29093. static get BumpTextureEnabled(): boolean;
  29094. static set BumpTextureEnabled(value: boolean);
  29095. private static _LightmapTextureEnabled;
  29096. /**
  29097. * Are lightmap textures enabled in the application.
  29098. */
  29099. static get LightmapTextureEnabled(): boolean;
  29100. static set LightmapTextureEnabled(value: boolean);
  29101. private static _RefractionTextureEnabled;
  29102. /**
  29103. * Are refraction textures enabled in the application.
  29104. */
  29105. static get RefractionTextureEnabled(): boolean;
  29106. static set RefractionTextureEnabled(value: boolean);
  29107. private static _ColorGradingTextureEnabled;
  29108. /**
  29109. * Are color grading textures enabled in the application.
  29110. */
  29111. static get ColorGradingTextureEnabled(): boolean;
  29112. static set ColorGradingTextureEnabled(value: boolean);
  29113. private static _FresnelEnabled;
  29114. /**
  29115. * Are fresnels enabled in the application.
  29116. */
  29117. static get FresnelEnabled(): boolean;
  29118. static set FresnelEnabled(value: boolean);
  29119. private static _ClearCoatTextureEnabled;
  29120. /**
  29121. * Are clear coat textures enabled in the application.
  29122. */
  29123. static get ClearCoatTextureEnabled(): boolean;
  29124. static set ClearCoatTextureEnabled(value: boolean);
  29125. private static _ClearCoatBumpTextureEnabled;
  29126. /**
  29127. * Are clear coat bump textures enabled in the application.
  29128. */
  29129. static get ClearCoatBumpTextureEnabled(): boolean;
  29130. static set ClearCoatBumpTextureEnabled(value: boolean);
  29131. private static _ClearCoatTintTextureEnabled;
  29132. /**
  29133. * Are clear coat tint textures enabled in the application.
  29134. */
  29135. static get ClearCoatTintTextureEnabled(): boolean;
  29136. static set ClearCoatTintTextureEnabled(value: boolean);
  29137. private static _SheenTextureEnabled;
  29138. /**
  29139. * Are sheen textures enabled in the application.
  29140. */
  29141. static get SheenTextureEnabled(): boolean;
  29142. static set SheenTextureEnabled(value: boolean);
  29143. private static _AnisotropicTextureEnabled;
  29144. /**
  29145. * Are anisotropic textures enabled in the application.
  29146. */
  29147. static get AnisotropicTextureEnabled(): boolean;
  29148. static set AnisotropicTextureEnabled(value: boolean);
  29149. private static _ThicknessTextureEnabled;
  29150. /**
  29151. * Are thickness textures enabled in the application.
  29152. */
  29153. static get ThicknessTextureEnabled(): boolean;
  29154. static set ThicknessTextureEnabled(value: boolean);
  29155. }
  29156. }
  29157. declare module BABYLON {
  29158. /** @hidden */
  29159. export var defaultFragmentDeclaration: {
  29160. name: string;
  29161. shader: string;
  29162. };
  29163. }
  29164. declare module BABYLON {
  29165. /** @hidden */
  29166. export var defaultUboDeclaration: {
  29167. name: string;
  29168. shader: string;
  29169. };
  29170. }
  29171. declare module BABYLON {
  29172. /** @hidden */
  29173. export var prePassDeclaration: {
  29174. name: string;
  29175. shader: string;
  29176. };
  29177. }
  29178. declare module BABYLON {
  29179. /** @hidden */
  29180. export var lightFragmentDeclaration: {
  29181. name: string;
  29182. shader: string;
  29183. };
  29184. }
  29185. declare module BABYLON {
  29186. /** @hidden */
  29187. export var lightUboDeclaration: {
  29188. name: string;
  29189. shader: string;
  29190. };
  29191. }
  29192. declare module BABYLON {
  29193. /** @hidden */
  29194. export var lightsFragmentFunctions: {
  29195. name: string;
  29196. shader: string;
  29197. };
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var shadowsFragmentFunctions: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var fresnelFunction: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var bumpFragmentMainFunctions: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var bumpFragmentFunctions: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var logDepthDeclaration: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var bumpFragment: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var depthPrePass: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var lightFragment: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var logDepthFragment: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var defaultPixelShader: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var defaultVertexDeclaration: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var bumpVertexDeclaration: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var bumpVertex: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var fogVertex: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /** @hidden */
  29299. export var shadowsVertex: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module BABYLON {
  29305. /** @hidden */
  29306. export var pointCloudVertex: {
  29307. name: string;
  29308. shader: string;
  29309. };
  29310. }
  29311. declare module BABYLON {
  29312. /** @hidden */
  29313. export var logDepthVertex: {
  29314. name: string;
  29315. shader: string;
  29316. };
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export var defaultVertexShader: {
  29321. name: string;
  29322. shader: string;
  29323. };
  29324. }
  29325. declare module BABYLON {
  29326. /**
  29327. * @hidden
  29328. */
  29329. export interface IMaterialDetailMapDefines {
  29330. DETAIL: boolean;
  29331. DETAILDIRECTUV: number;
  29332. DETAIL_NORMALBLENDMETHOD: number;
  29333. /** @hidden */
  29334. _areTexturesDirty: boolean;
  29335. }
  29336. /**
  29337. * Define the code related to the detail map parameters of a material
  29338. *
  29339. * Inspired from:
  29340. * 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
  29341. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29342. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29343. */
  29344. export class DetailMapConfiguration {
  29345. private _texture;
  29346. /**
  29347. * The detail texture of the material.
  29348. */
  29349. texture: Nullable<BaseTexture>;
  29350. /**
  29351. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29352. * Bigger values mean stronger blending
  29353. */
  29354. diffuseBlendLevel: number;
  29355. /**
  29356. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29357. * Bigger values mean stronger blending. Only used with PBR materials
  29358. */
  29359. roughnessBlendLevel: number;
  29360. /**
  29361. * Defines how strong the bump effect from the detail map is
  29362. * Bigger values mean stronger effect
  29363. */
  29364. bumpLevel: number;
  29365. private _normalBlendMethod;
  29366. /**
  29367. * The method used to blend the bump and detail normals together
  29368. */
  29369. normalBlendMethod: number;
  29370. private _isEnabled;
  29371. /**
  29372. * Enable or disable the detail map on this material
  29373. */
  29374. isEnabled: boolean;
  29375. /** @hidden */
  29376. private _internalMarkAllSubMeshesAsTexturesDirty;
  29377. /** @hidden */
  29378. _markAllSubMeshesAsTexturesDirty(): void;
  29379. /**
  29380. * Instantiate a new detail map
  29381. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29382. */
  29383. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29384. /**
  29385. * Gets whether the submesh is ready to be used or not.
  29386. * @param defines the list of "defines" to update.
  29387. * @param scene defines the scene the material belongs to.
  29388. * @returns - boolean indicating that the submesh is ready or not.
  29389. */
  29390. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29391. /**
  29392. * Update the defines for detail map usage
  29393. * @param defines the list of "defines" to update.
  29394. * @param scene defines the scene the material belongs to.
  29395. */
  29396. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29397. /**
  29398. * Binds the material data.
  29399. * @param uniformBuffer defines the Uniform buffer to fill in.
  29400. * @param scene defines the scene the material belongs to.
  29401. * @param isFrozen defines whether the material is frozen or not.
  29402. */
  29403. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29404. /**
  29405. * Checks to see if a texture is used in the material.
  29406. * @param texture - Base texture to use.
  29407. * @returns - Boolean specifying if a texture is used in the material.
  29408. */
  29409. hasTexture(texture: BaseTexture): boolean;
  29410. /**
  29411. * Returns an array of the actively used textures.
  29412. * @param activeTextures Array of BaseTextures
  29413. */
  29414. getActiveTextures(activeTextures: BaseTexture[]): void;
  29415. /**
  29416. * Returns the animatable textures.
  29417. * @param animatables Array of animatable textures.
  29418. */
  29419. getAnimatables(animatables: IAnimatable[]): void;
  29420. /**
  29421. * Disposes the resources of the material.
  29422. * @param forceDisposeTextures - Forces the disposal of all textures.
  29423. */
  29424. dispose(forceDisposeTextures?: boolean): void;
  29425. /**
  29426. * Get the current class name useful for serialization or dynamic coding.
  29427. * @returns "DetailMap"
  29428. */
  29429. getClassName(): string;
  29430. /**
  29431. * Add the required uniforms to the current list.
  29432. * @param uniforms defines the current uniform list.
  29433. */
  29434. static AddUniforms(uniforms: string[]): void;
  29435. /**
  29436. * Add the required samplers to the current list.
  29437. * @param samplers defines the current sampler list.
  29438. */
  29439. static AddSamplers(samplers: string[]): void;
  29440. /**
  29441. * Add the required uniforms to the current buffer.
  29442. * @param uniformBuffer defines the current uniform buffer.
  29443. */
  29444. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29445. /**
  29446. * Makes a duplicate of the current instance into another one.
  29447. * @param detailMap define the instance where to copy the info
  29448. */
  29449. copyTo(detailMap: DetailMapConfiguration): void;
  29450. /**
  29451. * Serializes this detail map instance
  29452. * @returns - An object with the serialized instance.
  29453. */
  29454. serialize(): any;
  29455. /**
  29456. * Parses a detail map setting from a serialized object.
  29457. * @param source - Serialized object.
  29458. * @param scene Defines the scene we are parsing for
  29459. * @param rootUrl Defines the rootUrl to load from
  29460. */
  29461. parse(source: any, scene: Scene, rootUrl: string): void;
  29462. }
  29463. }
  29464. declare module BABYLON {
  29465. /** @hidden */
  29466. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29467. MAINUV1: boolean;
  29468. MAINUV2: boolean;
  29469. DIFFUSE: boolean;
  29470. DIFFUSEDIRECTUV: number;
  29471. DETAIL: boolean;
  29472. DETAILDIRECTUV: number;
  29473. DETAIL_NORMALBLENDMETHOD: number;
  29474. AMBIENT: boolean;
  29475. AMBIENTDIRECTUV: number;
  29476. OPACITY: boolean;
  29477. OPACITYDIRECTUV: number;
  29478. OPACITYRGB: boolean;
  29479. REFLECTION: boolean;
  29480. EMISSIVE: boolean;
  29481. EMISSIVEDIRECTUV: number;
  29482. SPECULAR: boolean;
  29483. SPECULARDIRECTUV: number;
  29484. BUMP: boolean;
  29485. BUMPDIRECTUV: number;
  29486. PARALLAX: boolean;
  29487. PARALLAXOCCLUSION: boolean;
  29488. SPECULAROVERALPHA: boolean;
  29489. CLIPPLANE: boolean;
  29490. CLIPPLANE2: boolean;
  29491. CLIPPLANE3: boolean;
  29492. CLIPPLANE4: boolean;
  29493. CLIPPLANE5: boolean;
  29494. CLIPPLANE6: boolean;
  29495. ALPHATEST: boolean;
  29496. DEPTHPREPASS: boolean;
  29497. ALPHAFROMDIFFUSE: boolean;
  29498. POINTSIZE: boolean;
  29499. FOG: boolean;
  29500. SPECULARTERM: boolean;
  29501. DIFFUSEFRESNEL: boolean;
  29502. OPACITYFRESNEL: boolean;
  29503. REFLECTIONFRESNEL: boolean;
  29504. REFRACTIONFRESNEL: boolean;
  29505. EMISSIVEFRESNEL: boolean;
  29506. FRESNEL: boolean;
  29507. NORMAL: boolean;
  29508. UV1: boolean;
  29509. UV2: boolean;
  29510. VERTEXCOLOR: boolean;
  29511. VERTEXALPHA: boolean;
  29512. NUM_BONE_INFLUENCERS: number;
  29513. BonesPerMesh: number;
  29514. BONETEXTURE: boolean;
  29515. INSTANCES: boolean;
  29516. THIN_INSTANCES: boolean;
  29517. GLOSSINESS: boolean;
  29518. ROUGHNESS: boolean;
  29519. EMISSIVEASILLUMINATION: boolean;
  29520. LINKEMISSIVEWITHDIFFUSE: boolean;
  29521. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29522. LIGHTMAP: boolean;
  29523. LIGHTMAPDIRECTUV: number;
  29524. OBJECTSPACE_NORMALMAP: boolean;
  29525. USELIGHTMAPASSHADOWMAP: boolean;
  29526. REFLECTIONMAP_3D: boolean;
  29527. REFLECTIONMAP_SPHERICAL: boolean;
  29528. REFLECTIONMAP_PLANAR: boolean;
  29529. REFLECTIONMAP_CUBIC: boolean;
  29530. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29531. REFLECTIONMAP_PROJECTION: boolean;
  29532. REFLECTIONMAP_SKYBOX: boolean;
  29533. REFLECTIONMAP_EXPLICIT: boolean;
  29534. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29535. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29536. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29537. INVERTCUBICMAP: boolean;
  29538. LOGARITHMICDEPTH: boolean;
  29539. REFRACTION: boolean;
  29540. REFRACTIONMAP_3D: boolean;
  29541. REFLECTIONOVERALPHA: boolean;
  29542. TWOSIDEDLIGHTING: boolean;
  29543. SHADOWFLOAT: boolean;
  29544. MORPHTARGETS: boolean;
  29545. MORPHTARGETS_NORMAL: boolean;
  29546. MORPHTARGETS_TANGENT: boolean;
  29547. MORPHTARGETS_UV: boolean;
  29548. NUM_MORPH_INFLUENCERS: number;
  29549. NONUNIFORMSCALING: boolean;
  29550. PREMULTIPLYALPHA: boolean;
  29551. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29552. ALPHABLEND: boolean;
  29553. PREPASS: boolean;
  29554. SCENE_MRT_COUNT: number;
  29555. RGBDLIGHTMAP: boolean;
  29556. RGBDREFLECTION: boolean;
  29557. RGBDREFRACTION: boolean;
  29558. IMAGEPROCESSING: boolean;
  29559. VIGNETTE: boolean;
  29560. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29561. VIGNETTEBLENDMODEOPAQUE: boolean;
  29562. TONEMAPPING: boolean;
  29563. TONEMAPPING_ACES: boolean;
  29564. CONTRAST: boolean;
  29565. COLORCURVES: boolean;
  29566. COLORGRADING: boolean;
  29567. COLORGRADING3D: boolean;
  29568. SAMPLER3DGREENDEPTH: boolean;
  29569. SAMPLER3DBGRMAP: boolean;
  29570. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29571. MULTIVIEW: boolean;
  29572. /**
  29573. * If the reflection texture on this material is in linear color space
  29574. * @hidden
  29575. */
  29576. IS_REFLECTION_LINEAR: boolean;
  29577. /**
  29578. * If the refraction texture on this material is in linear color space
  29579. * @hidden
  29580. */
  29581. IS_REFRACTION_LINEAR: boolean;
  29582. EXPOSURE: boolean;
  29583. constructor();
  29584. setReflectionMode(modeToEnable: string): void;
  29585. }
  29586. /**
  29587. * This is the default material used in Babylon. It is the best trade off between quality
  29588. * and performances.
  29589. * @see https://doc.babylonjs.com/babylon101/materials
  29590. */
  29591. export class StandardMaterial extends PushMaterial {
  29592. private _diffuseTexture;
  29593. /**
  29594. * The basic texture of the material as viewed under a light.
  29595. */
  29596. diffuseTexture: Nullable<BaseTexture>;
  29597. private _ambientTexture;
  29598. /**
  29599. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29600. */
  29601. ambientTexture: Nullable<BaseTexture>;
  29602. private _opacityTexture;
  29603. /**
  29604. * Define the transparency of the material from a texture.
  29605. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29606. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29607. */
  29608. opacityTexture: Nullable<BaseTexture>;
  29609. private _reflectionTexture;
  29610. /**
  29611. * Define the texture used to display the reflection.
  29612. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29613. */
  29614. reflectionTexture: Nullable<BaseTexture>;
  29615. private _emissiveTexture;
  29616. /**
  29617. * Define texture of the material as if self lit.
  29618. * This will be mixed in the final result even in the absence of light.
  29619. */
  29620. emissiveTexture: Nullable<BaseTexture>;
  29621. private _specularTexture;
  29622. /**
  29623. * Define how the color and intensity of the highlight given by the light in the material.
  29624. */
  29625. specularTexture: Nullable<BaseTexture>;
  29626. private _bumpTexture;
  29627. /**
  29628. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29629. * 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.
  29630. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  29631. */
  29632. bumpTexture: Nullable<BaseTexture>;
  29633. private _lightmapTexture;
  29634. /**
  29635. * Complex lighting can be computationally expensive to compute at runtime.
  29636. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29637. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  29638. */
  29639. lightmapTexture: Nullable<BaseTexture>;
  29640. private _refractionTexture;
  29641. /**
  29642. * Define the texture used to display the refraction.
  29643. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29644. */
  29645. refractionTexture: Nullable<BaseTexture>;
  29646. /**
  29647. * The color of the material lit by the environmental background lighting.
  29648. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29649. */
  29650. ambientColor: Color3;
  29651. /**
  29652. * The basic color of the material as viewed under a light.
  29653. */
  29654. diffuseColor: Color3;
  29655. /**
  29656. * Define how the color and intensity of the highlight given by the light in the material.
  29657. */
  29658. specularColor: Color3;
  29659. /**
  29660. * Define the color of the material as if self lit.
  29661. * This will be mixed in the final result even in the absence of light.
  29662. */
  29663. emissiveColor: Color3;
  29664. /**
  29665. * Defines how sharp are the highlights in the material.
  29666. * The bigger the value the sharper giving a more glossy feeling to the result.
  29667. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29668. */
  29669. specularPower: number;
  29670. private _useAlphaFromDiffuseTexture;
  29671. /**
  29672. * Does the transparency come from the diffuse texture alpha channel.
  29673. */
  29674. useAlphaFromDiffuseTexture: boolean;
  29675. private _useEmissiveAsIllumination;
  29676. /**
  29677. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29678. */
  29679. useEmissiveAsIllumination: boolean;
  29680. private _linkEmissiveWithDiffuse;
  29681. /**
  29682. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29683. * the emissive level when the final color is close to one.
  29684. */
  29685. linkEmissiveWithDiffuse: boolean;
  29686. private _useSpecularOverAlpha;
  29687. /**
  29688. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29689. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29690. */
  29691. useSpecularOverAlpha: boolean;
  29692. private _useReflectionOverAlpha;
  29693. /**
  29694. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29695. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29696. */
  29697. useReflectionOverAlpha: boolean;
  29698. private _disableLighting;
  29699. /**
  29700. * Does lights from the scene impacts this material.
  29701. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29702. */
  29703. disableLighting: boolean;
  29704. private _useObjectSpaceNormalMap;
  29705. /**
  29706. * Allows using an object space normal map (instead of tangent space).
  29707. */
  29708. useObjectSpaceNormalMap: boolean;
  29709. private _useParallax;
  29710. /**
  29711. * Is parallax enabled or not.
  29712. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29713. */
  29714. useParallax: boolean;
  29715. private _useParallaxOcclusion;
  29716. /**
  29717. * Is parallax occlusion enabled or not.
  29718. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29719. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29720. */
  29721. useParallaxOcclusion: boolean;
  29722. /**
  29723. * 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.
  29724. */
  29725. parallaxScaleBias: number;
  29726. private _roughness;
  29727. /**
  29728. * Helps to define how blurry the reflections should appears in the material.
  29729. */
  29730. roughness: number;
  29731. /**
  29732. * In case of refraction, define the value of the index of refraction.
  29733. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29734. */
  29735. indexOfRefraction: number;
  29736. /**
  29737. * Invert the refraction texture alongside the y axis.
  29738. * It can be useful with procedural textures or probe for instance.
  29739. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29740. */
  29741. invertRefractionY: boolean;
  29742. /**
  29743. * Defines the alpha limits in alpha test mode.
  29744. */
  29745. alphaCutOff: number;
  29746. private _useLightmapAsShadowmap;
  29747. /**
  29748. * In case of light mapping, define whether the map contains light or shadow informations.
  29749. */
  29750. useLightmapAsShadowmap: boolean;
  29751. private _diffuseFresnelParameters;
  29752. /**
  29753. * Define the diffuse fresnel parameters of the material.
  29754. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29755. */
  29756. diffuseFresnelParameters: FresnelParameters;
  29757. private _opacityFresnelParameters;
  29758. /**
  29759. * Define the opacity fresnel parameters of the material.
  29760. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29761. */
  29762. opacityFresnelParameters: FresnelParameters;
  29763. private _reflectionFresnelParameters;
  29764. /**
  29765. * Define the reflection fresnel parameters of the material.
  29766. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29767. */
  29768. reflectionFresnelParameters: FresnelParameters;
  29769. private _refractionFresnelParameters;
  29770. /**
  29771. * Define the refraction fresnel parameters of the material.
  29772. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29773. */
  29774. refractionFresnelParameters: FresnelParameters;
  29775. private _emissiveFresnelParameters;
  29776. /**
  29777. * Define the emissive fresnel parameters of the material.
  29778. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29779. */
  29780. emissiveFresnelParameters: FresnelParameters;
  29781. private _useReflectionFresnelFromSpecular;
  29782. /**
  29783. * If true automatically deducts the fresnels values from the material specularity.
  29784. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29785. */
  29786. useReflectionFresnelFromSpecular: boolean;
  29787. private _useGlossinessFromSpecularMapAlpha;
  29788. /**
  29789. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29790. */
  29791. useGlossinessFromSpecularMapAlpha: boolean;
  29792. private _maxSimultaneousLights;
  29793. /**
  29794. * Defines the maximum number of lights that can be used in the material
  29795. */
  29796. maxSimultaneousLights: number;
  29797. private _invertNormalMapX;
  29798. /**
  29799. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29800. */
  29801. invertNormalMapX: boolean;
  29802. private _invertNormalMapY;
  29803. /**
  29804. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29805. */
  29806. invertNormalMapY: boolean;
  29807. private _twoSidedLighting;
  29808. /**
  29809. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29810. */
  29811. twoSidedLighting: boolean;
  29812. /**
  29813. * Default configuration related to image processing available in the standard Material.
  29814. */
  29815. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29816. /**
  29817. * Gets the image processing configuration used either in this material.
  29818. */
  29819. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29820. /**
  29821. * Sets the Default image processing configuration used either in the this material.
  29822. *
  29823. * If sets to null, the scene one is in use.
  29824. */
  29825. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29826. /**
  29827. * Keep track of the image processing observer to allow dispose and replace.
  29828. */
  29829. private _imageProcessingObserver;
  29830. /**
  29831. * Attaches a new image processing configuration to the Standard Material.
  29832. * @param configuration
  29833. */
  29834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29835. /**
  29836. * Gets wether the color curves effect is enabled.
  29837. */
  29838. get cameraColorCurvesEnabled(): boolean;
  29839. /**
  29840. * Sets wether the color curves effect is enabled.
  29841. */
  29842. set cameraColorCurvesEnabled(value: boolean);
  29843. /**
  29844. * Gets wether the color grading effect is enabled.
  29845. */
  29846. get cameraColorGradingEnabled(): boolean;
  29847. /**
  29848. * Gets wether the color grading effect is enabled.
  29849. */
  29850. set cameraColorGradingEnabled(value: boolean);
  29851. /**
  29852. * Gets wether tonemapping is enabled or not.
  29853. */
  29854. get cameraToneMappingEnabled(): boolean;
  29855. /**
  29856. * Sets wether tonemapping is enabled or not
  29857. */
  29858. set cameraToneMappingEnabled(value: boolean);
  29859. /**
  29860. * The camera exposure used on this material.
  29861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29862. * This corresponds to a photographic exposure.
  29863. */
  29864. get cameraExposure(): number;
  29865. /**
  29866. * The camera exposure used on this material.
  29867. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29868. * This corresponds to a photographic exposure.
  29869. */
  29870. set cameraExposure(value: number);
  29871. /**
  29872. * Gets The camera contrast used on this material.
  29873. */
  29874. get cameraContrast(): number;
  29875. /**
  29876. * Sets The camera contrast used on this material.
  29877. */
  29878. set cameraContrast(value: number);
  29879. /**
  29880. * Gets the Color Grading 2D Lookup Texture.
  29881. */
  29882. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29883. /**
  29884. * Sets the Color Grading 2D Lookup Texture.
  29885. */
  29886. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29887. /**
  29888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29890. * 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;
  29891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29892. */
  29893. get cameraColorCurves(): Nullable<ColorCurves>;
  29894. /**
  29895. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29896. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29897. * 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;
  29898. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29899. */
  29900. set cameraColorCurves(value: Nullable<ColorCurves>);
  29901. /**
  29902. * Should this material render to several textures at once
  29903. */
  29904. get shouldRenderToMRT(): boolean;
  29905. /**
  29906. * Defines the detail map parameters for the material.
  29907. */
  29908. readonly detailMap: DetailMapConfiguration;
  29909. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29910. protected _worldViewProjectionMatrix: Matrix;
  29911. protected _globalAmbientColor: Color3;
  29912. protected _useLogarithmicDepth: boolean;
  29913. protected _rebuildInParallel: boolean;
  29914. /**
  29915. * Instantiates a new standard material.
  29916. * This is the default material used in Babylon. It is the best trade off between quality
  29917. * and performances.
  29918. * @see https://doc.babylonjs.com/babylon101/materials
  29919. * @param name Define the name of the material in the scene
  29920. * @param scene Define the scene the material belong to
  29921. */
  29922. constructor(name: string, scene: Scene);
  29923. /**
  29924. * Gets a boolean indicating that current material needs to register RTT
  29925. */
  29926. get hasRenderTargetTextures(): boolean;
  29927. /**
  29928. * Gets the current class name of the material e.g. "StandardMaterial"
  29929. * Mainly use in serialization.
  29930. * @returns the class name
  29931. */
  29932. getClassName(): string;
  29933. /**
  29934. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29935. * You can try switching to logarithmic depth.
  29936. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29937. */
  29938. get useLogarithmicDepth(): boolean;
  29939. set useLogarithmicDepth(value: boolean);
  29940. /**
  29941. * Specifies if the material will require alpha blending
  29942. * @returns a boolean specifying if alpha blending is needed
  29943. */
  29944. needAlphaBlending(): boolean;
  29945. /**
  29946. * Specifies if this material should be rendered in alpha test mode
  29947. * @returns a boolean specifying if an alpha test is needed.
  29948. */
  29949. needAlphaTesting(): boolean;
  29950. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29951. /**
  29952. * Get the texture used for alpha test purpose.
  29953. * @returns the diffuse texture in case of the standard material.
  29954. */
  29955. getAlphaTestTexture(): Nullable<BaseTexture>;
  29956. /**
  29957. * Get if the submesh is ready to be used and all its information available.
  29958. * Child classes can use it to update shaders
  29959. * @param mesh defines the mesh to check
  29960. * @param subMesh defines which submesh to check
  29961. * @param useInstances specifies that instances should be used
  29962. * @returns a boolean indicating that the submesh is ready or not
  29963. */
  29964. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29965. /**
  29966. * Builds the material UBO layouts.
  29967. * Used internally during the effect preparation.
  29968. */
  29969. buildUniformLayout(): void;
  29970. /**
  29971. * Unbinds the material from the mesh
  29972. */
  29973. unbind(): void;
  29974. /**
  29975. * Binds the submesh to this material by preparing the effect and shader to draw
  29976. * @param world defines the world transformation matrix
  29977. * @param mesh defines the mesh containing the submesh
  29978. * @param subMesh defines the submesh to bind the material to
  29979. */
  29980. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29981. /**
  29982. * Get the list of animatables in the material.
  29983. * @returns the list of animatables object used in the material
  29984. */
  29985. getAnimatables(): IAnimatable[];
  29986. /**
  29987. * Gets the active textures from the material
  29988. * @returns an array of textures
  29989. */
  29990. getActiveTextures(): BaseTexture[];
  29991. /**
  29992. * Specifies if the material uses a texture
  29993. * @param texture defines the texture to check against the material
  29994. * @returns a boolean specifying if the material uses the texture
  29995. */
  29996. hasTexture(texture: BaseTexture): boolean;
  29997. /**
  29998. * Disposes the material
  29999. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30000. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30001. */
  30002. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30003. /**
  30004. * Makes a duplicate of the material, and gives it a new name
  30005. * @param name defines the new name for the duplicated material
  30006. * @returns the cloned material
  30007. */
  30008. clone(name: string): StandardMaterial;
  30009. /**
  30010. * Serializes this material in a JSON representation
  30011. * @returns the serialized material object
  30012. */
  30013. serialize(): any;
  30014. /**
  30015. * Creates a standard material from parsed material data
  30016. * @param source defines the JSON representation of the material
  30017. * @param scene defines the hosting scene
  30018. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30019. * @returns a new standard material
  30020. */
  30021. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30022. /**
  30023. * Are diffuse textures enabled in the application.
  30024. */
  30025. static get DiffuseTextureEnabled(): boolean;
  30026. static set DiffuseTextureEnabled(value: boolean);
  30027. /**
  30028. * Are detail textures enabled in the application.
  30029. */
  30030. static get DetailTextureEnabled(): boolean;
  30031. static set DetailTextureEnabled(value: boolean);
  30032. /**
  30033. * Are ambient textures enabled in the application.
  30034. */
  30035. static get AmbientTextureEnabled(): boolean;
  30036. static set AmbientTextureEnabled(value: boolean);
  30037. /**
  30038. * Are opacity textures enabled in the application.
  30039. */
  30040. static get OpacityTextureEnabled(): boolean;
  30041. static set OpacityTextureEnabled(value: boolean);
  30042. /**
  30043. * Are reflection textures enabled in the application.
  30044. */
  30045. static get ReflectionTextureEnabled(): boolean;
  30046. static set ReflectionTextureEnabled(value: boolean);
  30047. /**
  30048. * Are emissive textures enabled in the application.
  30049. */
  30050. static get EmissiveTextureEnabled(): boolean;
  30051. static set EmissiveTextureEnabled(value: boolean);
  30052. /**
  30053. * Are specular textures enabled in the application.
  30054. */
  30055. static get SpecularTextureEnabled(): boolean;
  30056. static set SpecularTextureEnabled(value: boolean);
  30057. /**
  30058. * Are bump textures enabled in the application.
  30059. */
  30060. static get BumpTextureEnabled(): boolean;
  30061. static set BumpTextureEnabled(value: boolean);
  30062. /**
  30063. * Are lightmap textures enabled in the application.
  30064. */
  30065. static get LightmapTextureEnabled(): boolean;
  30066. static set LightmapTextureEnabled(value: boolean);
  30067. /**
  30068. * Are refraction textures enabled in the application.
  30069. */
  30070. static get RefractionTextureEnabled(): boolean;
  30071. static set RefractionTextureEnabled(value: boolean);
  30072. /**
  30073. * Are color grading textures enabled in the application.
  30074. */
  30075. static get ColorGradingTextureEnabled(): boolean;
  30076. static set ColorGradingTextureEnabled(value: boolean);
  30077. /**
  30078. * Are fresnels enabled in the application.
  30079. */
  30080. static get FresnelEnabled(): boolean;
  30081. static set FresnelEnabled(value: boolean);
  30082. }
  30083. }
  30084. declare module BABYLON {
  30085. /**
  30086. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30087. *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.
  30088. * The SPS is also a particle system. It provides some methods to manage the particles.
  30089. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30090. *
  30091. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30092. */
  30093. export class SolidParticleSystem implements IDisposable {
  30094. /**
  30095. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30096. * Example : var p = SPS.particles[i];
  30097. */
  30098. particles: SolidParticle[];
  30099. /**
  30100. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30101. */
  30102. nbParticles: number;
  30103. /**
  30104. * If the particles must ever face the camera (default false). Useful for planar particles.
  30105. */
  30106. billboard: boolean;
  30107. /**
  30108. * Recompute normals when adding a shape
  30109. */
  30110. recomputeNormals: boolean;
  30111. /**
  30112. * This a counter ofr your own usage. It's not set by any SPS functions.
  30113. */
  30114. counter: number;
  30115. /**
  30116. * The SPS name. This name is also given to the underlying mesh.
  30117. */
  30118. name: string;
  30119. /**
  30120. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30121. */
  30122. mesh: Mesh;
  30123. /**
  30124. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30125. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30126. */
  30127. vars: any;
  30128. /**
  30129. * This array is populated when the SPS is set as 'pickable'.
  30130. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30131. * Each element of this array is an object `{idx: int, faceId: int}`.
  30132. * `idx` is the picked particle index in the `SPS.particles` array
  30133. * `faceId` is the picked face index counted within this particle.
  30134. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30135. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30136. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30137. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30138. */
  30139. pickedParticles: {
  30140. idx: number;
  30141. faceId: number;
  30142. }[];
  30143. /**
  30144. * This array is populated when the SPS is set as 'pickable'
  30145. * Each key of this array is a submesh index.
  30146. * Each element of this array is a second array defined like this :
  30147. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30148. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30149. * `idx` is the picked particle index in the `SPS.particles` array
  30150. * `faceId` is the picked face index counted within this particle.
  30151. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30152. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30153. */
  30154. pickedBySubMesh: {
  30155. idx: number;
  30156. faceId: number;
  30157. }[][];
  30158. /**
  30159. * This array is populated when `enableDepthSort` is set to true.
  30160. * Each element of this array is an instance of the class DepthSortedParticle.
  30161. */
  30162. depthSortedParticles: DepthSortedParticle[];
  30163. /**
  30164. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30165. * @hidden
  30166. */
  30167. _bSphereOnly: boolean;
  30168. /**
  30169. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30170. * @hidden
  30171. */
  30172. _bSphereRadiusFactor: number;
  30173. private _scene;
  30174. private _positions;
  30175. private _indices;
  30176. private _normals;
  30177. private _colors;
  30178. private _uvs;
  30179. private _indices32;
  30180. private _positions32;
  30181. private _normals32;
  30182. private _fixedNormal32;
  30183. private _colors32;
  30184. private _uvs32;
  30185. private _index;
  30186. private _updatable;
  30187. private _pickable;
  30188. private _isVisibilityBoxLocked;
  30189. private _alwaysVisible;
  30190. private _depthSort;
  30191. private _expandable;
  30192. private _shapeCounter;
  30193. private _copy;
  30194. private _color;
  30195. private _computeParticleColor;
  30196. private _computeParticleTexture;
  30197. private _computeParticleRotation;
  30198. private _computeParticleVertex;
  30199. private _computeBoundingBox;
  30200. private _depthSortParticles;
  30201. private _camera;
  30202. private _mustUnrotateFixedNormals;
  30203. private _particlesIntersect;
  30204. private _needs32Bits;
  30205. private _isNotBuilt;
  30206. private _lastParticleId;
  30207. private _idxOfId;
  30208. private _multimaterialEnabled;
  30209. private _useModelMaterial;
  30210. private _indicesByMaterial;
  30211. private _materialIndexes;
  30212. private _depthSortFunction;
  30213. private _materialSortFunction;
  30214. private _materials;
  30215. private _multimaterial;
  30216. private _materialIndexesById;
  30217. private _defaultMaterial;
  30218. private _autoUpdateSubMeshes;
  30219. private _tmpVertex;
  30220. /**
  30221. * Creates a SPS (Solid Particle System) object.
  30222. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30223. * @param scene (Scene) is the scene in which the SPS is added.
  30224. * @param options defines the options of the sps e.g.
  30225. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30226. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30227. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30228. * * 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.
  30229. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30230. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30231. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30232. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30233. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30234. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30235. */
  30236. constructor(name: string, scene: Scene, options?: {
  30237. updatable?: boolean;
  30238. isPickable?: boolean;
  30239. enableDepthSort?: boolean;
  30240. particleIntersection?: boolean;
  30241. boundingSphereOnly?: boolean;
  30242. bSphereRadiusFactor?: number;
  30243. expandable?: boolean;
  30244. useModelMaterial?: boolean;
  30245. enableMultiMaterial?: boolean;
  30246. });
  30247. /**
  30248. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30249. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30250. * @returns the created mesh
  30251. */
  30252. buildMesh(): Mesh;
  30253. /**
  30254. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30255. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30256. * Thus the particles generated from `digest()` have their property `position` set yet.
  30257. * @param mesh ( Mesh ) is the mesh to be digested
  30258. * @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
  30259. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30260. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30261. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30262. * @returns the current SPS
  30263. */
  30264. digest(mesh: Mesh, options?: {
  30265. facetNb?: number;
  30266. number?: number;
  30267. delta?: number;
  30268. storage?: [];
  30269. }): SolidParticleSystem;
  30270. /**
  30271. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30272. * @hidden
  30273. */
  30274. private _unrotateFixedNormals;
  30275. /**
  30276. * Resets the temporary working copy particle
  30277. * @hidden
  30278. */
  30279. private _resetCopy;
  30280. /**
  30281. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30282. * @param p the current index in the positions array to be updated
  30283. * @param ind the current index in the indices array
  30284. * @param shape a Vector3 array, the shape geometry
  30285. * @param positions the positions array to be updated
  30286. * @param meshInd the shape indices array
  30287. * @param indices the indices array to be updated
  30288. * @param meshUV the shape uv array
  30289. * @param uvs the uv array to be updated
  30290. * @param meshCol the shape color array
  30291. * @param colors the color array to be updated
  30292. * @param meshNor the shape normals array
  30293. * @param normals the normals array to be updated
  30294. * @param idx the particle index
  30295. * @param idxInShape the particle index in its shape
  30296. * @param options the addShape() method passed options
  30297. * @model the particle model
  30298. * @hidden
  30299. */
  30300. private _meshBuilder;
  30301. /**
  30302. * Returns a shape Vector3 array from positions float array
  30303. * @param positions float array
  30304. * @returns a vector3 array
  30305. * @hidden
  30306. */
  30307. private _posToShape;
  30308. /**
  30309. * Returns a shapeUV array from a float uvs (array deep copy)
  30310. * @param uvs as a float array
  30311. * @returns a shapeUV array
  30312. * @hidden
  30313. */
  30314. private _uvsToShapeUV;
  30315. /**
  30316. * Adds a new particle object in the particles array
  30317. * @param idx particle index in particles array
  30318. * @param id particle id
  30319. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30320. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30321. * @param model particle ModelShape object
  30322. * @param shapeId model shape identifier
  30323. * @param idxInShape index of the particle in the current model
  30324. * @param bInfo model bounding info object
  30325. * @param storage target storage array, if any
  30326. * @hidden
  30327. */
  30328. private _addParticle;
  30329. /**
  30330. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30331. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30332. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30333. * @param nb (positive integer) the number of particles to be created from this model
  30334. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30335. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30336. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30337. * @returns the number of shapes in the system
  30338. */
  30339. addShape(mesh: Mesh, nb: number, options?: {
  30340. positionFunction?: any;
  30341. vertexFunction?: any;
  30342. storage?: [];
  30343. }): number;
  30344. /**
  30345. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30346. * @hidden
  30347. */
  30348. private _rebuildParticle;
  30349. /**
  30350. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30351. * @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.
  30352. * @returns the SPS.
  30353. */
  30354. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30355. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30356. * Returns an array with the removed particles.
  30357. * 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.
  30358. * The SPS can't be empty so at least one particle needs to remain in place.
  30359. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30360. * @param start index of the first particle to remove
  30361. * @param end index of the last particle to remove (included)
  30362. * @returns an array populated with the removed particles
  30363. */
  30364. removeParticles(start: number, end: number): SolidParticle[];
  30365. /**
  30366. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30367. * @param solidParticleArray an array populated with Solid Particles objects
  30368. * @returns the SPS
  30369. */
  30370. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30371. /**
  30372. * Creates a new particle and modifies the SPS mesh geometry :
  30373. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30374. * - calls _addParticle() to populate the particle array
  30375. * factorized code from addShape() and insertParticlesFromArray()
  30376. * @param idx particle index in the particles array
  30377. * @param i particle index in its shape
  30378. * @param modelShape particle ModelShape object
  30379. * @param shape shape vertex array
  30380. * @param meshInd shape indices array
  30381. * @param meshUV shape uv array
  30382. * @param meshCol shape color array
  30383. * @param meshNor shape normals array
  30384. * @param bbInfo shape bounding info
  30385. * @param storage target particle storage
  30386. * @options addShape() passed options
  30387. * @hidden
  30388. */
  30389. private _insertNewParticle;
  30390. /**
  30391. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30392. * This method calls `updateParticle()` for each particle of the SPS.
  30393. * For an animated SPS, it is usually called within the render loop.
  30394. * 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.
  30395. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30396. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30397. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30398. * @returns the SPS.
  30399. */
  30400. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30401. /**
  30402. * Disposes the SPS.
  30403. */
  30404. dispose(): void;
  30405. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30406. * idx is the particle index in the SPS
  30407. * faceId is the picked face index counted within this particle.
  30408. * Returns null if the pickInfo can't identify a picked particle.
  30409. * @param pickingInfo (PickingInfo object)
  30410. * @returns {idx: number, faceId: number} or null
  30411. */
  30412. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30413. idx: number;
  30414. faceId: number;
  30415. }>;
  30416. /**
  30417. * Returns a SolidParticle object from its identifier : particle.id
  30418. * @param id (integer) the particle Id
  30419. * @returns the searched particle or null if not found in the SPS.
  30420. */
  30421. getParticleById(id: number): Nullable<SolidParticle>;
  30422. /**
  30423. * Returns a new array populated with the particles having the passed shapeId.
  30424. * @param shapeId (integer) the shape identifier
  30425. * @returns a new solid particle array
  30426. */
  30427. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30428. /**
  30429. * Populates the passed array "ref" with the particles having the passed shapeId.
  30430. * @param shapeId the shape identifier
  30431. * @returns the SPS
  30432. * @param ref
  30433. */
  30434. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30435. /**
  30436. * Computes the required SubMeshes according the materials assigned to the particles.
  30437. * @returns the solid particle system.
  30438. * Does nothing if called before the SPS mesh is built.
  30439. */
  30440. computeSubMeshes(): SolidParticleSystem;
  30441. /**
  30442. * Sorts the solid particles by material when MultiMaterial is enabled.
  30443. * Updates the indices32 array.
  30444. * Updates the indicesByMaterial array.
  30445. * Updates the mesh indices array.
  30446. * @returns the SPS
  30447. * @hidden
  30448. */
  30449. private _sortParticlesByMaterial;
  30450. /**
  30451. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30452. * @hidden
  30453. */
  30454. private _setMaterialIndexesById;
  30455. /**
  30456. * Returns an array with unique values of Materials from the passed array
  30457. * @param array the material array to be checked and filtered
  30458. * @hidden
  30459. */
  30460. private _filterUniqueMaterialId;
  30461. /**
  30462. * Sets a new Standard Material as _defaultMaterial if not already set.
  30463. * @hidden
  30464. */
  30465. private _setDefaultMaterial;
  30466. /**
  30467. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30468. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30469. * @returns the SPS.
  30470. */
  30471. refreshVisibleSize(): SolidParticleSystem;
  30472. /**
  30473. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30474. * @param size the size (float) of the visibility box
  30475. * note : this doesn't lock the SPS mesh bounding box.
  30476. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30477. */
  30478. setVisibilityBox(size: number): void;
  30479. /**
  30480. * Gets whether the SPS as always visible or not
  30481. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30482. */
  30483. get isAlwaysVisible(): boolean;
  30484. /**
  30485. * Sets the SPS as always visible or not
  30486. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30487. */
  30488. set isAlwaysVisible(val: boolean);
  30489. /**
  30490. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30491. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30492. */
  30493. set isVisibilityBoxLocked(val: boolean);
  30494. /**
  30495. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30496. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30497. */
  30498. get isVisibilityBoxLocked(): boolean;
  30499. /**
  30500. * Tells to `setParticles()` to compute the particle rotations or not.
  30501. * Default value : true. The SPS is faster when it's set to false.
  30502. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30503. */
  30504. set computeParticleRotation(val: boolean);
  30505. /**
  30506. * Tells to `setParticles()` to compute the particle colors or not.
  30507. * Default value : true. The SPS is faster when it's set to false.
  30508. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30509. */
  30510. set computeParticleColor(val: boolean);
  30511. set computeParticleTexture(val: boolean);
  30512. /**
  30513. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30514. * Default value : false. The SPS is faster when it's set to false.
  30515. * Note : the particle custom vertex positions aren't stored values.
  30516. */
  30517. set computeParticleVertex(val: boolean);
  30518. /**
  30519. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30520. */
  30521. set computeBoundingBox(val: boolean);
  30522. /**
  30523. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30524. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30525. * Default : `true`
  30526. */
  30527. set depthSortParticles(val: boolean);
  30528. /**
  30529. * Gets if `setParticles()` computes the particle rotations or not.
  30530. * Default value : true. The SPS is faster when it's set to false.
  30531. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30532. */
  30533. get computeParticleRotation(): boolean;
  30534. /**
  30535. * Gets if `setParticles()` computes the particle colors or not.
  30536. * Default value : true. The SPS is faster when it's set to false.
  30537. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30538. */
  30539. get computeParticleColor(): boolean;
  30540. /**
  30541. * Gets if `setParticles()` computes the particle textures or not.
  30542. * Default value : true. The SPS is faster when it's set to false.
  30543. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30544. */
  30545. get computeParticleTexture(): boolean;
  30546. /**
  30547. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30548. * Default value : false. The SPS is faster when it's set to false.
  30549. * Note : the particle custom vertex positions aren't stored values.
  30550. */
  30551. get computeParticleVertex(): boolean;
  30552. /**
  30553. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30554. */
  30555. get computeBoundingBox(): boolean;
  30556. /**
  30557. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30558. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30559. * Default : `true`
  30560. */
  30561. get depthSortParticles(): boolean;
  30562. /**
  30563. * Gets if the SPS is created as expandable at construction time.
  30564. * Default : `false`
  30565. */
  30566. get expandable(): boolean;
  30567. /**
  30568. * Gets if the SPS supports the Multi Materials
  30569. */
  30570. get multimaterialEnabled(): boolean;
  30571. /**
  30572. * Gets if the SPS uses the model materials for its own multimaterial.
  30573. */
  30574. get useModelMaterial(): boolean;
  30575. /**
  30576. * The SPS used material array.
  30577. */
  30578. get materials(): Material[];
  30579. /**
  30580. * Sets the SPS MultiMaterial from the passed materials.
  30581. * Note : the passed array is internally copied and not used then by reference.
  30582. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30583. */
  30584. setMultiMaterial(materials: Material[]): void;
  30585. /**
  30586. * The SPS computed multimaterial object
  30587. */
  30588. get multimaterial(): MultiMaterial;
  30589. set multimaterial(mm: MultiMaterial);
  30590. /**
  30591. * If the subMeshes must be updated on the next call to setParticles()
  30592. */
  30593. get autoUpdateSubMeshes(): boolean;
  30594. set autoUpdateSubMeshes(val: boolean);
  30595. /**
  30596. * This function does nothing. It may be overwritten to set all the particle first values.
  30597. * The SPS doesn't call this function, you may have to call it by your own.
  30598. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30599. */
  30600. initParticles(): void;
  30601. /**
  30602. * This function does nothing. It may be overwritten to recycle a particle.
  30603. * The SPS doesn't call this function, you may have to call it by your own.
  30604. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30605. * @param particle The particle to recycle
  30606. * @returns the recycled particle
  30607. */
  30608. recycleParticle(particle: SolidParticle): SolidParticle;
  30609. /**
  30610. * Updates a particle : this function should be overwritten by the user.
  30611. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30612. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30613. * @example : just set a particle position or velocity and recycle conditions
  30614. * @param particle The particle to update
  30615. * @returns the updated particle
  30616. */
  30617. updateParticle(particle: SolidParticle): SolidParticle;
  30618. /**
  30619. * Updates a vertex of a particle : it can be overwritten by the user.
  30620. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30621. * @param particle the current particle
  30622. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30623. * @param pt the index of the current vertex in the particle shape
  30624. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30625. * @example : just set a vertex particle position or color
  30626. * @returns the sps
  30627. */
  30628. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30629. /**
  30630. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30631. * This does nothing and may be overwritten by the user.
  30632. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30633. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30634. * @param update the boolean update value actually passed to setParticles()
  30635. */
  30636. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30637. /**
  30638. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30639. * This will be passed three parameters.
  30640. * This does nothing and may be overwritten by the user.
  30641. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30642. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30643. * @param update the boolean update value actually passed to setParticles()
  30644. */
  30645. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30646. }
  30647. }
  30648. declare module BABYLON {
  30649. /**
  30650. * Represents one particle of a solid particle system.
  30651. */
  30652. export class SolidParticle {
  30653. /**
  30654. * particle global index
  30655. */
  30656. idx: number;
  30657. /**
  30658. * particle identifier
  30659. */
  30660. id: number;
  30661. /**
  30662. * The color of the particle
  30663. */
  30664. color: Nullable<Color4>;
  30665. /**
  30666. * The world space position of the particle.
  30667. */
  30668. position: Vector3;
  30669. /**
  30670. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30671. */
  30672. rotation: Vector3;
  30673. /**
  30674. * The world space rotation quaternion of the particle.
  30675. */
  30676. rotationQuaternion: Nullable<Quaternion>;
  30677. /**
  30678. * The scaling of the particle.
  30679. */
  30680. scaling: Vector3;
  30681. /**
  30682. * The uvs of the particle.
  30683. */
  30684. uvs: Vector4;
  30685. /**
  30686. * The current speed of the particle.
  30687. */
  30688. velocity: Vector3;
  30689. /**
  30690. * The pivot point in the particle local space.
  30691. */
  30692. pivot: Vector3;
  30693. /**
  30694. * Must the particle be translated from its pivot point in its local space ?
  30695. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30696. * Default : false
  30697. */
  30698. translateFromPivot: boolean;
  30699. /**
  30700. * Is the particle active or not ?
  30701. */
  30702. alive: boolean;
  30703. /**
  30704. * Is the particle visible or not ?
  30705. */
  30706. isVisible: boolean;
  30707. /**
  30708. * Index of this particle in the global "positions" array (Internal use)
  30709. * @hidden
  30710. */
  30711. _pos: number;
  30712. /**
  30713. * @hidden Index of this particle in the global "indices" array (Internal use)
  30714. */
  30715. _ind: number;
  30716. /**
  30717. * @hidden ModelShape of this particle (Internal use)
  30718. */
  30719. _model: ModelShape;
  30720. /**
  30721. * ModelShape id of this particle
  30722. */
  30723. shapeId: number;
  30724. /**
  30725. * Index of the particle in its shape id
  30726. */
  30727. idxInShape: number;
  30728. /**
  30729. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30730. */
  30731. _modelBoundingInfo: BoundingInfo;
  30732. /**
  30733. * @hidden Particle BoundingInfo object (Internal use)
  30734. */
  30735. _boundingInfo: BoundingInfo;
  30736. /**
  30737. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30738. */
  30739. _sps: SolidParticleSystem;
  30740. /**
  30741. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30742. */
  30743. _stillInvisible: boolean;
  30744. /**
  30745. * @hidden Last computed particle rotation matrix
  30746. */
  30747. _rotationMatrix: number[];
  30748. /**
  30749. * Parent particle Id, if any.
  30750. * Default null.
  30751. */
  30752. parentId: Nullable<number>;
  30753. /**
  30754. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30755. */
  30756. materialIndex: Nullable<number>;
  30757. /**
  30758. * Custom object or properties.
  30759. */
  30760. props: Nullable<any>;
  30761. /**
  30762. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30763. * The possible values are :
  30764. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30765. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30766. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30767. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30768. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30769. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30770. * */
  30771. cullingStrategy: number;
  30772. /**
  30773. * @hidden Internal global position in the SPS.
  30774. */
  30775. _globalPosition: Vector3;
  30776. /**
  30777. * Creates a Solid Particle object.
  30778. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30779. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30780. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30781. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30782. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30783. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30784. * @param shapeId (integer) is the model shape identifier in the SPS.
  30785. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30786. * @param sps defines the sps it is associated to
  30787. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30788. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30789. */
  30790. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30791. /**
  30792. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30793. * @param target the particle target
  30794. * @returns the current particle
  30795. */
  30796. copyToRef(target: SolidParticle): SolidParticle;
  30797. /**
  30798. * Legacy support, changed scale to scaling
  30799. */
  30800. get scale(): Vector3;
  30801. /**
  30802. * Legacy support, changed scale to scaling
  30803. */
  30804. set scale(scale: Vector3);
  30805. /**
  30806. * Legacy support, changed quaternion to rotationQuaternion
  30807. */
  30808. get quaternion(): Nullable<Quaternion>;
  30809. /**
  30810. * Legacy support, changed quaternion to rotationQuaternion
  30811. */
  30812. set quaternion(q: Nullable<Quaternion>);
  30813. /**
  30814. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30815. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30816. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30817. * @returns true if it intersects
  30818. */
  30819. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30820. /**
  30821. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30822. * A particle is in the frustum if its bounding box intersects the frustum
  30823. * @param frustumPlanes defines the frustum to test
  30824. * @returns true if the particle is in the frustum planes
  30825. */
  30826. isInFrustum(frustumPlanes: Plane[]): boolean;
  30827. /**
  30828. * get the rotation matrix of the particle
  30829. * @hidden
  30830. */
  30831. getRotationMatrix(m: Matrix): void;
  30832. }
  30833. /**
  30834. * Represents the shape of the model used by one particle of a solid particle system.
  30835. * SPS internal tool, don't use it manually.
  30836. */
  30837. export class ModelShape {
  30838. /**
  30839. * The shape id
  30840. * @hidden
  30841. */
  30842. shapeID: number;
  30843. /**
  30844. * flat array of model positions (internal use)
  30845. * @hidden
  30846. */
  30847. _shape: Vector3[];
  30848. /**
  30849. * flat array of model UVs (internal use)
  30850. * @hidden
  30851. */
  30852. _shapeUV: number[];
  30853. /**
  30854. * color array of the model
  30855. * @hidden
  30856. */
  30857. _shapeColors: number[];
  30858. /**
  30859. * indices array of the model
  30860. * @hidden
  30861. */
  30862. _indices: number[];
  30863. /**
  30864. * normals array of the model
  30865. * @hidden
  30866. */
  30867. _normals: number[];
  30868. /**
  30869. * length of the shape in the model indices array (internal use)
  30870. * @hidden
  30871. */
  30872. _indicesLength: number;
  30873. /**
  30874. * Custom position function (internal use)
  30875. * @hidden
  30876. */
  30877. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30878. /**
  30879. * Custom vertex function (internal use)
  30880. * @hidden
  30881. */
  30882. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30883. /**
  30884. * Model material (internal use)
  30885. * @hidden
  30886. */
  30887. _material: Nullable<Material>;
  30888. /**
  30889. * 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.
  30890. * SPS internal tool, don't use it manually.
  30891. * @hidden
  30892. */
  30893. 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>);
  30894. }
  30895. /**
  30896. * Represents a Depth Sorted Particle in the solid particle system.
  30897. * @hidden
  30898. */
  30899. export class DepthSortedParticle {
  30900. /**
  30901. * Particle index
  30902. */
  30903. idx: number;
  30904. /**
  30905. * Index of the particle in the "indices" array
  30906. */
  30907. ind: number;
  30908. /**
  30909. * Length of the particle shape in the "indices" array
  30910. */
  30911. indicesLength: number;
  30912. /**
  30913. * Squared distance from the particle to the camera
  30914. */
  30915. sqDistance: number;
  30916. /**
  30917. * Material index when used with MultiMaterials
  30918. */
  30919. materialIndex: number;
  30920. /**
  30921. * Creates a new sorted particle
  30922. * @param materialIndex
  30923. */
  30924. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30925. }
  30926. /**
  30927. * Represents a solid particle vertex
  30928. */
  30929. export class SolidParticleVertex {
  30930. /**
  30931. * Vertex position
  30932. */
  30933. position: Vector3;
  30934. /**
  30935. * Vertex color
  30936. */
  30937. color: Color4;
  30938. /**
  30939. * Vertex UV
  30940. */
  30941. uv: Vector2;
  30942. /**
  30943. * Creates a new solid particle vertex
  30944. */
  30945. constructor();
  30946. /** Vertex x coordinate */
  30947. get x(): number;
  30948. set x(val: number);
  30949. /** Vertex y coordinate */
  30950. get y(): number;
  30951. set y(val: number);
  30952. /** Vertex z coordinate */
  30953. get z(): number;
  30954. set z(val: number);
  30955. }
  30956. }
  30957. declare module BABYLON {
  30958. /**
  30959. * @hidden
  30960. */
  30961. export class _MeshCollisionData {
  30962. _checkCollisions: boolean;
  30963. _collisionMask: number;
  30964. _collisionGroup: number;
  30965. _surroundingMeshes: Nullable<AbstractMesh[]>;
  30966. _collider: Nullable<Collider>;
  30967. _oldPositionForCollisions: Vector3;
  30968. _diffPositionForCollisions: Vector3;
  30969. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  30970. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  30971. }
  30972. }
  30973. declare module BABYLON {
  30974. /** @hidden */
  30975. class _FacetDataStorage {
  30976. facetPositions: Vector3[];
  30977. facetNormals: Vector3[];
  30978. facetPartitioning: number[][];
  30979. facetNb: number;
  30980. partitioningSubdivisions: number;
  30981. partitioningBBoxRatio: number;
  30982. facetDataEnabled: boolean;
  30983. facetParameters: any;
  30984. bbSize: Vector3;
  30985. subDiv: {
  30986. max: number;
  30987. X: number;
  30988. Y: number;
  30989. Z: number;
  30990. };
  30991. facetDepthSort: boolean;
  30992. facetDepthSortEnabled: boolean;
  30993. depthSortedIndices: IndicesArray;
  30994. depthSortedFacets: {
  30995. ind: number;
  30996. sqDistance: number;
  30997. }[];
  30998. facetDepthSortFunction: (f1: {
  30999. ind: number;
  31000. sqDistance: number;
  31001. }, f2: {
  31002. ind: number;
  31003. sqDistance: number;
  31004. }) => number;
  31005. facetDepthSortFrom: Vector3;
  31006. facetDepthSortOrigin: Vector3;
  31007. invertedMatrix: Matrix;
  31008. }
  31009. /**
  31010. * @hidden
  31011. **/
  31012. class _InternalAbstractMeshDataInfo {
  31013. _hasVertexAlpha: boolean;
  31014. _useVertexColors: boolean;
  31015. _numBoneInfluencers: number;
  31016. _applyFog: boolean;
  31017. _receiveShadows: boolean;
  31018. _facetData: _FacetDataStorage;
  31019. _visibility: number;
  31020. _skeleton: Nullable<Skeleton>;
  31021. _layerMask: number;
  31022. _computeBonesUsingShaders: boolean;
  31023. _isActive: boolean;
  31024. _onlyForInstances: boolean;
  31025. _isActiveIntermediate: boolean;
  31026. _onlyForInstancesIntermediate: boolean;
  31027. _actAsRegularMesh: boolean;
  31028. }
  31029. /**
  31030. * Class used to store all common mesh properties
  31031. */
  31032. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31033. /** No occlusion */
  31034. static OCCLUSION_TYPE_NONE: number;
  31035. /** Occlusion set to optimisitic */
  31036. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31037. /** Occlusion set to strict */
  31038. static OCCLUSION_TYPE_STRICT: number;
  31039. /** Use an accurante occlusion algorithm */
  31040. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31041. /** Use a conservative occlusion algorithm */
  31042. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31043. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31044. * Test order :
  31045. * Is the bounding sphere outside the frustum ?
  31046. * If not, are the bounding box vertices outside the frustum ?
  31047. * It not, then the cullable object is in the frustum.
  31048. */
  31049. static readonly CULLINGSTRATEGY_STANDARD: number;
  31050. /** Culling strategy : Bounding Sphere Only.
  31051. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31052. * It's also less accurate than the standard because some not visible objects can still be selected.
  31053. * Test : is the bounding sphere outside the frustum ?
  31054. * If not, then the cullable object is in the frustum.
  31055. */
  31056. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31057. /** Culling strategy : Optimistic Inclusion.
  31058. * This in an inclusion test first, then the standard exclusion test.
  31059. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31060. * 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.
  31061. * Anyway, it's as accurate as the standard strategy.
  31062. * Test :
  31063. * Is the cullable object bounding sphere center in the frustum ?
  31064. * If not, apply the default culling strategy.
  31065. */
  31066. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31067. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31068. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31069. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31070. * 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.
  31071. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31072. * Test :
  31073. * Is the cullable object bounding sphere center in the frustum ?
  31074. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31075. */
  31076. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31077. /**
  31078. * No billboard
  31079. */
  31080. static get BILLBOARDMODE_NONE(): number;
  31081. /** Billboard on X axis */
  31082. static get BILLBOARDMODE_X(): number;
  31083. /** Billboard on Y axis */
  31084. static get BILLBOARDMODE_Y(): number;
  31085. /** Billboard on Z axis */
  31086. static get BILLBOARDMODE_Z(): number;
  31087. /** Billboard on all axes */
  31088. static get BILLBOARDMODE_ALL(): number;
  31089. /** Billboard on using position instead of orientation */
  31090. static get BILLBOARDMODE_USE_POSITION(): number;
  31091. /** @hidden */
  31092. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31093. /**
  31094. * The culling strategy to use to check whether the mesh must be rendered or not.
  31095. * This value can be changed at any time and will be used on the next render mesh selection.
  31096. * The possible values are :
  31097. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31098. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31099. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31100. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31101. * Please read each static variable documentation to get details about the culling process.
  31102. * */
  31103. cullingStrategy: number;
  31104. /**
  31105. * Gets the number of facets in the mesh
  31106. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31107. */
  31108. get facetNb(): number;
  31109. /**
  31110. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31111. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31112. */
  31113. get partitioningSubdivisions(): number;
  31114. set partitioningSubdivisions(nb: number);
  31115. /**
  31116. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31117. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31118. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31119. */
  31120. get partitioningBBoxRatio(): number;
  31121. set partitioningBBoxRatio(ratio: number);
  31122. /**
  31123. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31124. * Works only for updatable meshes.
  31125. * Doesn't work with multi-materials
  31126. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31127. */
  31128. get mustDepthSortFacets(): boolean;
  31129. set mustDepthSortFacets(sort: boolean);
  31130. /**
  31131. * The location (Vector3) where the facet depth sort must be computed from.
  31132. * By default, the active camera position.
  31133. * Used only when facet depth sort is enabled
  31134. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31135. */
  31136. get facetDepthSortFrom(): Vector3;
  31137. set facetDepthSortFrom(location: Vector3);
  31138. /**
  31139. * gets a boolean indicating if facetData is enabled
  31140. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31141. */
  31142. get isFacetDataEnabled(): boolean;
  31143. /** @hidden */
  31144. _updateNonUniformScalingState(value: boolean): boolean;
  31145. /**
  31146. * An event triggered when this mesh collides with another one
  31147. */
  31148. onCollideObservable: Observable<AbstractMesh>;
  31149. /** Set a function to call when this mesh collides with another one */
  31150. set onCollide(callback: () => void);
  31151. /**
  31152. * An event triggered when the collision's position changes
  31153. */
  31154. onCollisionPositionChangeObservable: Observable<Vector3>;
  31155. /** Set a function to call when the collision's position changes */
  31156. set onCollisionPositionChange(callback: () => void);
  31157. /**
  31158. * An event triggered when material is changed
  31159. */
  31160. onMaterialChangedObservable: Observable<AbstractMesh>;
  31161. /**
  31162. * Gets or sets the orientation for POV movement & rotation
  31163. */
  31164. definedFacingForward: boolean;
  31165. /** @hidden */
  31166. _occlusionQuery: Nullable<WebGLQuery>;
  31167. /** @hidden */
  31168. _renderingGroup: Nullable<RenderingGroup>;
  31169. /**
  31170. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31171. */
  31172. get visibility(): number;
  31173. /**
  31174. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31175. */
  31176. set visibility(value: number);
  31177. /** Gets or sets the alpha index used to sort transparent meshes
  31178. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31179. */
  31180. alphaIndex: number;
  31181. /**
  31182. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31183. */
  31184. isVisible: boolean;
  31185. /**
  31186. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31187. */
  31188. isPickable: boolean;
  31189. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31190. showSubMeshesBoundingBox: boolean;
  31191. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31192. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31193. */
  31194. isBlocker: boolean;
  31195. /**
  31196. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31197. */
  31198. enablePointerMoveEvents: boolean;
  31199. /**
  31200. * Specifies the rendering group id for this mesh (0 by default)
  31201. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31202. */
  31203. renderingGroupId: number;
  31204. private _material;
  31205. /** Gets or sets current material */
  31206. get material(): Nullable<Material>;
  31207. set material(value: Nullable<Material>);
  31208. /**
  31209. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31210. * @see https://doc.babylonjs.com/babylon101/shadows
  31211. */
  31212. get receiveShadows(): boolean;
  31213. set receiveShadows(value: boolean);
  31214. /** Defines color to use when rendering outline */
  31215. outlineColor: Color3;
  31216. /** Define width to use when rendering outline */
  31217. outlineWidth: number;
  31218. /** Defines color to use when rendering overlay */
  31219. overlayColor: Color3;
  31220. /** Defines alpha to use when rendering overlay */
  31221. overlayAlpha: number;
  31222. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31223. get hasVertexAlpha(): boolean;
  31224. set hasVertexAlpha(value: boolean);
  31225. /** 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) */
  31226. get useVertexColors(): boolean;
  31227. set useVertexColors(value: boolean);
  31228. /**
  31229. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31230. */
  31231. get computeBonesUsingShaders(): boolean;
  31232. set computeBonesUsingShaders(value: boolean);
  31233. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31234. get numBoneInfluencers(): number;
  31235. set numBoneInfluencers(value: number);
  31236. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31237. get applyFog(): boolean;
  31238. set applyFog(value: boolean);
  31239. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31240. useOctreeForRenderingSelection: boolean;
  31241. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31242. useOctreeForPicking: boolean;
  31243. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31244. useOctreeForCollisions: boolean;
  31245. /**
  31246. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31247. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31248. */
  31249. get layerMask(): number;
  31250. set layerMask(value: number);
  31251. /**
  31252. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31253. */
  31254. alwaysSelectAsActiveMesh: boolean;
  31255. /**
  31256. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31257. */
  31258. doNotSyncBoundingInfo: boolean;
  31259. /**
  31260. * Gets or sets the current action manager
  31261. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31262. */
  31263. actionManager: Nullable<AbstractActionManager>;
  31264. private _meshCollisionData;
  31265. /**
  31266. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31267. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31268. */
  31269. ellipsoid: Vector3;
  31270. /**
  31271. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31272. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31273. */
  31274. ellipsoidOffset: Vector3;
  31275. /**
  31276. * Gets or sets a collision mask used to mask collisions (default is -1).
  31277. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31278. */
  31279. get collisionMask(): number;
  31280. set collisionMask(mask: number);
  31281. /**
  31282. * Gets or sets the current collision group mask (-1 by default).
  31283. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31284. */
  31285. get collisionGroup(): number;
  31286. set collisionGroup(mask: number);
  31287. /**
  31288. * Gets or sets current surrounding meshes (null by default).
  31289. *
  31290. * By default collision detection is tested against every mesh in the scene.
  31291. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31292. * meshes will be tested for the collision.
  31293. *
  31294. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31295. */
  31296. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31297. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31298. /**
  31299. * Defines edge width used when edgesRenderer is enabled
  31300. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31301. */
  31302. edgesWidth: number;
  31303. /**
  31304. * Defines edge color used when edgesRenderer is enabled
  31305. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31306. */
  31307. edgesColor: Color4;
  31308. /** @hidden */
  31309. _edgesRenderer: Nullable<IEdgesRenderer>;
  31310. /** @hidden */
  31311. _masterMesh: Nullable<AbstractMesh>;
  31312. /** @hidden */
  31313. _boundingInfo: Nullable<BoundingInfo>;
  31314. /** @hidden */
  31315. _renderId: number;
  31316. /**
  31317. * Gets or sets the list of subMeshes
  31318. * @see https://doc.babylonjs.com/how_to/multi_materials
  31319. */
  31320. subMeshes: SubMesh[];
  31321. /** @hidden */
  31322. _intersectionsInProgress: AbstractMesh[];
  31323. /** @hidden */
  31324. _unIndexed: boolean;
  31325. /** @hidden */
  31326. _lightSources: Light[];
  31327. /** Gets the list of lights affecting that mesh */
  31328. get lightSources(): Light[];
  31329. /** @hidden */
  31330. get _positions(): Nullable<Vector3[]>;
  31331. /** @hidden */
  31332. _waitingData: {
  31333. lods: Nullable<any>;
  31334. actions: Nullable<any>;
  31335. freezeWorldMatrix: Nullable<boolean>;
  31336. };
  31337. /** @hidden */
  31338. _bonesTransformMatrices: Nullable<Float32Array>;
  31339. /** @hidden */
  31340. _transformMatrixTexture: Nullable<RawTexture>;
  31341. /**
  31342. * Gets or sets a skeleton to apply skining transformations
  31343. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31344. */
  31345. set skeleton(value: Nullable<Skeleton>);
  31346. get skeleton(): Nullable<Skeleton>;
  31347. /**
  31348. * An event triggered when the mesh is rebuilt.
  31349. */
  31350. onRebuildObservable: Observable<AbstractMesh>;
  31351. /**
  31352. * Creates a new AbstractMesh
  31353. * @param name defines the name of the mesh
  31354. * @param scene defines the hosting scene
  31355. */
  31356. constructor(name: string, scene?: Nullable<Scene>);
  31357. /**
  31358. * Returns the string "AbstractMesh"
  31359. * @returns "AbstractMesh"
  31360. */
  31361. getClassName(): string;
  31362. /**
  31363. * Gets a string representation of the current mesh
  31364. * @param fullDetails defines a boolean indicating if full details must be included
  31365. * @returns a string representation of the current mesh
  31366. */
  31367. toString(fullDetails?: boolean): string;
  31368. /**
  31369. * @hidden
  31370. */
  31371. protected _getEffectiveParent(): Nullable<Node>;
  31372. /** @hidden */
  31373. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31374. /** @hidden */
  31375. _rebuild(): void;
  31376. /** @hidden */
  31377. _resyncLightSources(): void;
  31378. /** @hidden */
  31379. _resyncLightSource(light: Light): void;
  31380. /** @hidden */
  31381. _unBindEffect(): void;
  31382. /** @hidden */
  31383. _removeLightSource(light: Light, dispose: boolean): void;
  31384. private _markSubMeshesAsDirty;
  31385. /** @hidden */
  31386. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31387. /** @hidden */
  31388. _markSubMeshesAsAttributesDirty(): void;
  31389. /** @hidden */
  31390. _markSubMeshesAsMiscDirty(): void;
  31391. /**
  31392. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31393. */
  31394. get scaling(): Vector3;
  31395. set scaling(newScaling: Vector3);
  31396. /**
  31397. * Returns true if the mesh is blocked. Implemented by child classes
  31398. */
  31399. get isBlocked(): boolean;
  31400. /**
  31401. * Returns the mesh itself by default. Implemented by child classes
  31402. * @param camera defines the camera to use to pick the right LOD level
  31403. * @returns the currentAbstractMesh
  31404. */
  31405. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31406. /**
  31407. * Returns 0 by default. Implemented by child classes
  31408. * @returns an integer
  31409. */
  31410. getTotalVertices(): number;
  31411. /**
  31412. * Returns a positive integer : the total number of indices in this mesh geometry.
  31413. * @returns the numner of indices or zero if the mesh has no geometry.
  31414. */
  31415. getTotalIndices(): number;
  31416. /**
  31417. * Returns null by default. Implemented by child classes
  31418. * @returns null
  31419. */
  31420. getIndices(): Nullable<IndicesArray>;
  31421. /**
  31422. * Returns the array of the requested vertex data kind. Implemented by child classes
  31423. * @param kind defines the vertex data kind to use
  31424. * @returns null
  31425. */
  31426. getVerticesData(kind: string): Nullable<FloatArray>;
  31427. /**
  31428. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31429. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31430. * Note that a new underlying VertexBuffer object is created each call.
  31431. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31432. * @param kind defines vertex data kind:
  31433. * * VertexBuffer.PositionKind
  31434. * * VertexBuffer.UVKind
  31435. * * VertexBuffer.UV2Kind
  31436. * * VertexBuffer.UV3Kind
  31437. * * VertexBuffer.UV4Kind
  31438. * * VertexBuffer.UV5Kind
  31439. * * VertexBuffer.UV6Kind
  31440. * * VertexBuffer.ColorKind
  31441. * * VertexBuffer.MatricesIndicesKind
  31442. * * VertexBuffer.MatricesIndicesExtraKind
  31443. * * VertexBuffer.MatricesWeightsKind
  31444. * * VertexBuffer.MatricesWeightsExtraKind
  31445. * @param data defines the data source
  31446. * @param updatable defines if the data must be flagged as updatable (or static)
  31447. * @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
  31448. * @returns the current mesh
  31449. */
  31450. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31451. /**
  31452. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31453. * If the mesh has no geometry, it is simply returned as it is.
  31454. * @param kind defines vertex data kind:
  31455. * * VertexBuffer.PositionKind
  31456. * * VertexBuffer.UVKind
  31457. * * VertexBuffer.UV2Kind
  31458. * * VertexBuffer.UV3Kind
  31459. * * VertexBuffer.UV4Kind
  31460. * * VertexBuffer.UV5Kind
  31461. * * VertexBuffer.UV6Kind
  31462. * * VertexBuffer.ColorKind
  31463. * * VertexBuffer.MatricesIndicesKind
  31464. * * VertexBuffer.MatricesIndicesExtraKind
  31465. * * VertexBuffer.MatricesWeightsKind
  31466. * * VertexBuffer.MatricesWeightsExtraKind
  31467. * @param data defines the data source
  31468. * @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
  31469. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31470. * @returns the current mesh
  31471. */
  31472. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31473. /**
  31474. * Sets the mesh indices,
  31475. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31476. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31477. * @param totalVertices Defines the total number of vertices
  31478. * @returns the current mesh
  31479. */
  31480. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31481. /**
  31482. * Gets a boolean indicating if specific vertex data is present
  31483. * @param kind defines the vertex data kind to use
  31484. * @returns true is data kind is present
  31485. */
  31486. isVerticesDataPresent(kind: string): boolean;
  31487. /**
  31488. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31489. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31490. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31491. * @returns a BoundingInfo
  31492. */
  31493. getBoundingInfo(): BoundingInfo;
  31494. /**
  31495. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31496. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31497. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31498. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31499. * @returns the current mesh
  31500. */
  31501. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31502. /**
  31503. * Overwrite the current bounding info
  31504. * @param boundingInfo defines the new bounding info
  31505. * @returns the current mesh
  31506. */
  31507. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31508. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31509. get useBones(): boolean;
  31510. /** @hidden */
  31511. _preActivate(): void;
  31512. /** @hidden */
  31513. _preActivateForIntermediateRendering(renderId: number): void;
  31514. /** @hidden */
  31515. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31516. /** @hidden */
  31517. _postActivate(): void;
  31518. /** @hidden */
  31519. _freeze(): void;
  31520. /** @hidden */
  31521. _unFreeze(): void;
  31522. /**
  31523. * Gets the current world matrix
  31524. * @returns a Matrix
  31525. */
  31526. getWorldMatrix(): Matrix;
  31527. /** @hidden */
  31528. _getWorldMatrixDeterminant(): number;
  31529. /**
  31530. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31531. */
  31532. get isAnInstance(): boolean;
  31533. /**
  31534. * Gets a boolean indicating if this mesh has instances
  31535. */
  31536. get hasInstances(): boolean;
  31537. /**
  31538. * Gets a boolean indicating if this mesh has thin instances
  31539. */
  31540. get hasThinInstances(): boolean;
  31541. /**
  31542. * Perform relative position change from the point of view of behind the front of the mesh.
  31543. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31544. * Supports definition of mesh facing forward or backward
  31545. * @param amountRight defines the distance on the right axis
  31546. * @param amountUp defines the distance on the up axis
  31547. * @param amountForward defines the distance on the forward axis
  31548. * @returns the current mesh
  31549. */
  31550. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31551. /**
  31552. * Calculate relative position change from the point of view of behind the front of the mesh.
  31553. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31554. * Supports definition of mesh facing forward or backward
  31555. * @param amountRight defines the distance on the right axis
  31556. * @param amountUp defines the distance on the up axis
  31557. * @param amountForward defines the distance on the forward axis
  31558. * @returns the new displacement vector
  31559. */
  31560. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31561. /**
  31562. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31563. * Supports definition of mesh facing forward or backward
  31564. * @param flipBack defines the flip
  31565. * @param twirlClockwise defines the twirl
  31566. * @param tiltRight defines the tilt
  31567. * @returns the current mesh
  31568. */
  31569. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31570. /**
  31571. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31572. * Supports definition of mesh facing forward or backward.
  31573. * @param flipBack defines the flip
  31574. * @param twirlClockwise defines the twirl
  31575. * @param tiltRight defines the tilt
  31576. * @returns the new rotation vector
  31577. */
  31578. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31579. /**
  31580. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31581. * This means the mesh underlying bounding box and sphere are recomputed.
  31582. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31583. * @returns the current mesh
  31584. */
  31585. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31586. /** @hidden */
  31587. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31588. /** @hidden */
  31589. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31590. /** @hidden */
  31591. _updateBoundingInfo(): AbstractMesh;
  31592. /** @hidden */
  31593. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31594. /** @hidden */
  31595. protected _afterComputeWorldMatrix(): void;
  31596. /** @hidden */
  31597. get _effectiveMesh(): AbstractMesh;
  31598. /**
  31599. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31600. * A mesh is in the frustum if its bounding box intersects the frustum
  31601. * @param frustumPlanes defines the frustum to test
  31602. * @returns true if the mesh is in the frustum planes
  31603. */
  31604. isInFrustum(frustumPlanes: Plane[]): boolean;
  31605. /**
  31606. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31607. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31608. * @param frustumPlanes defines the frustum to test
  31609. * @returns true if the mesh is completely in the frustum planes
  31610. */
  31611. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31612. /**
  31613. * True if the mesh intersects another mesh or a SolidParticle object
  31614. * @param mesh defines a target mesh or SolidParticle to test
  31615. * @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)
  31616. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31617. * @returns true if there is an intersection
  31618. */
  31619. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31620. /**
  31621. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31622. * @param point defines the point to test
  31623. * @returns true if there is an intersection
  31624. */
  31625. intersectsPoint(point: Vector3): boolean;
  31626. /**
  31627. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31628. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31629. */
  31630. get checkCollisions(): boolean;
  31631. set checkCollisions(collisionEnabled: boolean);
  31632. /**
  31633. * Gets Collider object used to compute collisions (not physics)
  31634. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31635. */
  31636. get collider(): Nullable<Collider>;
  31637. /**
  31638. * Move the mesh using collision engine
  31639. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31640. * @param displacement defines the requested displacement vector
  31641. * @returns the current mesh
  31642. */
  31643. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31644. private _onCollisionPositionChange;
  31645. /** @hidden */
  31646. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31647. /** @hidden */
  31648. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31649. /** @hidden */
  31650. _checkCollision(collider: Collider): AbstractMesh;
  31651. /** @hidden */
  31652. _generatePointsArray(): boolean;
  31653. /**
  31654. * Checks if the passed Ray intersects with the mesh
  31655. * @param ray defines the ray to use
  31656. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31657. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31658. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31659. * @returns the picking info
  31660. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31661. */
  31662. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31663. /**
  31664. * Clones the current mesh
  31665. * @param name defines the mesh name
  31666. * @param newParent defines the new mesh parent
  31667. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31668. * @returns the new mesh
  31669. */
  31670. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31671. /**
  31672. * Disposes all the submeshes of the current meshnp
  31673. * @returns the current mesh
  31674. */
  31675. releaseSubMeshes(): AbstractMesh;
  31676. /**
  31677. * Releases resources associated with this abstract mesh.
  31678. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31679. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31680. */
  31681. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31682. /**
  31683. * Adds the passed mesh as a child to the current mesh
  31684. * @param mesh defines the child mesh
  31685. * @returns the current mesh
  31686. */
  31687. addChild(mesh: AbstractMesh): AbstractMesh;
  31688. /**
  31689. * Removes the passed mesh from the current mesh children list
  31690. * @param mesh defines the child mesh
  31691. * @returns the current mesh
  31692. */
  31693. removeChild(mesh: AbstractMesh): AbstractMesh;
  31694. /** @hidden */
  31695. private _initFacetData;
  31696. /**
  31697. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31698. * This method can be called within the render loop.
  31699. * 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
  31700. * @returns the current mesh
  31701. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31702. */
  31703. updateFacetData(): AbstractMesh;
  31704. /**
  31705. * Returns the facetLocalNormals array.
  31706. * The normals are expressed in the mesh local spac
  31707. * @returns an array of Vector3
  31708. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31709. */
  31710. getFacetLocalNormals(): Vector3[];
  31711. /**
  31712. * Returns the facetLocalPositions array.
  31713. * The facet positions are expressed in the mesh local space
  31714. * @returns an array of Vector3
  31715. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31716. */
  31717. getFacetLocalPositions(): Vector3[];
  31718. /**
  31719. * Returns the facetLocalPartioning array
  31720. * @returns an array of array of numbers
  31721. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31722. */
  31723. getFacetLocalPartitioning(): number[][];
  31724. /**
  31725. * Returns the i-th facet position in the world system.
  31726. * This method allocates a new Vector3 per call
  31727. * @param i defines the facet index
  31728. * @returns a new Vector3
  31729. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31730. */
  31731. getFacetPosition(i: number): Vector3;
  31732. /**
  31733. * Sets the reference Vector3 with the i-th facet position in the world system
  31734. * @param i defines the facet index
  31735. * @param ref defines the target vector
  31736. * @returns the current mesh
  31737. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31738. */
  31739. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31740. /**
  31741. * Returns the i-th facet normal in the world system.
  31742. * This method allocates a new Vector3 per call
  31743. * @param i defines the facet index
  31744. * @returns a new Vector3
  31745. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31746. */
  31747. getFacetNormal(i: number): Vector3;
  31748. /**
  31749. * Sets the reference Vector3 with the i-th facet normal in the world system
  31750. * @param i defines the facet index
  31751. * @param ref defines the target vector
  31752. * @returns the current mesh
  31753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31754. */
  31755. getFacetNormalToRef(i: number, ref: Vector3): this;
  31756. /**
  31757. * 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)
  31758. * @param x defines x coordinate
  31759. * @param y defines y coordinate
  31760. * @param z defines z coordinate
  31761. * @returns the array of facet indexes
  31762. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31763. */
  31764. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31765. /**
  31766. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31767. * @param projected sets as the (x,y,z) world projection on the facet
  31768. * @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
  31769. * @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
  31770. * @param x defines x coordinate
  31771. * @param y defines y coordinate
  31772. * @param z defines z coordinate
  31773. * @returns the face index if found (or null instead)
  31774. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31775. */
  31776. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31777. /**
  31778. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31779. * @param projected sets as the (x,y,z) local projection on the facet
  31780. * @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
  31781. * @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
  31782. * @param x defines x coordinate
  31783. * @param y defines y coordinate
  31784. * @param z defines z coordinate
  31785. * @returns the face index if found (or null instead)
  31786. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31787. */
  31788. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31789. /**
  31790. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31791. * @returns the parameters
  31792. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31793. */
  31794. getFacetDataParameters(): any;
  31795. /**
  31796. * Disables the feature FacetData and frees the related memory
  31797. * @returns the current mesh
  31798. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31799. */
  31800. disableFacetData(): AbstractMesh;
  31801. /**
  31802. * Updates the AbstractMesh indices array
  31803. * @param indices defines the data source
  31804. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31805. * @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)
  31806. * @returns the current mesh
  31807. */
  31808. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31809. /**
  31810. * Creates new normals data for the mesh
  31811. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31812. * @returns the current mesh
  31813. */
  31814. createNormals(updatable: boolean): AbstractMesh;
  31815. /**
  31816. * Align the mesh with a normal
  31817. * @param normal defines the normal to use
  31818. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31819. * @returns the current mesh
  31820. */
  31821. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31822. /** @hidden */
  31823. _checkOcclusionQuery(): boolean;
  31824. /**
  31825. * Disables the mesh edge rendering mode
  31826. * @returns the currentAbstractMesh
  31827. */
  31828. disableEdgesRendering(): AbstractMesh;
  31829. /**
  31830. * Enables the edge rendering mode on the mesh.
  31831. * This mode makes the mesh edges visible
  31832. * @param epsilon defines the maximal distance between two angles to detect a face
  31833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31834. * @returns the currentAbstractMesh
  31835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31836. */
  31837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31838. /**
  31839. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31840. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31841. */
  31842. getConnectedParticleSystems(): IParticleSystem[];
  31843. }
  31844. }
  31845. declare module BABYLON {
  31846. /**
  31847. * Interface used to define ActionEvent
  31848. */
  31849. export interface IActionEvent {
  31850. /** The mesh or sprite that triggered the action */
  31851. source: any;
  31852. /** The X mouse cursor position at the time of the event */
  31853. pointerX: number;
  31854. /** The Y mouse cursor position at the time of the event */
  31855. pointerY: number;
  31856. /** The mesh that is currently pointed at (can be null) */
  31857. meshUnderPointer: Nullable<AbstractMesh>;
  31858. /** the original (browser) event that triggered the ActionEvent */
  31859. sourceEvent?: any;
  31860. /** additional data for the event */
  31861. additionalData?: any;
  31862. }
  31863. /**
  31864. * ActionEvent is the event being sent when an action is triggered.
  31865. */
  31866. export class ActionEvent implements IActionEvent {
  31867. /** The mesh or sprite that triggered the action */
  31868. source: any;
  31869. /** The X mouse cursor position at the time of the event */
  31870. pointerX: number;
  31871. /** The Y mouse cursor position at the time of the event */
  31872. pointerY: number;
  31873. /** The mesh that is currently pointed at (can be null) */
  31874. meshUnderPointer: Nullable<AbstractMesh>;
  31875. /** the original (browser) event that triggered the ActionEvent */
  31876. sourceEvent?: any;
  31877. /** additional data for the event */
  31878. additionalData?: any;
  31879. /**
  31880. * Creates a new ActionEvent
  31881. * @param source The mesh or sprite that triggered the action
  31882. * @param pointerX The X mouse cursor position at the time of the event
  31883. * @param pointerY The Y mouse cursor position at the time of the event
  31884. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31885. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31886. * @param additionalData additional data for the event
  31887. */
  31888. constructor(
  31889. /** The mesh or sprite that triggered the action */
  31890. source: any,
  31891. /** The X mouse cursor position at the time of the event */
  31892. pointerX: number,
  31893. /** The Y mouse cursor position at the time of the event */
  31894. pointerY: number,
  31895. /** The mesh that is currently pointed at (can be null) */
  31896. meshUnderPointer: Nullable<AbstractMesh>,
  31897. /** the original (browser) event that triggered the ActionEvent */
  31898. sourceEvent?: any,
  31899. /** additional data for the event */
  31900. additionalData?: any);
  31901. /**
  31902. * Helper function to auto-create an ActionEvent from a source mesh.
  31903. * @param source The source mesh that triggered the event
  31904. * @param evt The original (browser) event
  31905. * @param additionalData additional data for the event
  31906. * @returns the new ActionEvent
  31907. */
  31908. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31909. /**
  31910. * Helper function to auto-create an ActionEvent from a source sprite
  31911. * @param source The source sprite that triggered the event
  31912. * @param scene Scene associated with the sprite
  31913. * @param evt The original (browser) event
  31914. * @param additionalData additional data for the event
  31915. * @returns the new ActionEvent
  31916. */
  31917. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31918. /**
  31919. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31920. * @param scene the scene where the event occurred
  31921. * @param evt The original (browser) event
  31922. * @returns the new ActionEvent
  31923. */
  31924. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31925. /**
  31926. * Helper function to auto-create an ActionEvent from a primitive
  31927. * @param prim defines the target primitive
  31928. * @param pointerPos defines the pointer position
  31929. * @param evt The original (browser) event
  31930. * @param additionalData additional data for the event
  31931. * @returns the new ActionEvent
  31932. */
  31933. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31934. }
  31935. }
  31936. declare module BABYLON {
  31937. /**
  31938. * Abstract class used to decouple action Manager from scene and meshes.
  31939. * Do not instantiate.
  31940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31941. */
  31942. export abstract class AbstractActionManager implements IDisposable {
  31943. /** Gets the list of active triggers */
  31944. static Triggers: {
  31945. [key: string]: number;
  31946. };
  31947. /** Gets the cursor to use when hovering items */
  31948. hoverCursor: string;
  31949. /** Gets the list of actions */
  31950. actions: IAction[];
  31951. /**
  31952. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31953. */
  31954. isRecursive: boolean;
  31955. /**
  31956. * Releases all associated resources
  31957. */
  31958. abstract dispose(): void;
  31959. /**
  31960. * Does this action manager has pointer triggers
  31961. */
  31962. abstract get hasPointerTriggers(): boolean;
  31963. /**
  31964. * Does this action manager has pick triggers
  31965. */
  31966. abstract get hasPickTriggers(): boolean;
  31967. /**
  31968. * Process a specific trigger
  31969. * @param trigger defines the trigger to process
  31970. * @param evt defines the event details to be processed
  31971. */
  31972. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  31973. /**
  31974. * Does this action manager handles actions of any of the given triggers
  31975. * @param triggers defines the triggers to be tested
  31976. * @return a boolean indicating whether one (or more) of the triggers is handled
  31977. */
  31978. abstract hasSpecificTriggers(triggers: number[]): boolean;
  31979. /**
  31980. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  31981. * speed.
  31982. * @param triggerA defines the trigger to be tested
  31983. * @param triggerB defines the trigger to be tested
  31984. * @return a boolean indicating whether one (or more) of the triggers is handled
  31985. */
  31986. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  31987. /**
  31988. * Does this action manager handles actions of a given trigger
  31989. * @param trigger defines the trigger to be tested
  31990. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  31991. * @return whether the trigger is handled
  31992. */
  31993. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  31994. /**
  31995. * Serialize this manager to a JSON object
  31996. * @param name defines the property name to store this manager
  31997. * @returns a JSON representation of this manager
  31998. */
  31999. abstract serialize(name: string): any;
  32000. /**
  32001. * Registers an action to this action manager
  32002. * @param action defines the action to be registered
  32003. * @return the action amended (prepared) after registration
  32004. */
  32005. abstract registerAction(action: IAction): Nullable<IAction>;
  32006. /**
  32007. * Unregisters an action to this action manager
  32008. * @param action defines the action to be unregistered
  32009. * @return a boolean indicating whether the action has been unregistered
  32010. */
  32011. abstract unregisterAction(action: IAction): Boolean;
  32012. /**
  32013. * Does exist one action manager with at least one trigger
  32014. **/
  32015. static get HasTriggers(): boolean;
  32016. /**
  32017. * Does exist one action manager with at least one pick trigger
  32018. **/
  32019. static get HasPickTriggers(): boolean;
  32020. /**
  32021. * Does exist one action manager that handles actions of a given trigger
  32022. * @param trigger defines the trigger to be tested
  32023. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32024. **/
  32025. static HasSpecificTrigger(trigger: number): boolean;
  32026. }
  32027. }
  32028. declare module BABYLON {
  32029. /**
  32030. * Defines how a node can be built from a string name.
  32031. */
  32032. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32033. /**
  32034. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32035. */
  32036. export class Node implements IBehaviorAware<Node> {
  32037. /** @hidden */
  32038. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32039. private static _NodeConstructors;
  32040. /**
  32041. * Add a new node constructor
  32042. * @param type defines the type name of the node to construct
  32043. * @param constructorFunc defines the constructor function
  32044. */
  32045. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32046. /**
  32047. * Returns a node constructor based on type name
  32048. * @param type defines the type name
  32049. * @param name defines the new node name
  32050. * @param scene defines the hosting scene
  32051. * @param options defines optional options to transmit to constructors
  32052. * @returns the new constructor or null
  32053. */
  32054. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32055. /**
  32056. * Gets or sets the name of the node
  32057. */
  32058. name: string;
  32059. /**
  32060. * Gets or sets the id of the node
  32061. */
  32062. id: string;
  32063. /**
  32064. * Gets or sets the unique id of the node
  32065. */
  32066. uniqueId: number;
  32067. /**
  32068. * Gets or sets a string used to store user defined state for the node
  32069. */
  32070. state: string;
  32071. /**
  32072. * Gets or sets an object used to store user defined information for the node
  32073. */
  32074. metadata: any;
  32075. /**
  32076. * For internal use only. Please do not use.
  32077. */
  32078. reservedDataStore: any;
  32079. /**
  32080. * List of inspectable custom properties (used by the Inspector)
  32081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32082. */
  32083. inspectableCustomProperties: IInspectable[];
  32084. private _doNotSerialize;
  32085. /**
  32086. * Gets or sets a boolean used to define if the node must be serialized
  32087. */
  32088. get doNotSerialize(): boolean;
  32089. set doNotSerialize(value: boolean);
  32090. /** @hidden */
  32091. _isDisposed: boolean;
  32092. /**
  32093. * Gets a list of Animations associated with the node
  32094. */
  32095. animations: Animation[];
  32096. protected _ranges: {
  32097. [name: string]: Nullable<AnimationRange>;
  32098. };
  32099. /**
  32100. * Callback raised when the node is ready to be used
  32101. */
  32102. onReady: Nullable<(node: Node) => void>;
  32103. private _isEnabled;
  32104. private _isParentEnabled;
  32105. private _isReady;
  32106. /** @hidden */
  32107. _currentRenderId: number;
  32108. private _parentUpdateId;
  32109. /** @hidden */
  32110. _childUpdateId: number;
  32111. /** @hidden */
  32112. _waitingParentId: Nullable<string>;
  32113. /** @hidden */
  32114. _scene: Scene;
  32115. /** @hidden */
  32116. _cache: any;
  32117. private _parentNode;
  32118. private _children;
  32119. /** @hidden */
  32120. _worldMatrix: Matrix;
  32121. /** @hidden */
  32122. _worldMatrixDeterminant: number;
  32123. /** @hidden */
  32124. _worldMatrixDeterminantIsDirty: boolean;
  32125. /** @hidden */
  32126. private _sceneRootNodesIndex;
  32127. /**
  32128. * Gets a boolean indicating if the node has been disposed
  32129. * @returns true if the node was disposed
  32130. */
  32131. isDisposed(): boolean;
  32132. /**
  32133. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32134. * @see https://doc.babylonjs.com/how_to/parenting
  32135. */
  32136. set parent(parent: Nullable<Node>);
  32137. get parent(): Nullable<Node>;
  32138. /** @hidden */
  32139. _addToSceneRootNodes(): void;
  32140. /** @hidden */
  32141. _removeFromSceneRootNodes(): void;
  32142. private _animationPropertiesOverride;
  32143. /**
  32144. * Gets or sets the animation properties override
  32145. */
  32146. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32147. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32148. /**
  32149. * Gets a string idenfifying the name of the class
  32150. * @returns "Node" string
  32151. */
  32152. getClassName(): string;
  32153. /** @hidden */
  32154. readonly _isNode: boolean;
  32155. /**
  32156. * An event triggered when the mesh is disposed
  32157. */
  32158. onDisposeObservable: Observable<Node>;
  32159. private _onDisposeObserver;
  32160. /**
  32161. * Sets a callback that will be raised when the node will be disposed
  32162. */
  32163. set onDispose(callback: () => void);
  32164. /**
  32165. * Creates a new Node
  32166. * @param name the name and id to be given to this node
  32167. * @param scene the scene this node will be added to
  32168. */
  32169. constructor(name: string, scene?: Nullable<Scene>);
  32170. /**
  32171. * Gets the scene of the node
  32172. * @returns a scene
  32173. */
  32174. getScene(): Scene;
  32175. /**
  32176. * Gets the engine of the node
  32177. * @returns a Engine
  32178. */
  32179. getEngine(): Engine;
  32180. private _behaviors;
  32181. /**
  32182. * Attach a behavior to the node
  32183. * @see https://doc.babylonjs.com/features/behaviour
  32184. * @param behavior defines the behavior to attach
  32185. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32186. * @returns the current Node
  32187. */
  32188. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32189. /**
  32190. * Remove an attached behavior
  32191. * @see https://doc.babylonjs.com/features/behaviour
  32192. * @param behavior defines the behavior to attach
  32193. * @returns the current Node
  32194. */
  32195. removeBehavior(behavior: Behavior<Node>): Node;
  32196. /**
  32197. * Gets the list of attached behaviors
  32198. * @see https://doc.babylonjs.com/features/behaviour
  32199. */
  32200. get behaviors(): Behavior<Node>[];
  32201. /**
  32202. * Gets an attached behavior by name
  32203. * @param name defines the name of the behavior to look for
  32204. * @see https://doc.babylonjs.com/features/behaviour
  32205. * @returns null if behavior was not found else the requested behavior
  32206. */
  32207. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32208. /**
  32209. * Returns the latest update of the World matrix
  32210. * @returns a Matrix
  32211. */
  32212. getWorldMatrix(): Matrix;
  32213. /** @hidden */
  32214. _getWorldMatrixDeterminant(): number;
  32215. /**
  32216. * Returns directly the latest state of the mesh World matrix.
  32217. * A Matrix is returned.
  32218. */
  32219. get worldMatrixFromCache(): Matrix;
  32220. /** @hidden */
  32221. _initCache(): void;
  32222. /** @hidden */
  32223. updateCache(force?: boolean): void;
  32224. /** @hidden */
  32225. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32226. /** @hidden */
  32227. _updateCache(ignoreParentClass?: boolean): void;
  32228. /** @hidden */
  32229. _isSynchronized(): boolean;
  32230. /** @hidden */
  32231. _markSyncedWithParent(): void;
  32232. /** @hidden */
  32233. isSynchronizedWithParent(): boolean;
  32234. /** @hidden */
  32235. isSynchronized(): boolean;
  32236. /**
  32237. * Is this node ready to be used/rendered
  32238. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32239. * @return true if the node is ready
  32240. */
  32241. isReady(completeCheck?: boolean): boolean;
  32242. /**
  32243. * Is this node enabled?
  32244. * 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
  32245. * @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
  32246. * @return whether this node (and its parent) is enabled
  32247. */
  32248. isEnabled(checkAncestors?: boolean): boolean;
  32249. /** @hidden */
  32250. protected _syncParentEnabledState(): void;
  32251. /**
  32252. * Set the enabled state of this node
  32253. * @param value defines the new enabled state
  32254. */
  32255. setEnabled(value: boolean): void;
  32256. /**
  32257. * Is this node a descendant of the given node?
  32258. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32259. * @param ancestor defines the parent node to inspect
  32260. * @returns a boolean indicating if this node is a descendant of the given node
  32261. */
  32262. isDescendantOf(ancestor: Node): boolean;
  32263. /** @hidden */
  32264. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32265. /**
  32266. * Will return all nodes that have this node as ascendant
  32267. * @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
  32268. * @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
  32269. * @return all children nodes of all types
  32270. */
  32271. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32272. /**
  32273. * Get all child-meshes of this node
  32274. * @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)
  32275. * @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
  32276. * @returns an array of AbstractMesh
  32277. */
  32278. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32279. /**
  32280. * Get all direct children of this node
  32281. * @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
  32282. * @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)
  32283. * @returns an array of Node
  32284. */
  32285. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32286. /** @hidden */
  32287. _setReady(state: boolean): void;
  32288. /**
  32289. * Get an animation by name
  32290. * @param name defines the name of the animation to look for
  32291. * @returns null if not found else the requested animation
  32292. */
  32293. getAnimationByName(name: string): Nullable<Animation>;
  32294. /**
  32295. * Creates an animation range for this node
  32296. * @param name defines the name of the range
  32297. * @param from defines the starting key
  32298. * @param to defines the end key
  32299. */
  32300. createAnimationRange(name: string, from: number, to: number): void;
  32301. /**
  32302. * Delete a specific animation range
  32303. * @param name defines the name of the range to delete
  32304. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32305. */
  32306. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32307. /**
  32308. * Get an animation range by name
  32309. * @param name defines the name of the animation range to look for
  32310. * @returns null if not found else the requested animation range
  32311. */
  32312. getAnimationRange(name: string): Nullable<AnimationRange>;
  32313. /**
  32314. * Gets the list of all animation ranges defined on this node
  32315. * @returns an array
  32316. */
  32317. getAnimationRanges(): Nullable<AnimationRange>[];
  32318. /**
  32319. * Will start the animation sequence
  32320. * @param name defines the range frames for animation sequence
  32321. * @param loop defines if the animation should loop (false by default)
  32322. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32323. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32324. * @returns the object created for this animation. If range does not exist, it will return null
  32325. */
  32326. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32327. /**
  32328. * Serialize animation ranges into a JSON compatible object
  32329. * @returns serialization object
  32330. */
  32331. serializeAnimationRanges(): any;
  32332. /**
  32333. * Computes the world matrix of the node
  32334. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32335. * @returns the world matrix
  32336. */
  32337. computeWorldMatrix(force?: boolean): Matrix;
  32338. /**
  32339. * Releases resources associated with this node.
  32340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32342. */
  32343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32344. /**
  32345. * Parse animation range data from a serialization object and store them into a given node
  32346. * @param node defines where to store the animation ranges
  32347. * @param parsedNode defines the serialization object to read data from
  32348. * @param scene defines the hosting scene
  32349. */
  32350. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32351. /**
  32352. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32353. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32354. * @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
  32355. * @returns the new bounding vectors
  32356. */
  32357. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32358. min: Vector3;
  32359. max: Vector3;
  32360. };
  32361. }
  32362. }
  32363. declare module BABYLON {
  32364. /**
  32365. * @hidden
  32366. */
  32367. export class _IAnimationState {
  32368. key: number;
  32369. repeatCount: number;
  32370. workValue?: any;
  32371. loopMode?: number;
  32372. offsetValue?: any;
  32373. highLimitValue?: any;
  32374. }
  32375. /**
  32376. * Class used to store any kind of animation
  32377. */
  32378. export class Animation {
  32379. /**Name of the animation */
  32380. name: string;
  32381. /**Property to animate */
  32382. targetProperty: string;
  32383. /**The frames per second of the animation */
  32384. framePerSecond: number;
  32385. /**The data type of the animation */
  32386. dataType: number;
  32387. /**The loop mode of the animation */
  32388. loopMode?: number | undefined;
  32389. /**Specifies if blending should be enabled */
  32390. enableBlending?: boolean | undefined;
  32391. /**
  32392. * Use matrix interpolation instead of using direct key value when animating matrices
  32393. */
  32394. static AllowMatricesInterpolation: boolean;
  32395. /**
  32396. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32397. */
  32398. static AllowMatrixDecomposeForInterpolation: boolean;
  32399. /** Define the Url to load snippets */
  32400. static SnippetUrl: string;
  32401. /** Snippet ID if the animation was created from the snippet server */
  32402. snippetId: string;
  32403. /**
  32404. * Stores the key frames of the animation
  32405. */
  32406. private _keys;
  32407. /**
  32408. * Stores the easing function of the animation
  32409. */
  32410. private _easingFunction;
  32411. /**
  32412. * @hidden Internal use only
  32413. */
  32414. _runtimeAnimations: RuntimeAnimation[];
  32415. /**
  32416. * The set of event that will be linked to this animation
  32417. */
  32418. private _events;
  32419. /**
  32420. * Stores an array of target property paths
  32421. */
  32422. targetPropertyPath: string[];
  32423. /**
  32424. * Stores the blending speed of the animation
  32425. */
  32426. blendingSpeed: number;
  32427. /**
  32428. * Stores the animation ranges for the animation
  32429. */
  32430. private _ranges;
  32431. /**
  32432. * @hidden Internal use
  32433. */
  32434. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32435. /**
  32436. * Sets up an animation
  32437. * @param property The property to animate
  32438. * @param animationType The animation type to apply
  32439. * @param framePerSecond The frames per second of the animation
  32440. * @param easingFunction The easing function used in the animation
  32441. * @returns The created animation
  32442. */
  32443. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32444. /**
  32445. * Create and start an animation on a node
  32446. * @param name defines the name of the global animation that will be run on all nodes
  32447. * @param node defines the root node where the animation will take place
  32448. * @param targetProperty defines property to animate
  32449. * @param framePerSecond defines the number of frame per second yo use
  32450. * @param totalFrame defines the number of frames in total
  32451. * @param from defines the initial value
  32452. * @param to defines the final value
  32453. * @param loopMode defines which loop mode you want to use (off by default)
  32454. * @param easingFunction defines the easing function to use (linear by default)
  32455. * @param onAnimationEnd defines the callback to call when animation end
  32456. * @returns the animatable created for this animation
  32457. */
  32458. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32459. /**
  32460. * Create and start an animation on a node and its descendants
  32461. * @param name defines the name of the global animation that will be run on all nodes
  32462. * @param node defines the root node where the animation will take place
  32463. * @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
  32464. * @param targetProperty defines property to animate
  32465. * @param framePerSecond defines the number of frame per second to use
  32466. * @param totalFrame defines the number of frames in total
  32467. * @param from defines the initial value
  32468. * @param to defines the final value
  32469. * @param loopMode defines which loop mode you want to use (off by default)
  32470. * @param easingFunction defines the easing function to use (linear by default)
  32471. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32472. * @returns the list of animatables created for all nodes
  32473. * @example https://www.babylonjs-playground.com/#MH0VLI
  32474. */
  32475. 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[]>;
  32476. /**
  32477. * Creates a new animation, merges it with the existing animations and starts it
  32478. * @param name Name of the animation
  32479. * @param node Node which contains the scene that begins the animations
  32480. * @param targetProperty Specifies which property to animate
  32481. * @param framePerSecond The frames per second of the animation
  32482. * @param totalFrame The total number of frames
  32483. * @param from The frame at the beginning of the animation
  32484. * @param to The frame at the end of the animation
  32485. * @param loopMode Specifies the loop mode of the animation
  32486. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32487. * @param onAnimationEnd Callback to run once the animation is complete
  32488. * @returns Nullable animation
  32489. */
  32490. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32491. /**
  32492. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32493. * @param sourceAnimation defines the Animation containing keyframes to convert
  32494. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32495. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32496. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32497. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32498. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32499. */
  32500. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32501. /**
  32502. * Transition property of an host to the target Value
  32503. * @param property The property to transition
  32504. * @param targetValue The target Value of the property
  32505. * @param host The object where the property to animate belongs
  32506. * @param scene Scene used to run the animation
  32507. * @param frameRate Framerate (in frame/s) to use
  32508. * @param transition The transition type we want to use
  32509. * @param duration The duration of the animation, in milliseconds
  32510. * @param onAnimationEnd Callback trigger at the end of the animation
  32511. * @returns Nullable animation
  32512. */
  32513. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32514. /**
  32515. * Return the array of runtime animations currently using this animation
  32516. */
  32517. get runtimeAnimations(): RuntimeAnimation[];
  32518. /**
  32519. * Specifies if any of the runtime animations are currently running
  32520. */
  32521. get hasRunningRuntimeAnimations(): boolean;
  32522. /**
  32523. * Initializes the animation
  32524. * @param name Name of the animation
  32525. * @param targetProperty Property to animate
  32526. * @param framePerSecond The frames per second of the animation
  32527. * @param dataType The data type of the animation
  32528. * @param loopMode The loop mode of the animation
  32529. * @param enableBlending Specifies if blending should be enabled
  32530. */
  32531. constructor(
  32532. /**Name of the animation */
  32533. name: string,
  32534. /**Property to animate */
  32535. targetProperty: string,
  32536. /**The frames per second of the animation */
  32537. framePerSecond: number,
  32538. /**The data type of the animation */
  32539. dataType: number,
  32540. /**The loop mode of the animation */
  32541. loopMode?: number | undefined,
  32542. /**Specifies if blending should be enabled */
  32543. enableBlending?: boolean | undefined);
  32544. /**
  32545. * Converts the animation to a string
  32546. * @param fullDetails support for multiple levels of logging within scene loading
  32547. * @returns String form of the animation
  32548. */
  32549. toString(fullDetails?: boolean): string;
  32550. /**
  32551. * Add an event to this animation
  32552. * @param event Event to add
  32553. */
  32554. addEvent(event: AnimationEvent): void;
  32555. /**
  32556. * Remove all events found at the given frame
  32557. * @param frame The frame to remove events from
  32558. */
  32559. removeEvents(frame: number): void;
  32560. /**
  32561. * Retrieves all the events from the animation
  32562. * @returns Events from the animation
  32563. */
  32564. getEvents(): AnimationEvent[];
  32565. /**
  32566. * Creates an animation range
  32567. * @param name Name of the animation range
  32568. * @param from Starting frame of the animation range
  32569. * @param to Ending frame of the animation
  32570. */
  32571. createRange(name: string, from: number, to: number): void;
  32572. /**
  32573. * Deletes an animation range by name
  32574. * @param name Name of the animation range to delete
  32575. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32576. */
  32577. deleteRange(name: string, deleteFrames?: boolean): void;
  32578. /**
  32579. * Gets the animation range by name, or null if not defined
  32580. * @param name Name of the animation range
  32581. * @returns Nullable animation range
  32582. */
  32583. getRange(name: string): Nullable<AnimationRange>;
  32584. /**
  32585. * Gets the key frames from the animation
  32586. * @returns The key frames of the animation
  32587. */
  32588. getKeys(): Array<IAnimationKey>;
  32589. /**
  32590. * Gets the highest frame rate of the animation
  32591. * @returns Highest frame rate of the animation
  32592. */
  32593. getHighestFrame(): number;
  32594. /**
  32595. * Gets the easing function of the animation
  32596. * @returns Easing function of the animation
  32597. */
  32598. getEasingFunction(): IEasingFunction;
  32599. /**
  32600. * Sets the easing function of the animation
  32601. * @param easingFunction A custom mathematical formula for animation
  32602. */
  32603. setEasingFunction(easingFunction: EasingFunction): void;
  32604. /**
  32605. * Interpolates a scalar linearly
  32606. * @param startValue Start value of the animation curve
  32607. * @param endValue End value of the animation curve
  32608. * @param gradient Scalar amount to interpolate
  32609. * @returns Interpolated scalar value
  32610. */
  32611. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32612. /**
  32613. * Interpolates a scalar cubically
  32614. * @param startValue Start value of the animation curve
  32615. * @param outTangent End tangent of the animation
  32616. * @param endValue End value of the animation curve
  32617. * @param inTangent Start tangent of the animation curve
  32618. * @param gradient Scalar amount to interpolate
  32619. * @returns Interpolated scalar value
  32620. */
  32621. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32622. /**
  32623. * Interpolates a quaternion using a spherical linear interpolation
  32624. * @param startValue Start value of the animation curve
  32625. * @param endValue End value of the animation curve
  32626. * @param gradient Scalar amount to interpolate
  32627. * @returns Interpolated quaternion value
  32628. */
  32629. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32630. /**
  32631. * Interpolates a quaternion cubically
  32632. * @param startValue Start value of the animation curve
  32633. * @param outTangent End tangent of the animation curve
  32634. * @param endValue End value of the animation curve
  32635. * @param inTangent Start tangent of the animation curve
  32636. * @param gradient Scalar amount to interpolate
  32637. * @returns Interpolated quaternion value
  32638. */
  32639. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32640. /**
  32641. * Interpolates a Vector3 linearl
  32642. * @param startValue Start value of the animation curve
  32643. * @param endValue End value of the animation curve
  32644. * @param gradient Scalar amount to interpolate
  32645. * @returns Interpolated scalar value
  32646. */
  32647. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32648. /**
  32649. * Interpolates a Vector3 cubically
  32650. * @param startValue Start value of the animation curve
  32651. * @param outTangent End tangent of the animation
  32652. * @param endValue End value of the animation curve
  32653. * @param inTangent Start tangent of the animation curve
  32654. * @param gradient Scalar amount to interpolate
  32655. * @returns InterpolatedVector3 value
  32656. */
  32657. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32658. /**
  32659. * Interpolates a Vector2 linearly
  32660. * @param startValue Start value of the animation curve
  32661. * @param endValue End value of the animation curve
  32662. * @param gradient Scalar amount to interpolate
  32663. * @returns Interpolated Vector2 value
  32664. */
  32665. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32666. /**
  32667. * Interpolates a Vector2 cubically
  32668. * @param startValue Start value of the animation curve
  32669. * @param outTangent End tangent of the animation
  32670. * @param endValue End value of the animation curve
  32671. * @param inTangent Start tangent of the animation curve
  32672. * @param gradient Scalar amount to interpolate
  32673. * @returns Interpolated Vector2 value
  32674. */
  32675. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32676. /**
  32677. * Interpolates a size linearly
  32678. * @param startValue Start value of the animation curve
  32679. * @param endValue End value of the animation curve
  32680. * @param gradient Scalar amount to interpolate
  32681. * @returns Interpolated Size value
  32682. */
  32683. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32684. /**
  32685. * Interpolates a Color3 linearly
  32686. * @param startValue Start value of the animation curve
  32687. * @param endValue End value of the animation curve
  32688. * @param gradient Scalar amount to interpolate
  32689. * @returns Interpolated Color3 value
  32690. */
  32691. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32692. /**
  32693. * Interpolates a Color4 linearly
  32694. * @param startValue Start value of the animation curve
  32695. * @param endValue End value of the animation curve
  32696. * @param gradient Scalar amount to interpolate
  32697. * @returns Interpolated Color3 value
  32698. */
  32699. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32700. /**
  32701. * @hidden Internal use only
  32702. */
  32703. _getKeyValue(value: any): any;
  32704. /**
  32705. * @hidden Internal use only
  32706. */
  32707. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32708. /**
  32709. * Defines the function to use to interpolate matrices
  32710. * @param startValue defines the start matrix
  32711. * @param endValue defines the end matrix
  32712. * @param gradient defines the gradient between both matrices
  32713. * @param result defines an optional target matrix where to store the interpolation
  32714. * @returns the interpolated matrix
  32715. */
  32716. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32717. /**
  32718. * Makes a copy of the animation
  32719. * @returns Cloned animation
  32720. */
  32721. clone(): Animation;
  32722. /**
  32723. * Sets the key frames of the animation
  32724. * @param values The animation key frames to set
  32725. */
  32726. setKeys(values: Array<IAnimationKey>): void;
  32727. /**
  32728. * Serializes the animation to an object
  32729. * @returns Serialized object
  32730. */
  32731. serialize(): any;
  32732. /**
  32733. * Float animation type
  32734. */
  32735. static readonly ANIMATIONTYPE_FLOAT: number;
  32736. /**
  32737. * Vector3 animation type
  32738. */
  32739. static readonly ANIMATIONTYPE_VECTOR3: number;
  32740. /**
  32741. * Quaternion animation type
  32742. */
  32743. static readonly ANIMATIONTYPE_QUATERNION: number;
  32744. /**
  32745. * Matrix animation type
  32746. */
  32747. static readonly ANIMATIONTYPE_MATRIX: number;
  32748. /**
  32749. * Color3 animation type
  32750. */
  32751. static readonly ANIMATIONTYPE_COLOR3: number;
  32752. /**
  32753. * Color3 animation type
  32754. */
  32755. static readonly ANIMATIONTYPE_COLOR4: number;
  32756. /**
  32757. * Vector2 animation type
  32758. */
  32759. static readonly ANIMATIONTYPE_VECTOR2: number;
  32760. /**
  32761. * Size animation type
  32762. */
  32763. static readonly ANIMATIONTYPE_SIZE: number;
  32764. /**
  32765. * Relative Loop Mode
  32766. */
  32767. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32768. /**
  32769. * Cycle Loop Mode
  32770. */
  32771. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32772. /**
  32773. * Constant Loop Mode
  32774. */
  32775. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32776. /** @hidden */
  32777. static _UniversalLerp(left: any, right: any, amount: number): any;
  32778. /**
  32779. * Parses an animation object and creates an animation
  32780. * @param parsedAnimation Parsed animation object
  32781. * @returns Animation object
  32782. */
  32783. static Parse(parsedAnimation: any): Animation;
  32784. /**
  32785. * Appends the serialized animations from the source animations
  32786. * @param source Source containing the animations
  32787. * @param destination Target to store the animations
  32788. */
  32789. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32790. /**
  32791. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32792. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32793. * @param url defines the url to load from
  32794. * @returns a promise that will resolve to the new animation or an array of animations
  32795. */
  32796. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32797. /**
  32798. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32799. * @param snippetId defines the snippet to load
  32800. * @returns a promise that will resolve to the new animation or a new array of animations
  32801. */
  32802. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32803. }
  32804. }
  32805. declare module BABYLON {
  32806. /**
  32807. * Interface containing an array of animations
  32808. */
  32809. export interface IAnimatable {
  32810. /**
  32811. * Array of animations
  32812. */
  32813. animations: Nullable<Array<Animation>>;
  32814. }
  32815. }
  32816. declare module BABYLON {
  32817. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32818. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32819. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32820. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32821. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32822. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32823. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32824. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32825. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32826. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32827. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32828. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32829. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32830. /**
  32831. * Decorator used to define property that can be serialized as reference to a camera
  32832. * @param sourceName defines the name of the property to decorate
  32833. */
  32834. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32835. /**
  32836. * Class used to help serialization objects
  32837. */
  32838. export class SerializationHelper {
  32839. /** @hidden */
  32840. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32841. /** @hidden */
  32842. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32843. /** @hidden */
  32844. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32845. /** @hidden */
  32846. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32847. /**
  32848. * Appends the serialized animations from the source animations
  32849. * @param source Source containing the animations
  32850. * @param destination Target to store the animations
  32851. */
  32852. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32853. /**
  32854. * Static function used to serialized a specific entity
  32855. * @param entity defines the entity to serialize
  32856. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32857. * @returns a JSON compatible object representing the serialization of the entity
  32858. */
  32859. static Serialize<T>(entity: T, serializationObject?: any): any;
  32860. /**
  32861. * Creates a new entity from a serialization data object
  32862. * @param creationFunction defines a function used to instanciated the new entity
  32863. * @param source defines the source serialization data
  32864. * @param scene defines the hosting scene
  32865. * @param rootUrl defines the root url for resources
  32866. * @returns a new entity
  32867. */
  32868. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32869. /**
  32870. * Clones an object
  32871. * @param creationFunction defines the function used to instanciate the new object
  32872. * @param source defines the source object
  32873. * @returns the cloned object
  32874. */
  32875. static Clone<T>(creationFunction: () => T, source: T): T;
  32876. /**
  32877. * Instanciates a new object based on a source one (some data will be shared between both object)
  32878. * @param creationFunction defines the function used to instanciate the new object
  32879. * @param source defines the source object
  32880. * @returns the new object
  32881. */
  32882. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32883. }
  32884. }
  32885. declare module BABYLON {
  32886. /**
  32887. * Base class of all the textures in babylon.
  32888. * It groups all the common properties the materials, post process, lights... might need
  32889. * in order to make a correct use of the texture.
  32890. */
  32891. export class BaseTexture implements IAnimatable {
  32892. /**
  32893. * Default anisotropic filtering level for the application.
  32894. * It is set to 4 as a good tradeoff between perf and quality.
  32895. */
  32896. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32897. /**
  32898. * Gets or sets the unique id of the texture
  32899. */
  32900. uniqueId: number;
  32901. /**
  32902. * Define the name of the texture.
  32903. */
  32904. name: string;
  32905. /**
  32906. * Gets or sets an object used to store user defined information.
  32907. */
  32908. metadata: any;
  32909. /**
  32910. * For internal use only. Please do not use.
  32911. */
  32912. reservedDataStore: any;
  32913. private _hasAlpha;
  32914. /**
  32915. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32916. */
  32917. set hasAlpha(value: boolean);
  32918. get hasAlpha(): boolean;
  32919. /**
  32920. * Defines if the alpha value should be determined via the rgb values.
  32921. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32922. */
  32923. getAlphaFromRGB: boolean;
  32924. /**
  32925. * Intensity or strength of the texture.
  32926. * It is commonly used by materials to fine tune the intensity of the texture
  32927. */
  32928. level: number;
  32929. /**
  32930. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32931. * This is part of the texture as textures usually maps to one uv set.
  32932. */
  32933. coordinatesIndex: number;
  32934. private _coordinatesMode;
  32935. /**
  32936. * How a texture is mapped.
  32937. *
  32938. * | Value | Type | Description |
  32939. * | ----- | ----------------------------------- | ----------- |
  32940. * | 0 | EXPLICIT_MODE | |
  32941. * | 1 | SPHERICAL_MODE | |
  32942. * | 2 | PLANAR_MODE | |
  32943. * | 3 | CUBIC_MODE | |
  32944. * | 4 | PROJECTION_MODE | |
  32945. * | 5 | SKYBOX_MODE | |
  32946. * | 6 | INVCUBIC_MODE | |
  32947. * | 7 | EQUIRECTANGULAR_MODE | |
  32948. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32949. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32950. */
  32951. set coordinatesMode(value: number);
  32952. get coordinatesMode(): number;
  32953. /**
  32954. * | Value | Type | Description |
  32955. * | ----- | ------------------ | ----------- |
  32956. * | 0 | CLAMP_ADDRESSMODE | |
  32957. * | 1 | WRAP_ADDRESSMODE | |
  32958. * | 2 | MIRROR_ADDRESSMODE | |
  32959. */
  32960. wrapU: number;
  32961. /**
  32962. * | Value | Type | Description |
  32963. * | ----- | ------------------ | ----------- |
  32964. * | 0 | CLAMP_ADDRESSMODE | |
  32965. * | 1 | WRAP_ADDRESSMODE | |
  32966. * | 2 | MIRROR_ADDRESSMODE | |
  32967. */
  32968. wrapV: number;
  32969. /**
  32970. * | Value | Type | Description |
  32971. * | ----- | ------------------ | ----------- |
  32972. * | 0 | CLAMP_ADDRESSMODE | |
  32973. * | 1 | WRAP_ADDRESSMODE | |
  32974. * | 2 | MIRROR_ADDRESSMODE | |
  32975. */
  32976. wrapR: number;
  32977. /**
  32978. * With compliant hardware and browser (supporting anisotropic filtering)
  32979. * this defines the level of anisotropic filtering in the texture.
  32980. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  32981. */
  32982. anisotropicFilteringLevel: number;
  32983. /**
  32984. * Define if the texture is a cube texture or if false a 2d texture.
  32985. */
  32986. get isCube(): boolean;
  32987. set isCube(value: boolean);
  32988. /**
  32989. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  32990. */
  32991. get is3D(): boolean;
  32992. set is3D(value: boolean);
  32993. /**
  32994. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  32995. */
  32996. get is2DArray(): boolean;
  32997. set is2DArray(value: boolean);
  32998. /**
  32999. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33000. * HDR texture are usually stored in linear space.
  33001. * This only impacts the PBR and Background materials
  33002. */
  33003. gammaSpace: boolean;
  33004. /**
  33005. * Gets or sets whether or not the texture contains RGBD data.
  33006. */
  33007. get isRGBD(): boolean;
  33008. set isRGBD(value: boolean);
  33009. /**
  33010. * Is Z inverted in the texture (useful in a cube texture).
  33011. */
  33012. invertZ: boolean;
  33013. /**
  33014. * Are mip maps generated for this texture or not.
  33015. */
  33016. get noMipmap(): boolean;
  33017. /**
  33018. * @hidden
  33019. */
  33020. lodLevelInAlpha: boolean;
  33021. /**
  33022. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33023. */
  33024. get lodGenerationOffset(): number;
  33025. set lodGenerationOffset(value: number);
  33026. /**
  33027. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33028. */
  33029. get lodGenerationScale(): number;
  33030. set lodGenerationScale(value: number);
  33031. /**
  33032. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33033. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33034. * average roughness values.
  33035. */
  33036. get linearSpecularLOD(): boolean;
  33037. set linearSpecularLOD(value: boolean);
  33038. /**
  33039. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33040. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33041. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33042. */
  33043. get irradianceTexture(): Nullable<BaseTexture>;
  33044. set irradianceTexture(value: Nullable<BaseTexture>);
  33045. /**
  33046. * Define if the texture is a render target.
  33047. */
  33048. isRenderTarget: boolean;
  33049. /**
  33050. * Define the unique id of the texture in the scene.
  33051. */
  33052. get uid(): string;
  33053. /** @hidden */
  33054. _prefiltered: boolean;
  33055. /**
  33056. * Return a string representation of the texture.
  33057. * @returns the texture as a string
  33058. */
  33059. toString(): string;
  33060. /**
  33061. * Get the class name of the texture.
  33062. * @returns "BaseTexture"
  33063. */
  33064. getClassName(): string;
  33065. /**
  33066. * Define the list of animation attached to the texture.
  33067. */
  33068. animations: Animation[];
  33069. /**
  33070. * An event triggered when the texture is disposed.
  33071. */
  33072. onDisposeObservable: Observable<BaseTexture>;
  33073. private _onDisposeObserver;
  33074. /**
  33075. * Callback triggered when the texture has been disposed.
  33076. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33077. */
  33078. set onDispose(callback: () => void);
  33079. /**
  33080. * Define the current state of the loading sequence when in delayed load mode.
  33081. */
  33082. delayLoadState: number;
  33083. private _scene;
  33084. private _engine;
  33085. /** @hidden */
  33086. _texture: Nullable<InternalTexture>;
  33087. private _uid;
  33088. /**
  33089. * Define if the texture is preventinga material to render or not.
  33090. * If not and the texture is not ready, the engine will use a default black texture instead.
  33091. */
  33092. get isBlocking(): boolean;
  33093. /**
  33094. * Instantiates a new BaseTexture.
  33095. * Base class of all the textures in babylon.
  33096. * It groups all the common properties the materials, post process, lights... might need
  33097. * in order to make a correct use of the texture.
  33098. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33099. */
  33100. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33101. /**
  33102. * Get the scene the texture belongs to.
  33103. * @returns the scene or null if undefined
  33104. */
  33105. getScene(): Nullable<Scene>;
  33106. /** @hidden */
  33107. protected _getEngine(): Nullable<ThinEngine>;
  33108. /**
  33109. * Get the texture transform matrix used to offset tile the texture for istance.
  33110. * @returns the transformation matrix
  33111. */
  33112. getTextureMatrix(): Matrix;
  33113. /**
  33114. * Get the texture reflection matrix used to rotate/transform the reflection.
  33115. * @returns the reflection matrix
  33116. */
  33117. getReflectionTextureMatrix(): Matrix;
  33118. /**
  33119. * Get the underlying lower level texture from Babylon.
  33120. * @returns the insternal texture
  33121. */
  33122. getInternalTexture(): Nullable<InternalTexture>;
  33123. /**
  33124. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33125. * @returns true if ready or not blocking
  33126. */
  33127. isReadyOrNotBlocking(): boolean;
  33128. /**
  33129. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33130. * @returns true if fully ready
  33131. */
  33132. isReady(): boolean;
  33133. private _cachedSize;
  33134. /**
  33135. * Get the size of the texture.
  33136. * @returns the texture size.
  33137. */
  33138. getSize(): ISize;
  33139. /**
  33140. * Get the base size of the texture.
  33141. * It can be different from the size if the texture has been resized for POT for instance
  33142. * @returns the base size
  33143. */
  33144. getBaseSize(): ISize;
  33145. /**
  33146. * Update the sampling mode of the texture.
  33147. * Default is Trilinear mode.
  33148. *
  33149. * | Value | Type | Description |
  33150. * | ----- | ------------------ | ----------- |
  33151. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33152. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33153. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33154. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33155. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33156. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33157. * | 7 | NEAREST_LINEAR | |
  33158. * | 8 | NEAREST_NEAREST | |
  33159. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33160. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33161. * | 11 | LINEAR_LINEAR | |
  33162. * | 12 | LINEAR_NEAREST | |
  33163. *
  33164. * > _mag_: magnification filter (close to the viewer)
  33165. * > _min_: minification filter (far from the viewer)
  33166. * > _mip_: filter used between mip map levels
  33167. *@param samplingMode Define the new sampling mode of the texture
  33168. */
  33169. updateSamplingMode(samplingMode: number): void;
  33170. /**
  33171. * Scales the texture if is `canRescale()`
  33172. * @param ratio the resize factor we want to use to rescale
  33173. */
  33174. scale(ratio: number): void;
  33175. /**
  33176. * Get if the texture can rescale.
  33177. */
  33178. get canRescale(): boolean;
  33179. /** @hidden */
  33180. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33181. /** @hidden */
  33182. _rebuild(): void;
  33183. /**
  33184. * Triggers the load sequence in delayed load mode.
  33185. */
  33186. delayLoad(): void;
  33187. /**
  33188. * Clones the texture.
  33189. * @returns the cloned texture
  33190. */
  33191. clone(): Nullable<BaseTexture>;
  33192. /**
  33193. * Get the texture underlying type (INT, FLOAT...)
  33194. */
  33195. get textureType(): number;
  33196. /**
  33197. * Get the texture underlying format (RGB, RGBA...)
  33198. */
  33199. get textureFormat(): number;
  33200. /**
  33201. * Indicates that textures need to be re-calculated for all materials
  33202. */
  33203. protected _markAllSubMeshesAsTexturesDirty(): void;
  33204. /**
  33205. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33206. * This will returns an RGBA array buffer containing either in values (0-255) or
  33207. * float values (0-1) depending of the underlying buffer type.
  33208. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33209. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33210. * @param buffer defines a user defined buffer to fill with data (can be null)
  33211. * @returns The Array buffer containing the pixels data.
  33212. */
  33213. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33214. /**
  33215. * Release and destroy the underlying lower level texture aka internalTexture.
  33216. */
  33217. releaseInternalTexture(): void;
  33218. /** @hidden */
  33219. get _lodTextureHigh(): Nullable<BaseTexture>;
  33220. /** @hidden */
  33221. get _lodTextureMid(): Nullable<BaseTexture>;
  33222. /** @hidden */
  33223. get _lodTextureLow(): Nullable<BaseTexture>;
  33224. /**
  33225. * Dispose the texture and release its associated resources.
  33226. */
  33227. dispose(): void;
  33228. /**
  33229. * Serialize the texture into a JSON representation that can be parsed later on.
  33230. * @returns the JSON representation of the texture
  33231. */
  33232. serialize(): any;
  33233. /**
  33234. * Helper function to be called back once a list of texture contains only ready textures.
  33235. * @param textures Define the list of textures to wait for
  33236. * @param callback Define the callback triggered once the entire list will be ready
  33237. */
  33238. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33239. private static _isScene;
  33240. }
  33241. }
  33242. declare module BABYLON {
  33243. /**
  33244. * Options to be used when creating an effect.
  33245. */
  33246. export interface IEffectCreationOptions {
  33247. /**
  33248. * Atrributes that will be used in the shader.
  33249. */
  33250. attributes: string[];
  33251. /**
  33252. * Uniform varible names that will be set in the shader.
  33253. */
  33254. uniformsNames: string[];
  33255. /**
  33256. * Uniform buffer variable names that will be set in the shader.
  33257. */
  33258. uniformBuffersNames: string[];
  33259. /**
  33260. * Sampler texture variable names that will be set in the shader.
  33261. */
  33262. samplers: string[];
  33263. /**
  33264. * Define statements that will be set in the shader.
  33265. */
  33266. defines: any;
  33267. /**
  33268. * Possible fallbacks for this effect to improve performance when needed.
  33269. */
  33270. fallbacks: Nullable<IEffectFallbacks>;
  33271. /**
  33272. * Callback that will be called when the shader is compiled.
  33273. */
  33274. onCompiled: Nullable<(effect: Effect) => void>;
  33275. /**
  33276. * Callback that will be called if an error occurs during shader compilation.
  33277. */
  33278. onError: Nullable<(effect: Effect, errors: string) => void>;
  33279. /**
  33280. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33281. */
  33282. indexParameters?: any;
  33283. /**
  33284. * Max number of lights that can be used in the shader.
  33285. */
  33286. maxSimultaneousLights?: number;
  33287. /**
  33288. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33289. */
  33290. transformFeedbackVaryings?: Nullable<string[]>;
  33291. /**
  33292. * 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
  33293. */
  33294. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33295. /**
  33296. * Is this effect rendering to several color attachments ?
  33297. */
  33298. multiTarget?: boolean;
  33299. }
  33300. /**
  33301. * Effect containing vertex and fragment shader that can be executed on an object.
  33302. */
  33303. export class Effect implements IDisposable {
  33304. /**
  33305. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33306. */
  33307. static ShadersRepository: string;
  33308. /**
  33309. * Enable logging of the shader code when a compilation error occurs
  33310. */
  33311. static LogShaderCodeOnCompilationError: boolean;
  33312. /**
  33313. * Name of the effect.
  33314. */
  33315. name: any;
  33316. /**
  33317. * String container all the define statements that should be set on the shader.
  33318. */
  33319. defines: string;
  33320. /**
  33321. * Callback that will be called when the shader is compiled.
  33322. */
  33323. onCompiled: Nullable<(effect: Effect) => void>;
  33324. /**
  33325. * Callback that will be called if an error occurs during shader compilation.
  33326. */
  33327. onError: Nullable<(effect: Effect, errors: string) => void>;
  33328. /**
  33329. * Callback that will be called when effect is bound.
  33330. */
  33331. onBind: Nullable<(effect: Effect) => void>;
  33332. /**
  33333. * Unique ID of the effect.
  33334. */
  33335. uniqueId: number;
  33336. /**
  33337. * Observable that will be called when the shader is compiled.
  33338. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33339. */
  33340. onCompileObservable: Observable<Effect>;
  33341. /**
  33342. * Observable that will be called if an error occurs during shader compilation.
  33343. */
  33344. onErrorObservable: Observable<Effect>;
  33345. /** @hidden */
  33346. _onBindObservable: Nullable<Observable<Effect>>;
  33347. /**
  33348. * @hidden
  33349. * Specifies if the effect was previously ready
  33350. */
  33351. _wasPreviouslyReady: boolean;
  33352. /**
  33353. * Observable that will be called when effect is bound.
  33354. */
  33355. get onBindObservable(): Observable<Effect>;
  33356. /** @hidden */
  33357. _bonesComputationForcedToCPU: boolean;
  33358. /** @hidden */
  33359. _multiTarget: boolean;
  33360. private static _uniqueIdSeed;
  33361. private _engine;
  33362. private _uniformBuffersNames;
  33363. private _uniformBuffersNamesList;
  33364. private _uniformsNames;
  33365. private _samplerList;
  33366. private _samplers;
  33367. private _isReady;
  33368. private _compilationError;
  33369. private _allFallbacksProcessed;
  33370. private _attributesNames;
  33371. private _attributes;
  33372. private _attributeLocationByName;
  33373. private _uniforms;
  33374. /**
  33375. * Key for the effect.
  33376. * @hidden
  33377. */
  33378. _key: string;
  33379. private _indexParameters;
  33380. private _fallbacks;
  33381. private _vertexSourceCode;
  33382. private _fragmentSourceCode;
  33383. private _vertexSourceCodeOverride;
  33384. private _fragmentSourceCodeOverride;
  33385. private _transformFeedbackVaryings;
  33386. /**
  33387. * Compiled shader to webGL program.
  33388. * @hidden
  33389. */
  33390. _pipelineContext: Nullable<IPipelineContext>;
  33391. private _valueCache;
  33392. private static _baseCache;
  33393. /**
  33394. * Instantiates an effect.
  33395. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33396. * @param baseName Name of the effect.
  33397. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33398. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33399. * @param samplers List of sampler variables that will be passed to the shader.
  33400. * @param engine Engine to be used to render the effect
  33401. * @param defines Define statements to be added to the shader.
  33402. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33403. * @param onCompiled Callback that will be called when the shader is compiled.
  33404. * @param onError Callback that will be called if an error occurs during shader compilation.
  33405. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33406. */
  33407. 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);
  33408. private _useFinalCode;
  33409. /**
  33410. * Unique key for this effect
  33411. */
  33412. get key(): string;
  33413. /**
  33414. * If the effect has been compiled and prepared.
  33415. * @returns if the effect is compiled and prepared.
  33416. */
  33417. isReady(): boolean;
  33418. private _isReadyInternal;
  33419. /**
  33420. * The engine the effect was initialized with.
  33421. * @returns the engine.
  33422. */
  33423. getEngine(): Engine;
  33424. /**
  33425. * The pipeline context for this effect
  33426. * @returns the associated pipeline context
  33427. */
  33428. getPipelineContext(): Nullable<IPipelineContext>;
  33429. /**
  33430. * The set of names of attribute variables for the shader.
  33431. * @returns An array of attribute names.
  33432. */
  33433. getAttributesNames(): string[];
  33434. /**
  33435. * Returns the attribute at the given index.
  33436. * @param index The index of the attribute.
  33437. * @returns The location of the attribute.
  33438. */
  33439. getAttributeLocation(index: number): number;
  33440. /**
  33441. * Returns the attribute based on the name of the variable.
  33442. * @param name of the attribute to look up.
  33443. * @returns the attribute location.
  33444. */
  33445. getAttributeLocationByName(name: string): number;
  33446. /**
  33447. * The number of attributes.
  33448. * @returns the numnber of attributes.
  33449. */
  33450. getAttributesCount(): number;
  33451. /**
  33452. * Gets the index of a uniform variable.
  33453. * @param uniformName of the uniform to look up.
  33454. * @returns the index.
  33455. */
  33456. getUniformIndex(uniformName: string): number;
  33457. /**
  33458. * Returns the attribute based on the name of the variable.
  33459. * @param uniformName of the uniform to look up.
  33460. * @returns the location of the uniform.
  33461. */
  33462. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33463. /**
  33464. * Returns an array of sampler variable names
  33465. * @returns The array of sampler variable names.
  33466. */
  33467. getSamplers(): string[];
  33468. /**
  33469. * Returns an array of uniform variable names
  33470. * @returns The array of uniform variable names.
  33471. */
  33472. getUniformNames(): string[];
  33473. /**
  33474. * Returns an array of uniform buffer variable names
  33475. * @returns The array of uniform buffer variable names.
  33476. */
  33477. getUniformBuffersNames(): string[];
  33478. /**
  33479. * Returns the index parameters used to create the effect
  33480. * @returns The index parameters object
  33481. */
  33482. getIndexParameters(): any;
  33483. /**
  33484. * The error from the last compilation.
  33485. * @returns the error string.
  33486. */
  33487. getCompilationError(): string;
  33488. /**
  33489. * Gets a boolean indicating that all fallbacks were used during compilation
  33490. * @returns true if all fallbacks were used
  33491. */
  33492. allFallbacksProcessed(): boolean;
  33493. /**
  33494. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33495. * @param func The callback to be used.
  33496. */
  33497. executeWhenCompiled(func: (effect: Effect) => void): void;
  33498. private _checkIsReady;
  33499. private _loadShader;
  33500. /**
  33501. * Gets the vertex shader source code of this effect
  33502. */
  33503. get vertexSourceCode(): string;
  33504. /**
  33505. * Gets the fragment shader source code of this effect
  33506. */
  33507. get fragmentSourceCode(): string;
  33508. /**
  33509. * Recompiles the webGL program
  33510. * @param vertexSourceCode The source code for the vertex shader.
  33511. * @param fragmentSourceCode The source code for the fragment shader.
  33512. * @param onCompiled Callback called when completed.
  33513. * @param onError Callback called on error.
  33514. * @hidden
  33515. */
  33516. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33517. /**
  33518. * Prepares the effect
  33519. * @hidden
  33520. */
  33521. _prepareEffect(): void;
  33522. private _getShaderCodeAndErrorLine;
  33523. private _processCompilationErrors;
  33524. /**
  33525. * Checks if the effect is supported. (Must be called after compilation)
  33526. */
  33527. get isSupported(): boolean;
  33528. /**
  33529. * Binds a texture to the engine to be used as output of the shader.
  33530. * @param channel Name of the output variable.
  33531. * @param texture Texture to bind.
  33532. * @hidden
  33533. */
  33534. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33535. /**
  33536. * Sets a texture on the engine to be used in the shader.
  33537. * @param channel Name of the sampler variable.
  33538. * @param texture Texture to set.
  33539. */
  33540. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33541. /**
  33542. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33543. * @param channel Name of the sampler variable.
  33544. * @param texture Texture to set.
  33545. */
  33546. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33547. /**
  33548. * Sets an array of textures on the engine to be used in the shader.
  33549. * @param channel Name of the variable.
  33550. * @param textures Textures to set.
  33551. */
  33552. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33553. /**
  33554. * 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)
  33555. * @param channel Name of the sampler variable.
  33556. * @param postProcess Post process to get the input texture from.
  33557. */
  33558. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33559. /**
  33560. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33561. * 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)
  33562. * @param channel Name of the sampler variable.
  33563. * @param postProcess Post process to get the output texture from.
  33564. */
  33565. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33566. /** @hidden */
  33567. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33568. /** @hidden */
  33569. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33570. /** @hidden */
  33571. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33572. /** @hidden */
  33573. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33574. /**
  33575. * Binds a buffer to a uniform.
  33576. * @param buffer Buffer to bind.
  33577. * @param name Name of the uniform variable to bind to.
  33578. */
  33579. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33580. /**
  33581. * Binds block to a uniform.
  33582. * @param blockName Name of the block to bind.
  33583. * @param index Index to bind.
  33584. */
  33585. bindUniformBlock(blockName: string, index: number): void;
  33586. /**
  33587. * Sets an interger value on a uniform variable.
  33588. * @param uniformName Name of the variable.
  33589. * @param value Value to be set.
  33590. * @returns this effect.
  33591. */
  33592. setInt(uniformName: string, value: number): Effect;
  33593. /**
  33594. * Sets an int array on a uniform variable.
  33595. * @param uniformName Name of the variable.
  33596. * @param array array to be set.
  33597. * @returns this effect.
  33598. */
  33599. setIntArray(uniformName: string, array: Int32Array): Effect;
  33600. /**
  33601. * 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)
  33602. * @param uniformName Name of the variable.
  33603. * @param array array to be set.
  33604. * @returns this effect.
  33605. */
  33606. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33607. /**
  33608. * 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)
  33609. * @param uniformName Name of the variable.
  33610. * @param array array to be set.
  33611. * @returns this effect.
  33612. */
  33613. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33614. /**
  33615. * 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)
  33616. * @param uniformName Name of the variable.
  33617. * @param array array to be set.
  33618. * @returns this effect.
  33619. */
  33620. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33621. /**
  33622. * Sets an float array on a uniform variable.
  33623. * @param uniformName Name of the variable.
  33624. * @param array array to be set.
  33625. * @returns this effect.
  33626. */
  33627. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33628. /**
  33629. * 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)
  33630. * @param uniformName Name of the variable.
  33631. * @param array array to be set.
  33632. * @returns this effect.
  33633. */
  33634. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33635. /**
  33636. * 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)
  33637. * @param uniformName Name of the variable.
  33638. * @param array array to be set.
  33639. * @returns this effect.
  33640. */
  33641. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33642. /**
  33643. * 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)
  33644. * @param uniformName Name of the variable.
  33645. * @param array array to be set.
  33646. * @returns this effect.
  33647. */
  33648. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33649. /**
  33650. * Sets an array on a uniform variable.
  33651. * @param uniformName Name of the variable.
  33652. * @param array array to be set.
  33653. * @returns this effect.
  33654. */
  33655. setArray(uniformName: string, array: number[]): Effect;
  33656. /**
  33657. * 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)
  33658. * @param uniformName Name of the variable.
  33659. * @param array array to be set.
  33660. * @returns this effect.
  33661. */
  33662. setArray2(uniformName: string, array: number[]): Effect;
  33663. /**
  33664. * 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)
  33665. * @param uniformName Name of the variable.
  33666. * @param array array to be set.
  33667. * @returns this effect.
  33668. */
  33669. setArray3(uniformName: string, array: number[]): Effect;
  33670. /**
  33671. * 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)
  33672. * @param uniformName Name of the variable.
  33673. * @param array array to be set.
  33674. * @returns this effect.
  33675. */
  33676. setArray4(uniformName: string, array: number[]): Effect;
  33677. /**
  33678. * Sets matrices on a uniform variable.
  33679. * @param uniformName Name of the variable.
  33680. * @param matrices matrices to be set.
  33681. * @returns this effect.
  33682. */
  33683. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33684. /**
  33685. * Sets matrix on a uniform variable.
  33686. * @param uniformName Name of the variable.
  33687. * @param matrix matrix to be set.
  33688. * @returns this effect.
  33689. */
  33690. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33691. /**
  33692. * 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)
  33693. * @param uniformName Name of the variable.
  33694. * @param matrix matrix to be set.
  33695. * @returns this effect.
  33696. */
  33697. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33698. /**
  33699. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33700. * @param uniformName Name of the variable.
  33701. * @param matrix matrix to be set.
  33702. * @returns this effect.
  33703. */
  33704. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33705. /**
  33706. * Sets a float on a uniform variable.
  33707. * @param uniformName Name of the variable.
  33708. * @param value value to be set.
  33709. * @returns this effect.
  33710. */
  33711. setFloat(uniformName: string, value: number): Effect;
  33712. /**
  33713. * Sets a boolean on a uniform variable.
  33714. * @param uniformName Name of the variable.
  33715. * @param bool value to be set.
  33716. * @returns this effect.
  33717. */
  33718. setBool(uniformName: string, bool: boolean): Effect;
  33719. /**
  33720. * Sets a Vector2 on a uniform variable.
  33721. * @param uniformName Name of the variable.
  33722. * @param vector2 vector2 to be set.
  33723. * @returns this effect.
  33724. */
  33725. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33726. /**
  33727. * Sets a float2 on a uniform variable.
  33728. * @param uniformName Name of the variable.
  33729. * @param x First float in float2.
  33730. * @param y Second float in float2.
  33731. * @returns this effect.
  33732. */
  33733. setFloat2(uniformName: string, x: number, y: number): Effect;
  33734. /**
  33735. * Sets a Vector3 on a uniform variable.
  33736. * @param uniformName Name of the variable.
  33737. * @param vector3 Value to be set.
  33738. * @returns this effect.
  33739. */
  33740. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33741. /**
  33742. * Sets a float3 on a uniform variable.
  33743. * @param uniformName Name of the variable.
  33744. * @param x First float in float3.
  33745. * @param y Second float in float3.
  33746. * @param z Third float in float3.
  33747. * @returns this effect.
  33748. */
  33749. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33750. /**
  33751. * Sets a Vector4 on a uniform variable.
  33752. * @param uniformName Name of the variable.
  33753. * @param vector4 Value to be set.
  33754. * @returns this effect.
  33755. */
  33756. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33757. /**
  33758. * Sets a float4 on a uniform variable.
  33759. * @param uniformName Name of the variable.
  33760. * @param x First float in float4.
  33761. * @param y Second float in float4.
  33762. * @param z Third float in float4.
  33763. * @param w Fourth float in float4.
  33764. * @returns this effect.
  33765. */
  33766. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33767. /**
  33768. * Sets a Color3 on a uniform variable.
  33769. * @param uniformName Name of the variable.
  33770. * @param color3 Value to be set.
  33771. * @returns this effect.
  33772. */
  33773. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33774. /**
  33775. * Sets a Color4 on a uniform variable.
  33776. * @param uniformName Name of the variable.
  33777. * @param color3 Value to be set.
  33778. * @param alpha Alpha value to be set.
  33779. * @returns this effect.
  33780. */
  33781. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33782. /**
  33783. * Sets a Color4 on a uniform variable
  33784. * @param uniformName defines the name of the variable
  33785. * @param color4 defines the value to be set
  33786. * @returns this effect.
  33787. */
  33788. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33789. /** Release all associated resources */
  33790. dispose(): void;
  33791. /**
  33792. * This function will add a new shader to the shader store
  33793. * @param name the name of the shader
  33794. * @param pixelShader optional pixel shader content
  33795. * @param vertexShader optional vertex shader content
  33796. */
  33797. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33798. /**
  33799. * Store of each shader (The can be looked up using effect.key)
  33800. */
  33801. static ShadersStore: {
  33802. [key: string]: string;
  33803. };
  33804. /**
  33805. * Store of each included file for a shader (The can be looked up using effect.key)
  33806. */
  33807. static IncludesShadersStore: {
  33808. [key: string]: string;
  33809. };
  33810. /**
  33811. * Resets the cache of effects.
  33812. */
  33813. static ResetCache(): void;
  33814. }
  33815. }
  33816. declare module BABYLON {
  33817. /**
  33818. * Interface used to describe the capabilities of the engine relatively to the current browser
  33819. */
  33820. export interface EngineCapabilities {
  33821. /** Maximum textures units per fragment shader */
  33822. maxTexturesImageUnits: number;
  33823. /** Maximum texture units per vertex shader */
  33824. maxVertexTextureImageUnits: number;
  33825. /** Maximum textures units in the entire pipeline */
  33826. maxCombinedTexturesImageUnits: number;
  33827. /** Maximum texture size */
  33828. maxTextureSize: number;
  33829. /** Maximum texture samples */
  33830. maxSamples?: number;
  33831. /** Maximum cube texture size */
  33832. maxCubemapTextureSize: number;
  33833. /** Maximum render texture size */
  33834. maxRenderTextureSize: number;
  33835. /** Maximum number of vertex attributes */
  33836. maxVertexAttribs: number;
  33837. /** Maximum number of varyings */
  33838. maxVaryingVectors: number;
  33839. /** Maximum number of uniforms per vertex shader */
  33840. maxVertexUniformVectors: number;
  33841. /** Maximum number of uniforms per fragment shader */
  33842. maxFragmentUniformVectors: number;
  33843. /** Defines if standard derivates (dx/dy) are supported */
  33844. standardDerivatives: boolean;
  33845. /** Defines if s3tc texture compression is supported */
  33846. s3tc?: WEBGL_compressed_texture_s3tc;
  33847. /** Defines if pvrtc texture compression is supported */
  33848. pvrtc: any;
  33849. /** Defines if etc1 texture compression is supported */
  33850. etc1: any;
  33851. /** Defines if etc2 texture compression is supported */
  33852. etc2: any;
  33853. /** Defines if astc texture compression is supported */
  33854. astc: any;
  33855. /** Defines if float textures are supported */
  33856. textureFloat: boolean;
  33857. /** Defines if vertex array objects are supported */
  33858. vertexArrayObject: boolean;
  33859. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33860. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33861. /** Gets the maximum level of anisotropy supported */
  33862. maxAnisotropy: number;
  33863. /** Defines if instancing is supported */
  33864. instancedArrays: boolean;
  33865. /** Defines if 32 bits indices are supported */
  33866. uintIndices: boolean;
  33867. /** Defines if high precision shaders are supported */
  33868. highPrecisionShaderSupported: boolean;
  33869. /** Defines if depth reading in the fragment shader is supported */
  33870. fragmentDepthSupported: boolean;
  33871. /** Defines if float texture linear filtering is supported*/
  33872. textureFloatLinearFiltering: boolean;
  33873. /** Defines if rendering to float textures is supported */
  33874. textureFloatRender: boolean;
  33875. /** Defines if half float textures are supported*/
  33876. textureHalfFloat: boolean;
  33877. /** Defines if half float texture linear filtering is supported*/
  33878. textureHalfFloatLinearFiltering: boolean;
  33879. /** Defines if rendering to half float textures is supported */
  33880. textureHalfFloatRender: boolean;
  33881. /** Defines if textureLOD shader command is supported */
  33882. textureLOD: boolean;
  33883. /** Defines if draw buffers extension is supported */
  33884. drawBuffersExtension: boolean;
  33885. /** Defines if depth textures are supported */
  33886. depthTextureExtension: boolean;
  33887. /** Defines if float color buffer are supported */
  33888. colorBufferFloat: boolean;
  33889. /** Gets disjoint timer query extension (null if not supported) */
  33890. timerQuery?: EXT_disjoint_timer_query;
  33891. /** Defines if timestamp can be used with timer query */
  33892. canUseTimestampForTimerQuery: boolean;
  33893. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33894. multiview?: any;
  33895. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33896. oculusMultiview?: any;
  33897. /** Function used to let the system compiles shaders in background */
  33898. parallelShaderCompile?: {
  33899. COMPLETION_STATUS_KHR: number;
  33900. };
  33901. /** Max number of texture samples for MSAA */
  33902. maxMSAASamples: number;
  33903. /** Defines if the blend min max extension is supported */
  33904. blendMinMax: boolean;
  33905. }
  33906. }
  33907. declare module BABYLON {
  33908. /**
  33909. * @hidden
  33910. **/
  33911. export class DepthCullingState {
  33912. private _isDepthTestDirty;
  33913. private _isDepthMaskDirty;
  33914. private _isDepthFuncDirty;
  33915. private _isCullFaceDirty;
  33916. private _isCullDirty;
  33917. private _isZOffsetDirty;
  33918. private _isFrontFaceDirty;
  33919. private _depthTest;
  33920. private _depthMask;
  33921. private _depthFunc;
  33922. private _cull;
  33923. private _cullFace;
  33924. private _zOffset;
  33925. private _frontFace;
  33926. /**
  33927. * Initializes the state.
  33928. */
  33929. constructor();
  33930. get isDirty(): boolean;
  33931. get zOffset(): number;
  33932. set zOffset(value: number);
  33933. get cullFace(): Nullable<number>;
  33934. set cullFace(value: Nullable<number>);
  33935. get cull(): Nullable<boolean>;
  33936. set cull(value: Nullable<boolean>);
  33937. get depthFunc(): Nullable<number>;
  33938. set depthFunc(value: Nullable<number>);
  33939. get depthMask(): boolean;
  33940. set depthMask(value: boolean);
  33941. get depthTest(): boolean;
  33942. set depthTest(value: boolean);
  33943. get frontFace(): Nullable<number>;
  33944. set frontFace(value: Nullable<number>);
  33945. reset(): void;
  33946. apply(gl: WebGLRenderingContext): void;
  33947. }
  33948. }
  33949. declare module BABYLON {
  33950. /**
  33951. * @hidden
  33952. **/
  33953. export class StencilState {
  33954. /** 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 */
  33955. static readonly ALWAYS: number;
  33956. /** Passed to stencilOperation to specify that stencil value must be kept */
  33957. static readonly KEEP: number;
  33958. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33959. static readonly REPLACE: number;
  33960. private _isStencilTestDirty;
  33961. private _isStencilMaskDirty;
  33962. private _isStencilFuncDirty;
  33963. private _isStencilOpDirty;
  33964. private _stencilTest;
  33965. private _stencilMask;
  33966. private _stencilFunc;
  33967. private _stencilFuncRef;
  33968. private _stencilFuncMask;
  33969. private _stencilOpStencilFail;
  33970. private _stencilOpDepthFail;
  33971. private _stencilOpStencilDepthPass;
  33972. get isDirty(): boolean;
  33973. get stencilFunc(): number;
  33974. set stencilFunc(value: number);
  33975. get stencilFuncRef(): number;
  33976. set stencilFuncRef(value: number);
  33977. get stencilFuncMask(): number;
  33978. set stencilFuncMask(value: number);
  33979. get stencilOpStencilFail(): number;
  33980. set stencilOpStencilFail(value: number);
  33981. get stencilOpDepthFail(): number;
  33982. set stencilOpDepthFail(value: number);
  33983. get stencilOpStencilDepthPass(): number;
  33984. set stencilOpStencilDepthPass(value: number);
  33985. get stencilMask(): number;
  33986. set stencilMask(value: number);
  33987. get stencilTest(): boolean;
  33988. set stencilTest(value: boolean);
  33989. constructor();
  33990. reset(): void;
  33991. apply(gl: WebGLRenderingContext): void;
  33992. }
  33993. }
  33994. declare module BABYLON {
  33995. /**
  33996. * @hidden
  33997. **/
  33998. export class AlphaState {
  33999. private _isAlphaBlendDirty;
  34000. private _isBlendFunctionParametersDirty;
  34001. private _isBlendEquationParametersDirty;
  34002. private _isBlendConstantsDirty;
  34003. private _alphaBlend;
  34004. private _blendFunctionParameters;
  34005. private _blendEquationParameters;
  34006. private _blendConstants;
  34007. /**
  34008. * Initializes the state.
  34009. */
  34010. constructor();
  34011. get isDirty(): boolean;
  34012. get alphaBlend(): boolean;
  34013. set alphaBlend(value: boolean);
  34014. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34015. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34016. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34017. reset(): void;
  34018. apply(gl: WebGLRenderingContext): void;
  34019. }
  34020. }
  34021. declare module BABYLON {
  34022. /** @hidden */
  34023. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34024. attributeProcessor(attribute: string): string;
  34025. varyingProcessor(varying: string, isFragment: boolean): string;
  34026. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34027. }
  34028. }
  34029. declare module BABYLON {
  34030. /**
  34031. * Interface for attribute information associated with buffer instanciation
  34032. */
  34033. export interface InstancingAttributeInfo {
  34034. /**
  34035. * Name of the GLSL attribute
  34036. * if attribute index is not specified, this is used to retrieve the index from the effect
  34037. */
  34038. attributeName: string;
  34039. /**
  34040. * Index/offset of the attribute in the vertex shader
  34041. * if not specified, this will be computes from the name.
  34042. */
  34043. index?: number;
  34044. /**
  34045. * size of the attribute, 1, 2, 3 or 4
  34046. */
  34047. attributeSize: number;
  34048. /**
  34049. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34050. */
  34051. offset: number;
  34052. /**
  34053. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34054. * default to 1
  34055. */
  34056. divisor?: number;
  34057. /**
  34058. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34059. * default is FLOAT
  34060. */
  34061. attributeType?: number;
  34062. /**
  34063. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34064. */
  34065. normalized?: boolean;
  34066. }
  34067. }
  34068. declare module BABYLON {
  34069. interface ThinEngine {
  34070. /**
  34071. * Update a video texture
  34072. * @param texture defines the texture to update
  34073. * @param video defines the video element to use
  34074. * @param invertY defines if data must be stored with Y axis inverted
  34075. */
  34076. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34077. }
  34078. }
  34079. declare module BABYLON {
  34080. interface ThinEngine {
  34081. /**
  34082. * Creates a dynamic texture
  34083. * @param width defines the width of the texture
  34084. * @param height defines the height of the texture
  34085. * @param generateMipMaps defines if the engine should generate the mip levels
  34086. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34087. * @returns the dynamic texture inside an InternalTexture
  34088. */
  34089. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34090. /**
  34091. * Update the content of a dynamic texture
  34092. * @param texture defines the texture to update
  34093. * @param canvas defines the canvas containing the source
  34094. * @param invertY defines if data must be stored with Y axis inverted
  34095. * @param premulAlpha defines if alpha is stored as premultiplied
  34096. * @param format defines the format of the data
  34097. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34098. */
  34099. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34100. }
  34101. }
  34102. declare module BABYLON {
  34103. /**
  34104. * Settings for finer control over video usage
  34105. */
  34106. export interface VideoTextureSettings {
  34107. /**
  34108. * Applies `autoplay` to video, if specified
  34109. */
  34110. autoPlay?: boolean;
  34111. /**
  34112. * Applies `loop` to video, if specified
  34113. */
  34114. loop?: boolean;
  34115. /**
  34116. * Automatically updates internal texture from video at every frame in the render loop
  34117. */
  34118. autoUpdateTexture: boolean;
  34119. /**
  34120. * Image src displayed during the video loading or until the user interacts with the video.
  34121. */
  34122. poster?: string;
  34123. }
  34124. /**
  34125. * If you want to display a video in your scene, this is the special texture for that.
  34126. * This special texture works similar to other textures, with the exception of a few parameters.
  34127. * @see https://doc.babylonjs.com/how_to/video_texture
  34128. */
  34129. export class VideoTexture extends Texture {
  34130. /**
  34131. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34132. */
  34133. readonly autoUpdateTexture: boolean;
  34134. /**
  34135. * The video instance used by the texture internally
  34136. */
  34137. readonly video: HTMLVideoElement;
  34138. private _onUserActionRequestedObservable;
  34139. /**
  34140. * Event triggerd when a dom action is required by the user to play the video.
  34141. * This happens due to recent changes in browser policies preventing video to auto start.
  34142. */
  34143. get onUserActionRequestedObservable(): Observable<Texture>;
  34144. private _generateMipMaps;
  34145. private _stillImageCaptured;
  34146. private _displayingPosterTexture;
  34147. private _settings;
  34148. private _createInternalTextureOnEvent;
  34149. private _frameId;
  34150. private _currentSrc;
  34151. /**
  34152. * Creates a video texture.
  34153. * If you want to display a video in your scene, this is the special texture for that.
  34154. * This special texture works similar to other textures, with the exception of a few parameters.
  34155. * @see https://doc.babylonjs.com/how_to/video_texture
  34156. * @param name optional name, will detect from video source, if not defined
  34157. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34158. * @param scene is obviously the current scene.
  34159. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34160. * @param invertY is false by default but can be used to invert video on Y axis
  34161. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34162. * @param settings allows finer control over video usage
  34163. */
  34164. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34165. private _getName;
  34166. private _getVideo;
  34167. private _createInternalTexture;
  34168. private reset;
  34169. /**
  34170. * @hidden Internal method to initiate `update`.
  34171. */
  34172. _rebuild(): void;
  34173. /**
  34174. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34175. */
  34176. update(): void;
  34177. /**
  34178. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34179. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34180. */
  34181. updateTexture(isVisible: boolean): void;
  34182. protected _updateInternalTexture: () => void;
  34183. /**
  34184. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34185. * @param url New url.
  34186. */
  34187. updateURL(url: string): void;
  34188. /**
  34189. * Clones the texture.
  34190. * @returns the cloned texture
  34191. */
  34192. clone(): VideoTexture;
  34193. /**
  34194. * Dispose the texture and release its associated resources.
  34195. */
  34196. dispose(): void;
  34197. /**
  34198. * Creates a video texture straight from a stream.
  34199. * @param scene Define the scene the texture should be created in
  34200. * @param stream Define the stream the texture should be created from
  34201. * @returns The created video texture as a promise
  34202. */
  34203. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34204. /**
  34205. * Creates a video texture straight from your WebCam video feed.
  34206. * @param scene Define the scene the texture should be created in
  34207. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34208. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34209. * @returns The created video texture as a promise
  34210. */
  34211. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34212. minWidth: number;
  34213. maxWidth: number;
  34214. minHeight: number;
  34215. maxHeight: number;
  34216. deviceId: string;
  34217. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34218. /**
  34219. * Creates a video texture straight from your WebCam video feed.
  34220. * @param scene Define the scene the texture should be created in
  34221. * @param onReady Define a callback to triggered once the texture will be ready
  34222. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34223. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34224. */
  34225. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34226. minWidth: number;
  34227. maxWidth: number;
  34228. minHeight: number;
  34229. maxHeight: number;
  34230. deviceId: string;
  34231. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34232. }
  34233. }
  34234. declare module BABYLON {
  34235. /**
  34236. * Defines the interface used by objects working like Scene
  34237. * @hidden
  34238. */
  34239. export interface ISceneLike {
  34240. _addPendingData(data: any): void;
  34241. _removePendingData(data: any): void;
  34242. offlineProvider: IOfflineProvider;
  34243. }
  34244. /** Interface defining initialization parameters for Engine class */
  34245. export interface EngineOptions extends WebGLContextAttributes {
  34246. /**
  34247. * Defines if the engine should no exceed a specified device ratio
  34248. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34249. */
  34250. limitDeviceRatio?: number;
  34251. /**
  34252. * Defines if webvr should be enabled automatically
  34253. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34254. */
  34255. autoEnableWebVR?: boolean;
  34256. /**
  34257. * Defines if webgl2 should be turned off even if supported
  34258. * @see https://doc.babylonjs.com/features/webgl2
  34259. */
  34260. disableWebGL2Support?: boolean;
  34261. /**
  34262. * Defines if webaudio should be initialized as well
  34263. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34264. */
  34265. audioEngine?: boolean;
  34266. /**
  34267. * Defines if animations should run using a deterministic lock step
  34268. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34269. */
  34270. deterministicLockstep?: boolean;
  34271. /** Defines the maximum steps to use with deterministic lock step mode */
  34272. lockstepMaxSteps?: number;
  34273. /** Defines the seconds between each deterministic lock step */
  34274. timeStep?: number;
  34275. /**
  34276. * Defines that engine should ignore context lost events
  34277. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34278. */
  34279. doNotHandleContextLost?: boolean;
  34280. /**
  34281. * Defines that engine should ignore modifying touch action attribute and style
  34282. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34283. */
  34284. doNotHandleTouchAction?: boolean;
  34285. /**
  34286. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34287. */
  34288. useHighPrecisionFloats?: boolean;
  34289. /**
  34290. * Make the canvas XR Compatible for XR sessions
  34291. */
  34292. xrCompatible?: boolean;
  34293. }
  34294. /**
  34295. * The base engine class (root of all engines)
  34296. */
  34297. export class ThinEngine {
  34298. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34299. static ExceptionList: ({
  34300. key: string;
  34301. capture: string;
  34302. captureConstraint: number;
  34303. targets: string[];
  34304. } | {
  34305. key: string;
  34306. capture: null;
  34307. captureConstraint: null;
  34308. targets: string[];
  34309. })[];
  34310. /** @hidden */
  34311. static _TextureLoaders: IInternalTextureLoader[];
  34312. /**
  34313. * Returns the current npm package of the sdk
  34314. */
  34315. static get NpmPackage(): string;
  34316. /**
  34317. * Returns the current version of the framework
  34318. */
  34319. static get Version(): string;
  34320. /**
  34321. * Returns a string describing the current engine
  34322. */
  34323. get description(): string;
  34324. /**
  34325. * Gets or sets the epsilon value used by collision engine
  34326. */
  34327. static CollisionsEpsilon: number;
  34328. /**
  34329. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34330. */
  34331. static get ShadersRepository(): string;
  34332. static set ShadersRepository(value: string);
  34333. /** @hidden */
  34334. _shaderProcessor: IShaderProcessor;
  34335. /**
  34336. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34337. */
  34338. forcePOTTextures: boolean;
  34339. /**
  34340. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34341. */
  34342. isFullscreen: boolean;
  34343. /**
  34344. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34345. */
  34346. cullBackFaces: boolean;
  34347. /**
  34348. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34349. */
  34350. renderEvenInBackground: boolean;
  34351. /**
  34352. * Gets or sets a boolean indicating that cache can be kept between frames
  34353. */
  34354. preventCacheWipeBetweenFrames: boolean;
  34355. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34356. validateShaderPrograms: boolean;
  34357. /**
  34358. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34359. * This can provide greater z depth for distant objects.
  34360. */
  34361. useReverseDepthBuffer: boolean;
  34362. /**
  34363. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34364. */
  34365. disableUniformBuffers: boolean;
  34366. /** @hidden */
  34367. _uniformBuffers: UniformBuffer[];
  34368. /**
  34369. * Gets a boolean indicating that the engine supports uniform buffers
  34370. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34371. */
  34372. get supportsUniformBuffers(): boolean;
  34373. /** @hidden */
  34374. _gl: WebGLRenderingContext;
  34375. /** @hidden */
  34376. _webGLVersion: number;
  34377. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34378. protected _windowIsBackground: boolean;
  34379. protected _creationOptions: EngineOptions;
  34380. protected _highPrecisionShadersAllowed: boolean;
  34381. /** @hidden */
  34382. get _shouldUseHighPrecisionShader(): boolean;
  34383. /**
  34384. * Gets a boolean indicating that only power of 2 textures are supported
  34385. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34386. */
  34387. get needPOTTextures(): boolean;
  34388. /** @hidden */
  34389. _badOS: boolean;
  34390. /** @hidden */
  34391. _badDesktopOS: boolean;
  34392. private _hardwareScalingLevel;
  34393. /** @hidden */
  34394. _caps: EngineCapabilities;
  34395. private _isStencilEnable;
  34396. private _glVersion;
  34397. private _glRenderer;
  34398. private _glVendor;
  34399. /** @hidden */
  34400. _videoTextureSupported: boolean;
  34401. protected _renderingQueueLaunched: boolean;
  34402. protected _activeRenderLoops: (() => void)[];
  34403. /**
  34404. * Observable signaled when a context lost event is raised
  34405. */
  34406. onContextLostObservable: Observable<ThinEngine>;
  34407. /**
  34408. * Observable signaled when a context restored event is raised
  34409. */
  34410. onContextRestoredObservable: Observable<ThinEngine>;
  34411. private _onContextLost;
  34412. private _onContextRestored;
  34413. protected _contextWasLost: boolean;
  34414. /** @hidden */
  34415. _doNotHandleContextLost: boolean;
  34416. /**
  34417. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34419. */
  34420. get doNotHandleContextLost(): boolean;
  34421. set doNotHandleContextLost(value: boolean);
  34422. /**
  34423. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34424. */
  34425. disableVertexArrayObjects: boolean;
  34426. /** @hidden */
  34427. protected _colorWrite: boolean;
  34428. /** @hidden */
  34429. protected _colorWriteChanged: boolean;
  34430. /** @hidden */
  34431. protected _depthCullingState: DepthCullingState;
  34432. /** @hidden */
  34433. protected _stencilState: StencilState;
  34434. /** @hidden */
  34435. _alphaState: AlphaState;
  34436. /** @hidden */
  34437. _alphaMode: number;
  34438. /** @hidden */
  34439. _alphaEquation: number;
  34440. /** @hidden */
  34441. _internalTexturesCache: InternalTexture[];
  34442. /** @hidden */
  34443. protected _activeChannel: number;
  34444. private _currentTextureChannel;
  34445. /** @hidden */
  34446. protected _boundTexturesCache: {
  34447. [key: string]: Nullable<InternalTexture>;
  34448. };
  34449. /** @hidden */
  34450. protected _currentEffect: Nullable<Effect>;
  34451. /** @hidden */
  34452. protected _currentProgram: Nullable<WebGLProgram>;
  34453. private _compiledEffects;
  34454. private _vertexAttribArraysEnabled;
  34455. /** @hidden */
  34456. protected _cachedViewport: Nullable<IViewportLike>;
  34457. private _cachedVertexArrayObject;
  34458. /** @hidden */
  34459. protected _cachedVertexBuffers: any;
  34460. /** @hidden */
  34461. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34462. /** @hidden */
  34463. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34464. /** @hidden */
  34465. _currentRenderTarget: Nullable<InternalTexture>;
  34466. private _uintIndicesCurrentlySet;
  34467. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34468. /** @hidden */
  34469. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34470. /** @hidden */
  34471. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34472. private _currentBufferPointers;
  34473. private _currentInstanceLocations;
  34474. private _currentInstanceBuffers;
  34475. private _textureUnits;
  34476. /** @hidden */
  34477. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34478. /** @hidden */
  34479. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34480. /** @hidden */
  34481. _boundRenderFunction: any;
  34482. private _vaoRecordInProgress;
  34483. private _mustWipeVertexAttributes;
  34484. private _emptyTexture;
  34485. private _emptyCubeTexture;
  34486. private _emptyTexture3D;
  34487. private _emptyTexture2DArray;
  34488. /** @hidden */
  34489. _frameHandler: number;
  34490. private _nextFreeTextureSlots;
  34491. private _maxSimultaneousTextures;
  34492. private _activeRequests;
  34493. /** @hidden */
  34494. _transformTextureUrl: Nullable<(url: string) => string>;
  34495. protected get _supportsHardwareTextureRescaling(): boolean;
  34496. private _framebufferDimensionsObject;
  34497. /**
  34498. * sets the object from which width and height will be taken from when getting render width and height
  34499. * Will fallback to the gl object
  34500. * @param dimensions the framebuffer width and height that will be used.
  34501. */
  34502. set framebufferDimensionsObject(dimensions: Nullable<{
  34503. framebufferWidth: number;
  34504. framebufferHeight: number;
  34505. }>);
  34506. /**
  34507. * Gets the current viewport
  34508. */
  34509. get currentViewport(): Nullable<IViewportLike>;
  34510. /**
  34511. * Gets the default empty texture
  34512. */
  34513. get emptyTexture(): InternalTexture;
  34514. /**
  34515. * Gets the default empty 3D texture
  34516. */
  34517. get emptyTexture3D(): InternalTexture;
  34518. /**
  34519. * Gets the default empty 2D array texture
  34520. */
  34521. get emptyTexture2DArray(): InternalTexture;
  34522. /**
  34523. * Gets the default empty cube texture
  34524. */
  34525. get emptyCubeTexture(): InternalTexture;
  34526. /**
  34527. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34528. */
  34529. readonly premultipliedAlpha: boolean;
  34530. /**
  34531. * Observable event triggered before each texture is initialized
  34532. */
  34533. onBeforeTextureInitObservable: Observable<Texture>;
  34534. /**
  34535. * Creates a new engine
  34536. * @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
  34537. * @param antialias defines enable antialiasing (default: false)
  34538. * @param options defines further options to be sent to the getContext() function
  34539. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34540. */
  34541. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34542. private _rebuildInternalTextures;
  34543. private _rebuildEffects;
  34544. /**
  34545. * Gets a boolean indicating if all created effects are ready
  34546. * @returns true if all effects are ready
  34547. */
  34548. areAllEffectsReady(): boolean;
  34549. protected _rebuildBuffers(): void;
  34550. protected _initGLContext(): void;
  34551. /**
  34552. * Gets version of the current webGL context
  34553. */
  34554. get webGLVersion(): number;
  34555. /**
  34556. * Gets a string idenfifying the name of the class
  34557. * @returns "Engine" string
  34558. */
  34559. getClassName(): string;
  34560. /**
  34561. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34562. */
  34563. get isStencilEnable(): boolean;
  34564. /** @hidden */
  34565. _prepareWorkingCanvas(): void;
  34566. /**
  34567. * Reset the texture cache to empty state
  34568. */
  34569. resetTextureCache(): void;
  34570. /**
  34571. * Gets an object containing information about the current webGL context
  34572. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34573. */
  34574. getGlInfo(): {
  34575. vendor: string;
  34576. renderer: string;
  34577. version: string;
  34578. };
  34579. /**
  34580. * Defines the hardware scaling level.
  34581. * By default the hardware scaling level is computed from the window device ratio.
  34582. * 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.
  34583. * @param level defines the level to use
  34584. */
  34585. setHardwareScalingLevel(level: number): void;
  34586. /**
  34587. * Gets the current hardware scaling level.
  34588. * By default the hardware scaling level is computed from the window device ratio.
  34589. * 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.
  34590. * @returns a number indicating the current hardware scaling level
  34591. */
  34592. getHardwareScalingLevel(): number;
  34593. /**
  34594. * Gets the list of loaded textures
  34595. * @returns an array containing all loaded textures
  34596. */
  34597. getLoadedTexturesCache(): InternalTexture[];
  34598. /**
  34599. * Gets the object containing all engine capabilities
  34600. * @returns the EngineCapabilities object
  34601. */
  34602. getCaps(): EngineCapabilities;
  34603. /**
  34604. * stop executing a render loop function and remove it from the execution array
  34605. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34606. */
  34607. stopRenderLoop(renderFunction?: () => void): void;
  34608. /** @hidden */
  34609. _renderLoop(): void;
  34610. /**
  34611. * Gets the HTML canvas attached with the current webGL context
  34612. * @returns a HTML canvas
  34613. */
  34614. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34615. /**
  34616. * Gets host window
  34617. * @returns the host window object
  34618. */
  34619. getHostWindow(): Nullable<Window>;
  34620. /**
  34621. * Gets the current render width
  34622. * @param useScreen defines if screen size must be used (or the current render target if any)
  34623. * @returns a number defining the current render width
  34624. */
  34625. getRenderWidth(useScreen?: boolean): number;
  34626. /**
  34627. * Gets the current render height
  34628. * @param useScreen defines if screen size must be used (or the current render target if any)
  34629. * @returns a number defining the current render height
  34630. */
  34631. getRenderHeight(useScreen?: boolean): number;
  34632. /**
  34633. * Can be used to override the current requestAnimationFrame requester.
  34634. * @hidden
  34635. */
  34636. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34637. /**
  34638. * Register and execute a render loop. The engine can have more than one render function
  34639. * @param renderFunction defines the function to continuously execute
  34640. */
  34641. runRenderLoop(renderFunction: () => void): void;
  34642. /**
  34643. * Clear the current render buffer or the current render target (if any is set up)
  34644. * @param color defines the color to use
  34645. * @param backBuffer defines if the back buffer must be cleared
  34646. * @param depth defines if the depth buffer must be cleared
  34647. * @param stencil defines if the stencil buffer must be cleared
  34648. */
  34649. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34650. private _viewportCached;
  34651. /** @hidden */
  34652. _viewport(x: number, y: number, width: number, height: number): void;
  34653. /**
  34654. * Set the WebGL's viewport
  34655. * @param viewport defines the viewport element to be used
  34656. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34657. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34658. */
  34659. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34660. /**
  34661. * Begin a new frame
  34662. */
  34663. beginFrame(): void;
  34664. /**
  34665. * Enf the current frame
  34666. */
  34667. endFrame(): void;
  34668. /**
  34669. * Resize the view according to the canvas' size
  34670. */
  34671. resize(): void;
  34672. /**
  34673. * Force a specific size of the canvas
  34674. * @param width defines the new canvas' width
  34675. * @param height defines the new canvas' height
  34676. * @returns true if the size was changed
  34677. */
  34678. setSize(width: number, height: number): boolean;
  34679. /**
  34680. * Binds the frame buffer to the specified texture.
  34681. * @param texture The texture to render to or null for the default canvas
  34682. * @param faceIndex The face of the texture to render to in case of cube texture
  34683. * @param requiredWidth The width of the target to render to
  34684. * @param requiredHeight The height of the target to render to
  34685. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34686. * @param lodLevel defines the lod level to bind to the frame buffer
  34687. * @param layer defines the 2d array index to bind to frame buffer to
  34688. */
  34689. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34690. /** @hidden */
  34691. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34692. /**
  34693. * Unbind the current render target texture from the webGL context
  34694. * @param texture defines the render target texture to unbind
  34695. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34696. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34697. */
  34698. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34699. /**
  34700. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34701. */
  34702. flushFramebuffer(): void;
  34703. /**
  34704. * Unbind the current render target and bind the default framebuffer
  34705. */
  34706. restoreDefaultFramebuffer(): void;
  34707. /** @hidden */
  34708. protected _resetVertexBufferBinding(): void;
  34709. /**
  34710. * Creates a vertex buffer
  34711. * @param data the data for the vertex buffer
  34712. * @returns the new WebGL static buffer
  34713. */
  34714. createVertexBuffer(data: DataArray): DataBuffer;
  34715. private _createVertexBuffer;
  34716. /**
  34717. * Creates a dynamic vertex buffer
  34718. * @param data the data for the dynamic vertex buffer
  34719. * @returns the new WebGL dynamic buffer
  34720. */
  34721. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34722. protected _resetIndexBufferBinding(): void;
  34723. /**
  34724. * Creates a new index buffer
  34725. * @param indices defines the content of the index buffer
  34726. * @param updatable defines if the index buffer must be updatable
  34727. * @returns a new webGL buffer
  34728. */
  34729. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34730. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34731. /**
  34732. * Bind a webGL buffer to the webGL context
  34733. * @param buffer defines the buffer to bind
  34734. */
  34735. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34736. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34737. private bindBuffer;
  34738. /**
  34739. * update the bound buffer with the given data
  34740. * @param data defines the data to update
  34741. */
  34742. updateArrayBuffer(data: Float32Array): void;
  34743. private _vertexAttribPointer;
  34744. /** @hidden */
  34745. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34746. private _bindVertexBuffersAttributes;
  34747. /**
  34748. * Records a vertex array object
  34749. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34750. * @param vertexBuffers defines the list of vertex buffers to store
  34751. * @param indexBuffer defines the index buffer to store
  34752. * @param effect defines the effect to store
  34753. * @returns the new vertex array object
  34754. */
  34755. recordVertexArrayObject(vertexBuffers: {
  34756. [key: string]: VertexBuffer;
  34757. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34758. /**
  34759. * Bind a specific vertex array object
  34760. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34761. * @param vertexArrayObject defines the vertex array object to bind
  34762. * @param indexBuffer defines the index buffer to bind
  34763. */
  34764. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34765. /**
  34766. * Bind webGl buffers directly to the webGL context
  34767. * @param vertexBuffer defines the vertex buffer to bind
  34768. * @param indexBuffer defines the index buffer to bind
  34769. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34770. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34771. * @param effect defines the effect associated with the vertex buffer
  34772. */
  34773. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34774. private _unbindVertexArrayObject;
  34775. /**
  34776. * Bind a list of vertex buffers to the webGL context
  34777. * @param vertexBuffers defines the list of vertex buffers to bind
  34778. * @param indexBuffer defines the index buffer to bind
  34779. * @param effect defines the effect associated with the vertex buffers
  34780. */
  34781. bindBuffers(vertexBuffers: {
  34782. [key: string]: Nullable<VertexBuffer>;
  34783. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34784. /**
  34785. * Unbind all instance attributes
  34786. */
  34787. unbindInstanceAttributes(): void;
  34788. /**
  34789. * Release and free the memory of a vertex array object
  34790. * @param vao defines the vertex array object to delete
  34791. */
  34792. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34793. /** @hidden */
  34794. _releaseBuffer(buffer: DataBuffer): boolean;
  34795. protected _deleteBuffer(buffer: DataBuffer): void;
  34796. /**
  34797. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34798. * @param instancesBuffer defines the webGL buffer to update and bind
  34799. * @param data defines the data to store in the buffer
  34800. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34801. */
  34802. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34803. /**
  34804. * Bind the content of a webGL buffer used with instantiation
  34805. * @param instancesBuffer defines the webGL buffer to bind
  34806. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34807. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34808. */
  34809. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34810. /**
  34811. * Disable the instance attribute corresponding to the name in parameter
  34812. * @param name defines the name of the attribute to disable
  34813. */
  34814. disableInstanceAttributeByName(name: string): void;
  34815. /**
  34816. * Disable the instance attribute corresponding to the location in parameter
  34817. * @param attributeLocation defines the attribute location of the attribute to disable
  34818. */
  34819. disableInstanceAttribute(attributeLocation: number): void;
  34820. /**
  34821. * Disable the attribute corresponding to the location in parameter
  34822. * @param attributeLocation defines the attribute location of the attribute to disable
  34823. */
  34824. disableAttributeByIndex(attributeLocation: number): void;
  34825. /**
  34826. * Send a draw order
  34827. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34828. * @param indexStart defines the starting index
  34829. * @param indexCount defines the number of index to draw
  34830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34831. */
  34832. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34833. /**
  34834. * Draw a list of points
  34835. * @param verticesStart defines the index of first vertex to draw
  34836. * @param verticesCount defines the count of vertices to draw
  34837. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34838. */
  34839. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34840. /**
  34841. * Draw a list of unindexed primitives
  34842. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34843. * @param verticesStart defines the index of first vertex to draw
  34844. * @param verticesCount defines the count of vertices to draw
  34845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34846. */
  34847. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34848. /**
  34849. * Draw a list of indexed primitives
  34850. * @param fillMode defines the primitive to use
  34851. * @param indexStart defines the starting index
  34852. * @param indexCount defines the number of index to draw
  34853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34854. */
  34855. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34856. /**
  34857. * Draw a list of unindexed primitives
  34858. * @param fillMode defines the primitive to use
  34859. * @param verticesStart defines the index of first vertex to draw
  34860. * @param verticesCount defines the count of vertices to draw
  34861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34862. */
  34863. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34864. private _drawMode;
  34865. /** @hidden */
  34866. protected _reportDrawCall(): void;
  34867. /** @hidden */
  34868. _releaseEffect(effect: Effect): void;
  34869. /** @hidden */
  34870. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34871. /**
  34872. * Create a new effect (used to store vertex/fragment shaders)
  34873. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34874. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34875. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34876. * @param samplers defines an array of string used to represent textures
  34877. * @param defines defines the string containing the defines to use to compile the shaders
  34878. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34879. * @param onCompiled defines a function to call when the effect creation is successful
  34880. * @param onError defines a function to call when the effect creation has failed
  34881. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34882. * @returns the new Effect
  34883. */
  34884. 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;
  34885. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34886. private _compileShader;
  34887. private _compileRawShader;
  34888. /** @hidden */
  34889. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34890. /**
  34891. * Directly creates a webGL program
  34892. * @param pipelineContext defines the pipeline context to attach to
  34893. * @param vertexCode defines the vertex shader code to use
  34894. * @param fragmentCode defines the fragment shader code to use
  34895. * @param context defines the webGL context to use (if not set, the current one will be used)
  34896. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34897. * @returns the new webGL program
  34898. */
  34899. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34900. /**
  34901. * Creates a webGL program
  34902. * @param pipelineContext defines the pipeline context to attach to
  34903. * @param vertexCode defines the vertex shader code to use
  34904. * @param fragmentCode defines the fragment shader code to use
  34905. * @param defines defines the string containing the defines to use to compile the shaders
  34906. * @param context defines the webGL context to use (if not set, the current one will be used)
  34907. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34908. * @returns the new webGL program
  34909. */
  34910. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34911. /**
  34912. * Creates a new pipeline context
  34913. * @returns the new pipeline
  34914. */
  34915. createPipelineContext(): IPipelineContext;
  34916. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34917. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34918. /** @hidden */
  34919. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34920. /** @hidden */
  34921. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34922. /** @hidden */
  34923. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34924. /**
  34925. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34926. * @param pipelineContext defines the pipeline context to use
  34927. * @param uniformsNames defines the list of uniform names
  34928. * @returns an array of webGL uniform locations
  34929. */
  34930. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34931. /**
  34932. * Gets the lsit of active attributes for a given webGL program
  34933. * @param pipelineContext defines the pipeline context to use
  34934. * @param attributesNames defines the list of attribute names to get
  34935. * @returns an array of indices indicating the offset of each attribute
  34936. */
  34937. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34938. /**
  34939. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34940. * @param effect defines the effect to activate
  34941. */
  34942. enableEffect(effect: Nullable<Effect>): void;
  34943. /**
  34944. * Set the value of an uniform to a number (int)
  34945. * @param uniform defines the webGL uniform location where to store the value
  34946. * @param value defines the int number to store
  34947. */
  34948. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34949. /**
  34950. * Set the value of an uniform to an array of int32
  34951. * @param uniform defines the webGL uniform location where to store the value
  34952. * @param array defines the array of int32 to store
  34953. */
  34954. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34955. /**
  34956. * Set the value of an uniform to an array of int32 (stored as vec2)
  34957. * @param uniform defines the webGL uniform location where to store the value
  34958. * @param array defines the array of int32 to store
  34959. */
  34960. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34961. /**
  34962. * Set the value of an uniform to an array of int32 (stored as vec3)
  34963. * @param uniform defines the webGL uniform location where to store the value
  34964. * @param array defines the array of int32 to store
  34965. */
  34966. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34967. /**
  34968. * Set the value of an uniform to an array of int32 (stored as vec4)
  34969. * @param uniform defines the webGL uniform location where to store the value
  34970. * @param array defines the array of int32 to store
  34971. */
  34972. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34973. /**
  34974. * Set the value of an uniform to an array of number
  34975. * @param uniform defines the webGL uniform location where to store the value
  34976. * @param array defines the array of number to store
  34977. */
  34978. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34979. /**
  34980. * Set the value of an uniform to an array of number (stored as vec2)
  34981. * @param uniform defines the webGL uniform location where to store the value
  34982. * @param array defines the array of number to store
  34983. */
  34984. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34985. /**
  34986. * Set the value of an uniform to an array of number (stored as vec3)
  34987. * @param uniform defines the webGL uniform location where to store the value
  34988. * @param array defines the array of number to store
  34989. */
  34990. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34991. /**
  34992. * Set the value of an uniform to an array of number (stored as vec4)
  34993. * @param uniform defines the webGL uniform location where to store the value
  34994. * @param array defines the array of number to store
  34995. */
  34996. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34997. /**
  34998. * Set the value of an uniform to an array of float32 (stored as matrices)
  34999. * @param uniform defines the webGL uniform location where to store the value
  35000. * @param matrices defines the array of float32 to store
  35001. */
  35002. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35003. /**
  35004. * Set the value of an uniform to a matrix (3x3)
  35005. * @param uniform defines the webGL uniform location where to store the value
  35006. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35007. */
  35008. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35009. /**
  35010. * Set the value of an uniform to a matrix (2x2)
  35011. * @param uniform defines the webGL uniform location where to store the value
  35012. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35013. */
  35014. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35015. /**
  35016. * Set the value of an uniform to a number (float)
  35017. * @param uniform defines the webGL uniform location where to store the value
  35018. * @param value defines the float number to store
  35019. */
  35020. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35021. /**
  35022. * Set the value of an uniform to a vec2
  35023. * @param uniform defines the webGL uniform location where to store the value
  35024. * @param x defines the 1st component of the value
  35025. * @param y defines the 2nd component of the value
  35026. */
  35027. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35028. /**
  35029. * Set the value of an uniform to a vec3
  35030. * @param uniform defines the webGL uniform location where to store the value
  35031. * @param x defines the 1st component of the value
  35032. * @param y defines the 2nd component of the value
  35033. * @param z defines the 3rd component of the value
  35034. */
  35035. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35036. /**
  35037. * Set the value of an uniform to a vec4
  35038. * @param uniform defines the webGL uniform location where to store the value
  35039. * @param x defines the 1st component of the value
  35040. * @param y defines the 2nd component of the value
  35041. * @param z defines the 3rd component of the value
  35042. * @param w defines the 4th component of the value
  35043. */
  35044. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35045. /**
  35046. * Apply all cached states (depth, culling, stencil and alpha)
  35047. */
  35048. applyStates(): void;
  35049. /**
  35050. * Enable or disable color writing
  35051. * @param enable defines the state to set
  35052. */
  35053. setColorWrite(enable: boolean): void;
  35054. /**
  35055. * Gets a boolean indicating if color writing is enabled
  35056. * @returns the current color writing state
  35057. */
  35058. getColorWrite(): boolean;
  35059. /**
  35060. * Gets the depth culling state manager
  35061. */
  35062. get depthCullingState(): DepthCullingState;
  35063. /**
  35064. * Gets the alpha state manager
  35065. */
  35066. get alphaState(): AlphaState;
  35067. /**
  35068. * Gets the stencil state manager
  35069. */
  35070. get stencilState(): StencilState;
  35071. /**
  35072. * Clears the list of texture accessible through engine.
  35073. * This can help preventing texture load conflict due to name collision.
  35074. */
  35075. clearInternalTexturesCache(): void;
  35076. /**
  35077. * Force the entire cache to be cleared
  35078. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35079. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35080. */
  35081. wipeCaches(bruteForce?: boolean): void;
  35082. /** @hidden */
  35083. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35084. min: number;
  35085. mag: number;
  35086. };
  35087. /** @hidden */
  35088. _createTexture(): WebGLTexture;
  35089. /**
  35090. * Usually called from Texture.ts.
  35091. * Passed information to create a WebGLTexture
  35092. * @param url defines a value which contains one of the following:
  35093. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35094. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35095. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35096. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35097. * @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)
  35098. * @param scene needed for loading to the correct scene
  35099. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35100. * @param onLoad optional callback to be called upon successful completion
  35101. * @param onError optional callback to be called upon failure
  35102. * @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
  35103. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35104. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35105. * @param forcedExtension defines the extension to use to pick the right loader
  35106. * @param mimeType defines an optional mime type
  35107. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35108. */
  35109. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  35110. /**
  35111. * Loads an image as an HTMLImageElement.
  35112. * @param input url string, ArrayBuffer, or Blob to load
  35113. * @param onLoad callback called when the image successfully loads
  35114. * @param onError callback called when the image fails to load
  35115. * @param offlineProvider offline provider for caching
  35116. * @param mimeType optional mime type
  35117. * @returns the HTMLImageElement of the loaded image
  35118. * @hidden
  35119. */
  35120. 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>;
  35121. /**
  35122. * @hidden
  35123. */
  35124. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35125. private _unpackFlipYCached;
  35126. /**
  35127. * In case you are sharing the context with other applications, it might
  35128. * be interested to not cache the unpack flip y state to ensure a consistent
  35129. * value would be set.
  35130. */
  35131. enableUnpackFlipYCached: boolean;
  35132. /** @hidden */
  35133. _unpackFlipY(value: boolean): void;
  35134. /** @hidden */
  35135. _getUnpackAlignement(): number;
  35136. private _getTextureTarget;
  35137. /**
  35138. * Update the sampling mode of a given texture
  35139. * @param samplingMode defines the required sampling mode
  35140. * @param texture defines the texture to update
  35141. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35142. */
  35143. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35144. /**
  35145. * Update the sampling mode of a given texture
  35146. * @param texture defines the texture to update
  35147. * @param wrapU defines the texture wrap mode of the u coordinates
  35148. * @param wrapV defines the texture wrap mode of the v coordinates
  35149. * @param wrapR defines the texture wrap mode of the r coordinates
  35150. */
  35151. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35152. /** @hidden */
  35153. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35154. width: number;
  35155. height: number;
  35156. layers?: number;
  35157. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35158. /** @hidden */
  35159. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35160. /** @hidden */
  35161. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35162. /**
  35163. * Update a portion of an internal texture
  35164. * @param texture defines the texture to update
  35165. * @param imageData defines the data to store into the texture
  35166. * @param xOffset defines the x coordinates of the update rectangle
  35167. * @param yOffset defines the y coordinates of the update rectangle
  35168. * @param width defines the width of the update rectangle
  35169. * @param height defines the height of the update rectangle
  35170. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35171. * @param lod defines the lod level to update (0 by default)
  35172. */
  35173. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35174. /** @hidden */
  35175. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35176. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35177. private _prepareWebGLTexture;
  35178. /** @hidden */
  35179. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35180. private _getDepthStencilBuffer;
  35181. /** @hidden */
  35182. _releaseFramebufferObjects(texture: InternalTexture): void;
  35183. /** @hidden */
  35184. _releaseTexture(texture: InternalTexture): void;
  35185. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35186. protected _setProgram(program: WebGLProgram): void;
  35187. protected _boundUniforms: {
  35188. [key: number]: WebGLUniformLocation;
  35189. };
  35190. /**
  35191. * Binds an effect to the webGL context
  35192. * @param effect defines the effect to bind
  35193. */
  35194. bindSamplers(effect: Effect): void;
  35195. private _activateCurrentTexture;
  35196. /** @hidden */
  35197. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35198. /** @hidden */
  35199. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35200. /**
  35201. * Unbind all textures from the webGL context
  35202. */
  35203. unbindAllTextures(): void;
  35204. /**
  35205. * Sets a texture to the according uniform.
  35206. * @param channel The texture channel
  35207. * @param uniform The uniform to set
  35208. * @param texture The texture to apply
  35209. */
  35210. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35211. private _bindSamplerUniformToChannel;
  35212. private _getTextureWrapMode;
  35213. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35214. /**
  35215. * Sets an array of texture to the webGL context
  35216. * @param channel defines the channel where the texture array must be set
  35217. * @param uniform defines the associated uniform location
  35218. * @param textures defines the array of textures to bind
  35219. */
  35220. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35221. /** @hidden */
  35222. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35223. private _setTextureParameterFloat;
  35224. private _setTextureParameterInteger;
  35225. /**
  35226. * Unbind all vertex attributes from the webGL context
  35227. */
  35228. unbindAllAttributes(): void;
  35229. /**
  35230. * 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
  35231. */
  35232. releaseEffects(): void;
  35233. /**
  35234. * Dispose and release all associated resources
  35235. */
  35236. dispose(): void;
  35237. /**
  35238. * Attach a new callback raised when context lost event is fired
  35239. * @param callback defines the callback to call
  35240. */
  35241. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35242. /**
  35243. * Attach a new callback raised when context restored event is fired
  35244. * @param callback defines the callback to call
  35245. */
  35246. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35247. /**
  35248. * Get the current error code of the webGL context
  35249. * @returns the error code
  35250. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35251. */
  35252. getError(): number;
  35253. private _canRenderToFloatFramebuffer;
  35254. private _canRenderToHalfFloatFramebuffer;
  35255. private _canRenderToFramebuffer;
  35256. /** @hidden */
  35257. _getWebGLTextureType(type: number): number;
  35258. /** @hidden */
  35259. _getInternalFormat(format: number): number;
  35260. /** @hidden */
  35261. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35262. /** @hidden */
  35263. _getRGBAMultiSampleBufferFormat(type: number): number;
  35264. /** @hidden */
  35265. _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;
  35266. /**
  35267. * Loads a file from a url
  35268. * @param url url to load
  35269. * @param onSuccess callback called when the file successfully loads
  35270. * @param onProgress callback called while file is loading (if the server supports this mode)
  35271. * @param offlineProvider defines the offline provider for caching
  35272. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35273. * @param onError callback called when the file fails to load
  35274. * @returns a file request object
  35275. * @hidden
  35276. */
  35277. 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;
  35278. /**
  35279. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35280. * @param x defines the x coordinate of the rectangle where pixels must be read
  35281. * @param y defines the y coordinate of the rectangle where pixels must be read
  35282. * @param width defines the width of the rectangle where pixels must be read
  35283. * @param height defines the height of the rectangle where pixels must be read
  35284. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35285. * @returns a Uint8Array containing RGBA colors
  35286. */
  35287. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35288. private static _isSupported;
  35289. /**
  35290. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35291. * @returns true if the engine can be created
  35292. * @ignorenaming
  35293. */
  35294. static isSupported(): boolean;
  35295. /**
  35296. * Find the next highest power of two.
  35297. * @param x Number to start search from.
  35298. * @return Next highest power of two.
  35299. */
  35300. static CeilingPOT(x: number): number;
  35301. /**
  35302. * Find the next lowest power of two.
  35303. * @param x Number to start search from.
  35304. * @return Next lowest power of two.
  35305. */
  35306. static FloorPOT(x: number): number;
  35307. /**
  35308. * Find the nearest power of two.
  35309. * @param x Number to start search from.
  35310. * @return Next nearest power of two.
  35311. */
  35312. static NearestPOT(x: number): number;
  35313. /**
  35314. * Get the closest exponent of two
  35315. * @param value defines the value to approximate
  35316. * @param max defines the maximum value to return
  35317. * @param mode defines how to define the closest value
  35318. * @returns closest exponent of two of the given value
  35319. */
  35320. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35321. /**
  35322. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35323. * @param func - the function to be called
  35324. * @param requester - the object that will request the next frame. Falls back to window.
  35325. * @returns frame number
  35326. */
  35327. static QueueNewFrame(func: () => void, requester?: any): number;
  35328. /**
  35329. * Gets host document
  35330. * @returns the host document object
  35331. */
  35332. getHostDocument(): Nullable<Document>;
  35333. }
  35334. }
  35335. declare module BABYLON {
  35336. /**
  35337. * Class representing spherical harmonics coefficients to the 3rd degree
  35338. */
  35339. export class SphericalHarmonics {
  35340. /**
  35341. * Defines whether or not the harmonics have been prescaled for rendering.
  35342. */
  35343. preScaled: boolean;
  35344. /**
  35345. * The l0,0 coefficients of the spherical harmonics
  35346. */
  35347. l00: Vector3;
  35348. /**
  35349. * The l1,-1 coefficients of the spherical harmonics
  35350. */
  35351. l1_1: Vector3;
  35352. /**
  35353. * The l1,0 coefficients of the spherical harmonics
  35354. */
  35355. l10: Vector3;
  35356. /**
  35357. * The l1,1 coefficients of the spherical harmonics
  35358. */
  35359. l11: Vector3;
  35360. /**
  35361. * The l2,-2 coefficients of the spherical harmonics
  35362. */
  35363. l2_2: Vector3;
  35364. /**
  35365. * The l2,-1 coefficients of the spherical harmonics
  35366. */
  35367. l2_1: Vector3;
  35368. /**
  35369. * The l2,0 coefficients of the spherical harmonics
  35370. */
  35371. l20: Vector3;
  35372. /**
  35373. * The l2,1 coefficients of the spherical harmonics
  35374. */
  35375. l21: Vector3;
  35376. /**
  35377. * The l2,2 coefficients of the spherical harmonics
  35378. */
  35379. l22: Vector3;
  35380. /**
  35381. * Adds a light to the spherical harmonics
  35382. * @param direction the direction of the light
  35383. * @param color the color of the light
  35384. * @param deltaSolidAngle the delta solid angle of the light
  35385. */
  35386. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35387. /**
  35388. * Scales the spherical harmonics by the given amount
  35389. * @param scale the amount to scale
  35390. */
  35391. scaleInPlace(scale: number): void;
  35392. /**
  35393. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35394. *
  35395. * ```
  35396. * E_lm = A_l * L_lm
  35397. * ```
  35398. *
  35399. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35400. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35401. * the scaling factors are given in equation 9.
  35402. */
  35403. convertIncidentRadianceToIrradiance(): void;
  35404. /**
  35405. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35406. *
  35407. * ```
  35408. * L = (1/pi) * E * rho
  35409. * ```
  35410. *
  35411. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35412. */
  35413. convertIrradianceToLambertianRadiance(): void;
  35414. /**
  35415. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35416. * required operations at run time.
  35417. *
  35418. * This is simply done by scaling back the SH with Ylm constants parameter.
  35419. * The trigonometric part being applied by the shader at run time.
  35420. */
  35421. preScaleForRendering(): void;
  35422. /**
  35423. * Constructs a spherical harmonics from an array.
  35424. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35425. * @returns the spherical harmonics
  35426. */
  35427. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35428. /**
  35429. * Gets the spherical harmonics from polynomial
  35430. * @param polynomial the spherical polynomial
  35431. * @returns the spherical harmonics
  35432. */
  35433. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35434. }
  35435. /**
  35436. * Class representing spherical polynomial coefficients to the 3rd degree
  35437. */
  35438. export class SphericalPolynomial {
  35439. private _harmonics;
  35440. /**
  35441. * The spherical harmonics used to create the polynomials.
  35442. */
  35443. get preScaledHarmonics(): SphericalHarmonics;
  35444. /**
  35445. * The x coefficients of the spherical polynomial
  35446. */
  35447. x: Vector3;
  35448. /**
  35449. * The y coefficients of the spherical polynomial
  35450. */
  35451. y: Vector3;
  35452. /**
  35453. * The z coefficients of the spherical polynomial
  35454. */
  35455. z: Vector3;
  35456. /**
  35457. * The xx coefficients of the spherical polynomial
  35458. */
  35459. xx: Vector3;
  35460. /**
  35461. * The yy coefficients of the spherical polynomial
  35462. */
  35463. yy: Vector3;
  35464. /**
  35465. * The zz coefficients of the spherical polynomial
  35466. */
  35467. zz: Vector3;
  35468. /**
  35469. * The xy coefficients of the spherical polynomial
  35470. */
  35471. xy: Vector3;
  35472. /**
  35473. * The yz coefficients of the spherical polynomial
  35474. */
  35475. yz: Vector3;
  35476. /**
  35477. * The zx coefficients of the spherical polynomial
  35478. */
  35479. zx: Vector3;
  35480. /**
  35481. * Adds an ambient color to the spherical polynomial
  35482. * @param color the color to add
  35483. */
  35484. addAmbient(color: Color3): void;
  35485. /**
  35486. * Scales the spherical polynomial by the given amount
  35487. * @param scale the amount to scale
  35488. */
  35489. scaleInPlace(scale: number): void;
  35490. /**
  35491. * Gets the spherical polynomial from harmonics
  35492. * @param harmonics the spherical harmonics
  35493. * @returns the spherical polynomial
  35494. */
  35495. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35496. /**
  35497. * Constructs a spherical polynomial from an array.
  35498. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35499. * @returns the spherical polynomial
  35500. */
  35501. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35502. }
  35503. }
  35504. declare module BABYLON {
  35505. /**
  35506. * Defines the source of the internal texture
  35507. */
  35508. export enum InternalTextureSource {
  35509. /**
  35510. * The source of the texture data is unknown
  35511. */
  35512. Unknown = 0,
  35513. /**
  35514. * Texture data comes from an URL
  35515. */
  35516. Url = 1,
  35517. /**
  35518. * Texture data is only used for temporary storage
  35519. */
  35520. Temp = 2,
  35521. /**
  35522. * Texture data comes from raw data (ArrayBuffer)
  35523. */
  35524. Raw = 3,
  35525. /**
  35526. * Texture content is dynamic (video or dynamic texture)
  35527. */
  35528. Dynamic = 4,
  35529. /**
  35530. * Texture content is generated by rendering to it
  35531. */
  35532. RenderTarget = 5,
  35533. /**
  35534. * Texture content is part of a multi render target process
  35535. */
  35536. MultiRenderTarget = 6,
  35537. /**
  35538. * Texture data comes from a cube data file
  35539. */
  35540. Cube = 7,
  35541. /**
  35542. * Texture data comes from a raw cube data
  35543. */
  35544. CubeRaw = 8,
  35545. /**
  35546. * Texture data come from a prefiltered cube data file
  35547. */
  35548. CubePrefiltered = 9,
  35549. /**
  35550. * Texture content is raw 3D data
  35551. */
  35552. Raw3D = 10,
  35553. /**
  35554. * Texture content is raw 2D array data
  35555. */
  35556. Raw2DArray = 11,
  35557. /**
  35558. * Texture content is a depth texture
  35559. */
  35560. Depth = 12,
  35561. /**
  35562. * Texture data comes from a raw cube data encoded with RGBD
  35563. */
  35564. CubeRawRGBD = 13
  35565. }
  35566. /**
  35567. * Class used to store data associated with WebGL texture data for the engine
  35568. * This class should not be used directly
  35569. */
  35570. export class InternalTexture {
  35571. /** @hidden */
  35572. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35573. /**
  35574. * Defines if the texture is ready
  35575. */
  35576. isReady: boolean;
  35577. /**
  35578. * Defines if the texture is a cube texture
  35579. */
  35580. isCube: boolean;
  35581. /**
  35582. * Defines if the texture contains 3D data
  35583. */
  35584. is3D: boolean;
  35585. /**
  35586. * Defines if the texture contains 2D array data
  35587. */
  35588. is2DArray: boolean;
  35589. /**
  35590. * Defines if the texture contains multiview data
  35591. */
  35592. isMultiview: boolean;
  35593. /**
  35594. * Gets the URL used to load this texture
  35595. */
  35596. url: string;
  35597. /**
  35598. * Gets the sampling mode of the texture
  35599. */
  35600. samplingMode: number;
  35601. /**
  35602. * Gets a boolean indicating if the texture needs mipmaps generation
  35603. */
  35604. generateMipMaps: boolean;
  35605. /**
  35606. * Gets the number of samples used by the texture (WebGL2+ only)
  35607. */
  35608. samples: number;
  35609. /**
  35610. * Gets the type of the texture (int, float...)
  35611. */
  35612. type: number;
  35613. /**
  35614. * Gets the format of the texture (RGB, RGBA...)
  35615. */
  35616. format: number;
  35617. /**
  35618. * Observable called when the texture is loaded
  35619. */
  35620. onLoadedObservable: Observable<InternalTexture>;
  35621. /**
  35622. * Gets the width of the texture
  35623. */
  35624. width: number;
  35625. /**
  35626. * Gets the height of the texture
  35627. */
  35628. height: number;
  35629. /**
  35630. * Gets the depth of the texture
  35631. */
  35632. depth: number;
  35633. /**
  35634. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35635. */
  35636. baseWidth: number;
  35637. /**
  35638. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35639. */
  35640. baseHeight: number;
  35641. /**
  35642. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35643. */
  35644. baseDepth: number;
  35645. /**
  35646. * Gets a boolean indicating if the texture is inverted on Y axis
  35647. */
  35648. invertY: boolean;
  35649. /** @hidden */
  35650. _invertVScale: boolean;
  35651. /** @hidden */
  35652. _associatedChannel: number;
  35653. /** @hidden */
  35654. _source: InternalTextureSource;
  35655. /** @hidden */
  35656. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35657. /** @hidden */
  35658. _bufferView: Nullable<ArrayBufferView>;
  35659. /** @hidden */
  35660. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35661. /** @hidden */
  35662. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35663. /** @hidden */
  35664. _size: number;
  35665. /** @hidden */
  35666. _extension: string;
  35667. /** @hidden */
  35668. _files: Nullable<string[]>;
  35669. /** @hidden */
  35670. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35671. /** @hidden */
  35672. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35673. /** @hidden */
  35674. _framebuffer: Nullable<WebGLFramebuffer>;
  35675. /** @hidden */
  35676. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35677. /** @hidden */
  35678. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35679. /** @hidden */
  35680. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35681. /** @hidden */
  35682. _attachments: Nullable<number[]>;
  35683. /** @hidden */
  35684. _textureArray: Nullable<InternalTexture[]>;
  35685. /** @hidden */
  35686. _cachedCoordinatesMode: Nullable<number>;
  35687. /** @hidden */
  35688. _cachedWrapU: Nullable<number>;
  35689. /** @hidden */
  35690. _cachedWrapV: Nullable<number>;
  35691. /** @hidden */
  35692. _cachedWrapR: Nullable<number>;
  35693. /** @hidden */
  35694. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35695. /** @hidden */
  35696. _isDisabled: boolean;
  35697. /** @hidden */
  35698. _compression: Nullable<string>;
  35699. /** @hidden */
  35700. _generateStencilBuffer: boolean;
  35701. /** @hidden */
  35702. _generateDepthBuffer: boolean;
  35703. /** @hidden */
  35704. _comparisonFunction: number;
  35705. /** @hidden */
  35706. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35707. /** @hidden */
  35708. _lodGenerationScale: number;
  35709. /** @hidden */
  35710. _lodGenerationOffset: number;
  35711. /** @hidden */
  35712. _depthStencilTexture: Nullable<InternalTexture>;
  35713. /** @hidden */
  35714. _colorTextureArray: Nullable<WebGLTexture>;
  35715. /** @hidden */
  35716. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35717. /** @hidden */
  35718. _lodTextureHigh: Nullable<BaseTexture>;
  35719. /** @hidden */
  35720. _lodTextureMid: Nullable<BaseTexture>;
  35721. /** @hidden */
  35722. _lodTextureLow: Nullable<BaseTexture>;
  35723. /** @hidden */
  35724. _isRGBD: boolean;
  35725. /** @hidden */
  35726. _linearSpecularLOD: boolean;
  35727. /** @hidden */
  35728. _irradianceTexture: Nullable<BaseTexture>;
  35729. /** @hidden */
  35730. _webGLTexture: Nullable<WebGLTexture>;
  35731. /** @hidden */
  35732. _references: number;
  35733. private _engine;
  35734. /**
  35735. * Gets the Engine the texture belongs to.
  35736. * @returns The babylon engine
  35737. */
  35738. getEngine(): ThinEngine;
  35739. /**
  35740. * Gets the data source type of the texture
  35741. */
  35742. get source(): InternalTextureSource;
  35743. /**
  35744. * Creates a new InternalTexture
  35745. * @param engine defines the engine to use
  35746. * @param source defines the type of data that will be used
  35747. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35748. */
  35749. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35750. /**
  35751. * Increments the number of references (ie. the number of Texture that point to it)
  35752. */
  35753. incrementReferences(): void;
  35754. /**
  35755. * Change the size of the texture (not the size of the content)
  35756. * @param width defines the new width
  35757. * @param height defines the new height
  35758. * @param depth defines the new depth (1 by default)
  35759. */
  35760. updateSize(width: int, height: int, depth?: int): void;
  35761. /** @hidden */
  35762. _rebuild(): void;
  35763. /** @hidden */
  35764. _swapAndDie(target: InternalTexture): void;
  35765. /**
  35766. * Dispose the current allocated resources
  35767. */
  35768. dispose(): void;
  35769. }
  35770. }
  35771. declare module BABYLON {
  35772. /**
  35773. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35774. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35775. */
  35776. export class Analyser {
  35777. /**
  35778. * Gets or sets the smoothing
  35779. * @ignorenaming
  35780. */
  35781. SMOOTHING: number;
  35782. /**
  35783. * Gets or sets the FFT table size
  35784. * @ignorenaming
  35785. */
  35786. FFT_SIZE: number;
  35787. /**
  35788. * Gets or sets the bar graph amplitude
  35789. * @ignorenaming
  35790. */
  35791. BARGRAPHAMPLITUDE: number;
  35792. /**
  35793. * Gets or sets the position of the debug canvas
  35794. * @ignorenaming
  35795. */
  35796. DEBUGCANVASPOS: {
  35797. x: number;
  35798. y: number;
  35799. };
  35800. /**
  35801. * Gets or sets the debug canvas size
  35802. * @ignorenaming
  35803. */
  35804. DEBUGCANVASSIZE: {
  35805. width: number;
  35806. height: number;
  35807. };
  35808. private _byteFreqs;
  35809. private _byteTime;
  35810. private _floatFreqs;
  35811. private _webAudioAnalyser;
  35812. private _debugCanvas;
  35813. private _debugCanvasContext;
  35814. private _scene;
  35815. private _registerFunc;
  35816. private _audioEngine;
  35817. /**
  35818. * Creates a new analyser
  35819. * @param scene defines hosting scene
  35820. */
  35821. constructor(scene: Scene);
  35822. /**
  35823. * Get the number of data values you will have to play with for the visualization
  35824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35825. * @returns a number
  35826. */
  35827. getFrequencyBinCount(): number;
  35828. /**
  35829. * Gets the current frequency data as a byte array
  35830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35831. * @returns a Uint8Array
  35832. */
  35833. getByteFrequencyData(): Uint8Array;
  35834. /**
  35835. * Gets the current waveform as a byte array
  35836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35837. * @returns a Uint8Array
  35838. */
  35839. getByteTimeDomainData(): Uint8Array;
  35840. /**
  35841. * Gets the current frequency data as a float array
  35842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35843. * @returns a Float32Array
  35844. */
  35845. getFloatFrequencyData(): Float32Array;
  35846. /**
  35847. * Renders the debug canvas
  35848. */
  35849. drawDebugCanvas(): void;
  35850. /**
  35851. * Stops rendering the debug canvas and removes it
  35852. */
  35853. stopDebugCanvas(): void;
  35854. /**
  35855. * Connects two audio nodes
  35856. * @param inputAudioNode defines first node to connect
  35857. * @param outputAudioNode defines second node to connect
  35858. */
  35859. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35860. /**
  35861. * Releases all associated resources
  35862. */
  35863. dispose(): void;
  35864. }
  35865. }
  35866. declare module BABYLON {
  35867. /**
  35868. * This represents an audio engine and it is responsible
  35869. * to play, synchronize and analyse sounds throughout the application.
  35870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35871. */
  35872. export interface IAudioEngine extends IDisposable {
  35873. /**
  35874. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35875. */
  35876. readonly canUseWebAudio: boolean;
  35877. /**
  35878. * Gets the current AudioContext if available.
  35879. */
  35880. readonly audioContext: Nullable<AudioContext>;
  35881. /**
  35882. * The master gain node defines the global audio volume of your audio engine.
  35883. */
  35884. readonly masterGain: GainNode;
  35885. /**
  35886. * Gets whether or not mp3 are supported by your browser.
  35887. */
  35888. readonly isMP3supported: boolean;
  35889. /**
  35890. * Gets whether or not ogg are supported by your browser.
  35891. */
  35892. readonly isOGGsupported: boolean;
  35893. /**
  35894. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35895. * @ignoreNaming
  35896. */
  35897. WarnedWebAudioUnsupported: boolean;
  35898. /**
  35899. * Defines if the audio engine relies on a custom unlocked button.
  35900. * In this case, the embedded button will not be displayed.
  35901. */
  35902. useCustomUnlockedButton: boolean;
  35903. /**
  35904. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35905. */
  35906. readonly unlocked: boolean;
  35907. /**
  35908. * Event raised when audio has been unlocked on the browser.
  35909. */
  35910. onAudioUnlockedObservable: Observable<AudioEngine>;
  35911. /**
  35912. * Event raised when audio has been locked on the browser.
  35913. */
  35914. onAudioLockedObservable: Observable<AudioEngine>;
  35915. /**
  35916. * Flags the audio engine in Locked state.
  35917. * This happens due to new browser policies preventing audio to autoplay.
  35918. */
  35919. lock(): void;
  35920. /**
  35921. * Unlocks the audio engine once a user action has been done on the dom.
  35922. * This is helpful to resume play once browser policies have been satisfied.
  35923. */
  35924. unlock(): void;
  35925. /**
  35926. * Gets the global volume sets on the master gain.
  35927. * @returns the global volume if set or -1 otherwise
  35928. */
  35929. getGlobalVolume(): number;
  35930. /**
  35931. * Sets the global volume of your experience (sets on the master gain).
  35932. * @param newVolume Defines the new global volume of the application
  35933. */
  35934. setGlobalVolume(newVolume: number): void;
  35935. /**
  35936. * Connect the audio engine to an audio analyser allowing some amazing
  35937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35938. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35939. * @param analyser The analyser to connect to the engine
  35940. */
  35941. connectToAnalyser(analyser: Analyser): void;
  35942. }
  35943. /**
  35944. * This represents the default audio engine used in babylon.
  35945. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35947. */
  35948. export class AudioEngine implements IAudioEngine {
  35949. private _audioContext;
  35950. private _audioContextInitialized;
  35951. private _muteButton;
  35952. private _hostElement;
  35953. /**
  35954. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35955. */
  35956. canUseWebAudio: boolean;
  35957. /**
  35958. * The master gain node defines the global audio volume of your audio engine.
  35959. */
  35960. masterGain: GainNode;
  35961. /**
  35962. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35963. * @ignoreNaming
  35964. */
  35965. WarnedWebAudioUnsupported: boolean;
  35966. /**
  35967. * Gets whether or not mp3 are supported by your browser.
  35968. */
  35969. isMP3supported: boolean;
  35970. /**
  35971. * Gets whether or not ogg are supported by your browser.
  35972. */
  35973. isOGGsupported: boolean;
  35974. /**
  35975. * Gets whether audio has been unlocked on the device.
  35976. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35977. * a user interaction has happened.
  35978. */
  35979. unlocked: boolean;
  35980. /**
  35981. * Defines if the audio engine relies on a custom unlocked button.
  35982. * In this case, the embedded button will not be displayed.
  35983. */
  35984. useCustomUnlockedButton: boolean;
  35985. /**
  35986. * Event raised when audio has been unlocked on the browser.
  35987. */
  35988. onAudioUnlockedObservable: Observable<AudioEngine>;
  35989. /**
  35990. * Event raised when audio has been locked on the browser.
  35991. */
  35992. onAudioLockedObservable: Observable<AudioEngine>;
  35993. /**
  35994. * Gets the current AudioContext if available.
  35995. */
  35996. get audioContext(): Nullable<AudioContext>;
  35997. private _connectedAnalyser;
  35998. /**
  35999. * Instantiates a new audio engine.
  36000. *
  36001. * There should be only one per page as some browsers restrict the number
  36002. * of audio contexts you can create.
  36003. * @param hostElement defines the host element where to display the mute icon if necessary
  36004. */
  36005. constructor(hostElement?: Nullable<HTMLElement>);
  36006. /**
  36007. * Flags the audio engine in Locked state.
  36008. * This happens due to new browser policies preventing audio to autoplay.
  36009. */
  36010. lock(): void;
  36011. /**
  36012. * Unlocks the audio engine once a user action has been done on the dom.
  36013. * This is helpful to resume play once browser policies have been satisfied.
  36014. */
  36015. unlock(): void;
  36016. private _resumeAudioContext;
  36017. private _initializeAudioContext;
  36018. private _tryToRun;
  36019. private _triggerRunningState;
  36020. private _triggerSuspendedState;
  36021. private _displayMuteButton;
  36022. private _moveButtonToTopLeft;
  36023. private _onResize;
  36024. private _hideMuteButton;
  36025. /**
  36026. * Destroy and release the resources associated with the audio ccontext.
  36027. */
  36028. dispose(): void;
  36029. /**
  36030. * Gets the global volume sets on the master gain.
  36031. * @returns the global volume if set or -1 otherwise
  36032. */
  36033. getGlobalVolume(): number;
  36034. /**
  36035. * Sets the global volume of your experience (sets on the master gain).
  36036. * @param newVolume Defines the new global volume of the application
  36037. */
  36038. setGlobalVolume(newVolume: number): void;
  36039. /**
  36040. * Connect the audio engine to an audio analyser allowing some amazing
  36041. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36042. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36043. * @param analyser The analyser to connect to the engine
  36044. */
  36045. connectToAnalyser(analyser: Analyser): void;
  36046. }
  36047. }
  36048. declare module BABYLON {
  36049. /**
  36050. * Interface used to present a loading screen while loading a scene
  36051. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36052. */
  36053. export interface ILoadingScreen {
  36054. /**
  36055. * Function called to display the loading screen
  36056. */
  36057. displayLoadingUI: () => void;
  36058. /**
  36059. * Function called to hide the loading screen
  36060. */
  36061. hideLoadingUI: () => void;
  36062. /**
  36063. * Gets or sets the color to use for the background
  36064. */
  36065. loadingUIBackgroundColor: string;
  36066. /**
  36067. * Gets or sets the text to display while loading
  36068. */
  36069. loadingUIText: string;
  36070. }
  36071. /**
  36072. * Class used for the default loading screen
  36073. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36074. */
  36075. export class DefaultLoadingScreen implements ILoadingScreen {
  36076. private _renderingCanvas;
  36077. private _loadingText;
  36078. private _loadingDivBackgroundColor;
  36079. private _loadingDiv;
  36080. private _loadingTextDiv;
  36081. /** Gets or sets the logo url to use for the default loading screen */
  36082. static DefaultLogoUrl: string;
  36083. /** Gets or sets the spinner url to use for the default loading screen */
  36084. static DefaultSpinnerUrl: string;
  36085. /**
  36086. * Creates a new default loading screen
  36087. * @param _renderingCanvas defines the canvas used to render the scene
  36088. * @param _loadingText defines the default text to display
  36089. * @param _loadingDivBackgroundColor defines the default background color
  36090. */
  36091. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36092. /**
  36093. * Function called to display the loading screen
  36094. */
  36095. displayLoadingUI(): void;
  36096. /**
  36097. * Function called to hide the loading screen
  36098. */
  36099. hideLoadingUI(): void;
  36100. /**
  36101. * Gets or sets the text to display while loading
  36102. */
  36103. set loadingUIText(text: string);
  36104. get loadingUIText(): string;
  36105. /**
  36106. * Gets or sets the color to use for the background
  36107. */
  36108. get loadingUIBackgroundColor(): string;
  36109. set loadingUIBackgroundColor(color: string);
  36110. private _resizeLoadingUI;
  36111. }
  36112. }
  36113. declare module BABYLON {
  36114. /**
  36115. * Interface for any object that can request an animation frame
  36116. */
  36117. export interface ICustomAnimationFrameRequester {
  36118. /**
  36119. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36120. */
  36121. renderFunction?: Function;
  36122. /**
  36123. * Called to request the next frame to render to
  36124. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36125. */
  36126. requestAnimationFrame: Function;
  36127. /**
  36128. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36129. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36130. */
  36131. requestID?: number;
  36132. }
  36133. }
  36134. declare module BABYLON {
  36135. /**
  36136. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36137. */
  36138. export class PerformanceMonitor {
  36139. private _enabled;
  36140. private _rollingFrameTime;
  36141. private _lastFrameTimeMs;
  36142. /**
  36143. * constructor
  36144. * @param frameSampleSize The number of samples required to saturate the sliding window
  36145. */
  36146. constructor(frameSampleSize?: number);
  36147. /**
  36148. * Samples current frame
  36149. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36150. */
  36151. sampleFrame(timeMs?: number): void;
  36152. /**
  36153. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36154. */
  36155. get averageFrameTime(): number;
  36156. /**
  36157. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36158. */
  36159. get averageFrameTimeVariance(): number;
  36160. /**
  36161. * Returns the frame time of the most recent frame
  36162. */
  36163. get instantaneousFrameTime(): number;
  36164. /**
  36165. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36166. */
  36167. get averageFPS(): number;
  36168. /**
  36169. * Returns the average framerate in frames per second using the most recent frame time
  36170. */
  36171. get instantaneousFPS(): number;
  36172. /**
  36173. * Returns true if enough samples have been taken to completely fill the sliding window
  36174. */
  36175. get isSaturated(): boolean;
  36176. /**
  36177. * Enables contributions to the sliding window sample set
  36178. */
  36179. enable(): void;
  36180. /**
  36181. * Disables contributions to the sliding window sample set
  36182. * Samples will not be interpolated over the disabled period
  36183. */
  36184. disable(): void;
  36185. /**
  36186. * Returns true if sampling is enabled
  36187. */
  36188. get isEnabled(): boolean;
  36189. /**
  36190. * Resets performance monitor
  36191. */
  36192. reset(): void;
  36193. }
  36194. /**
  36195. * RollingAverage
  36196. *
  36197. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36198. */
  36199. export class RollingAverage {
  36200. /**
  36201. * Current average
  36202. */
  36203. average: number;
  36204. /**
  36205. * Current variance
  36206. */
  36207. variance: number;
  36208. protected _samples: Array<number>;
  36209. protected _sampleCount: number;
  36210. protected _pos: number;
  36211. protected _m2: number;
  36212. /**
  36213. * constructor
  36214. * @param length The number of samples required to saturate the sliding window
  36215. */
  36216. constructor(length: number);
  36217. /**
  36218. * Adds a sample to the sample set
  36219. * @param v The sample value
  36220. */
  36221. add(v: number): void;
  36222. /**
  36223. * Returns previously added values or null if outside of history or outside the sliding window domain
  36224. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36225. * @return Value previously recorded with add() or null if outside of range
  36226. */
  36227. history(i: number): number;
  36228. /**
  36229. * Returns true if enough samples have been taken to completely fill the sliding window
  36230. * @return true if sample-set saturated
  36231. */
  36232. isSaturated(): boolean;
  36233. /**
  36234. * Resets the rolling average (equivalent to 0 samples taken so far)
  36235. */
  36236. reset(): void;
  36237. /**
  36238. * Wraps a value around the sample range boundaries
  36239. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36240. * @return Wrapped position in sample range
  36241. */
  36242. protected _wrapPosition(i: number): number;
  36243. }
  36244. }
  36245. declare module BABYLON {
  36246. /**
  36247. * This class is used to track a performance counter which is number based.
  36248. * The user has access to many properties which give statistics of different nature.
  36249. *
  36250. * The implementer can track two kinds of Performance Counter: time and count.
  36251. * 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.
  36252. * 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.
  36253. */
  36254. export class PerfCounter {
  36255. /**
  36256. * Gets or sets a global boolean to turn on and off all the counters
  36257. */
  36258. static Enabled: boolean;
  36259. /**
  36260. * Returns the smallest value ever
  36261. */
  36262. get min(): number;
  36263. /**
  36264. * Returns the biggest value ever
  36265. */
  36266. get max(): number;
  36267. /**
  36268. * Returns the average value since the performance counter is running
  36269. */
  36270. get average(): number;
  36271. /**
  36272. * Returns the average value of the last second the counter was monitored
  36273. */
  36274. get lastSecAverage(): number;
  36275. /**
  36276. * Returns the current value
  36277. */
  36278. get current(): number;
  36279. /**
  36280. * Gets the accumulated total
  36281. */
  36282. get total(): number;
  36283. /**
  36284. * Gets the total value count
  36285. */
  36286. get count(): number;
  36287. /**
  36288. * Creates a new counter
  36289. */
  36290. constructor();
  36291. /**
  36292. * Call this method to start monitoring a new frame.
  36293. * 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.
  36294. */
  36295. fetchNewFrame(): void;
  36296. /**
  36297. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36298. * @param newCount the count value to add to the monitored count
  36299. * @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.
  36300. */
  36301. addCount(newCount: number, fetchResult: boolean): void;
  36302. /**
  36303. * Start monitoring this performance counter
  36304. */
  36305. beginMonitoring(): void;
  36306. /**
  36307. * Compute the time lapsed since the previous beginMonitoring() call.
  36308. * @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
  36309. */
  36310. endMonitoring(newFrame?: boolean): void;
  36311. private _fetchResult;
  36312. private _startMonitoringTime;
  36313. private _min;
  36314. private _max;
  36315. private _average;
  36316. private _current;
  36317. private _totalValueCount;
  36318. private _totalAccumulated;
  36319. private _lastSecAverage;
  36320. private _lastSecAccumulated;
  36321. private _lastSecTime;
  36322. private _lastSecValueCount;
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. interface ThinEngine {
  36327. /**
  36328. * Sets alpha constants used by some alpha blending modes
  36329. * @param r defines the red component
  36330. * @param g defines the green component
  36331. * @param b defines the blue component
  36332. * @param a defines the alpha component
  36333. */
  36334. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36335. /**
  36336. * Sets the current alpha mode
  36337. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36339. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36340. */
  36341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36342. /**
  36343. * Gets the current alpha mode
  36344. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36345. * @returns the current alpha mode
  36346. */
  36347. getAlphaMode(): number;
  36348. /**
  36349. * Sets the current alpha equation
  36350. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36351. */
  36352. setAlphaEquation(equation: number): void;
  36353. /**
  36354. * Gets the current alpha equation.
  36355. * @returns the current alpha equation
  36356. */
  36357. getAlphaEquation(): number;
  36358. }
  36359. }
  36360. declare module BABYLON {
  36361. interface ThinEngine {
  36362. /** @hidden */
  36363. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * Defines the interface used by display changed events
  36369. */
  36370. export interface IDisplayChangedEventArgs {
  36371. /** Gets the vrDisplay object (if any) */
  36372. vrDisplay: Nullable<any>;
  36373. /** Gets a boolean indicating if webVR is supported */
  36374. vrSupported: boolean;
  36375. }
  36376. /**
  36377. * Defines the interface used by objects containing a viewport (like a camera)
  36378. */
  36379. interface IViewportOwnerLike {
  36380. /**
  36381. * Gets or sets the viewport
  36382. */
  36383. viewport: IViewportLike;
  36384. }
  36385. /**
  36386. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36387. */
  36388. export class Engine extends ThinEngine {
  36389. /** Defines that alpha blending is disabled */
  36390. static readonly ALPHA_DISABLE: number;
  36391. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36392. static readonly ALPHA_ADD: number;
  36393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36394. static readonly ALPHA_COMBINE: number;
  36395. /** Defines that alpha blending to DEST - SRC * DEST */
  36396. static readonly ALPHA_SUBTRACT: number;
  36397. /** Defines that alpha blending to SRC * DEST */
  36398. static readonly ALPHA_MULTIPLY: number;
  36399. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36400. static readonly ALPHA_MAXIMIZED: number;
  36401. /** Defines that alpha blending to SRC + DEST */
  36402. static readonly ALPHA_ONEONE: number;
  36403. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36404. static readonly ALPHA_PREMULTIPLIED: number;
  36405. /**
  36406. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36407. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36408. */
  36409. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36410. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36411. static readonly ALPHA_INTERPOLATE: number;
  36412. /**
  36413. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36414. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36415. */
  36416. static readonly ALPHA_SCREENMODE: number;
  36417. /** Defines that the ressource is not delayed*/
  36418. static readonly DELAYLOADSTATE_NONE: number;
  36419. /** Defines that the ressource was successfully delay loaded */
  36420. static readonly DELAYLOADSTATE_LOADED: number;
  36421. /** Defines that the ressource is currently delay loading */
  36422. static readonly DELAYLOADSTATE_LOADING: number;
  36423. /** Defines that the ressource is delayed and has not started loading */
  36424. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36426. static readonly NEVER: number;
  36427. /** 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 */
  36428. static readonly ALWAYS: number;
  36429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36430. static readonly LESS: number;
  36431. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36432. static readonly EQUAL: number;
  36433. /** 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 */
  36434. static readonly LEQUAL: number;
  36435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36436. static readonly GREATER: number;
  36437. /** 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 */
  36438. static readonly GEQUAL: number;
  36439. /** 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 */
  36440. static readonly NOTEQUAL: number;
  36441. /** Passed to stencilOperation to specify that stencil value must be kept */
  36442. static readonly KEEP: number;
  36443. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36444. static readonly REPLACE: number;
  36445. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36446. static readonly INCR: number;
  36447. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36448. static readonly DECR: number;
  36449. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36450. static readonly INVERT: number;
  36451. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36452. static readonly INCR_WRAP: number;
  36453. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36454. static readonly DECR_WRAP: number;
  36455. /** Texture is not repeating outside of 0..1 UVs */
  36456. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36457. /** Texture is repeating outside of 0..1 UVs */
  36458. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36459. /** Texture is repeating and mirrored */
  36460. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36461. /** ALPHA */
  36462. static readonly TEXTUREFORMAT_ALPHA: number;
  36463. /** LUMINANCE */
  36464. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36465. /** LUMINANCE_ALPHA */
  36466. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36467. /** RGB */
  36468. static readonly TEXTUREFORMAT_RGB: number;
  36469. /** RGBA */
  36470. static readonly TEXTUREFORMAT_RGBA: number;
  36471. /** RED */
  36472. static readonly TEXTUREFORMAT_RED: number;
  36473. /** RED (2nd reference) */
  36474. static readonly TEXTUREFORMAT_R: number;
  36475. /** RG */
  36476. static readonly TEXTUREFORMAT_RG: number;
  36477. /** RED_INTEGER */
  36478. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36479. /** RED_INTEGER (2nd reference) */
  36480. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36481. /** RG_INTEGER */
  36482. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36483. /** RGB_INTEGER */
  36484. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36485. /** RGBA_INTEGER */
  36486. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36487. /** UNSIGNED_BYTE */
  36488. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36489. /** UNSIGNED_BYTE (2nd reference) */
  36490. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36491. /** FLOAT */
  36492. static readonly TEXTURETYPE_FLOAT: number;
  36493. /** HALF_FLOAT */
  36494. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36495. /** BYTE */
  36496. static readonly TEXTURETYPE_BYTE: number;
  36497. /** SHORT */
  36498. static readonly TEXTURETYPE_SHORT: number;
  36499. /** UNSIGNED_SHORT */
  36500. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36501. /** INT */
  36502. static readonly TEXTURETYPE_INT: number;
  36503. /** UNSIGNED_INT */
  36504. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36505. /** UNSIGNED_SHORT_4_4_4_4 */
  36506. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36507. /** UNSIGNED_SHORT_5_5_5_1 */
  36508. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36509. /** UNSIGNED_SHORT_5_6_5 */
  36510. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36511. /** UNSIGNED_INT_2_10_10_10_REV */
  36512. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36513. /** UNSIGNED_INT_24_8 */
  36514. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36515. /** UNSIGNED_INT_10F_11F_11F_REV */
  36516. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36517. /** UNSIGNED_INT_5_9_9_9_REV */
  36518. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36519. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36520. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36521. /** nearest is mag = nearest and min = nearest and mip = linear */
  36522. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36524. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36525. /** Trilinear is mag = linear and min = linear and mip = linear */
  36526. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36527. /** nearest is mag = nearest and min = nearest and mip = linear */
  36528. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36529. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36530. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36531. /** Trilinear is mag = linear and min = linear and mip = linear */
  36532. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36533. /** mag = nearest and min = nearest and mip = nearest */
  36534. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36535. /** mag = nearest and min = linear and mip = nearest */
  36536. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36537. /** mag = nearest and min = linear and mip = linear */
  36538. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36539. /** mag = nearest and min = linear and mip = none */
  36540. static readonly TEXTURE_NEAREST_LINEAR: number;
  36541. /** mag = nearest and min = nearest and mip = none */
  36542. static readonly TEXTURE_NEAREST_NEAREST: number;
  36543. /** mag = linear and min = nearest and mip = nearest */
  36544. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36545. /** mag = linear and min = nearest and mip = linear */
  36546. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36547. /** mag = linear and min = linear and mip = none */
  36548. static readonly TEXTURE_LINEAR_LINEAR: number;
  36549. /** mag = linear and min = nearest and mip = none */
  36550. static readonly TEXTURE_LINEAR_NEAREST: number;
  36551. /** Explicit coordinates mode */
  36552. static readonly TEXTURE_EXPLICIT_MODE: number;
  36553. /** Spherical coordinates mode */
  36554. static readonly TEXTURE_SPHERICAL_MODE: number;
  36555. /** Planar coordinates mode */
  36556. static readonly TEXTURE_PLANAR_MODE: number;
  36557. /** Cubic coordinates mode */
  36558. static readonly TEXTURE_CUBIC_MODE: number;
  36559. /** Projection coordinates mode */
  36560. static readonly TEXTURE_PROJECTION_MODE: number;
  36561. /** Skybox coordinates mode */
  36562. static readonly TEXTURE_SKYBOX_MODE: number;
  36563. /** Inverse Cubic coordinates mode */
  36564. static readonly TEXTURE_INVCUBIC_MODE: number;
  36565. /** Equirectangular coordinates mode */
  36566. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36567. /** Equirectangular Fixed coordinates mode */
  36568. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36569. /** Equirectangular Fixed Mirrored coordinates mode */
  36570. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36571. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36572. static readonly SCALEMODE_FLOOR: number;
  36573. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36574. static readonly SCALEMODE_NEAREST: number;
  36575. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36576. static readonly SCALEMODE_CEILING: number;
  36577. /**
  36578. * Returns the current npm package of the sdk
  36579. */
  36580. static get NpmPackage(): string;
  36581. /**
  36582. * Returns the current version of the framework
  36583. */
  36584. static get Version(): string;
  36585. /** Gets the list of created engines */
  36586. static get Instances(): Engine[];
  36587. /**
  36588. * Gets the latest created engine
  36589. */
  36590. static get LastCreatedEngine(): Nullable<Engine>;
  36591. /**
  36592. * Gets the latest created scene
  36593. */
  36594. static get LastCreatedScene(): Nullable<Scene>;
  36595. /**
  36596. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36597. * @param flag defines which part of the materials must be marked as dirty
  36598. * @param predicate defines a predicate used to filter which materials should be affected
  36599. */
  36600. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36601. /**
  36602. * Method called to create the default loading screen.
  36603. * This can be overriden in your own app.
  36604. * @param canvas The rendering canvas element
  36605. * @returns The loading screen
  36606. */
  36607. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36608. /**
  36609. * Method called to create the default rescale post process on each engine.
  36610. */
  36611. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36612. /**
  36613. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36614. **/
  36615. enableOfflineSupport: boolean;
  36616. /**
  36617. * 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)
  36618. **/
  36619. disableManifestCheck: boolean;
  36620. /**
  36621. * Gets the list of created scenes
  36622. */
  36623. scenes: Scene[];
  36624. /**
  36625. * Event raised when a new scene is created
  36626. */
  36627. onNewSceneAddedObservable: Observable<Scene>;
  36628. /**
  36629. * Gets the list of created postprocesses
  36630. */
  36631. postProcesses: PostProcess[];
  36632. /**
  36633. * Gets a boolean indicating if the pointer is currently locked
  36634. */
  36635. isPointerLock: boolean;
  36636. /**
  36637. * Observable event triggered each time the rendering canvas is resized
  36638. */
  36639. onResizeObservable: Observable<Engine>;
  36640. /**
  36641. * Observable event triggered each time the canvas loses focus
  36642. */
  36643. onCanvasBlurObservable: Observable<Engine>;
  36644. /**
  36645. * Observable event triggered each time the canvas gains focus
  36646. */
  36647. onCanvasFocusObservable: Observable<Engine>;
  36648. /**
  36649. * Observable event triggered each time the canvas receives pointerout event
  36650. */
  36651. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36652. /**
  36653. * Observable raised when the engine begins a new frame
  36654. */
  36655. onBeginFrameObservable: Observable<Engine>;
  36656. /**
  36657. * If set, will be used to request the next animation frame for the render loop
  36658. */
  36659. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36660. /**
  36661. * Observable raised when the engine ends the current frame
  36662. */
  36663. onEndFrameObservable: Observable<Engine>;
  36664. /**
  36665. * Observable raised when the engine is about to compile a shader
  36666. */
  36667. onBeforeShaderCompilationObservable: Observable<Engine>;
  36668. /**
  36669. * Observable raised when the engine has jsut compiled a shader
  36670. */
  36671. onAfterShaderCompilationObservable: Observable<Engine>;
  36672. /**
  36673. * Gets the audio engine
  36674. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36675. * @ignorenaming
  36676. */
  36677. static audioEngine: IAudioEngine;
  36678. /**
  36679. * Default AudioEngine factory responsible of creating the Audio Engine.
  36680. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36681. */
  36682. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36683. /**
  36684. * Default offline support factory responsible of creating a tool used to store data locally.
  36685. * By default, this will create a Database object if the workload has been embedded.
  36686. */
  36687. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36688. private _loadingScreen;
  36689. private _pointerLockRequested;
  36690. private _rescalePostProcess;
  36691. private _deterministicLockstep;
  36692. private _lockstepMaxSteps;
  36693. private _timeStep;
  36694. protected get _supportsHardwareTextureRescaling(): boolean;
  36695. private _fps;
  36696. private _deltaTime;
  36697. /** @hidden */
  36698. _drawCalls: PerfCounter;
  36699. /** 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 */
  36700. canvasTabIndex: number;
  36701. /**
  36702. * Turn this value on if you want to pause FPS computation when in background
  36703. */
  36704. disablePerformanceMonitorInBackground: boolean;
  36705. private _performanceMonitor;
  36706. /**
  36707. * Gets the performance monitor attached to this engine
  36708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36709. */
  36710. get performanceMonitor(): PerformanceMonitor;
  36711. private _onFocus;
  36712. private _onBlur;
  36713. private _onCanvasPointerOut;
  36714. private _onCanvasBlur;
  36715. private _onCanvasFocus;
  36716. private _onFullscreenChange;
  36717. private _onPointerLockChange;
  36718. /**
  36719. * Gets the HTML element used to attach event listeners
  36720. * @returns a HTML element
  36721. */
  36722. getInputElement(): Nullable<HTMLElement>;
  36723. /**
  36724. * Creates a new engine
  36725. * @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
  36726. * @param antialias defines enable antialiasing (default: false)
  36727. * @param options defines further options to be sent to the getContext() function
  36728. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36729. */
  36730. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36731. /**
  36732. * Gets current aspect ratio
  36733. * @param viewportOwner defines the camera to use to get the aspect ratio
  36734. * @param useScreen defines if screen size must be used (or the current render target if any)
  36735. * @returns a number defining the aspect ratio
  36736. */
  36737. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36738. /**
  36739. * Gets current screen aspect ratio
  36740. * @returns a number defining the aspect ratio
  36741. */
  36742. getScreenAspectRatio(): number;
  36743. /**
  36744. * Gets the client rect of the HTML canvas attached with the current webGL context
  36745. * @returns a client rectanglee
  36746. */
  36747. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36748. /**
  36749. * Gets the client rect of the HTML element used for events
  36750. * @returns a client rectanglee
  36751. */
  36752. getInputElementClientRect(): Nullable<ClientRect>;
  36753. /**
  36754. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36755. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36756. * @returns true if engine is in deterministic lock step mode
  36757. */
  36758. isDeterministicLockStep(): boolean;
  36759. /**
  36760. * Gets the max steps when engine is running in deterministic lock step
  36761. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36762. * @returns the max steps
  36763. */
  36764. getLockstepMaxSteps(): number;
  36765. /**
  36766. * Returns the time in ms between steps when using deterministic lock step.
  36767. * @returns time step in (ms)
  36768. */
  36769. getTimeStep(): number;
  36770. /**
  36771. * Force the mipmap generation for the given render target texture
  36772. * @param texture defines the render target texture to use
  36773. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36774. */
  36775. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36776. /** States */
  36777. /**
  36778. * Set various states to the webGL context
  36779. * @param culling defines backface culling state
  36780. * @param zOffset defines the value to apply to zOffset (0 by default)
  36781. * @param force defines if states must be applied even if cache is up to date
  36782. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36783. */
  36784. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36785. /**
  36786. * Set the z offset to apply to current rendering
  36787. * @param value defines the offset to apply
  36788. */
  36789. setZOffset(value: number): void;
  36790. /**
  36791. * Gets the current value of the zOffset
  36792. * @returns the current zOffset state
  36793. */
  36794. getZOffset(): number;
  36795. /**
  36796. * Enable or disable depth buffering
  36797. * @param enable defines the state to set
  36798. */
  36799. setDepthBuffer(enable: boolean): void;
  36800. /**
  36801. * Gets a boolean indicating if depth writing is enabled
  36802. * @returns the current depth writing state
  36803. */
  36804. getDepthWrite(): boolean;
  36805. /**
  36806. * Enable or disable depth writing
  36807. * @param enable defines the state to set
  36808. */
  36809. setDepthWrite(enable: boolean): void;
  36810. /**
  36811. * Gets a boolean indicating if stencil buffer is enabled
  36812. * @returns the current stencil buffer state
  36813. */
  36814. getStencilBuffer(): boolean;
  36815. /**
  36816. * Enable or disable the stencil buffer
  36817. * @param enable defines if the stencil buffer must be enabled or disabled
  36818. */
  36819. setStencilBuffer(enable: boolean): void;
  36820. /**
  36821. * Gets the current stencil mask
  36822. * @returns a number defining the new stencil mask to use
  36823. */
  36824. getStencilMask(): number;
  36825. /**
  36826. * Sets the current stencil mask
  36827. * @param mask defines the new stencil mask to use
  36828. */
  36829. setStencilMask(mask: number): void;
  36830. /**
  36831. * Gets the current stencil function
  36832. * @returns a number defining the stencil function to use
  36833. */
  36834. getStencilFunction(): number;
  36835. /**
  36836. * Gets the current stencil reference value
  36837. * @returns a number defining the stencil reference value to use
  36838. */
  36839. getStencilFunctionReference(): number;
  36840. /**
  36841. * Gets the current stencil mask
  36842. * @returns a number defining the stencil mask to use
  36843. */
  36844. getStencilFunctionMask(): number;
  36845. /**
  36846. * Sets the current stencil function
  36847. * @param stencilFunc defines the new stencil function to use
  36848. */
  36849. setStencilFunction(stencilFunc: number): void;
  36850. /**
  36851. * Sets the current stencil reference
  36852. * @param reference defines the new stencil reference to use
  36853. */
  36854. setStencilFunctionReference(reference: number): void;
  36855. /**
  36856. * Sets the current stencil mask
  36857. * @param mask defines the new stencil mask to use
  36858. */
  36859. setStencilFunctionMask(mask: number): void;
  36860. /**
  36861. * Gets the current stencil operation when stencil fails
  36862. * @returns a number defining stencil operation to use when stencil fails
  36863. */
  36864. getStencilOperationFail(): number;
  36865. /**
  36866. * Gets the current stencil operation when depth fails
  36867. * @returns a number defining stencil operation to use when depth fails
  36868. */
  36869. getStencilOperationDepthFail(): number;
  36870. /**
  36871. * Gets the current stencil operation when stencil passes
  36872. * @returns a number defining stencil operation to use when stencil passes
  36873. */
  36874. getStencilOperationPass(): number;
  36875. /**
  36876. * Sets the stencil operation to use when stencil fails
  36877. * @param operation defines the stencil operation to use when stencil fails
  36878. */
  36879. setStencilOperationFail(operation: number): void;
  36880. /**
  36881. * Sets the stencil operation to use when depth fails
  36882. * @param operation defines the stencil operation to use when depth fails
  36883. */
  36884. setStencilOperationDepthFail(operation: number): void;
  36885. /**
  36886. * Sets the stencil operation to use when stencil passes
  36887. * @param operation defines the stencil operation to use when stencil passes
  36888. */
  36889. setStencilOperationPass(operation: number): void;
  36890. /**
  36891. * Sets a boolean indicating if the dithering state is enabled or disabled
  36892. * @param value defines the dithering state
  36893. */
  36894. setDitheringState(value: boolean): void;
  36895. /**
  36896. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36897. * @param value defines the rasterizer state
  36898. */
  36899. setRasterizerState(value: boolean): void;
  36900. /**
  36901. * Gets the current depth function
  36902. * @returns a number defining the depth function
  36903. */
  36904. getDepthFunction(): Nullable<number>;
  36905. /**
  36906. * Sets the current depth function
  36907. * @param depthFunc defines the function to use
  36908. */
  36909. setDepthFunction(depthFunc: number): void;
  36910. /**
  36911. * Sets the current depth function to GREATER
  36912. */
  36913. setDepthFunctionToGreater(): void;
  36914. /**
  36915. * Sets the current depth function to GEQUAL
  36916. */
  36917. setDepthFunctionToGreaterOrEqual(): void;
  36918. /**
  36919. * Sets the current depth function to LESS
  36920. */
  36921. setDepthFunctionToLess(): void;
  36922. /**
  36923. * Sets the current depth function to LEQUAL
  36924. */
  36925. setDepthFunctionToLessOrEqual(): void;
  36926. private _cachedStencilBuffer;
  36927. private _cachedStencilFunction;
  36928. private _cachedStencilMask;
  36929. private _cachedStencilOperationPass;
  36930. private _cachedStencilOperationFail;
  36931. private _cachedStencilOperationDepthFail;
  36932. private _cachedStencilReference;
  36933. /**
  36934. * Caches the the state of the stencil buffer
  36935. */
  36936. cacheStencilState(): void;
  36937. /**
  36938. * Restores the state of the stencil buffer
  36939. */
  36940. restoreStencilState(): void;
  36941. /**
  36942. * Directly set the WebGL Viewport
  36943. * @param x defines the x coordinate of the viewport (in screen space)
  36944. * @param y defines the y coordinate of the viewport (in screen space)
  36945. * @param width defines the width of the viewport (in screen space)
  36946. * @param height defines the height of the viewport (in screen space)
  36947. * @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
  36948. */
  36949. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36950. /**
  36951. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36952. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36953. * @param y defines the y-coordinate of the corner of the clear rectangle
  36954. * @param width defines the width of the clear rectangle
  36955. * @param height defines the height of the clear rectangle
  36956. * @param clearColor defines the clear color
  36957. */
  36958. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36959. /**
  36960. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36961. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36962. * @param y defines the y-coordinate of the corner of the clear rectangle
  36963. * @param width defines the width of the clear rectangle
  36964. * @param height defines the height of the clear rectangle
  36965. */
  36966. enableScissor(x: number, y: number, width: number, height: number): void;
  36967. /**
  36968. * Disable previously set scissor test rectangle
  36969. */
  36970. disableScissor(): void;
  36971. protected _reportDrawCall(): void;
  36972. /**
  36973. * Initializes a webVR display and starts listening to display change events
  36974. * The onVRDisplayChangedObservable will be notified upon these changes
  36975. * @returns The onVRDisplayChangedObservable
  36976. */
  36977. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36978. /** @hidden */
  36979. _prepareVRComponent(): void;
  36980. /** @hidden */
  36981. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36982. /** @hidden */
  36983. _submitVRFrame(): void;
  36984. /**
  36985. * Call this function to leave webVR mode
  36986. * Will do nothing if webVR is not supported or if there is no webVR device
  36987. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36988. */
  36989. disableVR(): void;
  36990. /**
  36991. * Gets a boolean indicating that the system is in VR mode and is presenting
  36992. * @returns true if VR mode is engaged
  36993. */
  36994. isVRPresenting(): boolean;
  36995. /** @hidden */
  36996. _requestVRFrame(): void;
  36997. /** @hidden */
  36998. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36999. /**
  37000. * Gets the source code of the vertex shader associated with a specific webGL program
  37001. * @param program defines the program to use
  37002. * @returns a string containing the source code of the vertex shader associated with the program
  37003. */
  37004. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37005. /**
  37006. * Gets the source code of the fragment shader associated with a specific webGL program
  37007. * @param program defines the program to use
  37008. * @returns a string containing the source code of the fragment shader associated with the program
  37009. */
  37010. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37011. /**
  37012. * Sets a depth stencil texture from a render target to the according uniform.
  37013. * @param channel The texture channel
  37014. * @param uniform The uniform to set
  37015. * @param texture The render target texture containing the depth stencil texture to apply
  37016. */
  37017. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37018. /**
  37019. * Sets a texture to the webGL context from a postprocess
  37020. * @param channel defines the channel to use
  37021. * @param postProcess defines the source postprocess
  37022. */
  37023. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37024. /**
  37025. * Binds the output of the passed in post process to the texture channel specified
  37026. * @param channel The channel the texture should be bound to
  37027. * @param postProcess The post process which's output should be bound
  37028. */
  37029. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37030. protected _rebuildBuffers(): void;
  37031. /** @hidden */
  37032. _renderFrame(): void;
  37033. _renderLoop(): void;
  37034. /** @hidden */
  37035. _renderViews(): boolean;
  37036. /**
  37037. * Toggle full screen mode
  37038. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37039. */
  37040. switchFullscreen(requestPointerLock: boolean): void;
  37041. /**
  37042. * Enters full screen mode
  37043. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37044. */
  37045. enterFullscreen(requestPointerLock: boolean): void;
  37046. /**
  37047. * Exits full screen mode
  37048. */
  37049. exitFullscreen(): void;
  37050. /**
  37051. * Enters Pointerlock mode
  37052. */
  37053. enterPointerlock(): void;
  37054. /**
  37055. * Exits Pointerlock mode
  37056. */
  37057. exitPointerlock(): void;
  37058. /**
  37059. * Begin a new frame
  37060. */
  37061. beginFrame(): void;
  37062. /**
  37063. * Enf the current frame
  37064. */
  37065. endFrame(): void;
  37066. resize(): void;
  37067. /**
  37068. * Force a specific size of the canvas
  37069. * @param width defines the new canvas' width
  37070. * @param height defines the new canvas' height
  37071. * @returns true if the size was changed
  37072. */
  37073. setSize(width: number, height: number): boolean;
  37074. /**
  37075. * Updates a dynamic vertex buffer.
  37076. * @param vertexBuffer the vertex buffer to update
  37077. * @param data the data used to update the vertex buffer
  37078. * @param byteOffset the byte offset of the data
  37079. * @param byteLength the byte length of the data
  37080. */
  37081. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37082. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37083. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37084. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37085. _releaseTexture(texture: InternalTexture): void;
  37086. /**
  37087. * @hidden
  37088. * Rescales a texture
  37089. * @param source input texutre
  37090. * @param destination destination texture
  37091. * @param scene scene to use to render the resize
  37092. * @param internalFormat format to use when resizing
  37093. * @param onComplete callback to be called when resize has completed
  37094. */
  37095. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37096. /**
  37097. * Gets the current framerate
  37098. * @returns a number representing the framerate
  37099. */
  37100. getFps(): number;
  37101. /**
  37102. * Gets the time spent between current and previous frame
  37103. * @returns a number representing the delta time in ms
  37104. */
  37105. getDeltaTime(): number;
  37106. private _measureFps;
  37107. /** @hidden */
  37108. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37109. /**
  37110. * Update a dynamic index buffer
  37111. * @param indexBuffer defines the target index buffer
  37112. * @param indices defines the data to update
  37113. * @param offset defines the offset in the target index buffer where update should start
  37114. */
  37115. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37116. /**
  37117. * Updates the sample count of a render target texture
  37118. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37119. * @param texture defines the texture to update
  37120. * @param samples defines the sample count to set
  37121. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37122. */
  37123. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37124. /**
  37125. * Updates a depth texture Comparison Mode and Function.
  37126. * If the comparison Function is equal to 0, the mode will be set to none.
  37127. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37128. * @param texture The texture to set the comparison function for
  37129. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37130. */
  37131. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37132. /**
  37133. * Creates a webGL buffer to use with instanciation
  37134. * @param capacity defines the size of the buffer
  37135. * @returns the webGL buffer
  37136. */
  37137. createInstancesBuffer(capacity: number): DataBuffer;
  37138. /**
  37139. * Delete a webGL buffer used with instanciation
  37140. * @param buffer defines the webGL buffer to delete
  37141. */
  37142. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37143. private _clientWaitAsync;
  37144. /** @hidden */
  37145. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37146. dispose(): void;
  37147. private _disableTouchAction;
  37148. /**
  37149. * Display the loading screen
  37150. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37151. */
  37152. displayLoadingUI(): void;
  37153. /**
  37154. * Hide the loading screen
  37155. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37156. */
  37157. hideLoadingUI(): void;
  37158. /**
  37159. * Gets the current loading screen object
  37160. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37161. */
  37162. get loadingScreen(): ILoadingScreen;
  37163. /**
  37164. * Sets the current loading screen object
  37165. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37166. */
  37167. set loadingScreen(loadingScreen: ILoadingScreen);
  37168. /**
  37169. * Sets the current loading screen text
  37170. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37171. */
  37172. set loadingUIText(text: string);
  37173. /**
  37174. * Sets the current loading screen background color
  37175. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37176. */
  37177. set loadingUIBackgroundColor(color: string);
  37178. /** Pointerlock and fullscreen */
  37179. /**
  37180. * Ask the browser to promote the current element to pointerlock mode
  37181. * @param element defines the DOM element to promote
  37182. */
  37183. static _RequestPointerlock(element: HTMLElement): void;
  37184. /**
  37185. * Asks the browser to exit pointerlock mode
  37186. */
  37187. static _ExitPointerlock(): void;
  37188. /**
  37189. * Ask the browser to promote the current element to fullscreen rendering mode
  37190. * @param element defines the DOM element to promote
  37191. */
  37192. static _RequestFullscreen(element: HTMLElement): void;
  37193. /**
  37194. * Asks the browser to exit fullscreen mode
  37195. */
  37196. static _ExitFullscreen(): void;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. /**
  37201. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37202. * during the life time of the application.
  37203. */
  37204. export class EngineStore {
  37205. /** Gets the list of created engines */
  37206. static Instances: Engine[];
  37207. /** @hidden */
  37208. static _LastCreatedScene: Nullable<Scene>;
  37209. /**
  37210. * Gets the latest created engine
  37211. */
  37212. static get LastCreatedEngine(): Nullable<Engine>;
  37213. /**
  37214. * Gets the latest created scene
  37215. */
  37216. static get LastCreatedScene(): Nullable<Scene>;
  37217. /**
  37218. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37219. * @ignorenaming
  37220. */
  37221. static UseFallbackTexture: boolean;
  37222. /**
  37223. * Texture content used if a texture cannot loaded
  37224. * @ignorenaming
  37225. */
  37226. static FallbackTexture: string;
  37227. }
  37228. }
  37229. declare module BABYLON {
  37230. /**
  37231. * Helper class that provides a small promise polyfill
  37232. */
  37233. export class PromisePolyfill {
  37234. /**
  37235. * Static function used to check if the polyfill is required
  37236. * If this is the case then the function will inject the polyfill to window.Promise
  37237. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37238. */
  37239. static Apply(force?: boolean): void;
  37240. }
  37241. }
  37242. declare module BABYLON {
  37243. /**
  37244. * Interface for screenshot methods with describe argument called `size` as object with options
  37245. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37246. */
  37247. export interface IScreenshotSize {
  37248. /**
  37249. * number in pixels for canvas height
  37250. */
  37251. height?: number;
  37252. /**
  37253. * multiplier allowing render at a higher or lower resolution
  37254. * If value is defined then height and width will be ignored and taken from camera
  37255. */
  37256. precision?: number;
  37257. /**
  37258. * number in pixels for canvas width
  37259. */
  37260. width?: number;
  37261. }
  37262. }
  37263. declare module BABYLON {
  37264. interface IColor4Like {
  37265. r: float;
  37266. g: float;
  37267. b: float;
  37268. a: float;
  37269. }
  37270. /**
  37271. * Class containing a set of static utilities functions
  37272. */
  37273. export class Tools {
  37274. /**
  37275. * Gets or sets the base URL to use to load assets
  37276. */
  37277. static get BaseUrl(): string;
  37278. static set BaseUrl(value: string);
  37279. /**
  37280. * Enable/Disable Custom HTTP Request Headers globally.
  37281. * default = false
  37282. * @see CustomRequestHeaders
  37283. */
  37284. static UseCustomRequestHeaders: boolean;
  37285. /**
  37286. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37287. * i.e. when loading files, where the server/service expects an Authorization header
  37288. */
  37289. static CustomRequestHeaders: {
  37290. [key: string]: string;
  37291. };
  37292. /**
  37293. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37294. */
  37295. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37296. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37297. /**
  37298. * Default behaviour for cors in the application.
  37299. * It can be a string if the expected behavior is identical in the entire app.
  37300. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37301. */
  37302. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37303. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37304. /**
  37305. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37306. * @ignorenaming
  37307. */
  37308. static get UseFallbackTexture(): boolean;
  37309. static set UseFallbackTexture(value: boolean);
  37310. /**
  37311. * Use this object to register external classes like custom textures or material
  37312. * to allow the laoders to instantiate them
  37313. */
  37314. static get RegisteredExternalClasses(): {
  37315. [key: string]: Object;
  37316. };
  37317. static set RegisteredExternalClasses(classes: {
  37318. [key: string]: Object;
  37319. });
  37320. /**
  37321. * Texture content used if a texture cannot loaded
  37322. * @ignorenaming
  37323. */
  37324. static get fallbackTexture(): string;
  37325. static set fallbackTexture(value: string);
  37326. /**
  37327. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37328. * @param u defines the coordinate on X axis
  37329. * @param v defines the coordinate on Y axis
  37330. * @param width defines the width of the source data
  37331. * @param height defines the height of the source data
  37332. * @param pixels defines the source byte array
  37333. * @param color defines the output color
  37334. */
  37335. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37336. /**
  37337. * Interpolates between a and b via alpha
  37338. * @param a The lower value (returned when alpha = 0)
  37339. * @param b The upper value (returned when alpha = 1)
  37340. * @param alpha The interpolation-factor
  37341. * @return The mixed value
  37342. */
  37343. static Mix(a: number, b: number, alpha: number): number;
  37344. /**
  37345. * Tries to instantiate a new object from a given class name
  37346. * @param className defines the class name to instantiate
  37347. * @returns the new object or null if the system was not able to do the instantiation
  37348. */
  37349. static Instantiate(className: string): any;
  37350. /**
  37351. * Provides a slice function that will work even on IE
  37352. * @param data defines the array to slice
  37353. * @param start defines the start of the data (optional)
  37354. * @param end defines the end of the data (optional)
  37355. * @returns the new sliced array
  37356. */
  37357. static Slice<T>(data: T, start?: number, end?: number): T;
  37358. /**
  37359. * Polyfill for setImmediate
  37360. * @param action defines the action to execute after the current execution block
  37361. */
  37362. static SetImmediate(action: () => void): void;
  37363. /**
  37364. * Function indicating if a number is an exponent of 2
  37365. * @param value defines the value to test
  37366. * @returns true if the value is an exponent of 2
  37367. */
  37368. static IsExponentOfTwo(value: number): boolean;
  37369. private static _tmpFloatArray;
  37370. /**
  37371. * Returns the nearest 32-bit single precision float representation of a Number
  37372. * @param value A Number. If the parameter is of a different type, it will get converted
  37373. * to a number or to NaN if it cannot be converted
  37374. * @returns number
  37375. */
  37376. static FloatRound(value: number): number;
  37377. /**
  37378. * Extracts the filename from a path
  37379. * @param path defines the path to use
  37380. * @returns the filename
  37381. */
  37382. static GetFilename(path: string): string;
  37383. /**
  37384. * Extracts the "folder" part of a path (everything before the filename).
  37385. * @param uri The URI to extract the info from
  37386. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37387. * @returns The "folder" part of the path
  37388. */
  37389. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37390. /**
  37391. * Extracts text content from a DOM element hierarchy
  37392. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37393. */
  37394. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37395. /**
  37396. * Convert an angle in radians to degrees
  37397. * @param angle defines the angle to convert
  37398. * @returns the angle in degrees
  37399. */
  37400. static ToDegrees(angle: number): number;
  37401. /**
  37402. * Convert an angle in degrees to radians
  37403. * @param angle defines the angle to convert
  37404. * @returns the angle in radians
  37405. */
  37406. static ToRadians(angle: number): number;
  37407. /**
  37408. * Returns an array if obj is not an array
  37409. * @param obj defines the object to evaluate as an array
  37410. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37411. * @returns either obj directly if obj is an array or a new array containing obj
  37412. */
  37413. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37414. /**
  37415. * Gets the pointer prefix to use
  37416. * @param engine defines the engine we are finding the prefix for
  37417. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37418. */
  37419. static GetPointerPrefix(engine: Engine): string;
  37420. /**
  37421. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37422. * @param url define the url we are trying
  37423. * @param element define the dom element where to configure the cors policy
  37424. */
  37425. static SetCorsBehavior(url: string | string[], element: {
  37426. crossOrigin: string | null;
  37427. }): void;
  37428. /**
  37429. * Removes unwanted characters from an url
  37430. * @param url defines the url to clean
  37431. * @returns the cleaned url
  37432. */
  37433. static CleanUrl(url: string): string;
  37434. /**
  37435. * Gets or sets a function used to pre-process url before using them to load assets
  37436. */
  37437. static get PreprocessUrl(): (url: string) => string;
  37438. static set PreprocessUrl(processor: (url: string) => string);
  37439. /**
  37440. * Loads an image as an HTMLImageElement.
  37441. * @param input url string, ArrayBuffer, or Blob to load
  37442. * @param onLoad callback called when the image successfully loads
  37443. * @param onError callback called when the image fails to load
  37444. * @param offlineProvider offline provider for caching
  37445. * @param mimeType optional mime type
  37446. * @returns the HTMLImageElement of the loaded image
  37447. */
  37448. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37449. /**
  37450. * Loads a file from a url
  37451. * @param url url string, ArrayBuffer, or Blob to load
  37452. * @param onSuccess callback called when the file successfully loads
  37453. * @param onProgress callback called while file is loading (if the server supports this mode)
  37454. * @param offlineProvider defines the offline provider for caching
  37455. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37456. * @param onError callback called when the file fails to load
  37457. * @returns a file request object
  37458. */
  37459. 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;
  37460. /**
  37461. * Loads a file from a url
  37462. * @param url the file url to load
  37463. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37464. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37465. */
  37466. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37467. /**
  37468. * Load a script (identified by an url). When the url returns, the
  37469. * content of this file is added into a new script element, attached to the DOM (body element)
  37470. * @param scriptUrl defines the url of the script to laod
  37471. * @param onSuccess defines the callback called when the script is loaded
  37472. * @param onError defines the callback to call if an error occurs
  37473. * @param scriptId defines the id of the script element
  37474. */
  37475. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37476. /**
  37477. * Load an asynchronous script (identified by an url). When the url returns, the
  37478. * content of this file is added into a new script element, attached to the DOM (body element)
  37479. * @param scriptUrl defines the url of the script to laod
  37480. * @param scriptId defines the id of the script element
  37481. * @returns a promise request object
  37482. */
  37483. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37484. /**
  37485. * Loads a file from a blob
  37486. * @param fileToLoad defines the blob to use
  37487. * @param callback defines the callback to call when data is loaded
  37488. * @param progressCallback defines the callback to call during loading process
  37489. * @returns a file request object
  37490. */
  37491. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37492. /**
  37493. * Reads a file from a File object
  37494. * @param file defines the file to load
  37495. * @param onSuccess defines the callback to call when data is loaded
  37496. * @param onProgress defines the callback to call during loading process
  37497. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37498. * @param onError defines the callback to call when an error occurs
  37499. * @returns a file request object
  37500. */
  37501. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37502. /**
  37503. * Creates a data url from a given string content
  37504. * @param content defines the content to convert
  37505. * @returns the new data url link
  37506. */
  37507. static FileAsURL(content: string): string;
  37508. /**
  37509. * Format the given number to a specific decimal format
  37510. * @param value defines the number to format
  37511. * @param decimals defines the number of decimals to use
  37512. * @returns the formatted string
  37513. */
  37514. static Format(value: number, decimals?: number): string;
  37515. /**
  37516. * Tries to copy an object by duplicating every property
  37517. * @param source defines the source object
  37518. * @param destination defines the target object
  37519. * @param doNotCopyList defines a list of properties to avoid
  37520. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37521. */
  37522. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37523. /**
  37524. * Gets a boolean indicating if the given object has no own property
  37525. * @param obj defines the object to test
  37526. * @returns true if object has no own property
  37527. */
  37528. static IsEmpty(obj: any): boolean;
  37529. /**
  37530. * Function used to register events at window level
  37531. * @param windowElement defines the Window object to use
  37532. * @param events defines the events to register
  37533. */
  37534. static RegisterTopRootEvents(windowElement: Window, events: {
  37535. name: string;
  37536. handler: Nullable<(e: FocusEvent) => any>;
  37537. }[]): void;
  37538. /**
  37539. * Function used to unregister events from window level
  37540. * @param windowElement defines the Window object to use
  37541. * @param events defines the events to unregister
  37542. */
  37543. static UnregisterTopRootEvents(windowElement: Window, events: {
  37544. name: string;
  37545. handler: Nullable<(e: FocusEvent) => any>;
  37546. }[]): void;
  37547. /**
  37548. * @ignore
  37549. */
  37550. static _ScreenshotCanvas: HTMLCanvasElement;
  37551. /**
  37552. * Dumps the current bound framebuffer
  37553. * @param width defines the rendering width
  37554. * @param height defines the rendering height
  37555. * @param engine defines the hosting engine
  37556. * @param successCallback defines the callback triggered once the data are available
  37557. * @param mimeType defines the mime type of the result
  37558. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37559. */
  37560. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37561. /**
  37562. * Converts the canvas data to blob.
  37563. * This acts as a polyfill for browsers not supporting the to blob function.
  37564. * @param canvas Defines the canvas to extract the data from
  37565. * @param successCallback Defines the callback triggered once the data are available
  37566. * @param mimeType Defines the mime type of the result
  37567. */
  37568. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37569. /**
  37570. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37571. * @param successCallback defines the callback triggered once the data are available
  37572. * @param mimeType defines the mime type of the result
  37573. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37574. */
  37575. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37576. /**
  37577. * Downloads a blob in the browser
  37578. * @param blob defines the blob to download
  37579. * @param fileName defines the name of the downloaded file
  37580. */
  37581. static Download(blob: Blob, fileName: string): void;
  37582. /**
  37583. * Captures a screenshot of the current rendering
  37584. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37585. * @param engine defines the rendering engine
  37586. * @param camera defines the source camera
  37587. * @param size This parameter can be set to a single number or to an object with the
  37588. * following (optional) properties: precision, width, height. If a single number is passed,
  37589. * it will be used for both width and height. If an object is passed, the screenshot size
  37590. * will be derived from the parameters. The precision property is a multiplier allowing
  37591. * rendering at a higher or lower resolution
  37592. * @param successCallback defines the callback receives a single parameter which contains the
  37593. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37594. * src parameter of an <img> to display it
  37595. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37596. * Check your browser for supported MIME types
  37597. */
  37598. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37599. /**
  37600. * Captures a screenshot of the current rendering
  37601. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37602. * @param engine defines the rendering engine
  37603. * @param camera defines the source camera
  37604. * @param size This parameter can be set to a single number or to an object with the
  37605. * following (optional) properties: precision, width, height. If a single number is passed,
  37606. * it will be used for both width and height. If an object is passed, the screenshot size
  37607. * will be derived from the parameters. The precision property is a multiplier allowing
  37608. * rendering at a higher or lower resolution
  37609. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37610. * Check your browser for supported MIME types
  37611. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37612. * to the src parameter of an <img> to display it
  37613. */
  37614. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37615. /**
  37616. * Generates an image screenshot from the specified camera.
  37617. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37618. * @param engine The engine to use for rendering
  37619. * @param camera The camera to use for rendering
  37620. * @param size This parameter can be set to a single number or to an object with the
  37621. * following (optional) properties: precision, width, height. If a single number is passed,
  37622. * it will be used for both width and height. If an object is passed, the screenshot size
  37623. * will be derived from the parameters. The precision property is a multiplier allowing
  37624. * rendering at a higher or lower resolution
  37625. * @param successCallback The callback receives a single parameter which contains the
  37626. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37627. * src parameter of an <img> to display it
  37628. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37629. * Check your browser for supported MIME types
  37630. * @param samples Texture samples (default: 1)
  37631. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37632. * @param fileName A name for for the downloaded file.
  37633. */
  37634. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37635. /**
  37636. * Generates an image screenshot from the specified camera.
  37637. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37638. * @param engine The engine to use for rendering
  37639. * @param camera The camera to use for rendering
  37640. * @param size This parameter can be set to a single number or to an object with the
  37641. * following (optional) properties: precision, width, height. If a single number is passed,
  37642. * it will be used for both width and height. If an object is passed, the screenshot size
  37643. * will be derived from the parameters. The precision property is a multiplier allowing
  37644. * rendering at a higher or lower resolution
  37645. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37646. * Check your browser for supported MIME types
  37647. * @param samples Texture samples (default: 1)
  37648. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37649. * @param fileName A name for for the downloaded file.
  37650. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37651. * to the src parameter of an <img> to display it
  37652. */
  37653. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37654. /**
  37655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37656. * Be aware Math.random() could cause collisions, but:
  37657. * "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"
  37658. * @returns a pseudo random id
  37659. */
  37660. static RandomId(): string;
  37661. /**
  37662. * Test if the given uri is a base64 string
  37663. * @param uri The uri to test
  37664. * @return True if the uri is a base64 string or false otherwise
  37665. */
  37666. static IsBase64(uri: string): boolean;
  37667. /**
  37668. * Decode the given base64 uri.
  37669. * @param uri The uri to decode
  37670. * @return The decoded base64 data.
  37671. */
  37672. static DecodeBase64(uri: string): ArrayBuffer;
  37673. /**
  37674. * Gets the absolute url.
  37675. * @param url the input url
  37676. * @return the absolute url
  37677. */
  37678. static GetAbsoluteUrl(url: string): string;
  37679. /**
  37680. * No log
  37681. */
  37682. static readonly NoneLogLevel: number;
  37683. /**
  37684. * Only message logs
  37685. */
  37686. static readonly MessageLogLevel: number;
  37687. /**
  37688. * Only warning logs
  37689. */
  37690. static readonly WarningLogLevel: number;
  37691. /**
  37692. * Only error logs
  37693. */
  37694. static readonly ErrorLogLevel: number;
  37695. /**
  37696. * All logs
  37697. */
  37698. static readonly AllLogLevel: number;
  37699. /**
  37700. * Gets a value indicating the number of loading errors
  37701. * @ignorenaming
  37702. */
  37703. static get errorsCount(): number;
  37704. /**
  37705. * Callback called when a new log is added
  37706. */
  37707. static OnNewCacheEntry: (entry: string) => void;
  37708. /**
  37709. * Log a message to the console
  37710. * @param message defines the message to log
  37711. */
  37712. static Log(message: string): void;
  37713. /**
  37714. * Write a warning message to the console
  37715. * @param message defines the message to log
  37716. */
  37717. static Warn(message: string): void;
  37718. /**
  37719. * Write an error message to the console
  37720. * @param message defines the message to log
  37721. */
  37722. static Error(message: string): void;
  37723. /**
  37724. * Gets current log cache (list of logs)
  37725. */
  37726. static get LogCache(): string;
  37727. /**
  37728. * Clears the log cache
  37729. */
  37730. static ClearLogCache(): void;
  37731. /**
  37732. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37733. */
  37734. static set LogLevels(level: number);
  37735. /**
  37736. * Checks if the window object exists
  37737. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37738. */
  37739. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37740. /**
  37741. * No performance log
  37742. */
  37743. static readonly PerformanceNoneLogLevel: number;
  37744. /**
  37745. * Use user marks to log performance
  37746. */
  37747. static readonly PerformanceUserMarkLogLevel: number;
  37748. /**
  37749. * Log performance to the console
  37750. */
  37751. static readonly PerformanceConsoleLogLevel: number;
  37752. private static _performance;
  37753. /**
  37754. * Sets the current performance log level
  37755. */
  37756. static set PerformanceLogLevel(level: number);
  37757. private static _StartPerformanceCounterDisabled;
  37758. private static _EndPerformanceCounterDisabled;
  37759. private static _StartUserMark;
  37760. private static _EndUserMark;
  37761. private static _StartPerformanceConsole;
  37762. private static _EndPerformanceConsole;
  37763. /**
  37764. * Starts a performance counter
  37765. */
  37766. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37767. /**
  37768. * Ends a specific performance coutner
  37769. */
  37770. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37771. /**
  37772. * Gets either window.performance.now() if supported or Date.now() else
  37773. */
  37774. static get Now(): number;
  37775. /**
  37776. * This method will return the name of the class used to create the instance of the given object.
  37777. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37778. * @param object the object to get the class name from
  37779. * @param isType defines if the object is actually a type
  37780. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37781. */
  37782. static GetClassName(object: any, isType?: boolean): string;
  37783. /**
  37784. * Gets the first element of an array satisfying a given predicate
  37785. * @param array defines the array to browse
  37786. * @param predicate defines the predicate to use
  37787. * @returns null if not found or the element
  37788. */
  37789. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37790. /**
  37791. * This method will return the name of the full name of the class, including its owning module (if any).
  37792. * 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).
  37793. * @param object the object to get the class name from
  37794. * @param isType defines if the object is actually a type
  37795. * @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.
  37796. * @ignorenaming
  37797. */
  37798. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37799. /**
  37800. * Returns a promise that resolves after the given amount of time.
  37801. * @param delay Number of milliseconds to delay
  37802. * @returns Promise that resolves after the given amount of time
  37803. */
  37804. static DelayAsync(delay: number): Promise<void>;
  37805. /**
  37806. * Utility function to detect if the current user agent is Safari
  37807. * @returns whether or not the current user agent is safari
  37808. */
  37809. static IsSafari(): boolean;
  37810. }
  37811. /**
  37812. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37813. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37814. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37815. * @param name The name of the class, case should be preserved
  37816. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37817. */
  37818. export function className(name: string, module?: string): (target: Object) => void;
  37819. /**
  37820. * An implementation of a loop for asynchronous functions.
  37821. */
  37822. export class AsyncLoop {
  37823. /**
  37824. * Defines the number of iterations for the loop
  37825. */
  37826. iterations: number;
  37827. /**
  37828. * Defines the current index of the loop.
  37829. */
  37830. index: number;
  37831. private _done;
  37832. private _fn;
  37833. private _successCallback;
  37834. /**
  37835. * Constructor.
  37836. * @param iterations the number of iterations.
  37837. * @param func the function to run each iteration
  37838. * @param successCallback the callback that will be called upon succesful execution
  37839. * @param offset starting offset.
  37840. */
  37841. constructor(
  37842. /**
  37843. * Defines the number of iterations for the loop
  37844. */
  37845. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37846. /**
  37847. * Execute the next iteration. Must be called after the last iteration was finished.
  37848. */
  37849. executeNext(): void;
  37850. /**
  37851. * Break the loop and run the success callback.
  37852. */
  37853. breakLoop(): void;
  37854. /**
  37855. * Create and run an async loop.
  37856. * @param iterations the number of iterations.
  37857. * @param fn the function to run each iteration
  37858. * @param successCallback the callback that will be called upon succesful execution
  37859. * @param offset starting offset.
  37860. * @returns the created async loop object
  37861. */
  37862. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37863. /**
  37864. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37865. * @param iterations total number of iterations
  37866. * @param syncedIterations number of synchronous iterations in each async iteration.
  37867. * @param fn the function to call each iteration.
  37868. * @param callback a success call back that will be called when iterating stops.
  37869. * @param breakFunction a break condition (optional)
  37870. * @param timeout timeout settings for the setTimeout function. default - 0.
  37871. * @returns the created async loop object
  37872. */
  37873. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37874. }
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37879. * The underlying implementation relies on an associative array to ensure the best performances.
  37880. * The value can be anything including 'null' but except 'undefined'
  37881. */
  37882. export class StringDictionary<T> {
  37883. /**
  37884. * This will clear this dictionary and copy the content from the 'source' one.
  37885. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37886. * @param source the dictionary to take the content from and copy to this dictionary
  37887. */
  37888. copyFrom(source: StringDictionary<T>): void;
  37889. /**
  37890. * Get a value based from its key
  37891. * @param key the given key to get the matching value from
  37892. * @return the value if found, otherwise undefined is returned
  37893. */
  37894. get(key: string): T | undefined;
  37895. /**
  37896. * Get a value from its key or add it if it doesn't exist.
  37897. * This method will ensure you that a given key/data will be present in the dictionary.
  37898. * @param key the given key to get the matching value from
  37899. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37900. * The factory will only be invoked if there's no data for the given key.
  37901. * @return the value corresponding to the key.
  37902. */
  37903. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37904. /**
  37905. * Get a value from its key if present in the dictionary otherwise add it
  37906. * @param key the key to get the value from
  37907. * @param val if there's no such key/value pair in the dictionary add it with this value
  37908. * @return the value corresponding to the key
  37909. */
  37910. getOrAdd(key: string, val: T): T;
  37911. /**
  37912. * Check if there's a given key in the dictionary
  37913. * @param key the key to check for
  37914. * @return true if the key is present, false otherwise
  37915. */
  37916. contains(key: string): boolean;
  37917. /**
  37918. * Add a new key and its corresponding value
  37919. * @param key the key to add
  37920. * @param value the value corresponding to the key
  37921. * @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
  37922. */
  37923. add(key: string, value: T): boolean;
  37924. /**
  37925. * Update a specific value associated to a key
  37926. * @param key defines the key to use
  37927. * @param value defines the value to store
  37928. * @returns true if the value was updated (or false if the key was not found)
  37929. */
  37930. set(key: string, value: T): boolean;
  37931. /**
  37932. * Get the element of the given key and remove it from the dictionary
  37933. * @param key defines the key to search
  37934. * @returns the value associated with the key or null if not found
  37935. */
  37936. getAndRemove(key: string): Nullable<T>;
  37937. /**
  37938. * Remove a key/value from the dictionary.
  37939. * @param key the key to remove
  37940. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37941. */
  37942. remove(key: string): boolean;
  37943. /**
  37944. * Clear the whole content of the dictionary
  37945. */
  37946. clear(): void;
  37947. /**
  37948. * Gets the current count
  37949. */
  37950. get count(): number;
  37951. /**
  37952. * Execute a callback on each key/val of the dictionary.
  37953. * Note that you can remove any element in this dictionary in the callback implementation
  37954. * @param callback the callback to execute on a given key/value pair
  37955. */
  37956. forEach(callback: (key: string, val: T) => void): void;
  37957. /**
  37958. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37959. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37960. * Note that you can remove any element in this dictionary in the callback implementation
  37961. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37962. * @returns the first item
  37963. */
  37964. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37965. private _count;
  37966. private _data;
  37967. }
  37968. }
  37969. declare module BABYLON {
  37970. /** @hidden */
  37971. export interface ICollisionCoordinator {
  37972. createCollider(): Collider;
  37973. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37974. init(scene: Scene): void;
  37975. }
  37976. /** @hidden */
  37977. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37978. private _scene;
  37979. private _scaledPosition;
  37980. private _scaledVelocity;
  37981. private _finalPosition;
  37982. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37983. createCollider(): Collider;
  37984. init(scene: Scene): void;
  37985. private _collideWithWorld;
  37986. }
  37987. }
  37988. declare module BABYLON {
  37989. /**
  37990. * Class used to manage all inputs for the scene.
  37991. */
  37992. export class InputManager {
  37993. /** The distance in pixel that you have to move to prevent some events */
  37994. static DragMovementThreshold: number;
  37995. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37996. static LongPressDelay: number;
  37997. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37998. static DoubleClickDelay: number;
  37999. /** If you need to check double click without raising a single click at first click, enable this flag */
  38000. static ExclusiveDoubleClickMode: boolean;
  38001. private _wheelEventName;
  38002. private _onPointerMove;
  38003. private _onPointerDown;
  38004. private _onPointerUp;
  38005. private _initClickEvent;
  38006. private _initActionManager;
  38007. private _delayedSimpleClick;
  38008. private _delayedSimpleClickTimeout;
  38009. private _previousDelayedSimpleClickTimeout;
  38010. private _meshPickProceed;
  38011. private _previousButtonPressed;
  38012. private _currentPickResult;
  38013. private _previousPickResult;
  38014. private _totalPointersPressed;
  38015. private _doubleClickOccured;
  38016. private _pointerOverMesh;
  38017. private _pickedDownMesh;
  38018. private _pickedUpMesh;
  38019. private _pointerX;
  38020. private _pointerY;
  38021. private _unTranslatedPointerX;
  38022. private _unTranslatedPointerY;
  38023. private _startingPointerPosition;
  38024. private _previousStartingPointerPosition;
  38025. private _startingPointerTime;
  38026. private _previousStartingPointerTime;
  38027. private _pointerCaptures;
  38028. private _onKeyDown;
  38029. private _onKeyUp;
  38030. private _onCanvasFocusObserver;
  38031. private _onCanvasBlurObserver;
  38032. private _scene;
  38033. /**
  38034. * Creates a new InputManager
  38035. * @param scene defines the hosting scene
  38036. */
  38037. constructor(scene: Scene);
  38038. /**
  38039. * Gets the mesh that is currently under the pointer
  38040. */
  38041. get meshUnderPointer(): Nullable<AbstractMesh>;
  38042. /**
  38043. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38044. */
  38045. get unTranslatedPointer(): Vector2;
  38046. /**
  38047. * Gets or sets the current on-screen X position of the pointer
  38048. */
  38049. get pointerX(): number;
  38050. set pointerX(value: number);
  38051. /**
  38052. * Gets or sets the current on-screen Y position of the pointer
  38053. */
  38054. get pointerY(): number;
  38055. set pointerY(value: number);
  38056. private _updatePointerPosition;
  38057. private _processPointerMove;
  38058. private _setRayOnPointerInfo;
  38059. private _checkPrePointerObservable;
  38060. /**
  38061. * Use this method to simulate a pointer move on a mesh
  38062. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38063. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38064. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38065. */
  38066. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38067. /**
  38068. * Use this method to simulate a pointer down on a mesh
  38069. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38070. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38071. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38072. */
  38073. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38074. private _processPointerDown;
  38075. /** @hidden */
  38076. _isPointerSwiping(): boolean;
  38077. /**
  38078. * Use this method to simulate a pointer up on a mesh
  38079. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38080. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38081. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38082. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38083. */
  38084. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38085. private _processPointerUp;
  38086. /**
  38087. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38088. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38089. * @returns true if the pointer was captured
  38090. */
  38091. isPointerCaptured(pointerId?: number): boolean;
  38092. /**
  38093. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38094. * @param attachUp defines if you want to attach events to pointerup
  38095. * @param attachDown defines if you want to attach events to pointerdown
  38096. * @param attachMove defines if you want to attach events to pointermove
  38097. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38098. */
  38099. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38100. /**
  38101. * Detaches all event handlers
  38102. */
  38103. detachControl(): void;
  38104. /**
  38105. * Force the value of meshUnderPointer
  38106. * @param mesh defines the mesh to use
  38107. */
  38108. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38109. /**
  38110. * Gets the mesh under the pointer
  38111. * @returns a Mesh or null if no mesh is under the pointer
  38112. */
  38113. getPointerOverMesh(): Nullable<AbstractMesh>;
  38114. }
  38115. }
  38116. declare module BABYLON {
  38117. /**
  38118. * This class defines the direct association between an animation and a target
  38119. */
  38120. export class TargetedAnimation {
  38121. /**
  38122. * Animation to perform
  38123. */
  38124. animation: Animation;
  38125. /**
  38126. * Target to animate
  38127. */
  38128. target: any;
  38129. /**
  38130. * Returns the string "TargetedAnimation"
  38131. * @returns "TargetedAnimation"
  38132. */
  38133. getClassName(): string;
  38134. /**
  38135. * Serialize the object
  38136. * @returns the JSON object representing the current entity
  38137. */
  38138. serialize(): any;
  38139. }
  38140. /**
  38141. * Use this class to create coordinated animations on multiple targets
  38142. */
  38143. export class AnimationGroup implements IDisposable {
  38144. /** The name of the animation group */
  38145. name: string;
  38146. private _scene;
  38147. private _targetedAnimations;
  38148. private _animatables;
  38149. private _from;
  38150. private _to;
  38151. private _isStarted;
  38152. private _isPaused;
  38153. private _speedRatio;
  38154. private _loopAnimation;
  38155. private _isAdditive;
  38156. /**
  38157. * Gets or sets the unique id of the node
  38158. */
  38159. uniqueId: number;
  38160. /**
  38161. * This observable will notify when one animation have ended
  38162. */
  38163. onAnimationEndObservable: Observable<TargetedAnimation>;
  38164. /**
  38165. * Observer raised when one animation loops
  38166. */
  38167. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38168. /**
  38169. * Observer raised when all animations have looped
  38170. */
  38171. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38172. /**
  38173. * This observable will notify when all animations have ended.
  38174. */
  38175. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38176. /**
  38177. * This observable will notify when all animations have paused.
  38178. */
  38179. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38180. /**
  38181. * This observable will notify when all animations are playing.
  38182. */
  38183. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38184. /**
  38185. * Gets the first frame
  38186. */
  38187. get from(): number;
  38188. /**
  38189. * Gets the last frame
  38190. */
  38191. get to(): number;
  38192. /**
  38193. * Define if the animations are started
  38194. */
  38195. get isStarted(): boolean;
  38196. /**
  38197. * Gets a value indicating that the current group is playing
  38198. */
  38199. get isPlaying(): boolean;
  38200. /**
  38201. * Gets or sets the speed ratio to use for all animations
  38202. */
  38203. get speedRatio(): number;
  38204. /**
  38205. * Gets or sets the speed ratio to use for all animations
  38206. */
  38207. set speedRatio(value: number);
  38208. /**
  38209. * Gets or sets if all animations should loop or not
  38210. */
  38211. get loopAnimation(): boolean;
  38212. set loopAnimation(value: boolean);
  38213. /**
  38214. * Gets or sets if all animations should be evaluated additively
  38215. */
  38216. get isAdditive(): boolean;
  38217. set isAdditive(value: boolean);
  38218. /**
  38219. * Gets the targeted animations for this animation group
  38220. */
  38221. get targetedAnimations(): Array<TargetedAnimation>;
  38222. /**
  38223. * returning the list of animatables controlled by this animation group.
  38224. */
  38225. get animatables(): Array<Animatable>;
  38226. /**
  38227. * Gets the list of target animations
  38228. */
  38229. get children(): TargetedAnimation[];
  38230. /**
  38231. * Instantiates a new Animation Group.
  38232. * This helps managing several animations at once.
  38233. * @see https://doc.babylonjs.com/how_to/group
  38234. * @param name Defines the name of the group
  38235. * @param scene Defines the scene the group belongs to
  38236. */
  38237. constructor(
  38238. /** The name of the animation group */
  38239. name: string, scene?: Nullable<Scene>);
  38240. /**
  38241. * Add an animation (with its target) in the group
  38242. * @param animation defines the animation we want to add
  38243. * @param target defines the target of the animation
  38244. * @returns the TargetedAnimation object
  38245. */
  38246. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38247. /**
  38248. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38249. * It can add constant keys at begin or end
  38250. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38251. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38252. * @returns the animation group
  38253. */
  38254. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38255. private _animationLoopCount;
  38256. private _animationLoopFlags;
  38257. private _processLoop;
  38258. /**
  38259. * Start all animations on given targets
  38260. * @param loop defines if animations must loop
  38261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38262. * @param from defines the from key (optional)
  38263. * @param to defines the to key (optional)
  38264. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38265. * @returns the current animation group
  38266. */
  38267. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38268. /**
  38269. * Pause all animations
  38270. * @returns the animation group
  38271. */
  38272. pause(): AnimationGroup;
  38273. /**
  38274. * Play all animations to initial state
  38275. * This function will start() the animations if they were not started or will restart() them if they were paused
  38276. * @param loop defines if animations must loop
  38277. * @returns the animation group
  38278. */
  38279. play(loop?: boolean): AnimationGroup;
  38280. /**
  38281. * Reset all animations to initial state
  38282. * @returns the animation group
  38283. */
  38284. reset(): AnimationGroup;
  38285. /**
  38286. * Restart animations from key 0
  38287. * @returns the animation group
  38288. */
  38289. restart(): AnimationGroup;
  38290. /**
  38291. * Stop all animations
  38292. * @returns the animation group
  38293. */
  38294. stop(): AnimationGroup;
  38295. /**
  38296. * Set animation weight for all animatables
  38297. * @param weight defines the weight to use
  38298. * @return the animationGroup
  38299. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38300. */
  38301. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38302. /**
  38303. * Synchronize and normalize all animatables with a source animatable
  38304. * @param root defines the root animatable to synchronize with
  38305. * @return the animationGroup
  38306. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38307. */
  38308. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38309. /**
  38310. * Goes to a specific frame in this animation group
  38311. * @param frame the frame number to go to
  38312. * @return the animationGroup
  38313. */
  38314. goToFrame(frame: number): AnimationGroup;
  38315. /**
  38316. * Dispose all associated resources
  38317. */
  38318. dispose(): void;
  38319. private _checkAnimationGroupEnded;
  38320. /**
  38321. * Clone the current animation group and returns a copy
  38322. * @param newName defines the name of the new group
  38323. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38324. * @returns the new aniamtion group
  38325. */
  38326. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38327. /**
  38328. * Serializes the animationGroup to an object
  38329. * @returns Serialized object
  38330. */
  38331. serialize(): any;
  38332. /**
  38333. * Returns a new AnimationGroup object parsed from the source provided.
  38334. * @param parsedAnimationGroup defines the source
  38335. * @param scene defines the scene that will receive the animationGroup
  38336. * @returns a new AnimationGroup
  38337. */
  38338. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38339. /**
  38340. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38341. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38342. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38343. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38344. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38345. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38346. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38347. */
  38348. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38349. /**
  38350. * Returns the string "AnimationGroup"
  38351. * @returns "AnimationGroup"
  38352. */
  38353. getClassName(): string;
  38354. /**
  38355. * Creates a detailled string about the object
  38356. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38357. * @returns a string representing the object
  38358. */
  38359. toString(fullDetails?: boolean): string;
  38360. }
  38361. }
  38362. declare module BABYLON {
  38363. /**
  38364. * Define an interface for all classes that will hold resources
  38365. */
  38366. export interface IDisposable {
  38367. /**
  38368. * Releases all held resources
  38369. */
  38370. dispose(): void;
  38371. }
  38372. /** Interface defining initialization parameters for Scene class */
  38373. export interface SceneOptions {
  38374. /**
  38375. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38376. * It will improve performance when the number of geometries becomes important.
  38377. */
  38378. useGeometryUniqueIdsMap?: boolean;
  38379. /**
  38380. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38381. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38382. */
  38383. useMaterialMeshMap?: boolean;
  38384. /**
  38385. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38386. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38387. */
  38388. useClonedMeshMap?: boolean;
  38389. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38390. virtual?: boolean;
  38391. }
  38392. /**
  38393. * Represents a scene to be rendered by the engine.
  38394. * @see https://doc.babylonjs.com/features/scene
  38395. */
  38396. export class Scene extends AbstractScene implements IAnimatable {
  38397. /** The fog is deactivated */
  38398. static readonly FOGMODE_NONE: number;
  38399. /** The fog density is following an exponential function */
  38400. static readonly FOGMODE_EXP: number;
  38401. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38402. static readonly FOGMODE_EXP2: number;
  38403. /** The fog density is following a linear function. */
  38404. static readonly FOGMODE_LINEAR: number;
  38405. /**
  38406. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38408. */
  38409. static MinDeltaTime: number;
  38410. /**
  38411. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38413. */
  38414. static MaxDeltaTime: number;
  38415. /**
  38416. * Factory used to create the default material.
  38417. * @param name The name of the material to create
  38418. * @param scene The scene to create the material for
  38419. * @returns The default material
  38420. */
  38421. static DefaultMaterialFactory(scene: Scene): Material;
  38422. /**
  38423. * Factory used to create the a collision coordinator.
  38424. * @returns The collision coordinator
  38425. */
  38426. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38427. /** @hidden */
  38428. _inputManager: InputManager;
  38429. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38430. cameraToUseForPointers: Nullable<Camera>;
  38431. /** @hidden */
  38432. readonly _isScene: boolean;
  38433. /** @hidden */
  38434. _blockEntityCollection: boolean;
  38435. /**
  38436. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38437. */
  38438. autoClear: boolean;
  38439. /**
  38440. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38441. */
  38442. autoClearDepthAndStencil: boolean;
  38443. /**
  38444. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38445. */
  38446. clearColor: Color4;
  38447. /**
  38448. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38449. */
  38450. ambientColor: Color3;
  38451. /**
  38452. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38453. * It should only be one of the following (if not the default embedded one):
  38454. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38455. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38456. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38457. * The material properties need to be setup according to the type of texture in use.
  38458. */
  38459. environmentBRDFTexture: BaseTexture;
  38460. /** @hidden */
  38461. protected _environmentTexture: Nullable<BaseTexture>;
  38462. /**
  38463. * Texture used in all pbr material as the reflection texture.
  38464. * As in the majority of the scene they are the same (exception for multi room and so on),
  38465. * this is easier to reference from here than from all the materials.
  38466. */
  38467. get environmentTexture(): Nullable<BaseTexture>;
  38468. /**
  38469. * Texture used in all pbr material as the reflection texture.
  38470. * As in the majority of the scene they are the same (exception for multi room and so on),
  38471. * this is easier to set here than in all the materials.
  38472. */
  38473. set environmentTexture(value: Nullable<BaseTexture>);
  38474. /** @hidden */
  38475. protected _environmentIntensity: number;
  38476. /**
  38477. * Intensity of the environment in all pbr material.
  38478. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38479. * As in the majority of the scene they are the same (exception for multi room and so on),
  38480. * this is easier to reference from here than from all the materials.
  38481. */
  38482. get environmentIntensity(): number;
  38483. /**
  38484. * Intensity of the environment in all pbr material.
  38485. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38486. * As in the majority of the scene they are the same (exception for multi room and so on),
  38487. * this is easier to set here than in all the materials.
  38488. */
  38489. set environmentIntensity(value: number);
  38490. /** @hidden */
  38491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38492. /**
  38493. * Default image processing configuration used either in the rendering
  38494. * Forward main pass or through the imageProcessingPostProcess if present.
  38495. * As in the majority of the scene they are the same (exception for multi camera),
  38496. * this is easier to reference from here than from all the materials and post process.
  38497. *
  38498. * No setter as we it is a shared configuration, you can set the values instead.
  38499. */
  38500. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38501. private _forceWireframe;
  38502. /**
  38503. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38504. */
  38505. set forceWireframe(value: boolean);
  38506. get forceWireframe(): boolean;
  38507. private _skipFrustumClipping;
  38508. /**
  38509. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38510. */
  38511. set skipFrustumClipping(value: boolean);
  38512. get skipFrustumClipping(): boolean;
  38513. private _forcePointsCloud;
  38514. /**
  38515. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38516. */
  38517. set forcePointsCloud(value: boolean);
  38518. get forcePointsCloud(): boolean;
  38519. /**
  38520. * Gets or sets the active clipplane 1
  38521. */
  38522. clipPlane: Nullable<Plane>;
  38523. /**
  38524. * Gets or sets the active clipplane 2
  38525. */
  38526. clipPlane2: Nullable<Plane>;
  38527. /**
  38528. * Gets or sets the active clipplane 3
  38529. */
  38530. clipPlane3: Nullable<Plane>;
  38531. /**
  38532. * Gets or sets the active clipplane 4
  38533. */
  38534. clipPlane4: Nullable<Plane>;
  38535. /**
  38536. * Gets or sets the active clipplane 5
  38537. */
  38538. clipPlane5: Nullable<Plane>;
  38539. /**
  38540. * Gets or sets the active clipplane 6
  38541. */
  38542. clipPlane6: Nullable<Plane>;
  38543. /**
  38544. * Gets or sets a boolean indicating if animations are enabled
  38545. */
  38546. animationsEnabled: boolean;
  38547. private _animationPropertiesOverride;
  38548. /**
  38549. * Gets or sets the animation properties override
  38550. */
  38551. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38552. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38553. /**
  38554. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38555. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38556. */
  38557. useConstantAnimationDeltaTime: boolean;
  38558. /**
  38559. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38560. * Please note that it requires to run a ray cast through the scene on every frame
  38561. */
  38562. constantlyUpdateMeshUnderPointer: boolean;
  38563. /**
  38564. * Defines the HTML cursor to use when hovering over interactive elements
  38565. */
  38566. hoverCursor: string;
  38567. /**
  38568. * Defines the HTML default cursor to use (empty by default)
  38569. */
  38570. defaultCursor: string;
  38571. /**
  38572. * Defines whether cursors are handled by the scene.
  38573. */
  38574. doNotHandleCursors: boolean;
  38575. /**
  38576. * This is used to call preventDefault() on pointer down
  38577. * in order to block unwanted artifacts like system double clicks
  38578. */
  38579. preventDefaultOnPointerDown: boolean;
  38580. /**
  38581. * This is used to call preventDefault() on pointer up
  38582. * in order to block unwanted artifacts like system double clicks
  38583. */
  38584. preventDefaultOnPointerUp: boolean;
  38585. /**
  38586. * Gets or sets user defined metadata
  38587. */
  38588. metadata: any;
  38589. /**
  38590. * For internal use only. Please do not use.
  38591. */
  38592. reservedDataStore: any;
  38593. /**
  38594. * Gets the name of the plugin used to load this scene (null by default)
  38595. */
  38596. loadingPluginName: string;
  38597. /**
  38598. * Use this array to add regular expressions used to disable offline support for specific urls
  38599. */
  38600. disableOfflineSupportExceptionRules: RegExp[];
  38601. /**
  38602. * An event triggered when the scene is disposed.
  38603. */
  38604. onDisposeObservable: Observable<Scene>;
  38605. private _onDisposeObserver;
  38606. /** Sets a function to be executed when this scene is disposed. */
  38607. set onDispose(callback: () => void);
  38608. /**
  38609. * An event triggered before rendering the scene (right after animations and physics)
  38610. */
  38611. onBeforeRenderObservable: Observable<Scene>;
  38612. private _onBeforeRenderObserver;
  38613. /** Sets a function to be executed before rendering this scene */
  38614. set beforeRender(callback: Nullable<() => void>);
  38615. /**
  38616. * An event triggered after rendering the scene
  38617. */
  38618. onAfterRenderObservable: Observable<Scene>;
  38619. /**
  38620. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38621. */
  38622. onAfterRenderCameraObservable: Observable<Camera>;
  38623. private _onAfterRenderObserver;
  38624. /** Sets a function to be executed after rendering this scene */
  38625. set afterRender(callback: Nullable<() => void>);
  38626. /**
  38627. * An event triggered before animating the scene
  38628. */
  38629. onBeforeAnimationsObservable: Observable<Scene>;
  38630. /**
  38631. * An event triggered after animations processing
  38632. */
  38633. onAfterAnimationsObservable: Observable<Scene>;
  38634. /**
  38635. * An event triggered before draw calls are ready to be sent
  38636. */
  38637. onBeforeDrawPhaseObservable: Observable<Scene>;
  38638. /**
  38639. * An event triggered after draw calls have been sent
  38640. */
  38641. onAfterDrawPhaseObservable: Observable<Scene>;
  38642. /**
  38643. * An event triggered when the scene is ready
  38644. */
  38645. onReadyObservable: Observable<Scene>;
  38646. /**
  38647. * An event triggered before rendering a camera
  38648. */
  38649. onBeforeCameraRenderObservable: Observable<Camera>;
  38650. private _onBeforeCameraRenderObserver;
  38651. /** Sets a function to be executed before rendering a camera*/
  38652. set beforeCameraRender(callback: () => void);
  38653. /**
  38654. * An event triggered after rendering a camera
  38655. */
  38656. onAfterCameraRenderObservable: Observable<Camera>;
  38657. private _onAfterCameraRenderObserver;
  38658. /** Sets a function to be executed after rendering a camera*/
  38659. set afterCameraRender(callback: () => void);
  38660. /**
  38661. * An event triggered when active meshes evaluation is about to start
  38662. */
  38663. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38664. /**
  38665. * An event triggered when active meshes evaluation is done
  38666. */
  38667. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38668. /**
  38669. * An event triggered when particles rendering is about to start
  38670. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38671. */
  38672. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38673. /**
  38674. * An event triggered when particles rendering is done
  38675. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38676. */
  38677. onAfterParticlesRenderingObservable: Observable<Scene>;
  38678. /**
  38679. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38680. */
  38681. onDataLoadedObservable: Observable<Scene>;
  38682. /**
  38683. * An event triggered when a camera is created
  38684. */
  38685. onNewCameraAddedObservable: Observable<Camera>;
  38686. /**
  38687. * An event triggered when a camera is removed
  38688. */
  38689. onCameraRemovedObservable: Observable<Camera>;
  38690. /**
  38691. * An event triggered when a light is created
  38692. */
  38693. onNewLightAddedObservable: Observable<Light>;
  38694. /**
  38695. * An event triggered when a light is removed
  38696. */
  38697. onLightRemovedObservable: Observable<Light>;
  38698. /**
  38699. * An event triggered when a geometry is created
  38700. */
  38701. onNewGeometryAddedObservable: Observable<Geometry>;
  38702. /**
  38703. * An event triggered when a geometry is removed
  38704. */
  38705. onGeometryRemovedObservable: Observable<Geometry>;
  38706. /**
  38707. * An event triggered when a transform node is created
  38708. */
  38709. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38710. /**
  38711. * An event triggered when a transform node is removed
  38712. */
  38713. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38714. /**
  38715. * An event triggered when a mesh is created
  38716. */
  38717. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38718. /**
  38719. * An event triggered when a mesh is removed
  38720. */
  38721. onMeshRemovedObservable: Observable<AbstractMesh>;
  38722. /**
  38723. * An event triggered when a skeleton is created
  38724. */
  38725. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38726. /**
  38727. * An event triggered when a skeleton is removed
  38728. */
  38729. onSkeletonRemovedObservable: Observable<Skeleton>;
  38730. /**
  38731. * An event triggered when a material is created
  38732. */
  38733. onNewMaterialAddedObservable: Observable<Material>;
  38734. /**
  38735. * An event triggered when a material is removed
  38736. */
  38737. onMaterialRemovedObservable: Observable<Material>;
  38738. /**
  38739. * An event triggered when a texture is created
  38740. */
  38741. onNewTextureAddedObservable: Observable<BaseTexture>;
  38742. /**
  38743. * An event triggered when a texture is removed
  38744. */
  38745. onTextureRemovedObservable: Observable<BaseTexture>;
  38746. /**
  38747. * An event triggered when render targets are about to be rendered
  38748. * Can happen multiple times per frame.
  38749. */
  38750. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38751. /**
  38752. * An event triggered when render targets were rendered.
  38753. * Can happen multiple times per frame.
  38754. */
  38755. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38756. /**
  38757. * An event triggered before calculating deterministic simulation step
  38758. */
  38759. onBeforeStepObservable: Observable<Scene>;
  38760. /**
  38761. * An event triggered after calculating deterministic simulation step
  38762. */
  38763. onAfterStepObservable: Observable<Scene>;
  38764. /**
  38765. * An event triggered when the activeCamera property is updated
  38766. */
  38767. onActiveCameraChanged: Observable<Scene>;
  38768. /**
  38769. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38770. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38771. * 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)
  38772. */
  38773. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38774. /**
  38775. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38776. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38777. * 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)
  38778. */
  38779. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38780. /**
  38781. * This Observable will when a mesh has been imported into the scene.
  38782. */
  38783. onMeshImportedObservable: Observable<AbstractMesh>;
  38784. /**
  38785. * This Observable will when an animation file has been imported into the scene.
  38786. */
  38787. onAnimationFileImportedObservable: Observable<Scene>;
  38788. /**
  38789. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38790. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38791. */
  38792. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38793. /** @hidden */
  38794. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38795. /**
  38796. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38797. */
  38798. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38799. /**
  38800. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38801. */
  38802. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38803. /**
  38804. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38805. */
  38806. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38807. /** Callback called when a pointer move is detected */
  38808. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38809. /** Callback called when a pointer down is detected */
  38810. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38811. /** Callback called when a pointer up is detected */
  38812. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38813. /** Callback called when a pointer pick is detected */
  38814. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38815. /**
  38816. * 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).
  38817. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38818. */
  38819. onPrePointerObservable: Observable<PointerInfoPre>;
  38820. /**
  38821. * Observable event triggered each time an input event is received from the rendering canvas
  38822. */
  38823. onPointerObservable: Observable<PointerInfo>;
  38824. /**
  38825. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38826. */
  38827. get unTranslatedPointer(): Vector2;
  38828. /**
  38829. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38830. */
  38831. static get DragMovementThreshold(): number;
  38832. static set DragMovementThreshold(value: number);
  38833. /**
  38834. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38835. */
  38836. static get LongPressDelay(): number;
  38837. static set LongPressDelay(value: number);
  38838. /**
  38839. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38840. */
  38841. static get DoubleClickDelay(): number;
  38842. static set DoubleClickDelay(value: number);
  38843. /** If you need to check double click without raising a single click at first click, enable this flag */
  38844. static get ExclusiveDoubleClickMode(): boolean;
  38845. static set ExclusiveDoubleClickMode(value: boolean);
  38846. /** @hidden */
  38847. _mirroredCameraPosition: Nullable<Vector3>;
  38848. /**
  38849. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38850. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38851. */
  38852. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38853. /**
  38854. * Observable event triggered each time an keyboard event is received from the hosting window
  38855. */
  38856. onKeyboardObservable: Observable<KeyboardInfo>;
  38857. private _useRightHandedSystem;
  38858. /**
  38859. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38860. */
  38861. set useRightHandedSystem(value: boolean);
  38862. get useRightHandedSystem(): boolean;
  38863. private _timeAccumulator;
  38864. private _currentStepId;
  38865. private _currentInternalStep;
  38866. /**
  38867. * Sets the step Id used by deterministic lock step
  38868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38869. * @param newStepId defines the step Id
  38870. */
  38871. setStepId(newStepId: number): void;
  38872. /**
  38873. * Gets the step Id used by deterministic lock step
  38874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38875. * @returns the step Id
  38876. */
  38877. getStepId(): number;
  38878. /**
  38879. * Gets the internal step used by deterministic lock step
  38880. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38881. * @returns the internal step
  38882. */
  38883. getInternalStep(): number;
  38884. private _fogEnabled;
  38885. /**
  38886. * Gets or sets a boolean indicating if fog is enabled on this scene
  38887. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38888. * (Default is true)
  38889. */
  38890. set fogEnabled(value: boolean);
  38891. get fogEnabled(): boolean;
  38892. private _fogMode;
  38893. /**
  38894. * Gets or sets the fog mode to use
  38895. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38896. * | mode | value |
  38897. * | --- | --- |
  38898. * | FOGMODE_NONE | 0 |
  38899. * | FOGMODE_EXP | 1 |
  38900. * | FOGMODE_EXP2 | 2 |
  38901. * | FOGMODE_LINEAR | 3 |
  38902. */
  38903. set fogMode(value: number);
  38904. get fogMode(): number;
  38905. /**
  38906. * Gets or sets the fog color to use
  38907. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38908. * (Default is Color3(0.2, 0.2, 0.3))
  38909. */
  38910. fogColor: Color3;
  38911. /**
  38912. * Gets or sets the fog density to use
  38913. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38914. * (Default is 0.1)
  38915. */
  38916. fogDensity: number;
  38917. /**
  38918. * Gets or sets the fog start distance to use
  38919. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38920. * (Default is 0)
  38921. */
  38922. fogStart: number;
  38923. /**
  38924. * Gets or sets the fog end distance to use
  38925. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38926. * (Default is 1000)
  38927. */
  38928. fogEnd: number;
  38929. /**
  38930. * Flag indicating that the frame buffer binding is handled by another component
  38931. */
  38932. prePass: boolean;
  38933. private _shadowsEnabled;
  38934. /**
  38935. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38936. */
  38937. set shadowsEnabled(value: boolean);
  38938. get shadowsEnabled(): boolean;
  38939. private _lightsEnabled;
  38940. /**
  38941. * Gets or sets a boolean indicating if lights are enabled on this scene
  38942. */
  38943. set lightsEnabled(value: boolean);
  38944. get lightsEnabled(): boolean;
  38945. /** All of the active cameras added to this scene. */
  38946. activeCameras: Camera[];
  38947. /** @hidden */
  38948. _activeCamera: Nullable<Camera>;
  38949. /** Gets or sets the current active camera */
  38950. get activeCamera(): Nullable<Camera>;
  38951. set activeCamera(value: Nullable<Camera>);
  38952. private _defaultMaterial;
  38953. /** The default material used on meshes when no material is affected */
  38954. get defaultMaterial(): Material;
  38955. /** The default material used on meshes when no material is affected */
  38956. set defaultMaterial(value: Material);
  38957. private _texturesEnabled;
  38958. /**
  38959. * Gets or sets a boolean indicating if textures are enabled on this scene
  38960. */
  38961. set texturesEnabled(value: boolean);
  38962. get texturesEnabled(): boolean;
  38963. /**
  38964. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38965. */
  38966. physicsEnabled: boolean;
  38967. /**
  38968. * Gets or sets a boolean indicating if particles are enabled on this scene
  38969. */
  38970. particlesEnabled: boolean;
  38971. /**
  38972. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38973. */
  38974. spritesEnabled: boolean;
  38975. private _skeletonsEnabled;
  38976. /**
  38977. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38978. */
  38979. set skeletonsEnabled(value: boolean);
  38980. get skeletonsEnabled(): boolean;
  38981. /**
  38982. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38983. */
  38984. lensFlaresEnabled: boolean;
  38985. /**
  38986. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38987. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38988. */
  38989. collisionsEnabled: boolean;
  38990. private _collisionCoordinator;
  38991. /** @hidden */
  38992. get collisionCoordinator(): ICollisionCoordinator;
  38993. /**
  38994. * Defines the gravity applied to this scene (used only for collisions)
  38995. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38996. */
  38997. gravity: Vector3;
  38998. /**
  38999. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39000. */
  39001. postProcessesEnabled: boolean;
  39002. /**
  39003. * The list of postprocesses added to the scene
  39004. */
  39005. postProcesses: PostProcess[];
  39006. /**
  39007. * Gets the current postprocess manager
  39008. */
  39009. postProcessManager: PostProcessManager;
  39010. /**
  39011. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39012. */
  39013. renderTargetsEnabled: boolean;
  39014. /**
  39015. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39016. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39017. */
  39018. dumpNextRenderTargets: boolean;
  39019. /**
  39020. * The list of user defined render targets added to the scene
  39021. */
  39022. customRenderTargets: RenderTargetTexture[];
  39023. /**
  39024. * Defines if texture loading must be delayed
  39025. * If true, textures will only be loaded when they need to be rendered
  39026. */
  39027. useDelayedTextureLoading: boolean;
  39028. /**
  39029. * Gets the list of meshes imported to the scene through SceneLoader
  39030. */
  39031. importedMeshesFiles: String[];
  39032. /**
  39033. * Gets or sets a boolean indicating if probes are enabled on this scene
  39034. */
  39035. probesEnabled: boolean;
  39036. /**
  39037. * Gets or sets the current offline provider to use to store scene data
  39038. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39039. */
  39040. offlineProvider: IOfflineProvider;
  39041. /**
  39042. * Gets or sets the action manager associated with the scene
  39043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39044. */
  39045. actionManager: AbstractActionManager;
  39046. private _meshesForIntersections;
  39047. /**
  39048. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39049. */
  39050. proceduralTexturesEnabled: boolean;
  39051. private _engine;
  39052. private _totalVertices;
  39053. /** @hidden */
  39054. _activeIndices: PerfCounter;
  39055. /** @hidden */
  39056. _activeParticles: PerfCounter;
  39057. /** @hidden */
  39058. _activeBones: PerfCounter;
  39059. private _animationRatio;
  39060. /** @hidden */
  39061. _animationTimeLast: number;
  39062. /** @hidden */
  39063. _animationTime: number;
  39064. /**
  39065. * Gets or sets a general scale for animation speed
  39066. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39067. */
  39068. animationTimeScale: number;
  39069. /** @hidden */
  39070. _cachedMaterial: Nullable<Material>;
  39071. /** @hidden */
  39072. _cachedEffect: Nullable<Effect>;
  39073. /** @hidden */
  39074. _cachedVisibility: Nullable<number>;
  39075. private _renderId;
  39076. private _frameId;
  39077. private _executeWhenReadyTimeoutId;
  39078. private _intermediateRendering;
  39079. private _viewUpdateFlag;
  39080. private _projectionUpdateFlag;
  39081. /** @hidden */
  39082. _toBeDisposed: Nullable<IDisposable>[];
  39083. private _activeRequests;
  39084. /** @hidden */
  39085. _pendingData: any[];
  39086. private _isDisposed;
  39087. /**
  39088. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39089. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39090. */
  39091. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39092. private _activeMeshes;
  39093. private _processedMaterials;
  39094. private _renderTargets;
  39095. /** @hidden */
  39096. _activeParticleSystems: SmartArray<IParticleSystem>;
  39097. private _activeSkeletons;
  39098. private _softwareSkinnedMeshes;
  39099. private _renderingManager;
  39100. /** @hidden */
  39101. _activeAnimatables: Animatable[];
  39102. private _transformMatrix;
  39103. private _sceneUbo;
  39104. /** @hidden */
  39105. _viewMatrix: Matrix;
  39106. private _projectionMatrix;
  39107. /** @hidden */
  39108. _forcedViewPosition: Nullable<Vector3>;
  39109. /** @hidden */
  39110. _frustumPlanes: Plane[];
  39111. /**
  39112. * Gets the list of frustum planes (built from the active camera)
  39113. */
  39114. get frustumPlanes(): Plane[];
  39115. /**
  39116. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39117. * This is useful if there are more lights that the maximum simulteanous authorized
  39118. */
  39119. requireLightSorting: boolean;
  39120. /** @hidden */
  39121. readonly useMaterialMeshMap: boolean;
  39122. /** @hidden */
  39123. readonly useClonedMeshMap: boolean;
  39124. private _externalData;
  39125. private _uid;
  39126. /**
  39127. * @hidden
  39128. * Backing store of defined scene components.
  39129. */
  39130. _components: ISceneComponent[];
  39131. /**
  39132. * @hidden
  39133. * Backing store of defined scene components.
  39134. */
  39135. _serializableComponents: ISceneSerializableComponent[];
  39136. /**
  39137. * List of components to register on the next registration step.
  39138. */
  39139. private _transientComponents;
  39140. /**
  39141. * Registers the transient components if needed.
  39142. */
  39143. private _registerTransientComponents;
  39144. /**
  39145. * @hidden
  39146. * Add a component to the scene.
  39147. * Note that the ccomponent could be registered on th next frame if this is called after
  39148. * the register component stage.
  39149. * @param component Defines the component to add to the scene
  39150. */
  39151. _addComponent(component: ISceneComponent): void;
  39152. /**
  39153. * @hidden
  39154. * Gets a component from the scene.
  39155. * @param name defines the name of the component to retrieve
  39156. * @returns the component or null if not present
  39157. */
  39158. _getComponent(name: string): Nullable<ISceneComponent>;
  39159. /**
  39160. * @hidden
  39161. * Defines the actions happening before camera updates.
  39162. */
  39163. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39164. /**
  39165. * @hidden
  39166. * Defines the actions happening before clear the canvas.
  39167. */
  39168. _beforeClearStage: Stage<SimpleStageAction>;
  39169. /**
  39170. * @hidden
  39171. * Defines the actions when collecting render targets for the frame.
  39172. */
  39173. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39174. /**
  39175. * @hidden
  39176. * Defines the actions happening for one camera in the frame.
  39177. */
  39178. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39179. /**
  39180. * @hidden
  39181. * Defines the actions happening during the per mesh ready checks.
  39182. */
  39183. _isReadyForMeshStage: Stage<MeshStageAction>;
  39184. /**
  39185. * @hidden
  39186. * Defines the actions happening before evaluate active mesh checks.
  39187. */
  39188. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39189. /**
  39190. * @hidden
  39191. * Defines the actions happening during the evaluate sub mesh checks.
  39192. */
  39193. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39194. /**
  39195. * @hidden
  39196. * Defines the actions happening during the active mesh stage.
  39197. */
  39198. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39199. /**
  39200. * @hidden
  39201. * Defines the actions happening during the per camera render target step.
  39202. */
  39203. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39204. /**
  39205. * @hidden
  39206. * Defines the actions happening just before the active camera is drawing.
  39207. */
  39208. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39209. /**
  39210. * @hidden
  39211. * Defines the actions happening just before a render target is drawing.
  39212. */
  39213. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39214. /**
  39215. * @hidden
  39216. * Defines the actions happening just before a rendering group is drawing.
  39217. */
  39218. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39219. /**
  39220. * @hidden
  39221. * Defines the actions happening just before a mesh is drawing.
  39222. */
  39223. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39224. /**
  39225. * @hidden
  39226. * Defines the actions happening just after a mesh has been drawn.
  39227. */
  39228. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39229. /**
  39230. * @hidden
  39231. * Defines the actions happening just after a rendering group has been drawn.
  39232. */
  39233. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39234. /**
  39235. * @hidden
  39236. * Defines the actions happening just after the active camera has been drawn.
  39237. */
  39238. _afterCameraDrawStage: Stage<CameraStageAction>;
  39239. /**
  39240. * @hidden
  39241. * Defines the actions happening just after a render target has been drawn.
  39242. */
  39243. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39244. /**
  39245. * @hidden
  39246. * Defines the actions happening just after rendering all cameras and computing intersections.
  39247. */
  39248. _afterRenderStage: Stage<SimpleStageAction>;
  39249. /**
  39250. * @hidden
  39251. * Defines the actions happening when a pointer move event happens.
  39252. */
  39253. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39254. /**
  39255. * @hidden
  39256. * Defines the actions happening when a pointer down event happens.
  39257. */
  39258. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39259. /**
  39260. * @hidden
  39261. * Defines the actions happening when a pointer up event happens.
  39262. */
  39263. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39264. /**
  39265. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39266. */
  39267. private geometriesByUniqueId;
  39268. /**
  39269. * Creates a new Scene
  39270. * @param engine defines the engine to use to render this scene
  39271. * @param options defines the scene options
  39272. */
  39273. constructor(engine: Engine, options?: SceneOptions);
  39274. /**
  39275. * Gets a string idenfifying the name of the class
  39276. * @returns "Scene" string
  39277. */
  39278. getClassName(): string;
  39279. private _defaultMeshCandidates;
  39280. /**
  39281. * @hidden
  39282. */
  39283. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39284. private _defaultSubMeshCandidates;
  39285. /**
  39286. * @hidden
  39287. */
  39288. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39289. /**
  39290. * Sets the default candidate providers for the scene.
  39291. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39292. * and getCollidingSubMeshCandidates to their default function
  39293. */
  39294. setDefaultCandidateProviders(): void;
  39295. /**
  39296. * Gets the mesh that is currently under the pointer
  39297. */
  39298. get meshUnderPointer(): Nullable<AbstractMesh>;
  39299. /**
  39300. * Gets or sets the current on-screen X position of the pointer
  39301. */
  39302. get pointerX(): number;
  39303. set pointerX(value: number);
  39304. /**
  39305. * Gets or sets the current on-screen Y position of the pointer
  39306. */
  39307. get pointerY(): number;
  39308. set pointerY(value: number);
  39309. /**
  39310. * Gets the cached material (ie. the latest rendered one)
  39311. * @returns the cached material
  39312. */
  39313. getCachedMaterial(): Nullable<Material>;
  39314. /**
  39315. * Gets the cached effect (ie. the latest rendered one)
  39316. * @returns the cached effect
  39317. */
  39318. getCachedEffect(): Nullable<Effect>;
  39319. /**
  39320. * Gets the cached visibility state (ie. the latest rendered one)
  39321. * @returns the cached visibility state
  39322. */
  39323. getCachedVisibility(): Nullable<number>;
  39324. /**
  39325. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39326. * @param material defines the current material
  39327. * @param effect defines the current effect
  39328. * @param visibility defines the current visibility state
  39329. * @returns true if one parameter is not cached
  39330. */
  39331. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39332. /**
  39333. * Gets the engine associated with the scene
  39334. * @returns an Engine
  39335. */
  39336. getEngine(): Engine;
  39337. /**
  39338. * Gets the total number of vertices rendered per frame
  39339. * @returns the total number of vertices rendered per frame
  39340. */
  39341. getTotalVertices(): number;
  39342. /**
  39343. * Gets the performance counter for total vertices
  39344. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39345. */
  39346. get totalVerticesPerfCounter(): PerfCounter;
  39347. /**
  39348. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39349. * @returns the total number of active indices rendered per frame
  39350. */
  39351. getActiveIndices(): number;
  39352. /**
  39353. * Gets the performance counter for active indices
  39354. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39355. */
  39356. get totalActiveIndicesPerfCounter(): PerfCounter;
  39357. /**
  39358. * Gets the total number of active particles rendered per frame
  39359. * @returns the total number of active particles rendered per frame
  39360. */
  39361. getActiveParticles(): number;
  39362. /**
  39363. * Gets the performance counter for active particles
  39364. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39365. */
  39366. get activeParticlesPerfCounter(): PerfCounter;
  39367. /**
  39368. * Gets the total number of active bones rendered per frame
  39369. * @returns the total number of active bones rendered per frame
  39370. */
  39371. getActiveBones(): number;
  39372. /**
  39373. * Gets the performance counter for active bones
  39374. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39375. */
  39376. get activeBonesPerfCounter(): PerfCounter;
  39377. /**
  39378. * Gets the array of active meshes
  39379. * @returns an array of AbstractMesh
  39380. */
  39381. getActiveMeshes(): SmartArray<AbstractMesh>;
  39382. /**
  39383. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39384. * @returns a number
  39385. */
  39386. getAnimationRatio(): number;
  39387. /**
  39388. * Gets an unique Id for the current render phase
  39389. * @returns a number
  39390. */
  39391. getRenderId(): number;
  39392. /**
  39393. * Gets an unique Id for the current frame
  39394. * @returns a number
  39395. */
  39396. getFrameId(): number;
  39397. /** Call this function if you want to manually increment the render Id*/
  39398. incrementRenderId(): void;
  39399. private _createUbo;
  39400. /**
  39401. * Use this method to simulate a pointer move on a mesh
  39402. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39403. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39404. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39405. * @returns the current scene
  39406. */
  39407. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39408. /**
  39409. * Use this method to simulate a pointer down on a mesh
  39410. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39411. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39412. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39413. * @returns the current scene
  39414. */
  39415. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39416. /**
  39417. * Use this method to simulate a pointer up on a mesh
  39418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39421. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39422. * @returns the current scene
  39423. */
  39424. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39425. /**
  39426. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39427. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39428. * @returns true if the pointer was captured
  39429. */
  39430. isPointerCaptured(pointerId?: number): boolean;
  39431. /**
  39432. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39433. * @param attachUp defines if you want to attach events to pointerup
  39434. * @param attachDown defines if you want to attach events to pointerdown
  39435. * @param attachMove defines if you want to attach events to pointermove
  39436. */
  39437. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39438. /** Detaches all event handlers*/
  39439. detachControl(): void;
  39440. /**
  39441. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39442. * Delay loaded resources are not taking in account
  39443. * @return true if all required resources are ready
  39444. */
  39445. isReady(): boolean;
  39446. /** Resets all cached information relative to material (including effect and visibility) */
  39447. resetCachedMaterial(): void;
  39448. /**
  39449. * Registers a function to be called before every frame render
  39450. * @param func defines the function to register
  39451. */
  39452. registerBeforeRender(func: () => void): void;
  39453. /**
  39454. * Unregisters a function called before every frame render
  39455. * @param func defines the function to unregister
  39456. */
  39457. unregisterBeforeRender(func: () => void): void;
  39458. /**
  39459. * Registers a function to be called after every frame render
  39460. * @param func defines the function to register
  39461. */
  39462. registerAfterRender(func: () => void): void;
  39463. /**
  39464. * Unregisters a function called after every frame render
  39465. * @param func defines the function to unregister
  39466. */
  39467. unregisterAfterRender(func: () => void): void;
  39468. private _executeOnceBeforeRender;
  39469. /**
  39470. * The provided function will run before render once and will be disposed afterwards.
  39471. * A timeout delay can be provided so that the function will be executed in N ms.
  39472. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39473. * @param func The function to be executed.
  39474. * @param timeout optional delay in ms
  39475. */
  39476. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39477. /** @hidden */
  39478. _addPendingData(data: any): void;
  39479. /** @hidden */
  39480. _removePendingData(data: any): void;
  39481. /**
  39482. * Returns the number of items waiting to be loaded
  39483. * @returns the number of items waiting to be loaded
  39484. */
  39485. getWaitingItemsCount(): number;
  39486. /**
  39487. * Returns a boolean indicating if the scene is still loading data
  39488. */
  39489. get isLoading(): boolean;
  39490. /**
  39491. * Registers a function to be executed when the scene is ready
  39492. * @param {Function} func - the function to be executed
  39493. */
  39494. executeWhenReady(func: () => void): void;
  39495. /**
  39496. * Returns a promise that resolves when the scene is ready
  39497. * @returns A promise that resolves when the scene is ready
  39498. */
  39499. whenReadyAsync(): Promise<void>;
  39500. /** @hidden */
  39501. _checkIsReady(): void;
  39502. /**
  39503. * Gets all animatable attached to the scene
  39504. */
  39505. get animatables(): Animatable[];
  39506. /**
  39507. * Resets the last animation time frame.
  39508. * Useful to override when animations start running when loading a scene for the first time.
  39509. */
  39510. resetLastAnimationTimeFrame(): void;
  39511. /**
  39512. * Gets the current view matrix
  39513. * @returns a Matrix
  39514. */
  39515. getViewMatrix(): Matrix;
  39516. /**
  39517. * Gets the current projection matrix
  39518. * @returns a Matrix
  39519. */
  39520. getProjectionMatrix(): Matrix;
  39521. /**
  39522. * Gets the current transform matrix
  39523. * @returns a Matrix made of View * Projection
  39524. */
  39525. getTransformMatrix(): Matrix;
  39526. /**
  39527. * Sets the current transform matrix
  39528. * @param viewL defines the View matrix to use
  39529. * @param projectionL defines the Projection matrix to use
  39530. * @param viewR defines the right View matrix to use (if provided)
  39531. * @param projectionR defines the right Projection matrix to use (if provided)
  39532. */
  39533. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39534. /**
  39535. * Gets the uniform buffer used to store scene data
  39536. * @returns a UniformBuffer
  39537. */
  39538. getSceneUniformBuffer(): UniformBuffer;
  39539. /**
  39540. * Gets an unique (relatively to the current scene) Id
  39541. * @returns an unique number for the scene
  39542. */
  39543. getUniqueId(): number;
  39544. /**
  39545. * Add a mesh to the list of scene's meshes
  39546. * @param newMesh defines the mesh to add
  39547. * @param recursive if all child meshes should also be added to the scene
  39548. */
  39549. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39550. /**
  39551. * Remove a mesh for the list of scene's meshes
  39552. * @param toRemove defines the mesh to remove
  39553. * @param recursive if all child meshes should also be removed from the scene
  39554. * @returns the index where the mesh was in the mesh list
  39555. */
  39556. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39557. /**
  39558. * Add a transform node to the list of scene's transform nodes
  39559. * @param newTransformNode defines the transform node to add
  39560. */
  39561. addTransformNode(newTransformNode: TransformNode): void;
  39562. /**
  39563. * Remove a transform node for the list of scene's transform nodes
  39564. * @param toRemove defines the transform node to remove
  39565. * @returns the index where the transform node was in the transform node list
  39566. */
  39567. removeTransformNode(toRemove: TransformNode): number;
  39568. /**
  39569. * Remove a skeleton for the list of scene's skeletons
  39570. * @param toRemove defines the skeleton to remove
  39571. * @returns the index where the skeleton was in the skeleton list
  39572. */
  39573. removeSkeleton(toRemove: Skeleton): number;
  39574. /**
  39575. * Remove a morph target for the list of scene's morph targets
  39576. * @param toRemove defines the morph target to remove
  39577. * @returns the index where the morph target was in the morph target list
  39578. */
  39579. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39580. /**
  39581. * Remove a light for the list of scene's lights
  39582. * @param toRemove defines the light to remove
  39583. * @returns the index where the light was in the light list
  39584. */
  39585. removeLight(toRemove: Light): number;
  39586. /**
  39587. * Remove a camera for the list of scene's cameras
  39588. * @param toRemove defines the camera to remove
  39589. * @returns the index where the camera was in the camera list
  39590. */
  39591. removeCamera(toRemove: Camera): number;
  39592. /**
  39593. * Remove a particle system for the list of scene's particle systems
  39594. * @param toRemove defines the particle system to remove
  39595. * @returns the index where the particle system was in the particle system list
  39596. */
  39597. removeParticleSystem(toRemove: IParticleSystem): number;
  39598. /**
  39599. * Remove a animation for the list of scene's animations
  39600. * @param toRemove defines the animation to remove
  39601. * @returns the index where the animation was in the animation list
  39602. */
  39603. removeAnimation(toRemove: Animation): number;
  39604. /**
  39605. * Will stop the animation of the given target
  39606. * @param target - the target
  39607. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39608. * @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)
  39609. */
  39610. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39611. /**
  39612. * Removes the given animation group from this scene.
  39613. * @param toRemove The animation group to remove
  39614. * @returns The index of the removed animation group
  39615. */
  39616. removeAnimationGroup(toRemove: AnimationGroup): number;
  39617. /**
  39618. * Removes the given multi-material from this scene.
  39619. * @param toRemove The multi-material to remove
  39620. * @returns The index of the removed multi-material
  39621. */
  39622. removeMultiMaterial(toRemove: MultiMaterial): number;
  39623. /**
  39624. * Removes the given material from this scene.
  39625. * @param toRemove The material to remove
  39626. * @returns The index of the removed material
  39627. */
  39628. removeMaterial(toRemove: Material): number;
  39629. /**
  39630. * Removes the given action manager from this scene.
  39631. * @param toRemove The action manager to remove
  39632. * @returns The index of the removed action manager
  39633. */
  39634. removeActionManager(toRemove: AbstractActionManager): number;
  39635. /**
  39636. * Removes the given texture from this scene.
  39637. * @param toRemove The texture to remove
  39638. * @returns The index of the removed texture
  39639. */
  39640. removeTexture(toRemove: BaseTexture): number;
  39641. /**
  39642. * Adds the given light to this scene
  39643. * @param newLight The light to add
  39644. */
  39645. addLight(newLight: Light): void;
  39646. /**
  39647. * Sorts the list list based on light priorities
  39648. */
  39649. sortLightsByPriority(): void;
  39650. /**
  39651. * Adds the given camera to this scene
  39652. * @param newCamera The camera to add
  39653. */
  39654. addCamera(newCamera: Camera): void;
  39655. /**
  39656. * Adds the given skeleton to this scene
  39657. * @param newSkeleton The skeleton to add
  39658. */
  39659. addSkeleton(newSkeleton: Skeleton): void;
  39660. /**
  39661. * Adds the given particle system to this scene
  39662. * @param newParticleSystem The particle system to add
  39663. */
  39664. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39665. /**
  39666. * Adds the given animation to this scene
  39667. * @param newAnimation The animation to add
  39668. */
  39669. addAnimation(newAnimation: Animation): void;
  39670. /**
  39671. * Adds the given animation group to this scene.
  39672. * @param newAnimationGroup The animation group to add
  39673. */
  39674. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39675. /**
  39676. * Adds the given multi-material to this scene
  39677. * @param newMultiMaterial The multi-material to add
  39678. */
  39679. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39680. /**
  39681. * Adds the given material to this scene
  39682. * @param newMaterial The material to add
  39683. */
  39684. addMaterial(newMaterial: Material): void;
  39685. /**
  39686. * Adds the given morph target to this scene
  39687. * @param newMorphTargetManager The morph target to add
  39688. */
  39689. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39690. /**
  39691. * Adds the given geometry to this scene
  39692. * @param newGeometry The geometry to add
  39693. */
  39694. addGeometry(newGeometry: Geometry): void;
  39695. /**
  39696. * Adds the given action manager to this scene
  39697. * @param newActionManager The action manager to add
  39698. */
  39699. addActionManager(newActionManager: AbstractActionManager): void;
  39700. /**
  39701. * Adds the given texture to this scene.
  39702. * @param newTexture The texture to add
  39703. */
  39704. addTexture(newTexture: BaseTexture): void;
  39705. /**
  39706. * Switch active camera
  39707. * @param newCamera defines the new active camera
  39708. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39709. */
  39710. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39711. /**
  39712. * sets the active camera of the scene using its ID
  39713. * @param id defines the camera's ID
  39714. * @return the new active camera or null if none found.
  39715. */
  39716. setActiveCameraByID(id: string): Nullable<Camera>;
  39717. /**
  39718. * sets the active camera of the scene using its name
  39719. * @param name defines the camera's name
  39720. * @returns the new active camera or null if none found.
  39721. */
  39722. setActiveCameraByName(name: string): Nullable<Camera>;
  39723. /**
  39724. * get an animation group using its name
  39725. * @param name defines the material's name
  39726. * @return the animation group or null if none found.
  39727. */
  39728. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39729. /**
  39730. * Get a material using its unique id
  39731. * @param uniqueId defines the material's unique id
  39732. * @return the material or null if none found.
  39733. */
  39734. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39735. /**
  39736. * get a material using its id
  39737. * @param id defines the material's ID
  39738. * @return the material or null if none found.
  39739. */
  39740. getMaterialByID(id: string): Nullable<Material>;
  39741. /**
  39742. * Gets a the last added material using a given id
  39743. * @param id defines the material's ID
  39744. * @return the last material with the given id or null if none found.
  39745. */
  39746. getLastMaterialByID(id: string): Nullable<Material>;
  39747. /**
  39748. * Gets a material using its name
  39749. * @param name defines the material's name
  39750. * @return the material or null if none found.
  39751. */
  39752. getMaterialByName(name: string): Nullable<Material>;
  39753. /**
  39754. * Get a texture using its unique id
  39755. * @param uniqueId defines the texture's unique id
  39756. * @return the texture or null if none found.
  39757. */
  39758. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39759. /**
  39760. * Gets a camera using its id
  39761. * @param id defines the id to look for
  39762. * @returns the camera or null if not found
  39763. */
  39764. getCameraByID(id: string): Nullable<Camera>;
  39765. /**
  39766. * Gets a camera using its unique id
  39767. * @param uniqueId defines the unique id to look for
  39768. * @returns the camera or null if not found
  39769. */
  39770. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39771. /**
  39772. * Gets a camera using its name
  39773. * @param name defines the camera's name
  39774. * @return the camera or null if none found.
  39775. */
  39776. getCameraByName(name: string): Nullable<Camera>;
  39777. /**
  39778. * Gets a bone using its id
  39779. * @param id defines the bone's id
  39780. * @return the bone or null if not found
  39781. */
  39782. getBoneByID(id: string): Nullable<Bone>;
  39783. /**
  39784. * Gets a bone using its id
  39785. * @param name defines the bone's name
  39786. * @return the bone or null if not found
  39787. */
  39788. getBoneByName(name: string): Nullable<Bone>;
  39789. /**
  39790. * Gets a light node using its name
  39791. * @param name defines the the light's name
  39792. * @return the light or null if none found.
  39793. */
  39794. getLightByName(name: string): Nullable<Light>;
  39795. /**
  39796. * Gets a light node using its id
  39797. * @param id defines the light's id
  39798. * @return the light or null if none found.
  39799. */
  39800. getLightByID(id: string): Nullable<Light>;
  39801. /**
  39802. * Gets a light node using its scene-generated unique ID
  39803. * @param uniqueId defines the light's unique id
  39804. * @return the light or null if none found.
  39805. */
  39806. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39807. /**
  39808. * Gets a particle system by id
  39809. * @param id defines the particle system id
  39810. * @return the corresponding system or null if none found
  39811. */
  39812. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39813. /**
  39814. * Gets a geometry using its ID
  39815. * @param id defines the geometry's id
  39816. * @return the geometry or null if none found.
  39817. */
  39818. getGeometryByID(id: string): Nullable<Geometry>;
  39819. private _getGeometryByUniqueID;
  39820. /**
  39821. * Add a new geometry to this scene
  39822. * @param geometry defines the geometry to be added to the scene.
  39823. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39824. * @return a boolean defining if the geometry was added or not
  39825. */
  39826. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39827. /**
  39828. * Removes an existing geometry
  39829. * @param geometry defines the geometry to be removed from the scene
  39830. * @return a boolean defining if the geometry was removed or not
  39831. */
  39832. removeGeometry(geometry: Geometry): boolean;
  39833. /**
  39834. * Gets the list of geometries attached to the scene
  39835. * @returns an array of Geometry
  39836. */
  39837. getGeometries(): Geometry[];
  39838. /**
  39839. * Gets the first added mesh found of a given ID
  39840. * @param id defines the id to search for
  39841. * @return the mesh found or null if not found at all
  39842. */
  39843. getMeshByID(id: string): Nullable<AbstractMesh>;
  39844. /**
  39845. * Gets a list of meshes using their id
  39846. * @param id defines the id to search for
  39847. * @returns a list of meshes
  39848. */
  39849. getMeshesByID(id: string): Array<AbstractMesh>;
  39850. /**
  39851. * Gets the first added transform node found of a given ID
  39852. * @param id defines the id to search for
  39853. * @return the found transform node or null if not found at all.
  39854. */
  39855. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39856. /**
  39857. * Gets a transform node with its auto-generated unique id
  39858. * @param uniqueId efines the unique id to search for
  39859. * @return the found transform node or null if not found at all.
  39860. */
  39861. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39862. /**
  39863. * Gets a list of transform nodes using their id
  39864. * @param id defines the id to search for
  39865. * @returns a list of transform nodes
  39866. */
  39867. getTransformNodesByID(id: string): Array<TransformNode>;
  39868. /**
  39869. * Gets a mesh with its auto-generated unique id
  39870. * @param uniqueId defines the unique id to search for
  39871. * @return the found mesh or null if not found at all.
  39872. */
  39873. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39874. /**
  39875. * Gets a the last added mesh using a given id
  39876. * @param id defines the id to search for
  39877. * @return the found mesh or null if not found at all.
  39878. */
  39879. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39880. /**
  39881. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39882. * @param id defines the id to search for
  39883. * @return the found node or null if not found at all
  39884. */
  39885. getLastEntryByID(id: string): Nullable<Node>;
  39886. /**
  39887. * Gets a node (Mesh, Camera, Light) using a given id
  39888. * @param id defines the id to search for
  39889. * @return the found node or null if not found at all
  39890. */
  39891. getNodeByID(id: string): Nullable<Node>;
  39892. /**
  39893. * Gets a node (Mesh, Camera, Light) using a given name
  39894. * @param name defines the name to search for
  39895. * @return the found node or null if not found at all.
  39896. */
  39897. getNodeByName(name: string): Nullable<Node>;
  39898. /**
  39899. * Gets a mesh using a given name
  39900. * @param name defines the name to search for
  39901. * @return the found mesh or null if not found at all.
  39902. */
  39903. getMeshByName(name: string): Nullable<AbstractMesh>;
  39904. /**
  39905. * Gets a transform node using a given name
  39906. * @param name defines the name to search for
  39907. * @return the found transform node or null if not found at all.
  39908. */
  39909. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39910. /**
  39911. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39912. * @param id defines the id to search for
  39913. * @return the found skeleton or null if not found at all.
  39914. */
  39915. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39916. /**
  39917. * Gets a skeleton using a given auto generated unique id
  39918. * @param uniqueId defines the unique id to search for
  39919. * @return the found skeleton or null if not found at all.
  39920. */
  39921. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39922. /**
  39923. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39924. * @param id defines the id to search for
  39925. * @return the found skeleton or null if not found at all.
  39926. */
  39927. getSkeletonById(id: string): Nullable<Skeleton>;
  39928. /**
  39929. * Gets a skeleton using a given name
  39930. * @param name defines the name to search for
  39931. * @return the found skeleton or null if not found at all.
  39932. */
  39933. getSkeletonByName(name: string): Nullable<Skeleton>;
  39934. /**
  39935. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39936. * @param id defines the id to search for
  39937. * @return the found morph target manager or null if not found at all.
  39938. */
  39939. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39940. /**
  39941. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39942. * @param id defines the id to search for
  39943. * @return the found morph target or null if not found at all.
  39944. */
  39945. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39946. /**
  39947. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39948. * @param name defines the name to search for
  39949. * @return the found morph target or null if not found at all.
  39950. */
  39951. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39952. /**
  39953. * Gets a boolean indicating if the given mesh is active
  39954. * @param mesh defines the mesh to look for
  39955. * @returns true if the mesh is in the active list
  39956. */
  39957. isActiveMesh(mesh: AbstractMesh): boolean;
  39958. /**
  39959. * Return a unique id as a string which can serve as an identifier for the scene
  39960. */
  39961. get uid(): string;
  39962. /**
  39963. * Add an externaly attached data from its key.
  39964. * This method call will fail and return false, if such key already exists.
  39965. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39966. * @param key the unique key that identifies the data
  39967. * @param data the data object to associate to the key for this Engine instance
  39968. * @return true if no such key were already present and the data was added successfully, false otherwise
  39969. */
  39970. addExternalData<T>(key: string, data: T): boolean;
  39971. /**
  39972. * Get an externaly attached data from its key
  39973. * @param key the unique key that identifies the data
  39974. * @return the associated data, if present (can be null), or undefined if not present
  39975. */
  39976. getExternalData<T>(key: string): Nullable<T>;
  39977. /**
  39978. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39979. * @param key the unique key that identifies the data
  39980. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39981. * @return the associated data, can be null if the factory returned null.
  39982. */
  39983. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39984. /**
  39985. * Remove an externaly attached data from the Engine instance
  39986. * @param key the unique key that identifies the data
  39987. * @return true if the data was successfully removed, false if it doesn't exist
  39988. */
  39989. removeExternalData(key: string): boolean;
  39990. private _evaluateSubMesh;
  39991. /**
  39992. * Clear the processed materials smart array preventing retention point in material dispose.
  39993. */
  39994. freeProcessedMaterials(): void;
  39995. private _preventFreeActiveMeshesAndRenderingGroups;
  39996. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39997. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39998. * when disposing several meshes in a row or a hierarchy of meshes.
  39999. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40000. */
  40001. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40002. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40003. /**
  40004. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40005. */
  40006. freeActiveMeshes(): void;
  40007. /**
  40008. * Clear the info related to rendering groups preventing retention points during dispose.
  40009. */
  40010. freeRenderingGroups(): void;
  40011. /** @hidden */
  40012. _isInIntermediateRendering(): boolean;
  40013. /**
  40014. * Lambda returning the list of potentially active meshes.
  40015. */
  40016. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40017. /**
  40018. * Lambda returning the list of potentially active sub meshes.
  40019. */
  40020. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40021. /**
  40022. * Lambda returning the list of potentially intersecting sub meshes.
  40023. */
  40024. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40025. /**
  40026. * Lambda returning the list of potentially colliding sub meshes.
  40027. */
  40028. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40029. private _activeMeshesFrozen;
  40030. private _skipEvaluateActiveMeshesCompletely;
  40031. /**
  40032. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40033. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40034. * @returns the current scene
  40035. */
  40036. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40037. /**
  40038. * Use this function to restart evaluating active meshes on every frame
  40039. * @returns the current scene
  40040. */
  40041. unfreezeActiveMeshes(): Scene;
  40042. private _evaluateActiveMeshes;
  40043. private _activeMesh;
  40044. /**
  40045. * Update the transform matrix to update from the current active camera
  40046. * @param force defines a boolean used to force the update even if cache is up to date
  40047. */
  40048. updateTransformMatrix(force?: boolean): void;
  40049. private _bindFrameBuffer;
  40050. /** @hidden */
  40051. _allowPostProcessClearColor: boolean;
  40052. /** @hidden */
  40053. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40054. private _processSubCameras;
  40055. private _checkIntersections;
  40056. /** @hidden */
  40057. _advancePhysicsEngineStep(step: number): void;
  40058. /**
  40059. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40060. */
  40061. getDeterministicFrameTime: () => number;
  40062. /** @hidden */
  40063. _animate(): void;
  40064. /** Execute all animations (for a frame) */
  40065. animate(): void;
  40066. /**
  40067. * Render the scene
  40068. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40069. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40070. */
  40071. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40072. /**
  40073. * Freeze all materials
  40074. * A frozen material will not be updatable but should be faster to render
  40075. */
  40076. freezeMaterials(): void;
  40077. /**
  40078. * Unfreeze all materials
  40079. * A frozen material will not be updatable but should be faster to render
  40080. */
  40081. unfreezeMaterials(): void;
  40082. /**
  40083. * Releases all held ressources
  40084. */
  40085. dispose(): void;
  40086. /**
  40087. * Gets if the scene is already disposed
  40088. */
  40089. get isDisposed(): boolean;
  40090. /**
  40091. * Call this function to reduce memory footprint of the scene.
  40092. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40093. */
  40094. clearCachedVertexData(): void;
  40095. /**
  40096. * This function will remove the local cached buffer data from texture.
  40097. * It will save memory but will prevent the texture from being rebuilt
  40098. */
  40099. cleanCachedTextureBuffer(): void;
  40100. /**
  40101. * Get the world extend vectors with an optional filter
  40102. *
  40103. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40104. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40105. */
  40106. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40107. min: Vector3;
  40108. max: Vector3;
  40109. };
  40110. /**
  40111. * Creates a ray that can be used to pick in the scene
  40112. * @param x defines the x coordinate of the origin (on-screen)
  40113. * @param y defines the y coordinate of the origin (on-screen)
  40114. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40115. * @param camera defines the camera to use for the picking
  40116. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40117. * @returns a Ray
  40118. */
  40119. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40120. /**
  40121. * Creates a ray that can be used to pick in the scene
  40122. * @param x defines the x coordinate of the origin (on-screen)
  40123. * @param y defines the y coordinate of the origin (on-screen)
  40124. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40125. * @param result defines the ray where to store the picking ray
  40126. * @param camera defines the camera to use for the picking
  40127. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40128. * @returns the current scene
  40129. */
  40130. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40131. /**
  40132. * Creates a ray that can be used to pick in the scene
  40133. * @param x defines the x coordinate of the origin (on-screen)
  40134. * @param y defines the y coordinate of the origin (on-screen)
  40135. * @param camera defines the camera to use for the picking
  40136. * @returns a Ray
  40137. */
  40138. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40139. /**
  40140. * Creates a ray that can be used to pick in the scene
  40141. * @param x defines the x coordinate of the origin (on-screen)
  40142. * @param y defines the y coordinate of the origin (on-screen)
  40143. * @param result defines the ray where to store the picking ray
  40144. * @param camera defines the camera to use for the picking
  40145. * @returns the current scene
  40146. */
  40147. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40148. /** Launch a ray to try to pick a mesh in the scene
  40149. * @param x position on screen
  40150. * @param y position on screen
  40151. * @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
  40152. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40153. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40154. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40155. * @returns a PickingInfo
  40156. */
  40157. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40158. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40159. * @param x position on screen
  40160. * @param y position on screen
  40161. * @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
  40162. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40163. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40164. * @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)
  40165. */
  40166. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40167. /** Use the given ray to pick a mesh in the scene
  40168. * @param ray The ray to use to pick meshes
  40169. * @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
  40170. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40172. * @returns a PickingInfo
  40173. */
  40174. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40175. /**
  40176. * Launch a ray to try to pick a mesh in the scene
  40177. * @param x X position on screen
  40178. * @param y Y position on screen
  40179. * @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
  40180. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40182. * @returns an array of PickingInfo
  40183. */
  40184. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40185. /**
  40186. * Launch a ray to try to pick a mesh in the scene
  40187. * @param ray Ray to use
  40188. * @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
  40189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40190. * @returns an array of PickingInfo
  40191. */
  40192. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40193. /**
  40194. * Force the value of meshUnderPointer
  40195. * @param mesh defines the mesh to use
  40196. */
  40197. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40198. /**
  40199. * Gets the mesh under the pointer
  40200. * @returns a Mesh or null if no mesh is under the pointer
  40201. */
  40202. getPointerOverMesh(): Nullable<AbstractMesh>;
  40203. /** @hidden */
  40204. _rebuildGeometries(): void;
  40205. /** @hidden */
  40206. _rebuildTextures(): void;
  40207. private _getByTags;
  40208. /**
  40209. * Get a list of meshes by tags
  40210. * @param tagsQuery defines the tags query to use
  40211. * @param forEach defines a predicate used to filter results
  40212. * @returns an array of Mesh
  40213. */
  40214. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40215. /**
  40216. * Get a list of cameras by tags
  40217. * @param tagsQuery defines the tags query to use
  40218. * @param forEach defines a predicate used to filter results
  40219. * @returns an array of Camera
  40220. */
  40221. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40222. /**
  40223. * Get a list of lights by tags
  40224. * @param tagsQuery defines the tags query to use
  40225. * @param forEach defines a predicate used to filter results
  40226. * @returns an array of Light
  40227. */
  40228. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40229. /**
  40230. * Get a list of materials by tags
  40231. * @param tagsQuery defines the tags query to use
  40232. * @param forEach defines a predicate used to filter results
  40233. * @returns an array of Material
  40234. */
  40235. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40236. /**
  40237. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40238. * This allowed control for front to back rendering or reversly depending of the special needs.
  40239. *
  40240. * @param renderingGroupId The rendering group id corresponding to its index
  40241. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40242. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40243. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40244. */
  40245. 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;
  40246. /**
  40247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40248. *
  40249. * @param renderingGroupId The rendering group id corresponding to its index
  40250. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40251. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40252. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40253. */
  40254. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40255. /**
  40256. * Gets the current auto clear configuration for one rendering group of the rendering
  40257. * manager.
  40258. * @param index the rendering group index to get the information for
  40259. * @returns The auto clear setup for the requested rendering group
  40260. */
  40261. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40262. private _blockMaterialDirtyMechanism;
  40263. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40264. get blockMaterialDirtyMechanism(): boolean;
  40265. set blockMaterialDirtyMechanism(value: boolean);
  40266. /**
  40267. * Will flag all materials as dirty to trigger new shader compilation
  40268. * @param flag defines the flag used to specify which material part must be marked as dirty
  40269. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40270. */
  40271. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40272. /** @hidden */
  40273. _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;
  40274. /** @hidden */
  40275. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40276. /** @hidden */
  40277. _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;
  40278. /** @hidden */
  40279. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40280. /** @hidden */
  40281. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40282. /** @hidden */
  40283. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40284. }
  40285. }
  40286. declare module BABYLON {
  40287. /**
  40288. * Set of assets to keep when moving a scene into an asset container.
  40289. */
  40290. export class KeepAssets extends AbstractScene {
  40291. }
  40292. /**
  40293. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40294. */
  40295. export class InstantiatedEntries {
  40296. /**
  40297. * List of new root nodes (eg. nodes with no parent)
  40298. */
  40299. rootNodes: TransformNode[];
  40300. /**
  40301. * List of new skeletons
  40302. */
  40303. skeletons: Skeleton[];
  40304. /**
  40305. * List of new animation groups
  40306. */
  40307. animationGroups: AnimationGroup[];
  40308. }
  40309. /**
  40310. * Container with a set of assets that can be added or removed from a scene.
  40311. */
  40312. export class AssetContainer extends AbstractScene {
  40313. private _wasAddedToScene;
  40314. /**
  40315. * The scene the AssetContainer belongs to.
  40316. */
  40317. scene: Scene;
  40318. /**
  40319. * Instantiates an AssetContainer.
  40320. * @param scene The scene the AssetContainer belongs to.
  40321. */
  40322. constructor(scene: Scene);
  40323. /**
  40324. * Instantiate or clone all meshes and add the new ones to the scene.
  40325. * Skeletons and animation groups will all be cloned
  40326. * @param nameFunction defines an optional function used to get new names for clones
  40327. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40328. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40329. */
  40330. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40331. /**
  40332. * Adds all the assets from the container to the scene.
  40333. */
  40334. addAllToScene(): void;
  40335. /**
  40336. * Removes all the assets in the container from the scene
  40337. */
  40338. removeAllFromScene(): void;
  40339. /**
  40340. * Disposes all the assets in the container
  40341. */
  40342. dispose(): void;
  40343. private _moveAssets;
  40344. /**
  40345. * Removes all the assets contained in the scene and adds them to the container.
  40346. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40347. */
  40348. moveAllFromScene(keepAssets?: KeepAssets): void;
  40349. /**
  40350. * 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.
  40351. * @returns the root mesh
  40352. */
  40353. createRootMesh(): Mesh;
  40354. /**
  40355. * Merge animations (direct and animation groups) from this asset container into a scene
  40356. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40357. * @param animatables set of animatables to retarget to a node from the scene
  40358. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40359. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40360. */
  40361. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40362. }
  40363. }
  40364. declare module BABYLON {
  40365. /**
  40366. * Defines how the parser contract is defined.
  40367. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40368. */
  40369. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40370. /**
  40371. * Defines how the individual parser contract is defined.
  40372. * These parser can parse an individual asset
  40373. */
  40374. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40375. /**
  40376. * Base class of the scene acting as a container for the different elements composing a scene.
  40377. * This class is dynamically extended by the different components of the scene increasing
  40378. * flexibility and reducing coupling
  40379. */
  40380. export abstract class AbstractScene {
  40381. /**
  40382. * Stores the list of available parsers in the application.
  40383. */
  40384. private static _BabylonFileParsers;
  40385. /**
  40386. * Stores the list of available individual parsers in the application.
  40387. */
  40388. private static _IndividualBabylonFileParsers;
  40389. /**
  40390. * Adds a parser in the list of available ones
  40391. * @param name Defines the name of the parser
  40392. * @param parser Defines the parser to add
  40393. */
  40394. static AddParser(name: string, parser: BabylonFileParser): void;
  40395. /**
  40396. * Gets a general parser from the list of avaialble ones
  40397. * @param name Defines the name of the parser
  40398. * @returns the requested parser or null
  40399. */
  40400. static GetParser(name: string): Nullable<BabylonFileParser>;
  40401. /**
  40402. * Adds n individual parser in the list of available ones
  40403. * @param name Defines the name of the parser
  40404. * @param parser Defines the parser to add
  40405. */
  40406. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40407. /**
  40408. * Gets an individual parser from the list of avaialble ones
  40409. * @param name Defines the name of the parser
  40410. * @returns the requested parser or null
  40411. */
  40412. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40413. /**
  40414. * Parser json data and populate both a scene and its associated container object
  40415. * @param jsonData Defines the data to parse
  40416. * @param scene Defines the scene to parse the data for
  40417. * @param container Defines the container attached to the parsing sequence
  40418. * @param rootUrl Defines the root url of the data
  40419. */
  40420. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40421. /**
  40422. * Gets the list of root nodes (ie. nodes with no parent)
  40423. */
  40424. rootNodes: Node[];
  40425. /** All of the cameras added to this scene
  40426. * @see https://doc.babylonjs.com/babylon101/cameras
  40427. */
  40428. cameras: Camera[];
  40429. /**
  40430. * All of the lights added to this scene
  40431. * @see https://doc.babylonjs.com/babylon101/lights
  40432. */
  40433. lights: Light[];
  40434. /**
  40435. * All of the (abstract) meshes added to this scene
  40436. */
  40437. meshes: AbstractMesh[];
  40438. /**
  40439. * The list of skeletons added to the scene
  40440. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40441. */
  40442. skeletons: Skeleton[];
  40443. /**
  40444. * All of the particle systems added to this scene
  40445. * @see https://doc.babylonjs.com/babylon101/particles
  40446. */
  40447. particleSystems: IParticleSystem[];
  40448. /**
  40449. * Gets a list of Animations associated with the scene
  40450. */
  40451. animations: Animation[];
  40452. /**
  40453. * All of the animation groups added to this scene
  40454. * @see https://doc.babylonjs.com/how_to/group
  40455. */
  40456. animationGroups: AnimationGroup[];
  40457. /**
  40458. * All of the multi-materials added to this scene
  40459. * @see https://doc.babylonjs.com/how_to/multi_materials
  40460. */
  40461. multiMaterials: MultiMaterial[];
  40462. /**
  40463. * All of the materials added to this scene
  40464. * In the context of a Scene, it is not supposed to be modified manually.
  40465. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40466. * Note also that the order of the Material within the array is not significant and might change.
  40467. * @see https://doc.babylonjs.com/babylon101/materials
  40468. */
  40469. materials: Material[];
  40470. /**
  40471. * The list of morph target managers added to the scene
  40472. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40473. */
  40474. morphTargetManagers: MorphTargetManager[];
  40475. /**
  40476. * The list of geometries used in the scene.
  40477. */
  40478. geometries: Geometry[];
  40479. /**
  40480. * All of the tranform nodes added to this scene
  40481. * In the context of a Scene, it is not supposed to be modified manually.
  40482. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40483. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40484. * @see https://doc.babylonjs.com/how_to/transformnode
  40485. */
  40486. transformNodes: TransformNode[];
  40487. /**
  40488. * ActionManagers available on the scene.
  40489. */
  40490. actionManagers: AbstractActionManager[];
  40491. /**
  40492. * Textures to keep.
  40493. */
  40494. textures: BaseTexture[];
  40495. /**
  40496. * Environment texture for the scene
  40497. */
  40498. environmentTexture: Nullable<BaseTexture>;
  40499. /**
  40500. * @returns all meshes, lights, cameras, transformNodes and bones
  40501. */
  40502. getNodes(): Array<Node>;
  40503. }
  40504. }
  40505. declare module BABYLON {
  40506. /**
  40507. * Interface used to define options for Sound class
  40508. */
  40509. export interface ISoundOptions {
  40510. /**
  40511. * Does the sound autoplay once loaded.
  40512. */
  40513. autoplay?: boolean;
  40514. /**
  40515. * Does the sound loop after it finishes playing once.
  40516. */
  40517. loop?: boolean;
  40518. /**
  40519. * Sound's volume
  40520. */
  40521. volume?: number;
  40522. /**
  40523. * Is it a spatial sound?
  40524. */
  40525. spatialSound?: boolean;
  40526. /**
  40527. * Maximum distance to hear that sound
  40528. */
  40529. maxDistance?: number;
  40530. /**
  40531. * Uses user defined attenuation function
  40532. */
  40533. useCustomAttenuation?: boolean;
  40534. /**
  40535. * Define the roll off factor of spatial sounds.
  40536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40537. */
  40538. rolloffFactor?: number;
  40539. /**
  40540. * Define the reference distance the sound should be heard perfectly.
  40541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40542. */
  40543. refDistance?: number;
  40544. /**
  40545. * Define the distance attenuation model the sound will follow.
  40546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40547. */
  40548. distanceModel?: string;
  40549. /**
  40550. * Defines the playback speed (1 by default)
  40551. */
  40552. playbackRate?: number;
  40553. /**
  40554. * Defines if the sound is from a streaming source
  40555. */
  40556. streaming?: boolean;
  40557. /**
  40558. * Defines an optional length (in seconds) inside the sound file
  40559. */
  40560. length?: number;
  40561. /**
  40562. * Defines an optional offset (in seconds) inside the sound file
  40563. */
  40564. offset?: number;
  40565. /**
  40566. * If true, URLs will not be required to state the audio file codec to use.
  40567. */
  40568. skipCodecCheck?: boolean;
  40569. }
  40570. /**
  40571. * Defines a sound that can be played in the application.
  40572. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40573. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40574. */
  40575. export class Sound {
  40576. /**
  40577. * The name of the sound in the scene.
  40578. */
  40579. name: string;
  40580. /**
  40581. * Does the sound autoplay once loaded.
  40582. */
  40583. autoplay: boolean;
  40584. /**
  40585. * Does the sound loop after it finishes playing once.
  40586. */
  40587. loop: boolean;
  40588. /**
  40589. * Does the sound use a custom attenuation curve to simulate the falloff
  40590. * happening when the source gets further away from the camera.
  40591. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40592. */
  40593. useCustomAttenuation: boolean;
  40594. /**
  40595. * The sound track id this sound belongs to.
  40596. */
  40597. soundTrackId: number;
  40598. /**
  40599. * Is this sound currently played.
  40600. */
  40601. isPlaying: boolean;
  40602. /**
  40603. * Is this sound currently paused.
  40604. */
  40605. isPaused: boolean;
  40606. /**
  40607. * Does this sound enables spatial sound.
  40608. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40609. */
  40610. spatialSound: boolean;
  40611. /**
  40612. * Define the reference distance the sound should be heard perfectly.
  40613. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40614. */
  40615. refDistance: number;
  40616. /**
  40617. * Define the roll off factor of spatial sounds.
  40618. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40619. */
  40620. rolloffFactor: number;
  40621. /**
  40622. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40623. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40624. */
  40625. maxDistance: number;
  40626. /**
  40627. * Define the distance attenuation model the sound will follow.
  40628. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40629. */
  40630. distanceModel: string;
  40631. /**
  40632. * @hidden
  40633. * Back Compat
  40634. **/
  40635. onended: () => any;
  40636. /**
  40637. * Gets or sets an object used to store user defined information for the sound.
  40638. */
  40639. metadata: any;
  40640. /**
  40641. * Observable event when the current playing sound finishes.
  40642. */
  40643. onEndedObservable: Observable<Sound>;
  40644. private _panningModel;
  40645. private _playbackRate;
  40646. private _streaming;
  40647. private _startTime;
  40648. private _startOffset;
  40649. private _position;
  40650. /** @hidden */
  40651. _positionInEmitterSpace: boolean;
  40652. private _localDirection;
  40653. private _volume;
  40654. private _isReadyToPlay;
  40655. private _isDirectional;
  40656. private _readyToPlayCallback;
  40657. private _audioBuffer;
  40658. private _soundSource;
  40659. private _streamingSource;
  40660. private _soundPanner;
  40661. private _soundGain;
  40662. private _inputAudioNode;
  40663. private _outputAudioNode;
  40664. private _coneInnerAngle;
  40665. private _coneOuterAngle;
  40666. private _coneOuterGain;
  40667. private _scene;
  40668. private _connectedTransformNode;
  40669. private _customAttenuationFunction;
  40670. private _registerFunc;
  40671. private _isOutputConnected;
  40672. private _htmlAudioElement;
  40673. private _urlType;
  40674. private _length?;
  40675. private _offset?;
  40676. /** @hidden */
  40677. static _SceneComponentInitialization: (scene: Scene) => void;
  40678. /**
  40679. * Create a sound and attach it to a scene
  40680. * @param name Name of your sound
  40681. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40682. * @param scene defines the scene the sound belongs to
  40683. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40684. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40685. */
  40686. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40687. /**
  40688. * Release the sound and its associated resources
  40689. */
  40690. dispose(): void;
  40691. /**
  40692. * Gets if the sounds is ready to be played or not.
  40693. * @returns true if ready, otherwise false
  40694. */
  40695. isReady(): boolean;
  40696. private _soundLoaded;
  40697. /**
  40698. * Sets the data of the sound from an audiobuffer
  40699. * @param audioBuffer The audioBuffer containing the data
  40700. */
  40701. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40702. /**
  40703. * Updates the current sounds options such as maxdistance, loop...
  40704. * @param options A JSON object containing values named as the object properties
  40705. */
  40706. updateOptions(options: ISoundOptions): void;
  40707. private _createSpatialParameters;
  40708. private _updateSpatialParameters;
  40709. /**
  40710. * Switch the panning model to HRTF:
  40711. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40712. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40713. */
  40714. switchPanningModelToHRTF(): void;
  40715. /**
  40716. * Switch the panning model to Equal Power:
  40717. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40719. */
  40720. switchPanningModelToEqualPower(): void;
  40721. private _switchPanningModel;
  40722. /**
  40723. * Connect this sound to a sound track audio node like gain...
  40724. * @param soundTrackAudioNode the sound track audio node to connect to
  40725. */
  40726. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40727. /**
  40728. * Transform this sound into a directional source
  40729. * @param coneInnerAngle Size of the inner cone in degree
  40730. * @param coneOuterAngle Size of the outer cone in degree
  40731. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40732. */
  40733. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40734. /**
  40735. * Gets or sets the inner angle for the directional cone.
  40736. */
  40737. get directionalConeInnerAngle(): number;
  40738. /**
  40739. * Gets or sets the inner angle for the directional cone.
  40740. */
  40741. set directionalConeInnerAngle(value: number);
  40742. /**
  40743. * Gets or sets the outer angle for the directional cone.
  40744. */
  40745. get directionalConeOuterAngle(): number;
  40746. /**
  40747. * Gets or sets the outer angle for the directional cone.
  40748. */
  40749. set directionalConeOuterAngle(value: number);
  40750. /**
  40751. * Sets the position of the emitter if spatial sound is enabled
  40752. * @param newPosition Defines the new posisiton
  40753. */
  40754. setPosition(newPosition: Vector3): void;
  40755. /**
  40756. * Sets the local direction of the emitter if spatial sound is enabled
  40757. * @param newLocalDirection Defines the new local direction
  40758. */
  40759. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40760. private _updateDirection;
  40761. /** @hidden */
  40762. updateDistanceFromListener(): void;
  40763. /**
  40764. * Sets a new custom attenuation function for the sound.
  40765. * @param callback Defines the function used for the attenuation
  40766. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40767. */
  40768. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40769. /**
  40770. * Play the sound
  40771. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40772. * @param offset (optional) Start the sound at a specific time in seconds
  40773. * @param length (optional) Sound duration (in seconds)
  40774. */
  40775. play(time?: number, offset?: number, length?: number): void;
  40776. private _onended;
  40777. /**
  40778. * Stop the sound
  40779. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40780. */
  40781. stop(time?: number): void;
  40782. /**
  40783. * Put the sound in pause
  40784. */
  40785. pause(): void;
  40786. /**
  40787. * Sets a dedicated volume for this sounds
  40788. * @param newVolume Define the new volume of the sound
  40789. * @param time Define time for gradual change to new volume
  40790. */
  40791. setVolume(newVolume: number, time?: number): void;
  40792. /**
  40793. * Set the sound play back rate
  40794. * @param newPlaybackRate Define the playback rate the sound should be played at
  40795. */
  40796. setPlaybackRate(newPlaybackRate: number): void;
  40797. /**
  40798. * Gets the volume of the sound.
  40799. * @returns the volume of the sound
  40800. */
  40801. getVolume(): number;
  40802. /**
  40803. * Attach the sound to a dedicated mesh
  40804. * @param transformNode The transform node to connect the sound with
  40805. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40806. */
  40807. attachToMesh(transformNode: TransformNode): void;
  40808. /**
  40809. * Detach the sound from the previously attached mesh
  40810. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40811. */
  40812. detachFromMesh(): void;
  40813. private _onRegisterAfterWorldMatrixUpdate;
  40814. /**
  40815. * Clone the current sound in the scene.
  40816. * @returns the new sound clone
  40817. */
  40818. clone(): Nullable<Sound>;
  40819. /**
  40820. * Gets the current underlying audio buffer containing the data
  40821. * @returns the audio buffer
  40822. */
  40823. getAudioBuffer(): Nullable<AudioBuffer>;
  40824. /**
  40825. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40826. * @returns the source node
  40827. */
  40828. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40829. /**
  40830. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40831. * @returns the gain node
  40832. */
  40833. getSoundGain(): Nullable<GainNode>;
  40834. /**
  40835. * Serializes the Sound in a JSON representation
  40836. * @returns the JSON representation of the sound
  40837. */
  40838. serialize(): any;
  40839. /**
  40840. * Parse a JSON representation of a sound to innstantiate in a given scene
  40841. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40842. * @param scene Define the scene the new parsed sound should be created in
  40843. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40844. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40845. * @returns the newly parsed sound
  40846. */
  40847. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40848. }
  40849. }
  40850. declare module BABYLON {
  40851. /**
  40852. * This defines an action helpful to play a defined sound on a triggered action.
  40853. */
  40854. export class PlaySoundAction extends Action {
  40855. private _sound;
  40856. /**
  40857. * Instantiate the action
  40858. * @param triggerOptions defines the trigger options
  40859. * @param sound defines the sound to play
  40860. * @param condition defines the trigger related conditions
  40861. */
  40862. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40863. /** @hidden */
  40864. _prepare(): void;
  40865. /**
  40866. * Execute the action and play the sound.
  40867. */
  40868. execute(): void;
  40869. /**
  40870. * Serializes the actions and its related information.
  40871. * @param parent defines the object to serialize in
  40872. * @returns the serialized object
  40873. */
  40874. serialize(parent: any): any;
  40875. }
  40876. /**
  40877. * This defines an action helpful to stop a defined sound on a triggered action.
  40878. */
  40879. export class StopSoundAction extends Action {
  40880. private _sound;
  40881. /**
  40882. * Instantiate the action
  40883. * @param triggerOptions defines the trigger options
  40884. * @param sound defines the sound to stop
  40885. * @param condition defines the trigger related conditions
  40886. */
  40887. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40888. /** @hidden */
  40889. _prepare(): void;
  40890. /**
  40891. * Execute the action and stop the sound.
  40892. */
  40893. execute(): void;
  40894. /**
  40895. * Serializes the actions and its related information.
  40896. * @param parent defines the object to serialize in
  40897. * @returns the serialized object
  40898. */
  40899. serialize(parent: any): any;
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * This defines an action responsible to change the value of a property
  40905. * by interpolating between its current value and the newly set one once triggered.
  40906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40907. */
  40908. export class InterpolateValueAction extends Action {
  40909. /**
  40910. * Defines the path of the property where the value should be interpolated
  40911. */
  40912. propertyPath: string;
  40913. /**
  40914. * Defines the target value at the end of the interpolation.
  40915. */
  40916. value: any;
  40917. /**
  40918. * Defines the time it will take for the property to interpolate to the value.
  40919. */
  40920. duration: number;
  40921. /**
  40922. * Defines if the other scene animations should be stopped when the action has been triggered
  40923. */
  40924. stopOtherAnimations?: boolean;
  40925. /**
  40926. * Defines a callback raised once the interpolation animation has been done.
  40927. */
  40928. onInterpolationDone?: () => void;
  40929. /**
  40930. * Observable triggered once the interpolation animation has been done.
  40931. */
  40932. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40933. private _target;
  40934. private _effectiveTarget;
  40935. private _property;
  40936. /**
  40937. * Instantiate the action
  40938. * @param triggerOptions defines the trigger options
  40939. * @param target defines the object containing the value to interpolate
  40940. * @param propertyPath defines the path to the property in the target object
  40941. * @param value defines the target value at the end of the interpolation
  40942. * @param duration deines the time it will take for the property to interpolate to the value.
  40943. * @param condition defines the trigger related conditions
  40944. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40945. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40946. */
  40947. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40948. /** @hidden */
  40949. _prepare(): void;
  40950. /**
  40951. * Execute the action starts the value interpolation.
  40952. */
  40953. execute(): void;
  40954. /**
  40955. * Serializes the actions and its related information.
  40956. * @param parent defines the object to serialize in
  40957. * @returns the serialized object
  40958. */
  40959. serialize(parent: any): any;
  40960. }
  40961. }
  40962. declare module BABYLON {
  40963. /**
  40964. * Options allowed during the creation of a sound track.
  40965. */
  40966. export interface ISoundTrackOptions {
  40967. /**
  40968. * The volume the sound track should take during creation
  40969. */
  40970. volume?: number;
  40971. /**
  40972. * Define if the sound track is the main sound track of the scene
  40973. */
  40974. mainTrack?: boolean;
  40975. }
  40976. /**
  40977. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40978. * It will be also used in a future release to apply effects on a specific track.
  40979. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40980. */
  40981. export class SoundTrack {
  40982. /**
  40983. * The unique identifier of the sound track in the scene.
  40984. */
  40985. id: number;
  40986. /**
  40987. * The list of sounds included in the sound track.
  40988. */
  40989. soundCollection: Array<Sound>;
  40990. private _outputAudioNode;
  40991. private _scene;
  40992. private _connectedAnalyser;
  40993. private _options;
  40994. private _isInitialized;
  40995. /**
  40996. * Creates a new sound track.
  40997. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40998. * @param scene Define the scene the sound track belongs to
  40999. * @param options
  41000. */
  41001. constructor(scene: Scene, options?: ISoundTrackOptions);
  41002. private _initializeSoundTrackAudioGraph;
  41003. /**
  41004. * Release the sound track and its associated resources
  41005. */
  41006. dispose(): void;
  41007. /**
  41008. * Adds a sound to this sound track
  41009. * @param sound define the cound to add
  41010. * @ignoreNaming
  41011. */
  41012. AddSound(sound: Sound): void;
  41013. /**
  41014. * Removes a sound to this sound track
  41015. * @param sound define the cound to remove
  41016. * @ignoreNaming
  41017. */
  41018. RemoveSound(sound: Sound): void;
  41019. /**
  41020. * Set a global volume for the full sound track.
  41021. * @param newVolume Define the new volume of the sound track
  41022. */
  41023. setVolume(newVolume: number): void;
  41024. /**
  41025. * Switch the panning model to HRTF:
  41026. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41028. */
  41029. switchPanningModelToHRTF(): void;
  41030. /**
  41031. * Switch the panning model to Equal Power:
  41032. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41033. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41034. */
  41035. switchPanningModelToEqualPower(): void;
  41036. /**
  41037. * Connect the sound track to an audio analyser allowing some amazing
  41038. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41040. * @param analyser The analyser to connect to the engine
  41041. */
  41042. connectToAnalyser(analyser: Analyser): void;
  41043. }
  41044. }
  41045. declare module BABYLON {
  41046. interface AbstractScene {
  41047. /**
  41048. * The list of sounds used in the scene.
  41049. */
  41050. sounds: Nullable<Array<Sound>>;
  41051. }
  41052. interface Scene {
  41053. /**
  41054. * @hidden
  41055. * Backing field
  41056. */
  41057. _mainSoundTrack: SoundTrack;
  41058. /**
  41059. * The main sound track played by the scene.
  41060. * It cotains your primary collection of sounds.
  41061. */
  41062. mainSoundTrack: SoundTrack;
  41063. /**
  41064. * The list of sound tracks added to the scene
  41065. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41066. */
  41067. soundTracks: Nullable<Array<SoundTrack>>;
  41068. /**
  41069. * Gets a sound using a given name
  41070. * @param name defines the name to search for
  41071. * @return the found sound or null if not found at all.
  41072. */
  41073. getSoundByName(name: string): Nullable<Sound>;
  41074. /**
  41075. * Gets or sets if audio support is enabled
  41076. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41077. */
  41078. audioEnabled: boolean;
  41079. /**
  41080. * Gets or sets if audio will be output to headphones
  41081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41082. */
  41083. headphone: boolean;
  41084. /**
  41085. * Gets or sets custom audio listener position provider
  41086. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41087. */
  41088. audioListenerPositionProvider: Nullable<() => Vector3>;
  41089. /**
  41090. * Gets or sets a refresh rate when using 3D audio positioning
  41091. */
  41092. audioPositioningRefreshRate: number;
  41093. }
  41094. /**
  41095. * Defines the sound scene component responsible to manage any sounds
  41096. * in a given scene.
  41097. */
  41098. export class AudioSceneComponent implements ISceneSerializableComponent {
  41099. /**
  41100. * The component name helpfull to identify the component in the list of scene components.
  41101. */
  41102. readonly name: string;
  41103. /**
  41104. * The scene the component belongs to.
  41105. */
  41106. scene: Scene;
  41107. private _audioEnabled;
  41108. /**
  41109. * Gets whether audio is enabled or not.
  41110. * Please use related enable/disable method to switch state.
  41111. */
  41112. get audioEnabled(): boolean;
  41113. private _headphone;
  41114. /**
  41115. * Gets whether audio is outputing to headphone or not.
  41116. * Please use the according Switch methods to change output.
  41117. */
  41118. get headphone(): boolean;
  41119. /**
  41120. * Gets or sets a refresh rate when using 3D audio positioning
  41121. */
  41122. audioPositioningRefreshRate: number;
  41123. private _audioListenerPositionProvider;
  41124. /**
  41125. * Gets the current audio listener position provider
  41126. */
  41127. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41128. /**
  41129. * Sets a custom listener position for all sounds in the scene
  41130. * By default, this is the position of the first active camera
  41131. */
  41132. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41133. /**
  41134. * Creates a new instance of the component for the given scene
  41135. * @param scene Defines the scene to register the component in
  41136. */
  41137. constructor(scene: Scene);
  41138. /**
  41139. * Registers the component in a given scene
  41140. */
  41141. register(): void;
  41142. /**
  41143. * Rebuilds the elements related to this component in case of
  41144. * context lost for instance.
  41145. */
  41146. rebuild(): void;
  41147. /**
  41148. * Serializes the component data to the specified json object
  41149. * @param serializationObject The object to serialize to
  41150. */
  41151. serialize(serializationObject: any): void;
  41152. /**
  41153. * Adds all the elements from the container to the scene
  41154. * @param container the container holding the elements
  41155. */
  41156. addFromContainer(container: AbstractScene): void;
  41157. /**
  41158. * Removes all the elements in the container from the scene
  41159. * @param container contains the elements to remove
  41160. * @param dispose if the removed element should be disposed (default: false)
  41161. */
  41162. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41163. /**
  41164. * Disposes the component and the associated ressources.
  41165. */
  41166. dispose(): void;
  41167. /**
  41168. * Disables audio in the associated scene.
  41169. */
  41170. disableAudio(): void;
  41171. /**
  41172. * Enables audio in the associated scene.
  41173. */
  41174. enableAudio(): void;
  41175. /**
  41176. * Switch audio to headphone output.
  41177. */
  41178. switchAudioModeForHeadphones(): void;
  41179. /**
  41180. * Switch audio to normal speakers.
  41181. */
  41182. switchAudioModeForNormalSpeakers(): void;
  41183. private _cachedCameraDirection;
  41184. private _cachedCameraPosition;
  41185. private _lastCheck;
  41186. private _afterRender;
  41187. }
  41188. }
  41189. declare module BABYLON {
  41190. /**
  41191. * Wraps one or more Sound objects and selects one with random weight for playback.
  41192. */
  41193. export class WeightedSound {
  41194. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41195. loop: boolean;
  41196. private _coneInnerAngle;
  41197. private _coneOuterAngle;
  41198. private _volume;
  41199. /** A Sound is currently playing. */
  41200. isPlaying: boolean;
  41201. /** A Sound is currently paused. */
  41202. isPaused: boolean;
  41203. private _sounds;
  41204. private _weights;
  41205. private _currentIndex?;
  41206. /**
  41207. * Creates a new WeightedSound from the list of sounds given.
  41208. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41209. * @param sounds Array of Sounds that will be selected from.
  41210. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41211. */
  41212. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41213. /**
  41214. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41215. */
  41216. get directionalConeInnerAngle(): number;
  41217. /**
  41218. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41219. */
  41220. set directionalConeInnerAngle(value: number);
  41221. /**
  41222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41224. */
  41225. get directionalConeOuterAngle(): number;
  41226. /**
  41227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41229. */
  41230. set directionalConeOuterAngle(value: number);
  41231. /**
  41232. * Playback volume.
  41233. */
  41234. get volume(): number;
  41235. /**
  41236. * Playback volume.
  41237. */
  41238. set volume(value: number);
  41239. private _onended;
  41240. /**
  41241. * Suspend playback
  41242. */
  41243. pause(): void;
  41244. /**
  41245. * Stop playback
  41246. */
  41247. stop(): void;
  41248. /**
  41249. * Start playback.
  41250. * @param startOffset Position the clip head at a specific time in seconds.
  41251. */
  41252. play(startOffset?: number): void;
  41253. }
  41254. }
  41255. declare module BABYLON {
  41256. /**
  41257. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41258. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41259. */
  41260. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41261. /**
  41262. * Gets the name of the behavior.
  41263. */
  41264. get name(): string;
  41265. /**
  41266. * The easing function used by animations
  41267. */
  41268. static EasingFunction: BackEase;
  41269. /**
  41270. * The easing mode used by animations
  41271. */
  41272. static EasingMode: number;
  41273. /**
  41274. * The duration of the animation, in milliseconds
  41275. */
  41276. transitionDuration: number;
  41277. /**
  41278. * Length of the distance animated by the transition when lower radius is reached
  41279. */
  41280. lowerRadiusTransitionRange: number;
  41281. /**
  41282. * Length of the distance animated by the transition when upper radius is reached
  41283. */
  41284. upperRadiusTransitionRange: number;
  41285. private _autoTransitionRange;
  41286. /**
  41287. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41288. */
  41289. get autoTransitionRange(): boolean;
  41290. /**
  41291. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41292. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41293. */
  41294. set autoTransitionRange(value: boolean);
  41295. private _attachedCamera;
  41296. private _onAfterCheckInputsObserver;
  41297. private _onMeshTargetChangedObserver;
  41298. /**
  41299. * Initializes the behavior.
  41300. */
  41301. init(): void;
  41302. /**
  41303. * Attaches the behavior to its arc rotate camera.
  41304. * @param camera Defines the camera to attach the behavior to
  41305. */
  41306. attach(camera: ArcRotateCamera): void;
  41307. /**
  41308. * Detaches the behavior from its current arc rotate camera.
  41309. */
  41310. detach(): void;
  41311. private _radiusIsAnimating;
  41312. private _radiusBounceTransition;
  41313. private _animatables;
  41314. private _cachedWheelPrecision;
  41315. /**
  41316. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41317. * @param radiusLimit The limit to check against.
  41318. * @return Bool to indicate if at limit.
  41319. */
  41320. private _isRadiusAtLimit;
  41321. /**
  41322. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41323. * @param radiusDelta The delta by which to animate to. Can be negative.
  41324. */
  41325. private _applyBoundRadiusAnimation;
  41326. /**
  41327. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41328. */
  41329. protected _clearAnimationLocks(): void;
  41330. /**
  41331. * Stops and removes all animations that have been applied to the camera
  41332. */
  41333. stopAllAnimations(): void;
  41334. }
  41335. }
  41336. declare module BABYLON {
  41337. /**
  41338. * 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.
  41339. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41340. */
  41341. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41342. /**
  41343. * Gets the name of the behavior.
  41344. */
  41345. get name(): string;
  41346. private _mode;
  41347. private _radiusScale;
  41348. private _positionScale;
  41349. private _defaultElevation;
  41350. private _elevationReturnTime;
  41351. private _elevationReturnWaitTime;
  41352. private _zoomStopsAnimation;
  41353. private _framingTime;
  41354. /**
  41355. * The easing function used by animations
  41356. */
  41357. static EasingFunction: ExponentialEase;
  41358. /**
  41359. * The easing mode used by animations
  41360. */
  41361. static EasingMode: number;
  41362. /**
  41363. * Sets the current mode used by the behavior
  41364. */
  41365. set mode(mode: number);
  41366. /**
  41367. * Gets current mode used by the behavior.
  41368. */
  41369. get mode(): number;
  41370. /**
  41371. * Sets the scale applied to the radius (1 by default)
  41372. */
  41373. set radiusScale(radius: number);
  41374. /**
  41375. * Gets the scale applied to the radius
  41376. */
  41377. get radiusScale(): number;
  41378. /**
  41379. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41380. */
  41381. set positionScale(scale: number);
  41382. /**
  41383. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41384. */
  41385. get positionScale(): number;
  41386. /**
  41387. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41388. * behaviour is triggered, in radians.
  41389. */
  41390. set defaultElevation(elevation: number);
  41391. /**
  41392. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41393. * behaviour is triggered, in radians.
  41394. */
  41395. get defaultElevation(): number;
  41396. /**
  41397. * Sets the time (in milliseconds) taken to return to the default beta position.
  41398. * Negative value indicates camera should not return to default.
  41399. */
  41400. set elevationReturnTime(speed: number);
  41401. /**
  41402. * Gets the time (in milliseconds) taken to return to the default beta position.
  41403. * Negative value indicates camera should not return to default.
  41404. */
  41405. get elevationReturnTime(): number;
  41406. /**
  41407. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41408. */
  41409. set elevationReturnWaitTime(time: number);
  41410. /**
  41411. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41412. */
  41413. get elevationReturnWaitTime(): number;
  41414. /**
  41415. * Sets the flag that indicates if user zooming should stop animation.
  41416. */
  41417. set zoomStopsAnimation(flag: boolean);
  41418. /**
  41419. * Gets the flag that indicates if user zooming should stop animation.
  41420. */
  41421. get zoomStopsAnimation(): boolean;
  41422. /**
  41423. * Sets the transition time when framing the mesh, in milliseconds
  41424. */
  41425. set framingTime(time: number);
  41426. /**
  41427. * Gets the transition time when framing the mesh, in milliseconds
  41428. */
  41429. get framingTime(): number;
  41430. /**
  41431. * Define if the behavior should automatically change the configured
  41432. * camera limits and sensibilities.
  41433. */
  41434. autoCorrectCameraLimitsAndSensibility: boolean;
  41435. private _onPrePointerObservableObserver;
  41436. private _onAfterCheckInputsObserver;
  41437. private _onMeshTargetChangedObserver;
  41438. private _attachedCamera;
  41439. private _isPointerDown;
  41440. private _lastInteractionTime;
  41441. /**
  41442. * Initializes the behavior.
  41443. */
  41444. init(): void;
  41445. /**
  41446. * Attaches the behavior to its arc rotate camera.
  41447. * @param camera Defines the camera to attach the behavior to
  41448. */
  41449. attach(camera: ArcRotateCamera): void;
  41450. /**
  41451. * Detaches the behavior from its current arc rotate camera.
  41452. */
  41453. detach(): void;
  41454. private _animatables;
  41455. private _betaIsAnimating;
  41456. private _betaTransition;
  41457. private _radiusTransition;
  41458. private _vectorTransition;
  41459. /**
  41460. * Targets the given mesh and updates zoom level accordingly.
  41461. * @param mesh The mesh to target.
  41462. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41463. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41464. */
  41465. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41466. /**
  41467. * Targets the given mesh with its children and updates zoom level accordingly.
  41468. * @param mesh The mesh to target.
  41469. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41470. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41471. */
  41472. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41473. /**
  41474. * Targets the given meshes with their children and updates zoom level accordingly.
  41475. * @param meshes The mesh to target.
  41476. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41477. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41478. */
  41479. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41480. /**
  41481. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41482. * @param minimumWorld Determines the smaller position of the bounding box extend
  41483. * @param maximumWorld Determines the bigger position of the bounding box extend
  41484. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41485. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41486. */
  41487. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41488. /**
  41489. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41490. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41491. * frustum width.
  41492. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41493. * to fully enclose the mesh in the viewing frustum.
  41494. */
  41495. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41496. /**
  41497. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41498. * is automatically returned to its default position (expected to be above ground plane).
  41499. */
  41500. private _maintainCameraAboveGround;
  41501. /**
  41502. * Returns the frustum slope based on the canvas ratio and camera FOV
  41503. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41504. */
  41505. private _getFrustumSlope;
  41506. /**
  41507. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41508. */
  41509. private _clearAnimationLocks;
  41510. /**
  41511. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41512. */
  41513. private _applyUserInteraction;
  41514. /**
  41515. * Stops and removes all animations that have been applied to the camera
  41516. */
  41517. stopAllAnimations(): void;
  41518. /**
  41519. * Gets a value indicating if the user is moving the camera
  41520. */
  41521. get isUserIsMoving(): boolean;
  41522. /**
  41523. * The camera can move all the way towards the mesh.
  41524. */
  41525. static IgnoreBoundsSizeMode: number;
  41526. /**
  41527. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41528. */
  41529. static FitFrustumSidesMode: number;
  41530. }
  41531. }
  41532. declare module BABYLON {
  41533. /**
  41534. * Base class for Camera Pointer Inputs.
  41535. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41536. * for example usage.
  41537. */
  41538. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41539. /**
  41540. * Defines the camera the input is attached to.
  41541. */
  41542. abstract camera: Camera;
  41543. /**
  41544. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41545. */
  41546. protected _altKey: boolean;
  41547. protected _ctrlKey: boolean;
  41548. protected _metaKey: boolean;
  41549. protected _shiftKey: boolean;
  41550. /**
  41551. * Which mouse buttons were pressed at time of last mouse event.
  41552. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41553. */
  41554. protected _buttonsPressed: number;
  41555. /**
  41556. * Defines the buttons associated with the input to handle camera move.
  41557. */
  41558. buttons: number[];
  41559. /**
  41560. * Attach the input controls to a specific dom element to get the input from.
  41561. * @param element Defines the element the controls should be listened from
  41562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41563. */
  41564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41565. /**
  41566. * Detach the current controls from the specified dom element.
  41567. * @param element Defines the element to stop listening the inputs from
  41568. */
  41569. detachControl(element: Nullable<HTMLElement>): void;
  41570. /**
  41571. * Gets the class name of the current input.
  41572. * @returns the class name
  41573. */
  41574. getClassName(): string;
  41575. /**
  41576. * Get the friendly name associated with the input class.
  41577. * @returns the input friendly name
  41578. */
  41579. getSimpleName(): string;
  41580. /**
  41581. * Called on pointer POINTERDOUBLETAP event.
  41582. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41583. */
  41584. protected onDoubleTap(type: string): void;
  41585. /**
  41586. * Called on pointer POINTERMOVE event if only a single touch is active.
  41587. * Override this method to provide functionality.
  41588. */
  41589. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41590. /**
  41591. * Called on pointer POINTERMOVE event if multiple touches are active.
  41592. * Override this method to provide functionality.
  41593. */
  41594. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41595. /**
  41596. * Called on JS contextmenu event.
  41597. * Override this method to provide functionality.
  41598. */
  41599. protected onContextMenu(evt: PointerEvent): void;
  41600. /**
  41601. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41602. * press.
  41603. * Override this method to provide functionality.
  41604. */
  41605. protected onButtonDown(evt: PointerEvent): void;
  41606. /**
  41607. * Called each time a new POINTERUP event occurs. Ie, for each button
  41608. * release.
  41609. * Override this method to provide functionality.
  41610. */
  41611. protected onButtonUp(evt: PointerEvent): void;
  41612. /**
  41613. * Called when window becomes inactive.
  41614. * Override this method to provide functionality.
  41615. */
  41616. protected onLostFocus(): void;
  41617. private _pointerInput;
  41618. private _observer;
  41619. private _onLostFocus;
  41620. private pointA;
  41621. private pointB;
  41622. }
  41623. }
  41624. declare module BABYLON {
  41625. /**
  41626. * Manage the pointers inputs to control an arc rotate camera.
  41627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41628. */
  41629. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41630. /**
  41631. * Defines the camera the input is attached to.
  41632. */
  41633. camera: ArcRotateCamera;
  41634. /**
  41635. * Gets the class name of the current input.
  41636. * @returns the class name
  41637. */
  41638. getClassName(): string;
  41639. /**
  41640. * Defines the buttons associated with the input to handle camera move.
  41641. */
  41642. buttons: number[];
  41643. /**
  41644. * Defines the pointer angular sensibility along the X axis or how fast is
  41645. * the camera rotating.
  41646. */
  41647. angularSensibilityX: number;
  41648. /**
  41649. * Defines the pointer angular sensibility along the Y axis or how fast is
  41650. * the camera rotating.
  41651. */
  41652. angularSensibilityY: number;
  41653. /**
  41654. * Defines the pointer pinch precision or how fast is the camera zooming.
  41655. */
  41656. pinchPrecision: number;
  41657. /**
  41658. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41659. * from 0.
  41660. * It defines the percentage of current camera.radius to use as delta when
  41661. * pinch zoom is used.
  41662. */
  41663. pinchDeltaPercentage: number;
  41664. /**
  41665. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41666. * that any object in the plane at the camera's target point will scale
  41667. * perfectly with finger motion.
  41668. * Overrides pinchDeltaPercentage and pinchPrecision.
  41669. */
  41670. useNaturalPinchZoom: boolean;
  41671. /**
  41672. * Defines the pointer panning sensibility or how fast is the camera moving.
  41673. */
  41674. panningSensibility: number;
  41675. /**
  41676. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41677. */
  41678. multiTouchPanning: boolean;
  41679. /**
  41680. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41681. * zoom (pinch) through multitouch.
  41682. */
  41683. multiTouchPanAndZoom: boolean;
  41684. /**
  41685. * Revers pinch action direction.
  41686. */
  41687. pinchInwards: boolean;
  41688. private _isPanClick;
  41689. private _twoFingerActivityCount;
  41690. private _isPinching;
  41691. /**
  41692. * Called on pointer POINTERMOVE event if only a single touch is active.
  41693. */
  41694. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41695. /**
  41696. * Called on pointer POINTERDOUBLETAP event.
  41697. */
  41698. protected onDoubleTap(type: string): void;
  41699. /**
  41700. * Called on pointer POINTERMOVE event if multiple touches are active.
  41701. */
  41702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41703. /**
  41704. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41705. * press.
  41706. */
  41707. protected onButtonDown(evt: PointerEvent): void;
  41708. /**
  41709. * Called each time a new POINTERUP event occurs. Ie, for each button
  41710. * release.
  41711. */
  41712. protected onButtonUp(evt: PointerEvent): void;
  41713. /**
  41714. * Called when window becomes inactive.
  41715. */
  41716. protected onLostFocus(): void;
  41717. }
  41718. }
  41719. declare module BABYLON {
  41720. /**
  41721. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41722. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41723. */
  41724. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41725. /**
  41726. * Defines the camera the input is attached to.
  41727. */
  41728. camera: ArcRotateCamera;
  41729. /**
  41730. * Defines the list of key codes associated with the up action (increase alpha)
  41731. */
  41732. keysUp: number[];
  41733. /**
  41734. * Defines the list of key codes associated with the down action (decrease alpha)
  41735. */
  41736. keysDown: number[];
  41737. /**
  41738. * Defines the list of key codes associated with the left action (increase beta)
  41739. */
  41740. keysLeft: number[];
  41741. /**
  41742. * Defines the list of key codes associated with the right action (decrease beta)
  41743. */
  41744. keysRight: number[];
  41745. /**
  41746. * Defines the list of key codes associated with the reset action.
  41747. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41748. */
  41749. keysReset: number[];
  41750. /**
  41751. * Defines the panning sensibility of the inputs.
  41752. * (How fast is the camera panning)
  41753. */
  41754. panningSensibility: number;
  41755. /**
  41756. * Defines the zooming sensibility of the inputs.
  41757. * (How fast is the camera zooming)
  41758. */
  41759. zoomingSensibility: number;
  41760. /**
  41761. * Defines whether maintaining the alt key down switch the movement mode from
  41762. * orientation to zoom.
  41763. */
  41764. useAltToZoom: boolean;
  41765. /**
  41766. * Rotation speed of the camera
  41767. */
  41768. angularSpeed: number;
  41769. private _keys;
  41770. private _ctrlPressed;
  41771. private _altPressed;
  41772. private _onCanvasBlurObserver;
  41773. private _onKeyboardObserver;
  41774. private _engine;
  41775. private _scene;
  41776. /**
  41777. * Attach the input controls to a specific dom element to get the input from.
  41778. * @param element Defines the element the controls should be listened from
  41779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41780. */
  41781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41782. /**
  41783. * Detach the current controls from the specified dom element.
  41784. * @param element Defines the element to stop listening the inputs from
  41785. */
  41786. detachControl(element: Nullable<HTMLElement>): void;
  41787. /**
  41788. * Update the current camera state depending on the inputs that have been used this frame.
  41789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41790. */
  41791. checkInputs(): void;
  41792. /**
  41793. * Gets the class name of the current intput.
  41794. * @returns the class name
  41795. */
  41796. getClassName(): string;
  41797. /**
  41798. * Get the friendly name associated with the input class.
  41799. * @returns the input friendly name
  41800. */
  41801. getSimpleName(): string;
  41802. }
  41803. }
  41804. declare module BABYLON {
  41805. /**
  41806. * Manage the mouse wheel inputs to control an arc rotate camera.
  41807. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41808. */
  41809. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41810. /**
  41811. * Defines the camera the input is attached to.
  41812. */
  41813. camera: ArcRotateCamera;
  41814. /**
  41815. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41816. */
  41817. wheelPrecision: number;
  41818. /**
  41819. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41820. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41821. */
  41822. wheelDeltaPercentage: number;
  41823. private _wheel;
  41824. private _observer;
  41825. private computeDeltaFromMouseWheelLegacyEvent;
  41826. /**
  41827. * Attach the input controls to a specific dom element to get the input from.
  41828. * @param element Defines the element the controls should be listened from
  41829. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41830. */
  41831. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41832. /**
  41833. * Detach the current controls from the specified dom element.
  41834. * @param element Defines the element to stop listening the inputs from
  41835. */
  41836. detachControl(element: Nullable<HTMLElement>): void;
  41837. /**
  41838. * Gets the class name of the current intput.
  41839. * @returns the class name
  41840. */
  41841. getClassName(): string;
  41842. /**
  41843. * Get the friendly name associated with the input class.
  41844. * @returns the input friendly name
  41845. */
  41846. getSimpleName(): string;
  41847. }
  41848. }
  41849. declare module BABYLON {
  41850. /**
  41851. * Default Inputs manager for the ArcRotateCamera.
  41852. * It groups all the default supported inputs for ease of use.
  41853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41854. */
  41855. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41856. /**
  41857. * Instantiates a new ArcRotateCameraInputsManager.
  41858. * @param camera Defines the camera the inputs belong to
  41859. */
  41860. constructor(camera: ArcRotateCamera);
  41861. /**
  41862. * Add mouse wheel input support to the input manager.
  41863. * @returns the current input manager
  41864. */
  41865. addMouseWheel(): ArcRotateCameraInputsManager;
  41866. /**
  41867. * Add pointers input support to the input manager.
  41868. * @returns the current input manager
  41869. */
  41870. addPointers(): ArcRotateCameraInputsManager;
  41871. /**
  41872. * Add keyboard input support to the input manager.
  41873. * @returns the current input manager
  41874. */
  41875. addKeyboard(): ArcRotateCameraInputsManager;
  41876. }
  41877. }
  41878. declare module BABYLON {
  41879. /**
  41880. * This represents an orbital type of camera.
  41881. *
  41882. * 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.
  41883. * 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.
  41884. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41885. */
  41886. export class ArcRotateCamera extends TargetCamera {
  41887. /**
  41888. * Defines the rotation angle of the camera along the longitudinal axis.
  41889. */
  41890. alpha: number;
  41891. /**
  41892. * Defines the rotation angle of the camera along the latitudinal axis.
  41893. */
  41894. beta: number;
  41895. /**
  41896. * Defines the radius of the camera from it s target point.
  41897. */
  41898. radius: number;
  41899. protected _target: Vector3;
  41900. protected _targetHost: Nullable<AbstractMesh>;
  41901. /**
  41902. * Defines the target point of the camera.
  41903. * The camera looks towards it form the radius distance.
  41904. */
  41905. get target(): Vector3;
  41906. set target(value: Vector3);
  41907. /**
  41908. * Define the current local position of the camera in the scene
  41909. */
  41910. get position(): Vector3;
  41911. set position(newPosition: Vector3);
  41912. protected _upVector: Vector3;
  41913. protected _upToYMatrix: Matrix;
  41914. protected _YToUpMatrix: Matrix;
  41915. /**
  41916. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41917. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41918. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41919. */
  41920. set upVector(vec: Vector3);
  41921. get upVector(): Vector3;
  41922. /**
  41923. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41924. */
  41925. setMatUp(): void;
  41926. /**
  41927. * Current inertia value on the longitudinal axis.
  41928. * The bigger this number the longer it will take for the camera to stop.
  41929. */
  41930. inertialAlphaOffset: number;
  41931. /**
  41932. * Current inertia value on the latitudinal axis.
  41933. * The bigger this number the longer it will take for the camera to stop.
  41934. */
  41935. inertialBetaOffset: number;
  41936. /**
  41937. * Current inertia value on the radius axis.
  41938. * The bigger this number the longer it will take for the camera to stop.
  41939. */
  41940. inertialRadiusOffset: number;
  41941. /**
  41942. * Minimum allowed angle on the longitudinal axis.
  41943. * This can help limiting how the Camera is able to move in the scene.
  41944. */
  41945. lowerAlphaLimit: Nullable<number>;
  41946. /**
  41947. * Maximum allowed angle on the longitudinal axis.
  41948. * This can help limiting how the Camera is able to move in the scene.
  41949. */
  41950. upperAlphaLimit: Nullable<number>;
  41951. /**
  41952. * Minimum allowed angle on the latitudinal axis.
  41953. * This can help limiting how the Camera is able to move in the scene.
  41954. */
  41955. lowerBetaLimit: number;
  41956. /**
  41957. * Maximum allowed angle on the latitudinal axis.
  41958. * This can help limiting how the Camera is able to move in the scene.
  41959. */
  41960. upperBetaLimit: number;
  41961. /**
  41962. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41963. * This can help limiting how the Camera is able to move in the scene.
  41964. */
  41965. lowerRadiusLimit: Nullable<number>;
  41966. /**
  41967. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41968. * This can help limiting how the Camera is able to move in the scene.
  41969. */
  41970. upperRadiusLimit: Nullable<number>;
  41971. /**
  41972. * Defines the current inertia value used during panning of the camera along the X axis.
  41973. */
  41974. inertialPanningX: number;
  41975. /**
  41976. * Defines the current inertia value used during panning of the camera along the Y axis.
  41977. */
  41978. inertialPanningY: number;
  41979. /**
  41980. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41981. * Basically if your fingers moves away from more than this distance you will be considered
  41982. * in pinch mode.
  41983. */
  41984. pinchToPanMaxDistance: number;
  41985. /**
  41986. * Defines the maximum distance the camera can pan.
  41987. * This could help keeping the cammera always in your scene.
  41988. */
  41989. panningDistanceLimit: Nullable<number>;
  41990. /**
  41991. * Defines the target of the camera before paning.
  41992. */
  41993. panningOriginTarget: Vector3;
  41994. /**
  41995. * Defines the value of the inertia used during panning.
  41996. * 0 would mean stop inertia and one would mean no decelleration at all.
  41997. */
  41998. panningInertia: number;
  41999. /**
  42000. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42001. */
  42002. get angularSensibilityX(): number;
  42003. set angularSensibilityX(value: number);
  42004. /**
  42005. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42006. */
  42007. get angularSensibilityY(): number;
  42008. set angularSensibilityY(value: number);
  42009. /**
  42010. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42011. */
  42012. get pinchPrecision(): number;
  42013. set pinchPrecision(value: number);
  42014. /**
  42015. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42016. * It will be used instead of pinchDeltaPrecision if different from 0.
  42017. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42018. */
  42019. get pinchDeltaPercentage(): number;
  42020. set pinchDeltaPercentage(value: number);
  42021. /**
  42022. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42023. * and pinch delta percentage.
  42024. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42025. * that any object in the plane at the camera's target point will scale
  42026. * perfectly with finger motion.
  42027. */
  42028. get useNaturalPinchZoom(): boolean;
  42029. set useNaturalPinchZoom(value: boolean);
  42030. /**
  42031. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42032. */
  42033. get panningSensibility(): number;
  42034. set panningSensibility(value: number);
  42035. /**
  42036. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42037. */
  42038. get keysUp(): number[];
  42039. set keysUp(value: number[]);
  42040. /**
  42041. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42042. */
  42043. get keysDown(): number[];
  42044. set keysDown(value: number[]);
  42045. /**
  42046. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42047. */
  42048. get keysLeft(): number[];
  42049. set keysLeft(value: number[]);
  42050. /**
  42051. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42052. */
  42053. get keysRight(): number[];
  42054. set keysRight(value: number[]);
  42055. /**
  42056. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42057. */
  42058. get wheelPrecision(): number;
  42059. set wheelPrecision(value: number);
  42060. /**
  42061. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42062. * It will be used instead of pinchDeltaPrecision if different from 0.
  42063. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42064. */
  42065. get wheelDeltaPercentage(): number;
  42066. set wheelDeltaPercentage(value: number);
  42067. /**
  42068. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42069. */
  42070. zoomOnFactor: number;
  42071. /**
  42072. * Defines a screen offset for the camera position.
  42073. */
  42074. targetScreenOffset: Vector2;
  42075. /**
  42076. * Allows the camera to be completely reversed.
  42077. * If false the camera can not arrive upside down.
  42078. */
  42079. allowUpsideDown: boolean;
  42080. /**
  42081. * Define if double tap/click is used to restore the previously saved state of the camera.
  42082. */
  42083. useInputToRestoreState: boolean;
  42084. /** @hidden */
  42085. _viewMatrix: Matrix;
  42086. /** @hidden */
  42087. _useCtrlForPanning: boolean;
  42088. /** @hidden */
  42089. _panningMouseButton: number;
  42090. /**
  42091. * Defines the input associated to the camera.
  42092. */
  42093. inputs: ArcRotateCameraInputsManager;
  42094. /** @hidden */
  42095. _reset: () => void;
  42096. /**
  42097. * Defines the allowed panning axis.
  42098. */
  42099. panningAxis: Vector3;
  42100. protected _localDirection: Vector3;
  42101. protected _transformedDirection: Vector3;
  42102. private _bouncingBehavior;
  42103. /**
  42104. * Gets the bouncing behavior of the camera if it has been enabled.
  42105. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42106. */
  42107. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42108. /**
  42109. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42110. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42111. */
  42112. get useBouncingBehavior(): boolean;
  42113. set useBouncingBehavior(value: boolean);
  42114. private _framingBehavior;
  42115. /**
  42116. * Gets the framing behavior of the camera if it has been enabled.
  42117. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42118. */
  42119. get framingBehavior(): Nullable<FramingBehavior>;
  42120. /**
  42121. * Defines if the framing behavior of the camera is enabled on the camera.
  42122. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42123. */
  42124. get useFramingBehavior(): boolean;
  42125. set useFramingBehavior(value: boolean);
  42126. private _autoRotationBehavior;
  42127. /**
  42128. * Gets the auto rotation behavior of the camera if it has been enabled.
  42129. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42130. */
  42131. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42132. /**
  42133. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42134. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42135. */
  42136. get useAutoRotationBehavior(): boolean;
  42137. set useAutoRotationBehavior(value: boolean);
  42138. /**
  42139. * Observable triggered when the mesh target has been changed on the camera.
  42140. */
  42141. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42142. /**
  42143. * Event raised when the camera is colliding with a mesh.
  42144. */
  42145. onCollide: (collidedMesh: AbstractMesh) => void;
  42146. /**
  42147. * Defines whether the camera should check collision with the objects oh the scene.
  42148. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42149. */
  42150. checkCollisions: boolean;
  42151. /**
  42152. * Defines the collision radius of the camera.
  42153. * This simulates a sphere around the camera.
  42154. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42155. */
  42156. collisionRadius: Vector3;
  42157. protected _collider: Collider;
  42158. protected _previousPosition: Vector3;
  42159. protected _collisionVelocity: Vector3;
  42160. protected _newPosition: Vector3;
  42161. protected _previousAlpha: number;
  42162. protected _previousBeta: number;
  42163. protected _previousRadius: number;
  42164. protected _collisionTriggered: boolean;
  42165. protected _targetBoundingCenter: Nullable<Vector3>;
  42166. private _computationVector;
  42167. /**
  42168. * Instantiates a new ArcRotateCamera in a given scene
  42169. * @param name Defines the name of the camera
  42170. * @param alpha Defines the camera rotation along the logitudinal axis
  42171. * @param beta Defines the camera rotation along the latitudinal axis
  42172. * @param radius Defines the camera distance from its target
  42173. * @param target Defines the camera target
  42174. * @param scene Defines the scene the camera belongs to
  42175. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42176. */
  42177. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42178. /** @hidden */
  42179. _initCache(): void;
  42180. /** @hidden */
  42181. _updateCache(ignoreParentClass?: boolean): void;
  42182. protected _getTargetPosition(): Vector3;
  42183. private _storedAlpha;
  42184. private _storedBeta;
  42185. private _storedRadius;
  42186. private _storedTarget;
  42187. private _storedTargetScreenOffset;
  42188. /**
  42189. * Stores the current state of the camera (alpha, beta, radius and target)
  42190. * @returns the camera itself
  42191. */
  42192. storeState(): Camera;
  42193. /**
  42194. * @hidden
  42195. * Restored camera state. You must call storeState() first
  42196. */
  42197. _restoreStateValues(): boolean;
  42198. /** @hidden */
  42199. _isSynchronizedViewMatrix(): boolean;
  42200. /**
  42201. * Attached controls to the current camera.
  42202. * @param element Defines the element the controls should be listened from
  42203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42204. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42205. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42206. */
  42207. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42208. /**
  42209. * Detach the current controls from the camera.
  42210. * The camera will stop reacting to inputs.
  42211. * @param element Defines the element to stop listening the inputs from
  42212. */
  42213. detachControl(element: HTMLElement): void;
  42214. /** @hidden */
  42215. _checkInputs(): void;
  42216. protected _checkLimits(): void;
  42217. /**
  42218. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42219. */
  42220. rebuildAnglesAndRadius(): void;
  42221. /**
  42222. * Use a position to define the current camera related information like alpha, beta and radius
  42223. * @param position Defines the position to set the camera at
  42224. */
  42225. setPosition(position: Vector3): void;
  42226. /**
  42227. * Defines the target the camera should look at.
  42228. * This will automatically adapt alpha beta and radius to fit within the new target.
  42229. * @param target Defines the new target as a Vector or a mesh
  42230. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42231. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42232. */
  42233. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42234. /** @hidden */
  42235. _getViewMatrix(): Matrix;
  42236. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42237. /**
  42238. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42239. * @param meshes Defines the mesh to zoom on
  42240. * @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)
  42241. */
  42242. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42243. /**
  42244. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42245. * The target will be changed but the radius
  42246. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42247. * @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)
  42248. */
  42249. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42250. min: Vector3;
  42251. max: Vector3;
  42252. distance: number;
  42253. }, doNotUpdateMaxZ?: boolean): void;
  42254. /**
  42255. * @override
  42256. * Override Camera.createRigCamera
  42257. */
  42258. createRigCamera(name: string, cameraIndex: number): Camera;
  42259. /**
  42260. * @hidden
  42261. * @override
  42262. * Override Camera._updateRigCameras
  42263. */
  42264. _updateRigCameras(): void;
  42265. /**
  42266. * Destroy the camera and release the current resources hold by it.
  42267. */
  42268. dispose(): void;
  42269. /**
  42270. * Gets the current object class name.
  42271. * @return the class name
  42272. */
  42273. getClassName(): string;
  42274. }
  42275. }
  42276. declare module BABYLON {
  42277. /**
  42278. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42279. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42280. */
  42281. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42282. /**
  42283. * Gets the name of the behavior.
  42284. */
  42285. get name(): string;
  42286. private _zoomStopsAnimation;
  42287. private _idleRotationSpeed;
  42288. private _idleRotationWaitTime;
  42289. private _idleRotationSpinupTime;
  42290. /**
  42291. * Sets the flag that indicates if user zooming should stop animation.
  42292. */
  42293. set zoomStopsAnimation(flag: boolean);
  42294. /**
  42295. * Gets the flag that indicates if user zooming should stop animation.
  42296. */
  42297. get zoomStopsAnimation(): boolean;
  42298. /**
  42299. * Sets the default speed at which the camera rotates around the model.
  42300. */
  42301. set idleRotationSpeed(speed: number);
  42302. /**
  42303. * Gets the default speed at which the camera rotates around the model.
  42304. */
  42305. get idleRotationSpeed(): number;
  42306. /**
  42307. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42308. */
  42309. set idleRotationWaitTime(time: number);
  42310. /**
  42311. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42312. */
  42313. get idleRotationWaitTime(): number;
  42314. /**
  42315. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42316. */
  42317. set idleRotationSpinupTime(time: number);
  42318. /**
  42319. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42320. */
  42321. get idleRotationSpinupTime(): number;
  42322. /**
  42323. * Gets a value indicating if the camera is currently rotating because of this behavior
  42324. */
  42325. get rotationInProgress(): boolean;
  42326. private _onPrePointerObservableObserver;
  42327. private _onAfterCheckInputsObserver;
  42328. private _attachedCamera;
  42329. private _isPointerDown;
  42330. private _lastFrameTime;
  42331. private _lastInteractionTime;
  42332. private _cameraRotationSpeed;
  42333. /**
  42334. * Initializes the behavior.
  42335. */
  42336. init(): void;
  42337. /**
  42338. * Attaches the behavior to its arc rotate camera.
  42339. * @param camera Defines the camera to attach the behavior to
  42340. */
  42341. attach(camera: ArcRotateCamera): void;
  42342. /**
  42343. * Detaches the behavior from its current arc rotate camera.
  42344. */
  42345. detach(): void;
  42346. /**
  42347. * Returns true if user is scrolling.
  42348. * @return true if user is scrolling.
  42349. */
  42350. private _userIsZooming;
  42351. private _lastFrameRadius;
  42352. private _shouldAnimationStopForInteraction;
  42353. /**
  42354. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42355. */
  42356. private _applyUserInteraction;
  42357. private _userIsMoving;
  42358. }
  42359. }
  42360. declare module BABYLON {
  42361. /**
  42362. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42363. */
  42364. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42365. private ui;
  42366. /**
  42367. * The name of the behavior
  42368. */
  42369. name: string;
  42370. /**
  42371. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42372. */
  42373. distanceAwayFromFace: number;
  42374. /**
  42375. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42376. */
  42377. distanceAwayFromBottomOfFace: number;
  42378. private _faceVectors;
  42379. private _target;
  42380. private _scene;
  42381. private _onRenderObserver;
  42382. private _tmpMatrix;
  42383. private _tmpVector;
  42384. /**
  42385. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42386. * @param ui The transform node that should be attched to the mesh
  42387. */
  42388. constructor(ui: TransformNode);
  42389. /**
  42390. * Initializes the behavior
  42391. */
  42392. init(): void;
  42393. private _closestFace;
  42394. private _zeroVector;
  42395. private _lookAtTmpMatrix;
  42396. private _lookAtToRef;
  42397. /**
  42398. * Attaches the AttachToBoxBehavior to the passed in mesh
  42399. * @param target The mesh that the specified node will be attached to
  42400. */
  42401. attach(target: Mesh): void;
  42402. /**
  42403. * Detaches the behavior from the mesh
  42404. */
  42405. detach(): void;
  42406. }
  42407. }
  42408. declare module BABYLON {
  42409. /**
  42410. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42411. */
  42412. export class FadeInOutBehavior implements Behavior<Mesh> {
  42413. /**
  42414. * Time in milliseconds to delay before fading in (Default: 0)
  42415. */
  42416. delay: number;
  42417. /**
  42418. * Time in milliseconds for the mesh to fade in (Default: 300)
  42419. */
  42420. fadeInTime: number;
  42421. private _millisecondsPerFrame;
  42422. private _hovered;
  42423. private _hoverValue;
  42424. private _ownerNode;
  42425. /**
  42426. * Instatiates the FadeInOutBehavior
  42427. */
  42428. constructor();
  42429. /**
  42430. * The name of the behavior
  42431. */
  42432. get name(): string;
  42433. /**
  42434. * Initializes the behavior
  42435. */
  42436. init(): void;
  42437. /**
  42438. * Attaches the fade behavior on the passed in mesh
  42439. * @param ownerNode The mesh that will be faded in/out once attached
  42440. */
  42441. attach(ownerNode: Mesh): void;
  42442. /**
  42443. * Detaches the behavior from the mesh
  42444. */
  42445. detach(): void;
  42446. /**
  42447. * Triggers the mesh to begin fading in or out
  42448. * @param value if the object should fade in or out (true to fade in)
  42449. */
  42450. fadeIn(value: boolean): void;
  42451. private _update;
  42452. private _setAllVisibility;
  42453. }
  42454. }
  42455. declare module BABYLON {
  42456. /**
  42457. * Class containing a set of static utilities functions for managing Pivots
  42458. * @hidden
  42459. */
  42460. export class PivotTools {
  42461. private static _PivotCached;
  42462. private static _OldPivotPoint;
  42463. private static _PivotTranslation;
  42464. private static _PivotTmpVector;
  42465. /** @hidden */
  42466. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42467. /** @hidden */
  42468. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /**
  42473. * Class containing static functions to help procedurally build meshes
  42474. */
  42475. export class PlaneBuilder {
  42476. /**
  42477. * Creates a plane mesh
  42478. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42479. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42480. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42482. * * 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
  42483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42484. * @param name defines the name of the mesh
  42485. * @param options defines the options used to create the mesh
  42486. * @param scene defines the hosting scene
  42487. * @returns the plane mesh
  42488. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42489. */
  42490. static CreatePlane(name: string, options: {
  42491. size?: number;
  42492. width?: number;
  42493. height?: number;
  42494. sideOrientation?: number;
  42495. frontUVs?: Vector4;
  42496. backUVs?: Vector4;
  42497. updatable?: boolean;
  42498. sourcePlane?: Plane;
  42499. }, scene?: Nullable<Scene>): Mesh;
  42500. }
  42501. }
  42502. declare module BABYLON {
  42503. /**
  42504. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42505. */
  42506. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42507. private static _AnyMouseID;
  42508. /**
  42509. * Abstract mesh the behavior is set on
  42510. */
  42511. attachedNode: AbstractMesh;
  42512. private _dragPlane;
  42513. private _scene;
  42514. private _pointerObserver;
  42515. private _beforeRenderObserver;
  42516. private static _planeScene;
  42517. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42518. /**
  42519. * 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)
  42520. */
  42521. maxDragAngle: number;
  42522. /**
  42523. * @hidden
  42524. */
  42525. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42526. /**
  42527. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42528. */
  42529. currentDraggingPointerID: number;
  42530. /**
  42531. * The last position where the pointer hit the drag plane in world space
  42532. */
  42533. lastDragPosition: Vector3;
  42534. /**
  42535. * If the behavior is currently in a dragging state
  42536. */
  42537. dragging: boolean;
  42538. /**
  42539. * 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)
  42540. */
  42541. dragDeltaRatio: number;
  42542. /**
  42543. * If the drag plane orientation should be updated during the dragging (Default: true)
  42544. */
  42545. updateDragPlane: boolean;
  42546. private _debugMode;
  42547. private _moving;
  42548. /**
  42549. * Fires each time the attached mesh is dragged with the pointer
  42550. * * delta between last drag position and current drag position in world space
  42551. * * dragDistance along the drag axis
  42552. * * dragPlaneNormal normal of the current drag plane used during the drag
  42553. * * dragPlanePoint in world space where the drag intersects the drag plane
  42554. */
  42555. onDragObservable: Observable<{
  42556. delta: Vector3;
  42557. dragPlanePoint: Vector3;
  42558. dragPlaneNormal: Vector3;
  42559. dragDistance: number;
  42560. pointerId: number;
  42561. }>;
  42562. /**
  42563. * Fires each time a drag begins (eg. mouse down on mesh)
  42564. */
  42565. onDragStartObservable: Observable<{
  42566. dragPlanePoint: Vector3;
  42567. pointerId: number;
  42568. }>;
  42569. /**
  42570. * Fires each time a drag ends (eg. mouse release after drag)
  42571. */
  42572. onDragEndObservable: Observable<{
  42573. dragPlanePoint: Vector3;
  42574. pointerId: number;
  42575. }>;
  42576. /**
  42577. * If the attached mesh should be moved when dragged
  42578. */
  42579. moveAttached: boolean;
  42580. /**
  42581. * If the drag behavior will react to drag events (Default: true)
  42582. */
  42583. enabled: boolean;
  42584. /**
  42585. * If pointer events should start and release the drag (Default: true)
  42586. */
  42587. startAndReleaseDragOnPointerEvents: boolean;
  42588. /**
  42589. * If camera controls should be detached during the drag
  42590. */
  42591. detachCameraControls: boolean;
  42592. /**
  42593. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42594. */
  42595. useObjectOrientationForDragging: boolean;
  42596. private _options;
  42597. /**
  42598. * Gets the options used by the behavior
  42599. */
  42600. get options(): {
  42601. dragAxis?: Vector3;
  42602. dragPlaneNormal?: Vector3;
  42603. };
  42604. /**
  42605. * Sets the options used by the behavior
  42606. */
  42607. set options(options: {
  42608. dragAxis?: Vector3;
  42609. dragPlaneNormal?: Vector3;
  42610. });
  42611. /**
  42612. * Creates a pointer drag behavior that can be attached to a mesh
  42613. * @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)
  42614. */
  42615. constructor(options?: {
  42616. dragAxis?: Vector3;
  42617. dragPlaneNormal?: Vector3;
  42618. });
  42619. /**
  42620. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42621. */
  42622. validateDrag: (targetPosition: Vector3) => boolean;
  42623. /**
  42624. * The name of the behavior
  42625. */
  42626. get name(): string;
  42627. /**
  42628. * Initializes the behavior
  42629. */
  42630. init(): void;
  42631. private _tmpVector;
  42632. private _alternatePickedPoint;
  42633. private _worldDragAxis;
  42634. private _targetPosition;
  42635. private _attachedElement;
  42636. /**
  42637. * Attaches the drag behavior the passed in mesh
  42638. * @param ownerNode The mesh that will be dragged around once attached
  42639. * @param predicate Predicate to use for pick filtering
  42640. */
  42641. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42642. /**
  42643. * Force relase the drag action by code.
  42644. */
  42645. releaseDrag(): void;
  42646. private _startDragRay;
  42647. private _lastPointerRay;
  42648. /**
  42649. * Simulates the start of a pointer drag event on the behavior
  42650. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42651. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42652. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42653. */
  42654. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42655. private _startDrag;
  42656. private _dragDelta;
  42657. private _moveDrag;
  42658. private _pickWithRayOnDragPlane;
  42659. private _pointA;
  42660. private _pointB;
  42661. private _pointC;
  42662. private _lineA;
  42663. private _lineB;
  42664. private _localAxis;
  42665. private _lookAt;
  42666. private _updateDragPlanePosition;
  42667. /**
  42668. * Detaches the behavior from the mesh
  42669. */
  42670. detach(): void;
  42671. }
  42672. }
  42673. declare module BABYLON {
  42674. /**
  42675. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42676. */
  42677. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42678. private _dragBehaviorA;
  42679. private _dragBehaviorB;
  42680. private _startDistance;
  42681. private _initialScale;
  42682. private _targetScale;
  42683. private _ownerNode;
  42684. private _sceneRenderObserver;
  42685. /**
  42686. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42687. */
  42688. constructor();
  42689. /**
  42690. * The name of the behavior
  42691. */
  42692. get name(): string;
  42693. /**
  42694. * Initializes the behavior
  42695. */
  42696. init(): void;
  42697. private _getCurrentDistance;
  42698. /**
  42699. * Attaches the scale behavior the passed in mesh
  42700. * @param ownerNode The mesh that will be scaled around once attached
  42701. */
  42702. attach(ownerNode: Mesh): void;
  42703. /**
  42704. * Detaches the behavior from the mesh
  42705. */
  42706. detach(): void;
  42707. }
  42708. }
  42709. declare module BABYLON {
  42710. /**
  42711. * 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
  42712. */
  42713. export class SixDofDragBehavior implements Behavior<Mesh> {
  42714. private static _virtualScene;
  42715. private _ownerNode;
  42716. private _sceneRenderObserver;
  42717. private _scene;
  42718. private _targetPosition;
  42719. private _virtualOriginMesh;
  42720. private _virtualDragMesh;
  42721. private _pointerObserver;
  42722. private _moving;
  42723. private _startingOrientation;
  42724. private _attachedElement;
  42725. /**
  42726. * 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)
  42727. */
  42728. private zDragFactor;
  42729. /**
  42730. * If the object should rotate to face the drag origin
  42731. */
  42732. rotateDraggedObject: boolean;
  42733. /**
  42734. * If the behavior is currently in a dragging state
  42735. */
  42736. dragging: boolean;
  42737. /**
  42738. * 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)
  42739. */
  42740. dragDeltaRatio: number;
  42741. /**
  42742. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42743. */
  42744. currentDraggingPointerID: number;
  42745. /**
  42746. * If camera controls should be detached during the drag
  42747. */
  42748. detachCameraControls: boolean;
  42749. /**
  42750. * Fires each time a drag starts
  42751. */
  42752. onDragStartObservable: Observable<{}>;
  42753. /**
  42754. * Fires each time a drag ends (eg. mouse release after drag)
  42755. */
  42756. onDragEndObservable: Observable<{}>;
  42757. /**
  42758. * 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
  42759. */
  42760. constructor();
  42761. /**
  42762. * The name of the behavior
  42763. */
  42764. get name(): string;
  42765. /**
  42766. * Initializes the behavior
  42767. */
  42768. init(): void;
  42769. /**
  42770. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42771. */
  42772. private get _pointerCamera();
  42773. /**
  42774. * Attaches the scale behavior the passed in mesh
  42775. * @param ownerNode The mesh that will be scaled around once attached
  42776. */
  42777. attach(ownerNode: Mesh): void;
  42778. /**
  42779. * Detaches the behavior from the mesh
  42780. */
  42781. detach(): void;
  42782. }
  42783. }
  42784. declare module BABYLON {
  42785. /**
  42786. * Class used to apply inverse kinematics to bones
  42787. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42788. */
  42789. export class BoneIKController {
  42790. private static _tmpVecs;
  42791. private static _tmpQuat;
  42792. private static _tmpMats;
  42793. /**
  42794. * Gets or sets the target mesh
  42795. */
  42796. targetMesh: AbstractMesh;
  42797. /** Gets or sets the mesh used as pole */
  42798. poleTargetMesh: AbstractMesh;
  42799. /**
  42800. * Gets or sets the bone used as pole
  42801. */
  42802. poleTargetBone: Nullable<Bone>;
  42803. /**
  42804. * Gets or sets the target position
  42805. */
  42806. targetPosition: Vector3;
  42807. /**
  42808. * Gets or sets the pole target position
  42809. */
  42810. poleTargetPosition: Vector3;
  42811. /**
  42812. * Gets or sets the pole target local offset
  42813. */
  42814. poleTargetLocalOffset: Vector3;
  42815. /**
  42816. * Gets or sets the pole angle
  42817. */
  42818. poleAngle: number;
  42819. /**
  42820. * Gets or sets the mesh associated with the controller
  42821. */
  42822. mesh: AbstractMesh;
  42823. /**
  42824. * 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)
  42825. */
  42826. slerpAmount: number;
  42827. private _bone1Quat;
  42828. private _bone1Mat;
  42829. private _bone2Ang;
  42830. private _bone1;
  42831. private _bone2;
  42832. private _bone1Length;
  42833. private _bone2Length;
  42834. private _maxAngle;
  42835. private _maxReach;
  42836. private _rightHandedSystem;
  42837. private _bendAxis;
  42838. private _slerping;
  42839. private _adjustRoll;
  42840. /**
  42841. * Gets or sets maximum allowed angle
  42842. */
  42843. get maxAngle(): number;
  42844. set maxAngle(value: number);
  42845. /**
  42846. * Creates a new BoneIKController
  42847. * @param mesh defines the mesh to control
  42848. * @param bone defines the bone to control
  42849. * @param options defines options to set up the controller
  42850. */
  42851. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42852. targetMesh?: AbstractMesh;
  42853. poleTargetMesh?: AbstractMesh;
  42854. poleTargetBone?: Bone;
  42855. poleTargetLocalOffset?: Vector3;
  42856. poleAngle?: number;
  42857. bendAxis?: Vector3;
  42858. maxAngle?: number;
  42859. slerpAmount?: number;
  42860. });
  42861. private _setMaxAngle;
  42862. /**
  42863. * Force the controller to update the bones
  42864. */
  42865. update(): void;
  42866. }
  42867. }
  42868. declare module BABYLON {
  42869. /**
  42870. * Class used to make a bone look toward a point in space
  42871. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42872. */
  42873. export class BoneLookController {
  42874. private static _tmpVecs;
  42875. private static _tmpQuat;
  42876. private static _tmpMats;
  42877. /**
  42878. * The target Vector3 that the bone will look at
  42879. */
  42880. target: Vector3;
  42881. /**
  42882. * The mesh that the bone is attached to
  42883. */
  42884. mesh: AbstractMesh;
  42885. /**
  42886. * The bone that will be looking to the target
  42887. */
  42888. bone: Bone;
  42889. /**
  42890. * The up axis of the coordinate system that is used when the bone is rotated
  42891. */
  42892. upAxis: Vector3;
  42893. /**
  42894. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42895. */
  42896. upAxisSpace: Space;
  42897. /**
  42898. * Used to make an adjustment to the yaw of the bone
  42899. */
  42900. adjustYaw: number;
  42901. /**
  42902. * Used to make an adjustment to the pitch of the bone
  42903. */
  42904. adjustPitch: number;
  42905. /**
  42906. * Used to make an adjustment to the roll of the bone
  42907. */
  42908. adjustRoll: number;
  42909. /**
  42910. * 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)
  42911. */
  42912. slerpAmount: number;
  42913. private _minYaw;
  42914. private _maxYaw;
  42915. private _minPitch;
  42916. private _maxPitch;
  42917. private _minYawSin;
  42918. private _minYawCos;
  42919. private _maxYawSin;
  42920. private _maxYawCos;
  42921. private _midYawConstraint;
  42922. private _minPitchTan;
  42923. private _maxPitchTan;
  42924. private _boneQuat;
  42925. private _slerping;
  42926. private _transformYawPitch;
  42927. private _transformYawPitchInv;
  42928. private _firstFrameSkipped;
  42929. private _yawRange;
  42930. private _fowardAxis;
  42931. /**
  42932. * Gets or sets the minimum yaw angle that the bone can look to
  42933. */
  42934. get minYaw(): number;
  42935. set minYaw(value: number);
  42936. /**
  42937. * Gets or sets the maximum yaw angle that the bone can look to
  42938. */
  42939. get maxYaw(): number;
  42940. set maxYaw(value: number);
  42941. /**
  42942. * Gets or sets the minimum pitch angle that the bone can look to
  42943. */
  42944. get minPitch(): number;
  42945. set minPitch(value: number);
  42946. /**
  42947. * Gets or sets the maximum pitch angle that the bone can look to
  42948. */
  42949. get maxPitch(): number;
  42950. set maxPitch(value: number);
  42951. /**
  42952. * Create a BoneLookController
  42953. * @param mesh the mesh that the bone belongs to
  42954. * @param bone the bone that will be looking to the target
  42955. * @param target the target Vector3 to look at
  42956. * @param options optional settings:
  42957. * * maxYaw: the maximum angle the bone will yaw to
  42958. * * minYaw: the minimum angle the bone will yaw to
  42959. * * maxPitch: the maximum angle the bone will pitch to
  42960. * * minPitch: the minimum angle the bone will yaw to
  42961. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42962. * * upAxis: the up axis of the coordinate system
  42963. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42964. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42965. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42966. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42967. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42968. * * adjustRoll: used to make an adjustment to the roll of the bone
  42969. **/
  42970. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42971. maxYaw?: number;
  42972. minYaw?: number;
  42973. maxPitch?: number;
  42974. minPitch?: number;
  42975. slerpAmount?: number;
  42976. upAxis?: Vector3;
  42977. upAxisSpace?: Space;
  42978. yawAxis?: Vector3;
  42979. pitchAxis?: Vector3;
  42980. adjustYaw?: number;
  42981. adjustPitch?: number;
  42982. adjustRoll?: number;
  42983. });
  42984. /**
  42985. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42986. */
  42987. update(): void;
  42988. private _getAngleDiff;
  42989. private _getAngleBetween;
  42990. private _isAngleBetween;
  42991. }
  42992. }
  42993. declare module BABYLON {
  42994. /**
  42995. * Manage the gamepad inputs to control an arc rotate camera.
  42996. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42997. */
  42998. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42999. /**
  43000. * Defines the camera the input is attached to.
  43001. */
  43002. camera: ArcRotateCamera;
  43003. /**
  43004. * Defines the gamepad the input is gathering event from.
  43005. */
  43006. gamepad: Nullable<Gamepad>;
  43007. /**
  43008. * Defines the gamepad rotation sensiblity.
  43009. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43010. */
  43011. gamepadRotationSensibility: number;
  43012. /**
  43013. * Defines the gamepad move sensiblity.
  43014. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43015. */
  43016. gamepadMoveSensibility: number;
  43017. private _yAxisScale;
  43018. /**
  43019. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43020. */
  43021. get invertYAxis(): boolean;
  43022. set invertYAxis(value: boolean);
  43023. private _onGamepadConnectedObserver;
  43024. private _onGamepadDisconnectedObserver;
  43025. /**
  43026. * Attach the input controls to a specific dom element to get the input from.
  43027. * @param element Defines the element the controls should be listened from
  43028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43029. */
  43030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43031. /**
  43032. * Detach the current controls from the specified dom element.
  43033. * @param element Defines the element to stop listening the inputs from
  43034. */
  43035. detachControl(element: Nullable<HTMLElement>): void;
  43036. /**
  43037. * Update the current camera state depending on the inputs that have been used this frame.
  43038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43039. */
  43040. checkInputs(): void;
  43041. /**
  43042. * Gets the class name of the current intput.
  43043. * @returns the class name
  43044. */
  43045. getClassName(): string;
  43046. /**
  43047. * Get the friendly name associated with the input class.
  43048. * @returns the input friendly name
  43049. */
  43050. getSimpleName(): string;
  43051. }
  43052. }
  43053. declare module BABYLON {
  43054. interface ArcRotateCameraInputsManager {
  43055. /**
  43056. * Add orientation input support to the input manager.
  43057. * @returns the current input manager
  43058. */
  43059. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43060. }
  43061. /**
  43062. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43063. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43064. */
  43065. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43066. /**
  43067. * Defines the camera the input is attached to.
  43068. */
  43069. camera: ArcRotateCamera;
  43070. /**
  43071. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43072. */
  43073. alphaCorrection: number;
  43074. /**
  43075. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43076. */
  43077. gammaCorrection: number;
  43078. private _alpha;
  43079. private _gamma;
  43080. private _dirty;
  43081. private _deviceOrientationHandler;
  43082. /**
  43083. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43084. */
  43085. constructor();
  43086. /**
  43087. * Attach the input controls to a specific dom element to get the input from.
  43088. * @param element Defines the element the controls should be listened from
  43089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43090. */
  43091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43092. /** @hidden */
  43093. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43094. /**
  43095. * Update the current camera state depending on the inputs that have been used this frame.
  43096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43097. */
  43098. checkInputs(): void;
  43099. /**
  43100. * Detach the current controls from the specified dom element.
  43101. * @param element Defines the element to stop listening the inputs from
  43102. */
  43103. detachControl(element: Nullable<HTMLElement>): void;
  43104. /**
  43105. * Gets the class name of the current intput.
  43106. * @returns the class name
  43107. */
  43108. getClassName(): string;
  43109. /**
  43110. * Get the friendly name associated with the input class.
  43111. * @returns the input friendly name
  43112. */
  43113. getSimpleName(): string;
  43114. }
  43115. }
  43116. declare module BABYLON {
  43117. /**
  43118. * Listen to mouse events to control the camera.
  43119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43120. */
  43121. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43122. /**
  43123. * Defines the camera the input is attached to.
  43124. */
  43125. camera: FlyCamera;
  43126. /**
  43127. * Defines if touch is enabled. (Default is true.)
  43128. */
  43129. touchEnabled: boolean;
  43130. /**
  43131. * Defines the buttons associated with the input to handle camera rotation.
  43132. */
  43133. buttons: number[];
  43134. /**
  43135. * Assign buttons for Yaw control.
  43136. */
  43137. buttonsYaw: number[];
  43138. /**
  43139. * Assign buttons for Pitch control.
  43140. */
  43141. buttonsPitch: number[];
  43142. /**
  43143. * Assign buttons for Roll control.
  43144. */
  43145. buttonsRoll: number[];
  43146. /**
  43147. * Detect if any button is being pressed while mouse is moved.
  43148. * -1 = Mouse locked.
  43149. * 0 = Left button.
  43150. * 1 = Middle Button.
  43151. * 2 = Right Button.
  43152. */
  43153. activeButton: number;
  43154. /**
  43155. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43156. * Higher values reduce its sensitivity.
  43157. */
  43158. angularSensibility: number;
  43159. private _mousemoveCallback;
  43160. private _observer;
  43161. private _rollObserver;
  43162. private previousPosition;
  43163. private noPreventDefault;
  43164. private element;
  43165. /**
  43166. * Listen to mouse events to control the camera.
  43167. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43169. */
  43170. constructor(touchEnabled?: boolean);
  43171. /**
  43172. * Attach the mouse control to the HTML DOM element.
  43173. * @param element Defines the element that listens to the input events.
  43174. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43175. */
  43176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43177. /**
  43178. * Detach the current controls from the specified dom element.
  43179. * @param element Defines the element to stop listening the inputs from
  43180. */
  43181. detachControl(element: Nullable<HTMLElement>): void;
  43182. /**
  43183. * Gets the class name of the current input.
  43184. * @returns the class name.
  43185. */
  43186. getClassName(): string;
  43187. /**
  43188. * Get the friendly name associated with the input class.
  43189. * @returns the input's friendly name.
  43190. */
  43191. getSimpleName(): string;
  43192. private _pointerInput;
  43193. private _onMouseMove;
  43194. /**
  43195. * Rotate camera by mouse offset.
  43196. */
  43197. private rotateCamera;
  43198. }
  43199. }
  43200. declare module BABYLON {
  43201. /**
  43202. * Default Inputs manager for the FlyCamera.
  43203. * It groups all the default supported inputs for ease of use.
  43204. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43205. */
  43206. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43207. /**
  43208. * Instantiates a new FlyCameraInputsManager.
  43209. * @param camera Defines the camera the inputs belong to.
  43210. */
  43211. constructor(camera: FlyCamera);
  43212. /**
  43213. * Add keyboard input support to the input manager.
  43214. * @returns the new FlyCameraKeyboardMoveInput().
  43215. */
  43216. addKeyboard(): FlyCameraInputsManager;
  43217. /**
  43218. * Add mouse input support to the input manager.
  43219. * @param touchEnabled Enable touch screen support.
  43220. * @returns the new FlyCameraMouseInput().
  43221. */
  43222. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43223. }
  43224. }
  43225. declare module BABYLON {
  43226. /**
  43227. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43228. * such as in a 3D Space Shooter or a Flight Simulator.
  43229. */
  43230. export class FlyCamera extends TargetCamera {
  43231. /**
  43232. * Define the collision ellipsoid of the camera.
  43233. * This is helpful for simulating a camera body, like a player's body.
  43234. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43235. */
  43236. ellipsoid: Vector3;
  43237. /**
  43238. * Define an offset for the position of the ellipsoid around the camera.
  43239. * This can be helpful if the camera is attached away from the player's body center,
  43240. * such as at its head.
  43241. */
  43242. ellipsoidOffset: Vector3;
  43243. /**
  43244. * Enable or disable collisions of the camera with the rest of the scene objects.
  43245. */
  43246. checkCollisions: boolean;
  43247. /**
  43248. * Enable or disable gravity on the camera.
  43249. */
  43250. applyGravity: boolean;
  43251. /**
  43252. * Define the current direction the camera is moving to.
  43253. */
  43254. cameraDirection: Vector3;
  43255. /**
  43256. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43257. * This overrides and empties cameraRotation.
  43258. */
  43259. rotationQuaternion: Quaternion;
  43260. /**
  43261. * Track Roll to maintain the wanted Rolling when looking around.
  43262. */
  43263. _trackRoll: number;
  43264. /**
  43265. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43266. */
  43267. rollCorrect: number;
  43268. /**
  43269. * Mimic a banked turn, Rolling the camera when Yawing.
  43270. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43271. */
  43272. bankedTurn: boolean;
  43273. /**
  43274. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43275. */
  43276. bankedTurnLimit: number;
  43277. /**
  43278. * Value of 0 disables the banked Roll.
  43279. * Value of 1 is equal to the Yaw angle in radians.
  43280. */
  43281. bankedTurnMultiplier: number;
  43282. /**
  43283. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43284. */
  43285. inputs: FlyCameraInputsManager;
  43286. /**
  43287. * Gets the input sensibility for mouse input.
  43288. * Higher values reduce sensitivity.
  43289. */
  43290. get angularSensibility(): number;
  43291. /**
  43292. * Sets the input sensibility for a mouse input.
  43293. * Higher values reduce sensitivity.
  43294. */
  43295. set angularSensibility(value: number);
  43296. /**
  43297. * Get the keys for camera movement forward.
  43298. */
  43299. get keysForward(): number[];
  43300. /**
  43301. * Set the keys for camera movement forward.
  43302. */
  43303. set keysForward(value: number[]);
  43304. /**
  43305. * Get the keys for camera movement backward.
  43306. */
  43307. get keysBackward(): number[];
  43308. set keysBackward(value: number[]);
  43309. /**
  43310. * Get the keys for camera movement up.
  43311. */
  43312. get keysUp(): number[];
  43313. /**
  43314. * Set the keys for camera movement up.
  43315. */
  43316. set keysUp(value: number[]);
  43317. /**
  43318. * Get the keys for camera movement down.
  43319. */
  43320. get keysDown(): number[];
  43321. /**
  43322. * Set the keys for camera movement down.
  43323. */
  43324. set keysDown(value: number[]);
  43325. /**
  43326. * Get the keys for camera movement left.
  43327. */
  43328. get keysLeft(): number[];
  43329. /**
  43330. * Set the keys for camera movement left.
  43331. */
  43332. set keysLeft(value: number[]);
  43333. /**
  43334. * Set the keys for camera movement right.
  43335. */
  43336. get keysRight(): number[];
  43337. /**
  43338. * Set the keys for camera movement right.
  43339. */
  43340. set keysRight(value: number[]);
  43341. /**
  43342. * Event raised when the camera collides with a mesh in the scene.
  43343. */
  43344. onCollide: (collidedMesh: AbstractMesh) => void;
  43345. private _collider;
  43346. private _needMoveForGravity;
  43347. private _oldPosition;
  43348. private _diffPosition;
  43349. private _newPosition;
  43350. /** @hidden */
  43351. _localDirection: Vector3;
  43352. /** @hidden */
  43353. _transformedDirection: Vector3;
  43354. /**
  43355. * Instantiates a FlyCamera.
  43356. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43357. * such as in a 3D Space Shooter or a Flight Simulator.
  43358. * @param name Define the name of the camera in the scene.
  43359. * @param position Define the starting position of the camera in the scene.
  43360. * @param scene Define the scene the camera belongs to.
  43361. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43362. */
  43363. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43364. /**
  43365. * Attach a control to the HTML DOM element.
  43366. * @param element Defines the element that listens to the input events.
  43367. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43368. */
  43369. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43370. /**
  43371. * Detach a control from the HTML DOM element.
  43372. * The camera will stop reacting to that input.
  43373. * @param element Defines the element that listens to the input events.
  43374. */
  43375. detachControl(element: HTMLElement): void;
  43376. private _collisionMask;
  43377. /**
  43378. * Get the mask that the camera ignores in collision events.
  43379. */
  43380. get collisionMask(): number;
  43381. /**
  43382. * Set the mask that the camera ignores in collision events.
  43383. */
  43384. set collisionMask(mask: number);
  43385. /** @hidden */
  43386. _collideWithWorld(displacement: Vector3): void;
  43387. /** @hidden */
  43388. private _onCollisionPositionChange;
  43389. /** @hidden */
  43390. _checkInputs(): void;
  43391. /** @hidden */
  43392. _decideIfNeedsToMove(): boolean;
  43393. /** @hidden */
  43394. _updatePosition(): void;
  43395. /**
  43396. * Restore the Roll to its target value at the rate specified.
  43397. * @param rate - Higher means slower restoring.
  43398. * @hidden
  43399. */
  43400. restoreRoll(rate: number): void;
  43401. /**
  43402. * Destroy the camera and release the current resources held by it.
  43403. */
  43404. dispose(): void;
  43405. /**
  43406. * Get the current object class name.
  43407. * @returns the class name.
  43408. */
  43409. getClassName(): string;
  43410. }
  43411. }
  43412. declare module BABYLON {
  43413. /**
  43414. * Listen to keyboard events to control the camera.
  43415. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43416. */
  43417. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43418. /**
  43419. * Defines the camera the input is attached to.
  43420. */
  43421. camera: FlyCamera;
  43422. /**
  43423. * The list of keyboard keys used to control the forward move of the camera.
  43424. */
  43425. keysForward: number[];
  43426. /**
  43427. * The list of keyboard keys used to control the backward move of the camera.
  43428. */
  43429. keysBackward: number[];
  43430. /**
  43431. * The list of keyboard keys used to control the forward move of the camera.
  43432. */
  43433. keysUp: number[];
  43434. /**
  43435. * The list of keyboard keys used to control the backward move of the camera.
  43436. */
  43437. keysDown: number[];
  43438. /**
  43439. * The list of keyboard keys used to control the right strafe move of the camera.
  43440. */
  43441. keysRight: number[];
  43442. /**
  43443. * The list of keyboard keys used to control the left strafe move of the camera.
  43444. */
  43445. keysLeft: number[];
  43446. private _keys;
  43447. private _onCanvasBlurObserver;
  43448. private _onKeyboardObserver;
  43449. private _engine;
  43450. private _scene;
  43451. /**
  43452. * Attach the input controls to a specific dom element to get the input from.
  43453. * @param element Defines the element the controls should be listened from
  43454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43455. */
  43456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43457. /**
  43458. * Detach the current controls from the specified dom element.
  43459. * @param element Defines the element to stop listening the inputs from
  43460. */
  43461. detachControl(element: Nullable<HTMLElement>): void;
  43462. /**
  43463. * Gets the class name of the current intput.
  43464. * @returns the class name
  43465. */
  43466. getClassName(): string;
  43467. /** @hidden */
  43468. _onLostFocus(e: FocusEvent): void;
  43469. /**
  43470. * Get the friendly name associated with the input class.
  43471. * @returns the input friendly name
  43472. */
  43473. getSimpleName(): string;
  43474. /**
  43475. * Update the current camera state depending on the inputs that have been used this frame.
  43476. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43477. */
  43478. checkInputs(): void;
  43479. }
  43480. }
  43481. declare module BABYLON {
  43482. /**
  43483. * Manage the mouse wheel inputs to control a follow camera.
  43484. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43485. */
  43486. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43487. /**
  43488. * Defines the camera the input is attached to.
  43489. */
  43490. camera: FollowCamera;
  43491. /**
  43492. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43493. */
  43494. axisControlRadius: boolean;
  43495. /**
  43496. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43497. */
  43498. axisControlHeight: boolean;
  43499. /**
  43500. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43501. */
  43502. axisControlRotation: boolean;
  43503. /**
  43504. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43505. * relation to mouseWheel events.
  43506. */
  43507. wheelPrecision: number;
  43508. /**
  43509. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43510. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43511. */
  43512. wheelDeltaPercentage: number;
  43513. private _wheel;
  43514. private _observer;
  43515. /**
  43516. * Attach the input controls to a specific dom element to get the input from.
  43517. * @param element Defines the element the controls should be listened from
  43518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43519. */
  43520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43521. /**
  43522. * Detach the current controls from the specified dom element.
  43523. * @param element Defines the element to stop listening the inputs from
  43524. */
  43525. detachControl(element: Nullable<HTMLElement>): void;
  43526. /**
  43527. * Gets the class name of the current intput.
  43528. * @returns the class name
  43529. */
  43530. getClassName(): string;
  43531. /**
  43532. * Get the friendly name associated with the input class.
  43533. * @returns the input friendly name
  43534. */
  43535. getSimpleName(): string;
  43536. }
  43537. }
  43538. declare module BABYLON {
  43539. /**
  43540. * Manage the pointers inputs to control an follow camera.
  43541. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43542. */
  43543. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43544. /**
  43545. * Defines the camera the input is attached to.
  43546. */
  43547. camera: FollowCamera;
  43548. /**
  43549. * Gets the class name of the current input.
  43550. * @returns the class name
  43551. */
  43552. getClassName(): string;
  43553. /**
  43554. * Defines the pointer angular sensibility along the X axis or how fast is
  43555. * the camera rotating.
  43556. * A negative number will reverse the axis direction.
  43557. */
  43558. angularSensibilityX: number;
  43559. /**
  43560. * Defines the pointer angular sensibility along the Y axis or how fast is
  43561. * the camera rotating.
  43562. * A negative number will reverse the axis direction.
  43563. */
  43564. angularSensibilityY: number;
  43565. /**
  43566. * Defines the pointer pinch precision or how fast is the camera zooming.
  43567. * A negative number will reverse the axis direction.
  43568. */
  43569. pinchPrecision: number;
  43570. /**
  43571. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43572. * from 0.
  43573. * It defines the percentage of current camera.radius to use as delta when
  43574. * pinch zoom is used.
  43575. */
  43576. pinchDeltaPercentage: number;
  43577. /**
  43578. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43579. */
  43580. axisXControlRadius: boolean;
  43581. /**
  43582. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43583. */
  43584. axisXControlHeight: boolean;
  43585. /**
  43586. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43587. */
  43588. axisXControlRotation: boolean;
  43589. /**
  43590. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43591. */
  43592. axisYControlRadius: boolean;
  43593. /**
  43594. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43595. */
  43596. axisYControlHeight: boolean;
  43597. /**
  43598. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43599. */
  43600. axisYControlRotation: boolean;
  43601. /**
  43602. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43603. */
  43604. axisPinchControlRadius: boolean;
  43605. /**
  43606. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43607. */
  43608. axisPinchControlHeight: boolean;
  43609. /**
  43610. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43611. */
  43612. axisPinchControlRotation: boolean;
  43613. /**
  43614. * Log error messages if basic misconfiguration has occurred.
  43615. */
  43616. warningEnable: boolean;
  43617. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43618. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43619. private _warningCounter;
  43620. private _warning;
  43621. }
  43622. }
  43623. declare module BABYLON {
  43624. /**
  43625. * Default Inputs manager for the FollowCamera.
  43626. * It groups all the default supported inputs for ease of use.
  43627. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43628. */
  43629. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43630. /**
  43631. * Instantiates a new FollowCameraInputsManager.
  43632. * @param camera Defines the camera the inputs belong to
  43633. */
  43634. constructor(camera: FollowCamera);
  43635. /**
  43636. * Add keyboard input support to the input manager.
  43637. * @returns the current input manager
  43638. */
  43639. addKeyboard(): FollowCameraInputsManager;
  43640. /**
  43641. * Add mouse wheel input support to the input manager.
  43642. * @returns the current input manager
  43643. */
  43644. addMouseWheel(): FollowCameraInputsManager;
  43645. /**
  43646. * Add pointers input support to the input manager.
  43647. * @returns the current input manager
  43648. */
  43649. addPointers(): FollowCameraInputsManager;
  43650. /**
  43651. * Add orientation input support to the input manager.
  43652. * @returns the current input manager
  43653. */
  43654. addVRDeviceOrientation(): FollowCameraInputsManager;
  43655. }
  43656. }
  43657. declare module BABYLON {
  43658. /**
  43659. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43660. * an arc rotate version arcFollowCamera are available.
  43661. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43662. */
  43663. export class FollowCamera extends TargetCamera {
  43664. /**
  43665. * Distance the follow camera should follow an object at
  43666. */
  43667. radius: number;
  43668. /**
  43669. * Minimum allowed distance of the camera to the axis of rotation
  43670. * (The camera can not get closer).
  43671. * This can help limiting how the Camera is able to move in the scene.
  43672. */
  43673. lowerRadiusLimit: Nullable<number>;
  43674. /**
  43675. * Maximum allowed distance of the camera to the axis of rotation
  43676. * (The camera can not get further).
  43677. * This can help limiting how the Camera is able to move in the scene.
  43678. */
  43679. upperRadiusLimit: Nullable<number>;
  43680. /**
  43681. * Define a rotation offset between the camera and the object it follows
  43682. */
  43683. rotationOffset: number;
  43684. /**
  43685. * Minimum allowed angle to camera position relative to target object.
  43686. * This can help limiting how the Camera is able to move in the scene.
  43687. */
  43688. lowerRotationOffsetLimit: Nullable<number>;
  43689. /**
  43690. * Maximum allowed angle to camera position relative to target object.
  43691. * This can help limiting how the Camera is able to move in the scene.
  43692. */
  43693. upperRotationOffsetLimit: Nullable<number>;
  43694. /**
  43695. * Define a height offset between the camera and the object it follows.
  43696. * It can help following an object from the top (like a car chaing a plane)
  43697. */
  43698. heightOffset: number;
  43699. /**
  43700. * Minimum allowed height of camera position relative to target object.
  43701. * This can help limiting how the Camera is able to move in the scene.
  43702. */
  43703. lowerHeightOffsetLimit: Nullable<number>;
  43704. /**
  43705. * Maximum allowed height of camera position relative to target object.
  43706. * This can help limiting how the Camera is able to move in the scene.
  43707. */
  43708. upperHeightOffsetLimit: Nullable<number>;
  43709. /**
  43710. * Define how fast the camera can accelerate to follow it s target.
  43711. */
  43712. cameraAcceleration: number;
  43713. /**
  43714. * Define the speed limit of the camera following an object.
  43715. */
  43716. maxCameraSpeed: number;
  43717. /**
  43718. * Define the target of the camera.
  43719. */
  43720. lockedTarget: Nullable<AbstractMesh>;
  43721. /**
  43722. * Defines the input associated with the camera.
  43723. */
  43724. inputs: FollowCameraInputsManager;
  43725. /**
  43726. * Instantiates the follow camera.
  43727. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43728. * @param name Define the name of the camera in the scene
  43729. * @param position Define the position of the camera
  43730. * @param scene Define the scene the camera belong to
  43731. * @param lockedTarget Define the target of the camera
  43732. */
  43733. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43734. private _follow;
  43735. /**
  43736. * Attached controls to the current camera.
  43737. * @param element Defines the element the controls should be listened from
  43738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43739. */
  43740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43741. /**
  43742. * Detach the current controls from the camera.
  43743. * The camera will stop reacting to inputs.
  43744. * @param element Defines the element to stop listening the inputs from
  43745. */
  43746. detachControl(element: HTMLElement): void;
  43747. /** @hidden */
  43748. _checkInputs(): void;
  43749. private _checkLimits;
  43750. /**
  43751. * Gets the camera class name.
  43752. * @returns the class name
  43753. */
  43754. getClassName(): string;
  43755. }
  43756. /**
  43757. * Arc Rotate version of the follow camera.
  43758. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43759. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43760. */
  43761. export class ArcFollowCamera extends TargetCamera {
  43762. /** The longitudinal angle of the camera */
  43763. alpha: number;
  43764. /** The latitudinal angle of the camera */
  43765. beta: number;
  43766. /** The radius of the camera from its target */
  43767. radius: number;
  43768. /** Define the camera target (the mesh it should follow) */
  43769. target: Nullable<AbstractMesh>;
  43770. private _cartesianCoordinates;
  43771. /**
  43772. * Instantiates a new ArcFollowCamera
  43773. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43774. * @param name Define the name of the camera
  43775. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43776. * @param beta Define the rotation angle of the camera around the elevation axis
  43777. * @param radius Define the radius of the camera from its target point
  43778. * @param target Define the target of the camera
  43779. * @param scene Define the scene the camera belongs to
  43780. */
  43781. constructor(name: string,
  43782. /** The longitudinal angle of the camera */
  43783. alpha: number,
  43784. /** The latitudinal angle of the camera */
  43785. beta: number,
  43786. /** The radius of the camera from its target */
  43787. radius: number,
  43788. /** Define the camera target (the mesh it should follow) */
  43789. target: Nullable<AbstractMesh>, scene: Scene);
  43790. private _follow;
  43791. /** @hidden */
  43792. _checkInputs(): void;
  43793. /**
  43794. * Returns the class name of the object.
  43795. * It is mostly used internally for serialization purposes.
  43796. */
  43797. getClassName(): string;
  43798. }
  43799. }
  43800. declare module BABYLON {
  43801. /**
  43802. * Manage the keyboard inputs to control the movement of a follow camera.
  43803. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43804. */
  43805. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43806. /**
  43807. * Defines the camera the input is attached to.
  43808. */
  43809. camera: FollowCamera;
  43810. /**
  43811. * Defines the list of key codes associated with the up action (increase heightOffset)
  43812. */
  43813. keysHeightOffsetIncr: number[];
  43814. /**
  43815. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43816. */
  43817. keysHeightOffsetDecr: number[];
  43818. /**
  43819. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43820. */
  43821. keysHeightOffsetModifierAlt: boolean;
  43822. /**
  43823. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43824. */
  43825. keysHeightOffsetModifierCtrl: boolean;
  43826. /**
  43827. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43828. */
  43829. keysHeightOffsetModifierShift: boolean;
  43830. /**
  43831. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43832. */
  43833. keysRotationOffsetIncr: number[];
  43834. /**
  43835. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43836. */
  43837. keysRotationOffsetDecr: number[];
  43838. /**
  43839. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43840. */
  43841. keysRotationOffsetModifierAlt: boolean;
  43842. /**
  43843. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43844. */
  43845. keysRotationOffsetModifierCtrl: boolean;
  43846. /**
  43847. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43848. */
  43849. keysRotationOffsetModifierShift: boolean;
  43850. /**
  43851. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43852. */
  43853. keysRadiusIncr: number[];
  43854. /**
  43855. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43856. */
  43857. keysRadiusDecr: number[];
  43858. /**
  43859. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43860. */
  43861. keysRadiusModifierAlt: boolean;
  43862. /**
  43863. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43864. */
  43865. keysRadiusModifierCtrl: boolean;
  43866. /**
  43867. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43868. */
  43869. keysRadiusModifierShift: boolean;
  43870. /**
  43871. * Defines the rate of change of heightOffset.
  43872. */
  43873. heightSensibility: number;
  43874. /**
  43875. * Defines the rate of change of rotationOffset.
  43876. */
  43877. rotationSensibility: number;
  43878. /**
  43879. * Defines the rate of change of radius.
  43880. */
  43881. radiusSensibility: number;
  43882. private _keys;
  43883. private _ctrlPressed;
  43884. private _altPressed;
  43885. private _shiftPressed;
  43886. private _onCanvasBlurObserver;
  43887. private _onKeyboardObserver;
  43888. private _engine;
  43889. private _scene;
  43890. /**
  43891. * Attach the input controls to a specific dom element to get the input from.
  43892. * @param element Defines the element the controls should be listened from
  43893. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43894. */
  43895. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43896. /**
  43897. * Detach the current controls from the specified dom element.
  43898. * @param element Defines the element to stop listening the inputs from
  43899. */
  43900. detachControl(element: Nullable<HTMLElement>): void;
  43901. /**
  43902. * Update the current camera state depending on the inputs that have been used this frame.
  43903. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43904. */
  43905. checkInputs(): void;
  43906. /**
  43907. * Gets the class name of the current input.
  43908. * @returns the class name
  43909. */
  43910. getClassName(): string;
  43911. /**
  43912. * Get the friendly name associated with the input class.
  43913. * @returns the input friendly name
  43914. */
  43915. getSimpleName(): string;
  43916. /**
  43917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43918. * allow modification of the heightOffset value.
  43919. */
  43920. private _modifierHeightOffset;
  43921. /**
  43922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43923. * allow modification of the rotationOffset value.
  43924. */
  43925. private _modifierRotationOffset;
  43926. /**
  43927. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43928. * allow modification of the radius value.
  43929. */
  43930. private _modifierRadius;
  43931. }
  43932. }
  43933. declare module BABYLON {
  43934. interface FreeCameraInputsManager {
  43935. /**
  43936. * @hidden
  43937. */
  43938. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43939. /**
  43940. * Add orientation input support to the input manager.
  43941. * @returns the current input manager
  43942. */
  43943. addDeviceOrientation(): FreeCameraInputsManager;
  43944. }
  43945. /**
  43946. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43947. * Screen rotation is taken into account.
  43948. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43949. */
  43950. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43951. private _camera;
  43952. private _screenOrientationAngle;
  43953. private _constantTranform;
  43954. private _screenQuaternion;
  43955. private _alpha;
  43956. private _beta;
  43957. private _gamma;
  43958. /**
  43959. * Can be used to detect if a device orientation sensor is available on a device
  43960. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43961. * @returns a promise that will resolve on orientation change
  43962. */
  43963. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43964. /**
  43965. * @hidden
  43966. */
  43967. _onDeviceOrientationChangedObservable: Observable<void>;
  43968. /**
  43969. * Instantiates a new input
  43970. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43971. */
  43972. constructor();
  43973. /**
  43974. * Define the camera controlled by the input.
  43975. */
  43976. get camera(): FreeCamera;
  43977. set camera(camera: FreeCamera);
  43978. /**
  43979. * Attach the input controls to a specific dom element to get the input from.
  43980. * @param element Defines the element the controls should be listened from
  43981. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43982. */
  43983. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43984. private _orientationChanged;
  43985. private _deviceOrientation;
  43986. /**
  43987. * Detach the current controls from the specified dom element.
  43988. * @param element Defines the element to stop listening the inputs from
  43989. */
  43990. detachControl(element: Nullable<HTMLElement>): void;
  43991. /**
  43992. * Update the current camera state depending on the inputs that have been used this frame.
  43993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43994. */
  43995. checkInputs(): void;
  43996. /**
  43997. * Gets the class name of the current intput.
  43998. * @returns the class name
  43999. */
  44000. getClassName(): string;
  44001. /**
  44002. * Get the friendly name associated with the input class.
  44003. * @returns the input friendly name
  44004. */
  44005. getSimpleName(): string;
  44006. }
  44007. }
  44008. declare module BABYLON {
  44009. /**
  44010. * Manage the gamepad inputs to control a free camera.
  44011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44012. */
  44013. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44014. /**
  44015. * Define the camera the input is attached to.
  44016. */
  44017. camera: FreeCamera;
  44018. /**
  44019. * Define the Gamepad controlling the input
  44020. */
  44021. gamepad: Nullable<Gamepad>;
  44022. /**
  44023. * Defines the gamepad rotation sensiblity.
  44024. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44025. */
  44026. gamepadAngularSensibility: number;
  44027. /**
  44028. * Defines the gamepad move sensiblity.
  44029. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44030. */
  44031. gamepadMoveSensibility: number;
  44032. private _yAxisScale;
  44033. /**
  44034. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44035. */
  44036. get invertYAxis(): boolean;
  44037. set invertYAxis(value: boolean);
  44038. private _onGamepadConnectedObserver;
  44039. private _onGamepadDisconnectedObserver;
  44040. private _cameraTransform;
  44041. private _deltaTransform;
  44042. private _vector3;
  44043. private _vector2;
  44044. /**
  44045. * Attach the input controls to a specific dom element to get the input from.
  44046. * @param element Defines the element the controls should be listened from
  44047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44048. */
  44049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44050. /**
  44051. * Detach the current controls from the specified dom element.
  44052. * @param element Defines the element to stop listening the inputs from
  44053. */
  44054. detachControl(element: Nullable<HTMLElement>): void;
  44055. /**
  44056. * Update the current camera state depending on the inputs that have been used this frame.
  44057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44058. */
  44059. checkInputs(): void;
  44060. /**
  44061. * Gets the class name of the current intput.
  44062. * @returns the class name
  44063. */
  44064. getClassName(): string;
  44065. /**
  44066. * Get the friendly name associated with the input class.
  44067. * @returns the input friendly name
  44068. */
  44069. getSimpleName(): string;
  44070. }
  44071. }
  44072. declare module BABYLON {
  44073. /**
  44074. * Defines the potential axis of a Joystick
  44075. */
  44076. export enum JoystickAxis {
  44077. /** X axis */
  44078. X = 0,
  44079. /** Y axis */
  44080. Y = 1,
  44081. /** Z axis */
  44082. Z = 2
  44083. }
  44084. /**
  44085. * Represents the different customization options available
  44086. * for VirtualJoystick
  44087. */
  44088. interface VirtualJoystickCustomizations {
  44089. /**
  44090. * Size of the joystick's puck
  44091. */
  44092. puckSize: number;
  44093. /**
  44094. * Size of the joystick's container
  44095. */
  44096. containerSize: number;
  44097. /**
  44098. * Color of the joystick && puck
  44099. */
  44100. color: string;
  44101. /**
  44102. * Image URL for the joystick's puck
  44103. */
  44104. puckImage?: string;
  44105. /**
  44106. * Image URL for the joystick's container
  44107. */
  44108. containerImage?: string;
  44109. /**
  44110. * Defines the unmoving position of the joystick container
  44111. */
  44112. position?: {
  44113. x: number;
  44114. y: number;
  44115. };
  44116. /**
  44117. * Defines whether or not the joystick container is always visible
  44118. */
  44119. alwaysVisible: boolean;
  44120. /**
  44121. * Defines whether or not to limit the movement of the puck to the joystick's container
  44122. */
  44123. limitToContainer: boolean;
  44124. }
  44125. /**
  44126. * Class used to define virtual joystick (used in touch mode)
  44127. */
  44128. export class VirtualJoystick {
  44129. /**
  44130. * Gets or sets a boolean indicating that left and right values must be inverted
  44131. */
  44132. reverseLeftRight: boolean;
  44133. /**
  44134. * Gets or sets a boolean indicating that up and down values must be inverted
  44135. */
  44136. reverseUpDown: boolean;
  44137. /**
  44138. * Gets the offset value for the position (ie. the change of the position value)
  44139. */
  44140. deltaPosition: Vector3;
  44141. /**
  44142. * Gets a boolean indicating if the virtual joystick was pressed
  44143. */
  44144. pressed: boolean;
  44145. /**
  44146. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44147. */
  44148. static Canvas: Nullable<HTMLCanvasElement>;
  44149. /**
  44150. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44151. */
  44152. limitToContainer: boolean;
  44153. private static _globalJoystickIndex;
  44154. private static _alwaysVisibleSticks;
  44155. private static vjCanvasContext;
  44156. private static vjCanvasWidth;
  44157. private static vjCanvasHeight;
  44158. private static halfWidth;
  44159. private static _GetDefaultOptions;
  44160. private _action;
  44161. private _axisTargetedByLeftAndRight;
  44162. private _axisTargetedByUpAndDown;
  44163. private _joystickSensibility;
  44164. private _inversedSensibility;
  44165. private _joystickPointerID;
  44166. private _joystickColor;
  44167. private _joystickPointerPos;
  44168. private _joystickPreviousPointerPos;
  44169. private _joystickPointerStartPos;
  44170. private _deltaJoystickVector;
  44171. private _leftJoystick;
  44172. private _touches;
  44173. private _joystickPosition;
  44174. private _alwaysVisible;
  44175. private _puckImage;
  44176. private _containerImage;
  44177. private _joystickPuckSize;
  44178. private _joystickContainerSize;
  44179. private _clearPuckSize;
  44180. private _clearContainerSize;
  44181. private _clearPuckSizeOffset;
  44182. private _clearContainerSizeOffset;
  44183. private _onPointerDownHandlerRef;
  44184. private _onPointerMoveHandlerRef;
  44185. private _onPointerUpHandlerRef;
  44186. private _onResize;
  44187. /**
  44188. * Creates a new virtual joystick
  44189. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44190. * @param customizations Defines the options we want to customize the VirtualJoystick
  44191. */
  44192. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44193. /**
  44194. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44195. * @param newJoystickSensibility defines the new sensibility
  44196. */
  44197. setJoystickSensibility(newJoystickSensibility: number): void;
  44198. private _onPointerDown;
  44199. private _onPointerMove;
  44200. private _onPointerUp;
  44201. /**
  44202. * Change the color of the virtual joystick
  44203. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44204. */
  44205. setJoystickColor(newColor: string): void;
  44206. /**
  44207. * Size of the joystick's container
  44208. */
  44209. set containerSize(newSize: number);
  44210. get containerSize(): number;
  44211. /**
  44212. * Size of the joystick's puck
  44213. */
  44214. set puckSize(newSize: number);
  44215. get puckSize(): number;
  44216. /**
  44217. * Clears the set position of the joystick
  44218. */
  44219. clearPosition(): void;
  44220. /**
  44221. * Defines whether or not the joystick container is always visible
  44222. */
  44223. set alwaysVisible(value: boolean);
  44224. get alwaysVisible(): boolean;
  44225. /**
  44226. * Sets the constant position of the Joystick container
  44227. * @param x X axis coordinate
  44228. * @param y Y axis coordinate
  44229. */
  44230. setPosition(x: number, y: number): void;
  44231. /**
  44232. * Defines a callback to call when the joystick is touched
  44233. * @param action defines the callback
  44234. */
  44235. setActionOnTouch(action: () => any): void;
  44236. /**
  44237. * Defines which axis you'd like to control for left & right
  44238. * @param axis defines the axis to use
  44239. */
  44240. setAxisForLeftRight(axis: JoystickAxis): void;
  44241. /**
  44242. * Defines which axis you'd like to control for up & down
  44243. * @param axis defines the axis to use
  44244. */
  44245. setAxisForUpDown(axis: JoystickAxis): void;
  44246. /**
  44247. * Clears the canvas from the previous puck / container draw
  44248. */
  44249. private _clearPreviousDraw;
  44250. /**
  44251. * Loads `urlPath` to be used for the container's image
  44252. * @param urlPath defines the urlPath of an image to use
  44253. */
  44254. setContainerImage(urlPath: string): void;
  44255. /**
  44256. * Loads `urlPath` to be used for the puck's image
  44257. * @param urlPath defines the urlPath of an image to use
  44258. */
  44259. setPuckImage(urlPath: string): void;
  44260. /**
  44261. * Draws the Virtual Joystick's container
  44262. */
  44263. private _drawContainer;
  44264. /**
  44265. * Draws the Virtual Joystick's puck
  44266. */
  44267. private _drawPuck;
  44268. private _drawVirtualJoystick;
  44269. /**
  44270. * Release internal HTML canvas
  44271. */
  44272. releaseCanvas(): void;
  44273. }
  44274. }
  44275. declare module BABYLON {
  44276. interface FreeCameraInputsManager {
  44277. /**
  44278. * Add virtual joystick input support to the input manager.
  44279. * @returns the current input manager
  44280. */
  44281. addVirtualJoystick(): FreeCameraInputsManager;
  44282. }
  44283. /**
  44284. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44285. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44286. */
  44287. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44288. /**
  44289. * Defines the camera the input is attached to.
  44290. */
  44291. camera: FreeCamera;
  44292. private _leftjoystick;
  44293. private _rightjoystick;
  44294. /**
  44295. * Gets the left stick of the virtual joystick.
  44296. * @returns The virtual Joystick
  44297. */
  44298. getLeftJoystick(): VirtualJoystick;
  44299. /**
  44300. * Gets the right stick of the virtual joystick.
  44301. * @returns The virtual Joystick
  44302. */
  44303. getRightJoystick(): VirtualJoystick;
  44304. /**
  44305. * Update the current camera state depending on the inputs that have been used this frame.
  44306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44307. */
  44308. checkInputs(): void;
  44309. /**
  44310. * Attach the input controls to a specific dom element to get the input from.
  44311. * @param element Defines the element the controls should be listened from
  44312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44313. */
  44314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44315. /**
  44316. * Detach the current controls from the specified dom element.
  44317. * @param element Defines the element to stop listening the inputs from
  44318. */
  44319. detachControl(element: Nullable<HTMLElement>): void;
  44320. /**
  44321. * Gets the class name of the current intput.
  44322. * @returns the class name
  44323. */
  44324. getClassName(): string;
  44325. /**
  44326. * Get the friendly name associated with the input class.
  44327. * @returns the input friendly name
  44328. */
  44329. getSimpleName(): string;
  44330. }
  44331. }
  44332. declare module BABYLON {
  44333. /**
  44334. * This represents a FPS type of camera controlled by touch.
  44335. * This is like a universal camera minus the Gamepad controls.
  44336. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44337. */
  44338. export class TouchCamera extends FreeCamera {
  44339. /**
  44340. * Defines the touch sensibility for rotation.
  44341. * The higher the faster.
  44342. */
  44343. get touchAngularSensibility(): number;
  44344. set touchAngularSensibility(value: number);
  44345. /**
  44346. * Defines the touch sensibility for move.
  44347. * The higher the faster.
  44348. */
  44349. get touchMoveSensibility(): number;
  44350. set touchMoveSensibility(value: number);
  44351. /**
  44352. * Instantiates a new touch camera.
  44353. * This represents a FPS type of camera controlled by touch.
  44354. * This is like a universal camera minus the Gamepad controls.
  44355. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44356. * @param name Define the name of the camera in the scene
  44357. * @param position Define the start position of the camera in the scene
  44358. * @param scene Define the scene the camera belongs to
  44359. */
  44360. constructor(name: string, position: Vector3, scene: Scene);
  44361. /**
  44362. * Gets the current object class name.
  44363. * @return the class name
  44364. */
  44365. getClassName(): string;
  44366. /** @hidden */
  44367. _setupInputs(): void;
  44368. }
  44369. }
  44370. declare module BABYLON {
  44371. /**
  44372. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44373. * being tilted forward or back and left or right.
  44374. */
  44375. export class DeviceOrientationCamera extends FreeCamera {
  44376. private _initialQuaternion;
  44377. private _quaternionCache;
  44378. private _tmpDragQuaternion;
  44379. private _disablePointerInputWhenUsingDeviceOrientation;
  44380. /**
  44381. * Creates a new device orientation camera
  44382. * @param name The name of the camera
  44383. * @param position The start position camera
  44384. * @param scene The scene the camera belongs to
  44385. */
  44386. constructor(name: string, position: Vector3, scene: Scene);
  44387. /**
  44388. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44389. */
  44390. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44391. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44392. private _dragFactor;
  44393. /**
  44394. * Enabled turning on the y axis when the orientation sensor is active
  44395. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44396. */
  44397. enableHorizontalDragging(dragFactor?: number): void;
  44398. /**
  44399. * Gets the current instance class name ("DeviceOrientationCamera").
  44400. * This helps avoiding instanceof at run time.
  44401. * @returns the class name
  44402. */
  44403. getClassName(): string;
  44404. /**
  44405. * @hidden
  44406. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44407. */
  44408. _checkInputs(): void;
  44409. /**
  44410. * Reset the camera to its default orientation on the specified axis only.
  44411. * @param axis The axis to reset
  44412. */
  44413. resetToCurrentRotation(axis?: Axis): void;
  44414. }
  44415. }
  44416. declare module BABYLON {
  44417. /**
  44418. * Defines supported buttons for XBox360 compatible gamepads
  44419. */
  44420. export enum Xbox360Button {
  44421. /** A */
  44422. A = 0,
  44423. /** B */
  44424. B = 1,
  44425. /** X */
  44426. X = 2,
  44427. /** Y */
  44428. Y = 3,
  44429. /** Left button */
  44430. LB = 4,
  44431. /** Right button */
  44432. RB = 5,
  44433. /** Back */
  44434. Back = 8,
  44435. /** Start */
  44436. Start = 9,
  44437. /** Left stick */
  44438. LeftStick = 10,
  44439. /** Right stick */
  44440. RightStick = 11
  44441. }
  44442. /** Defines values for XBox360 DPad */
  44443. export enum Xbox360Dpad {
  44444. /** Up */
  44445. Up = 12,
  44446. /** Down */
  44447. Down = 13,
  44448. /** Left */
  44449. Left = 14,
  44450. /** Right */
  44451. Right = 15
  44452. }
  44453. /**
  44454. * Defines a XBox360 gamepad
  44455. */
  44456. export class Xbox360Pad extends Gamepad {
  44457. private _leftTrigger;
  44458. private _rightTrigger;
  44459. private _onlefttriggerchanged;
  44460. private _onrighttriggerchanged;
  44461. private _onbuttondown;
  44462. private _onbuttonup;
  44463. private _ondpaddown;
  44464. private _ondpadup;
  44465. /** Observable raised when a button is pressed */
  44466. onButtonDownObservable: Observable<Xbox360Button>;
  44467. /** Observable raised when a button is released */
  44468. onButtonUpObservable: Observable<Xbox360Button>;
  44469. /** Observable raised when a pad is pressed */
  44470. onPadDownObservable: Observable<Xbox360Dpad>;
  44471. /** Observable raised when a pad is released */
  44472. onPadUpObservable: Observable<Xbox360Dpad>;
  44473. private _buttonA;
  44474. private _buttonB;
  44475. private _buttonX;
  44476. private _buttonY;
  44477. private _buttonBack;
  44478. private _buttonStart;
  44479. private _buttonLB;
  44480. private _buttonRB;
  44481. private _buttonLeftStick;
  44482. private _buttonRightStick;
  44483. private _dPadUp;
  44484. private _dPadDown;
  44485. private _dPadLeft;
  44486. private _dPadRight;
  44487. private _isXboxOnePad;
  44488. /**
  44489. * Creates a new XBox360 gamepad object
  44490. * @param id defines the id of this gamepad
  44491. * @param index defines its index
  44492. * @param gamepad defines the internal HTML gamepad object
  44493. * @param xboxOne defines if it is a XBox One gamepad
  44494. */
  44495. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44496. /**
  44497. * Defines the callback to call when left trigger is pressed
  44498. * @param callback defines the callback to use
  44499. */
  44500. onlefttriggerchanged(callback: (value: number) => void): void;
  44501. /**
  44502. * Defines the callback to call when right trigger is pressed
  44503. * @param callback defines the callback to use
  44504. */
  44505. onrighttriggerchanged(callback: (value: number) => void): void;
  44506. /**
  44507. * Gets the left trigger value
  44508. */
  44509. get leftTrigger(): number;
  44510. /**
  44511. * Sets the left trigger value
  44512. */
  44513. set leftTrigger(newValue: number);
  44514. /**
  44515. * Gets the right trigger value
  44516. */
  44517. get rightTrigger(): number;
  44518. /**
  44519. * Sets the right trigger value
  44520. */
  44521. set rightTrigger(newValue: number);
  44522. /**
  44523. * Defines the callback to call when a button is pressed
  44524. * @param callback defines the callback to use
  44525. */
  44526. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44527. /**
  44528. * Defines the callback to call when a button is released
  44529. * @param callback defines the callback to use
  44530. */
  44531. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44532. /**
  44533. * Defines the callback to call when a pad is pressed
  44534. * @param callback defines the callback to use
  44535. */
  44536. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44537. /**
  44538. * Defines the callback to call when a pad is released
  44539. * @param callback defines the callback to use
  44540. */
  44541. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44542. private _setButtonValue;
  44543. private _setDPadValue;
  44544. /**
  44545. * Gets the value of the `A` button
  44546. */
  44547. get buttonA(): number;
  44548. /**
  44549. * Sets the value of the `A` button
  44550. */
  44551. set buttonA(value: number);
  44552. /**
  44553. * Gets the value of the `B` button
  44554. */
  44555. get buttonB(): number;
  44556. /**
  44557. * Sets the value of the `B` button
  44558. */
  44559. set buttonB(value: number);
  44560. /**
  44561. * Gets the value of the `X` button
  44562. */
  44563. get buttonX(): number;
  44564. /**
  44565. * Sets the value of the `X` button
  44566. */
  44567. set buttonX(value: number);
  44568. /**
  44569. * Gets the value of the `Y` button
  44570. */
  44571. get buttonY(): number;
  44572. /**
  44573. * Sets the value of the `Y` button
  44574. */
  44575. set buttonY(value: number);
  44576. /**
  44577. * Gets the value of the `Start` button
  44578. */
  44579. get buttonStart(): number;
  44580. /**
  44581. * Sets the value of the `Start` button
  44582. */
  44583. set buttonStart(value: number);
  44584. /**
  44585. * Gets the value of the `Back` button
  44586. */
  44587. get buttonBack(): number;
  44588. /**
  44589. * Sets the value of the `Back` button
  44590. */
  44591. set buttonBack(value: number);
  44592. /**
  44593. * Gets the value of the `Left` button
  44594. */
  44595. get buttonLB(): number;
  44596. /**
  44597. * Sets the value of the `Left` button
  44598. */
  44599. set buttonLB(value: number);
  44600. /**
  44601. * Gets the value of the `Right` button
  44602. */
  44603. get buttonRB(): number;
  44604. /**
  44605. * Sets the value of the `Right` button
  44606. */
  44607. set buttonRB(value: number);
  44608. /**
  44609. * Gets the value of the Left joystick
  44610. */
  44611. get buttonLeftStick(): number;
  44612. /**
  44613. * Sets the value of the Left joystick
  44614. */
  44615. set buttonLeftStick(value: number);
  44616. /**
  44617. * Gets the value of the Right joystick
  44618. */
  44619. get buttonRightStick(): number;
  44620. /**
  44621. * Sets the value of the Right joystick
  44622. */
  44623. set buttonRightStick(value: number);
  44624. /**
  44625. * Gets the value of D-pad up
  44626. */
  44627. get dPadUp(): number;
  44628. /**
  44629. * Sets the value of D-pad up
  44630. */
  44631. set dPadUp(value: number);
  44632. /**
  44633. * Gets the value of D-pad down
  44634. */
  44635. get dPadDown(): number;
  44636. /**
  44637. * Sets the value of D-pad down
  44638. */
  44639. set dPadDown(value: number);
  44640. /**
  44641. * Gets the value of D-pad left
  44642. */
  44643. get dPadLeft(): number;
  44644. /**
  44645. * Sets the value of D-pad left
  44646. */
  44647. set dPadLeft(value: number);
  44648. /**
  44649. * Gets the value of D-pad right
  44650. */
  44651. get dPadRight(): number;
  44652. /**
  44653. * Sets the value of D-pad right
  44654. */
  44655. set dPadRight(value: number);
  44656. /**
  44657. * Force the gamepad to synchronize with device values
  44658. */
  44659. update(): void;
  44660. /**
  44661. * Disposes the gamepad
  44662. */
  44663. dispose(): void;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /**
  44668. * Defines supported buttons for DualShock compatible gamepads
  44669. */
  44670. export enum DualShockButton {
  44671. /** Cross */
  44672. Cross = 0,
  44673. /** Circle */
  44674. Circle = 1,
  44675. /** Square */
  44676. Square = 2,
  44677. /** Triangle */
  44678. Triangle = 3,
  44679. /** L1 */
  44680. L1 = 4,
  44681. /** R1 */
  44682. R1 = 5,
  44683. /** Share */
  44684. Share = 8,
  44685. /** Options */
  44686. Options = 9,
  44687. /** Left stick */
  44688. LeftStick = 10,
  44689. /** Right stick */
  44690. RightStick = 11
  44691. }
  44692. /** Defines values for DualShock DPad */
  44693. export enum DualShockDpad {
  44694. /** Up */
  44695. Up = 12,
  44696. /** Down */
  44697. Down = 13,
  44698. /** Left */
  44699. Left = 14,
  44700. /** Right */
  44701. Right = 15
  44702. }
  44703. /**
  44704. * Defines a DualShock gamepad
  44705. */
  44706. export class DualShockPad extends Gamepad {
  44707. private _leftTrigger;
  44708. private _rightTrigger;
  44709. private _onlefttriggerchanged;
  44710. private _onrighttriggerchanged;
  44711. private _onbuttondown;
  44712. private _onbuttonup;
  44713. private _ondpaddown;
  44714. private _ondpadup;
  44715. /** Observable raised when a button is pressed */
  44716. onButtonDownObservable: Observable<DualShockButton>;
  44717. /** Observable raised when a button is released */
  44718. onButtonUpObservable: Observable<DualShockButton>;
  44719. /** Observable raised when a pad is pressed */
  44720. onPadDownObservable: Observable<DualShockDpad>;
  44721. /** Observable raised when a pad is released */
  44722. onPadUpObservable: Observable<DualShockDpad>;
  44723. private _buttonCross;
  44724. private _buttonCircle;
  44725. private _buttonSquare;
  44726. private _buttonTriangle;
  44727. private _buttonShare;
  44728. private _buttonOptions;
  44729. private _buttonL1;
  44730. private _buttonR1;
  44731. private _buttonLeftStick;
  44732. private _buttonRightStick;
  44733. private _dPadUp;
  44734. private _dPadDown;
  44735. private _dPadLeft;
  44736. private _dPadRight;
  44737. /**
  44738. * Creates a new DualShock gamepad object
  44739. * @param id defines the id of this gamepad
  44740. * @param index defines its index
  44741. * @param gamepad defines the internal HTML gamepad object
  44742. */
  44743. constructor(id: string, index: number, gamepad: any);
  44744. /**
  44745. * Defines the callback to call when left trigger is pressed
  44746. * @param callback defines the callback to use
  44747. */
  44748. onlefttriggerchanged(callback: (value: number) => void): void;
  44749. /**
  44750. * Defines the callback to call when right trigger is pressed
  44751. * @param callback defines the callback to use
  44752. */
  44753. onrighttriggerchanged(callback: (value: number) => void): void;
  44754. /**
  44755. * Gets the left trigger value
  44756. */
  44757. get leftTrigger(): number;
  44758. /**
  44759. * Sets the left trigger value
  44760. */
  44761. set leftTrigger(newValue: number);
  44762. /**
  44763. * Gets the right trigger value
  44764. */
  44765. get rightTrigger(): number;
  44766. /**
  44767. * Sets the right trigger value
  44768. */
  44769. set rightTrigger(newValue: number);
  44770. /**
  44771. * Defines the callback to call when a button is pressed
  44772. * @param callback defines the callback to use
  44773. */
  44774. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44775. /**
  44776. * Defines the callback to call when a button is released
  44777. * @param callback defines the callback to use
  44778. */
  44779. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44780. /**
  44781. * Defines the callback to call when a pad is pressed
  44782. * @param callback defines the callback to use
  44783. */
  44784. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44785. /**
  44786. * Defines the callback to call when a pad is released
  44787. * @param callback defines the callback to use
  44788. */
  44789. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44790. private _setButtonValue;
  44791. private _setDPadValue;
  44792. /**
  44793. * Gets the value of the `Cross` button
  44794. */
  44795. get buttonCross(): number;
  44796. /**
  44797. * Sets the value of the `Cross` button
  44798. */
  44799. set buttonCross(value: number);
  44800. /**
  44801. * Gets the value of the `Circle` button
  44802. */
  44803. get buttonCircle(): number;
  44804. /**
  44805. * Sets the value of the `Circle` button
  44806. */
  44807. set buttonCircle(value: number);
  44808. /**
  44809. * Gets the value of the `Square` button
  44810. */
  44811. get buttonSquare(): number;
  44812. /**
  44813. * Sets the value of the `Square` button
  44814. */
  44815. set buttonSquare(value: number);
  44816. /**
  44817. * Gets the value of the `Triangle` button
  44818. */
  44819. get buttonTriangle(): number;
  44820. /**
  44821. * Sets the value of the `Triangle` button
  44822. */
  44823. set buttonTriangle(value: number);
  44824. /**
  44825. * Gets the value of the `Options` button
  44826. */
  44827. get buttonOptions(): number;
  44828. /**
  44829. * Sets the value of the `Options` button
  44830. */
  44831. set buttonOptions(value: number);
  44832. /**
  44833. * Gets the value of the `Share` button
  44834. */
  44835. get buttonShare(): number;
  44836. /**
  44837. * Sets the value of the `Share` button
  44838. */
  44839. set buttonShare(value: number);
  44840. /**
  44841. * Gets the value of the `L1` button
  44842. */
  44843. get buttonL1(): number;
  44844. /**
  44845. * Sets the value of the `L1` button
  44846. */
  44847. set buttonL1(value: number);
  44848. /**
  44849. * Gets the value of the `R1` button
  44850. */
  44851. get buttonR1(): number;
  44852. /**
  44853. * Sets the value of the `R1` button
  44854. */
  44855. set buttonR1(value: number);
  44856. /**
  44857. * Gets the value of the Left joystick
  44858. */
  44859. get buttonLeftStick(): number;
  44860. /**
  44861. * Sets the value of the Left joystick
  44862. */
  44863. set buttonLeftStick(value: number);
  44864. /**
  44865. * Gets the value of the Right joystick
  44866. */
  44867. get buttonRightStick(): number;
  44868. /**
  44869. * Sets the value of the Right joystick
  44870. */
  44871. set buttonRightStick(value: number);
  44872. /**
  44873. * Gets the value of D-pad up
  44874. */
  44875. get dPadUp(): number;
  44876. /**
  44877. * Sets the value of D-pad up
  44878. */
  44879. set dPadUp(value: number);
  44880. /**
  44881. * Gets the value of D-pad down
  44882. */
  44883. get dPadDown(): number;
  44884. /**
  44885. * Sets the value of D-pad down
  44886. */
  44887. set dPadDown(value: number);
  44888. /**
  44889. * Gets the value of D-pad left
  44890. */
  44891. get dPadLeft(): number;
  44892. /**
  44893. * Sets the value of D-pad left
  44894. */
  44895. set dPadLeft(value: number);
  44896. /**
  44897. * Gets the value of D-pad right
  44898. */
  44899. get dPadRight(): number;
  44900. /**
  44901. * Sets the value of D-pad right
  44902. */
  44903. set dPadRight(value: number);
  44904. /**
  44905. * Force the gamepad to synchronize with device values
  44906. */
  44907. update(): void;
  44908. /**
  44909. * Disposes the gamepad
  44910. */
  44911. dispose(): void;
  44912. }
  44913. }
  44914. declare module BABYLON {
  44915. /**
  44916. * Manager for handling gamepads
  44917. */
  44918. export class GamepadManager {
  44919. private _scene?;
  44920. private _babylonGamepads;
  44921. private _oneGamepadConnected;
  44922. /** @hidden */
  44923. _isMonitoring: boolean;
  44924. private _gamepadEventSupported;
  44925. private _gamepadSupport?;
  44926. /**
  44927. * observable to be triggered when the gamepad controller has been connected
  44928. */
  44929. onGamepadConnectedObservable: Observable<Gamepad>;
  44930. /**
  44931. * observable to be triggered when the gamepad controller has been disconnected
  44932. */
  44933. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44934. private _onGamepadConnectedEvent;
  44935. private _onGamepadDisconnectedEvent;
  44936. /**
  44937. * Initializes the gamepad manager
  44938. * @param _scene BabylonJS scene
  44939. */
  44940. constructor(_scene?: Scene | undefined);
  44941. /**
  44942. * The gamepads in the game pad manager
  44943. */
  44944. get gamepads(): Gamepad[];
  44945. /**
  44946. * Get the gamepad controllers based on type
  44947. * @param type The type of gamepad controller
  44948. * @returns Nullable gamepad
  44949. */
  44950. getGamepadByType(type?: number): Nullable<Gamepad>;
  44951. /**
  44952. * Disposes the gamepad manager
  44953. */
  44954. dispose(): void;
  44955. private _addNewGamepad;
  44956. private _startMonitoringGamepads;
  44957. private _stopMonitoringGamepads;
  44958. /** @hidden */
  44959. _checkGamepadsStatus(): void;
  44960. private _updateGamepadObjects;
  44961. }
  44962. }
  44963. declare module BABYLON {
  44964. interface Scene {
  44965. /** @hidden */
  44966. _gamepadManager: Nullable<GamepadManager>;
  44967. /**
  44968. * Gets the gamepad manager associated with the scene
  44969. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  44970. */
  44971. gamepadManager: GamepadManager;
  44972. }
  44973. /**
  44974. * Interface representing a free camera inputs manager
  44975. */
  44976. interface FreeCameraInputsManager {
  44977. /**
  44978. * Adds gamepad input support to the FreeCameraInputsManager.
  44979. * @returns the FreeCameraInputsManager
  44980. */
  44981. addGamepad(): FreeCameraInputsManager;
  44982. }
  44983. /**
  44984. * Interface representing an arc rotate camera inputs manager
  44985. */
  44986. interface ArcRotateCameraInputsManager {
  44987. /**
  44988. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44989. * @returns the camera inputs manager
  44990. */
  44991. addGamepad(): ArcRotateCameraInputsManager;
  44992. }
  44993. /**
  44994. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44995. */
  44996. export class GamepadSystemSceneComponent implements ISceneComponent {
  44997. /**
  44998. * The component name helpfull to identify the component in the list of scene components.
  44999. */
  45000. readonly name: string;
  45001. /**
  45002. * The scene the component belongs to.
  45003. */
  45004. scene: Scene;
  45005. /**
  45006. * Creates a new instance of the component for the given scene
  45007. * @param scene Defines the scene to register the component in
  45008. */
  45009. constructor(scene: Scene);
  45010. /**
  45011. * Registers the component in a given scene
  45012. */
  45013. register(): void;
  45014. /**
  45015. * Rebuilds the elements related to this component in case of
  45016. * context lost for instance.
  45017. */
  45018. rebuild(): void;
  45019. /**
  45020. * Disposes the component and the associated ressources
  45021. */
  45022. dispose(): void;
  45023. private _beforeCameraUpdate;
  45024. }
  45025. }
  45026. declare module BABYLON {
  45027. /**
  45028. * 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,
  45029. * which still works and will still be found in many Playgrounds.
  45030. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45031. */
  45032. export class UniversalCamera extends TouchCamera {
  45033. /**
  45034. * Defines the gamepad rotation sensiblity.
  45035. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45036. */
  45037. get gamepadAngularSensibility(): number;
  45038. set gamepadAngularSensibility(value: number);
  45039. /**
  45040. * Defines the gamepad move sensiblity.
  45041. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45042. */
  45043. get gamepadMoveSensibility(): number;
  45044. set gamepadMoveSensibility(value: number);
  45045. /**
  45046. * 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,
  45047. * which still works and will still be found in many Playgrounds.
  45048. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45049. * @param name Define the name of the camera in the scene
  45050. * @param position Define the start position of the camera in the scene
  45051. * @param scene Define the scene the camera belongs to
  45052. */
  45053. constructor(name: string, position: Vector3, scene: Scene);
  45054. /**
  45055. * Gets the current object class name.
  45056. * @return the class name
  45057. */
  45058. getClassName(): string;
  45059. }
  45060. }
  45061. declare module BABYLON {
  45062. /**
  45063. * This represents a FPS type of camera. This is only here for back compat purpose.
  45064. * Please use the UniversalCamera instead as both are identical.
  45065. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45066. */
  45067. export class GamepadCamera extends UniversalCamera {
  45068. /**
  45069. * Instantiates a new Gamepad Camera
  45070. * This represents a FPS type of camera. This is only here for back compat purpose.
  45071. * Please use the UniversalCamera instead as both are identical.
  45072. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45073. * @param name Define the name of the camera in the scene
  45074. * @param position Define the start position of the camera in the scene
  45075. * @param scene Define the scene the camera belongs to
  45076. */
  45077. constructor(name: string, position: Vector3, scene: Scene);
  45078. /**
  45079. * Gets the current object class name.
  45080. * @return the class name
  45081. */
  45082. getClassName(): string;
  45083. }
  45084. }
  45085. declare module BABYLON {
  45086. /** @hidden */
  45087. export var passPixelShader: {
  45088. name: string;
  45089. shader: string;
  45090. };
  45091. }
  45092. declare module BABYLON {
  45093. /** @hidden */
  45094. export var passCubePixelShader: {
  45095. name: string;
  45096. shader: string;
  45097. };
  45098. }
  45099. declare module BABYLON {
  45100. /**
  45101. * PassPostProcess which produces an output the same as it's input
  45102. */
  45103. export class PassPostProcess extends PostProcess {
  45104. /**
  45105. * Creates the PassPostProcess
  45106. * @param name The name of the effect.
  45107. * @param options The required width/height ratio to downsize to before computing the render pass.
  45108. * @param camera The camera to apply the render pass to.
  45109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45110. * @param engine The engine which the post process will be applied. (default: current engine)
  45111. * @param reusable If the post process can be reused on the same frame. (default: false)
  45112. * @param textureType The type of texture to be used when performing the post processing.
  45113. * @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)
  45114. */
  45115. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45116. }
  45117. /**
  45118. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45119. */
  45120. export class PassCubePostProcess extends PostProcess {
  45121. private _face;
  45122. /**
  45123. * Gets or sets the cube face to display.
  45124. * * 0 is +X
  45125. * * 1 is -X
  45126. * * 2 is +Y
  45127. * * 3 is -Y
  45128. * * 4 is +Z
  45129. * * 5 is -Z
  45130. */
  45131. get face(): number;
  45132. set face(value: number);
  45133. /**
  45134. * Creates the PassCubePostProcess
  45135. * @param name The name of the effect.
  45136. * @param options The required width/height ratio to downsize to before computing the render pass.
  45137. * @param camera The camera to apply the render pass to.
  45138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45139. * @param engine The engine which the post process will be applied. (default: current engine)
  45140. * @param reusable If the post process can be reused on the same frame. (default: false)
  45141. * @param textureType The type of texture to be used when performing the post processing.
  45142. * @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)
  45143. */
  45144. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45145. }
  45146. }
  45147. declare module BABYLON {
  45148. /** @hidden */
  45149. export var anaglyphPixelShader: {
  45150. name: string;
  45151. shader: string;
  45152. };
  45153. }
  45154. declare module BABYLON {
  45155. /**
  45156. * Postprocess used to generate anaglyphic rendering
  45157. */
  45158. export class AnaglyphPostProcess extends PostProcess {
  45159. private _passedProcess;
  45160. /**
  45161. * Creates a new AnaglyphPostProcess
  45162. * @param name defines postprocess name
  45163. * @param options defines creation options or target ratio scale
  45164. * @param rigCameras defines cameras using this postprocess
  45165. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45166. * @param engine defines hosting engine
  45167. * @param reusable defines if the postprocess will be reused multiple times per frame
  45168. */
  45169. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45170. }
  45171. }
  45172. declare module BABYLON {
  45173. /**
  45174. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45175. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45176. */
  45177. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45178. /**
  45179. * Creates a new AnaglyphArcRotateCamera
  45180. * @param name defines camera name
  45181. * @param alpha defines alpha angle (in radians)
  45182. * @param beta defines beta angle (in radians)
  45183. * @param radius defines radius
  45184. * @param target defines camera target
  45185. * @param interaxialDistance defines distance between each color axis
  45186. * @param scene defines the hosting scene
  45187. */
  45188. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45189. /**
  45190. * Gets camera class name
  45191. * @returns AnaglyphArcRotateCamera
  45192. */
  45193. getClassName(): string;
  45194. }
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45199. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45200. */
  45201. export class AnaglyphFreeCamera extends FreeCamera {
  45202. /**
  45203. * Creates a new AnaglyphFreeCamera
  45204. * @param name defines camera name
  45205. * @param position defines initial position
  45206. * @param interaxialDistance defines distance between each color axis
  45207. * @param scene defines the hosting scene
  45208. */
  45209. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45210. /**
  45211. * Gets camera class name
  45212. * @returns AnaglyphFreeCamera
  45213. */
  45214. getClassName(): string;
  45215. }
  45216. }
  45217. declare module BABYLON {
  45218. /**
  45219. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45220. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45221. */
  45222. export class AnaglyphGamepadCamera extends GamepadCamera {
  45223. /**
  45224. * Creates a new AnaglyphGamepadCamera
  45225. * @param name defines camera name
  45226. * @param position defines initial position
  45227. * @param interaxialDistance defines distance between each color axis
  45228. * @param scene defines the hosting scene
  45229. */
  45230. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45231. /**
  45232. * Gets camera class name
  45233. * @returns AnaglyphGamepadCamera
  45234. */
  45235. getClassName(): string;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45241. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45242. */
  45243. export class AnaglyphUniversalCamera extends UniversalCamera {
  45244. /**
  45245. * Creates a new AnaglyphUniversalCamera
  45246. * @param name defines camera name
  45247. * @param position defines initial position
  45248. * @param interaxialDistance defines distance between each color axis
  45249. * @param scene defines the hosting scene
  45250. */
  45251. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45252. /**
  45253. * Gets camera class name
  45254. * @returns AnaglyphUniversalCamera
  45255. */
  45256. getClassName(): string;
  45257. }
  45258. }
  45259. declare module BABYLON {
  45260. /**
  45261. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45262. * @see https://doc.babylonjs.com/features/cameras
  45263. */
  45264. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45265. /**
  45266. * Creates a new StereoscopicArcRotateCamera
  45267. * @param name defines camera name
  45268. * @param alpha defines alpha angle (in radians)
  45269. * @param beta defines beta angle (in radians)
  45270. * @param radius defines radius
  45271. * @param target defines camera target
  45272. * @param interaxialDistance defines distance between each color axis
  45273. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45274. * @param scene defines the hosting scene
  45275. */
  45276. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45277. /**
  45278. * Gets camera class name
  45279. * @returns StereoscopicArcRotateCamera
  45280. */
  45281. getClassName(): string;
  45282. }
  45283. }
  45284. declare module BABYLON {
  45285. /**
  45286. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45287. * @see https://doc.babylonjs.com/features/cameras
  45288. */
  45289. export class StereoscopicFreeCamera extends FreeCamera {
  45290. /**
  45291. * Creates a new StereoscopicFreeCamera
  45292. * @param name defines camera name
  45293. * @param position defines initial position
  45294. * @param interaxialDistance defines distance between each color axis
  45295. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45296. * @param scene defines the hosting scene
  45297. */
  45298. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45299. /**
  45300. * Gets camera class name
  45301. * @returns StereoscopicFreeCamera
  45302. */
  45303. getClassName(): string;
  45304. }
  45305. }
  45306. declare module BABYLON {
  45307. /**
  45308. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45309. * @see https://doc.babylonjs.com/features/cameras
  45310. */
  45311. export class StereoscopicGamepadCamera extends GamepadCamera {
  45312. /**
  45313. * Creates a new StereoscopicGamepadCamera
  45314. * @param name defines camera name
  45315. * @param position defines initial position
  45316. * @param interaxialDistance defines distance between each color axis
  45317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45318. * @param scene defines the hosting scene
  45319. */
  45320. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45321. /**
  45322. * Gets camera class name
  45323. * @returns StereoscopicGamepadCamera
  45324. */
  45325. getClassName(): string;
  45326. }
  45327. }
  45328. declare module BABYLON {
  45329. /**
  45330. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45331. * @see https://doc.babylonjs.com/features/cameras
  45332. */
  45333. export class StereoscopicUniversalCamera extends UniversalCamera {
  45334. /**
  45335. * Creates a new StereoscopicUniversalCamera
  45336. * @param name defines camera name
  45337. * @param position defines initial position
  45338. * @param interaxialDistance defines distance between each color axis
  45339. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45340. * @param scene defines the hosting scene
  45341. */
  45342. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45343. /**
  45344. * Gets camera class name
  45345. * @returns StereoscopicUniversalCamera
  45346. */
  45347. getClassName(): string;
  45348. }
  45349. }
  45350. declare module BABYLON {
  45351. /**
  45352. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45353. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45354. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45355. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45356. */
  45357. export class VirtualJoysticksCamera extends FreeCamera {
  45358. /**
  45359. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45360. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45361. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45362. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45363. * @param name Define the name of the camera in the scene
  45364. * @param position Define the start position of the camera in the scene
  45365. * @param scene Define the scene the camera belongs to
  45366. */
  45367. constructor(name: string, position: Vector3, scene: Scene);
  45368. /**
  45369. * Gets the current object class name.
  45370. * @return the class name
  45371. */
  45372. getClassName(): string;
  45373. }
  45374. }
  45375. declare module BABYLON {
  45376. /**
  45377. * This represents all the required metrics to create a VR camera.
  45378. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45379. */
  45380. export class VRCameraMetrics {
  45381. /**
  45382. * Define the horizontal resolution off the screen.
  45383. */
  45384. hResolution: number;
  45385. /**
  45386. * Define the vertical resolution off the screen.
  45387. */
  45388. vResolution: number;
  45389. /**
  45390. * Define the horizontal screen size.
  45391. */
  45392. hScreenSize: number;
  45393. /**
  45394. * Define the vertical screen size.
  45395. */
  45396. vScreenSize: number;
  45397. /**
  45398. * Define the vertical screen center position.
  45399. */
  45400. vScreenCenter: number;
  45401. /**
  45402. * Define the distance of the eyes to the screen.
  45403. */
  45404. eyeToScreenDistance: number;
  45405. /**
  45406. * Define the distance between both lenses
  45407. */
  45408. lensSeparationDistance: number;
  45409. /**
  45410. * Define the distance between both viewer's eyes.
  45411. */
  45412. interpupillaryDistance: number;
  45413. /**
  45414. * Define the distortion factor of the VR postprocess.
  45415. * Please, touch with care.
  45416. */
  45417. distortionK: number[];
  45418. /**
  45419. * Define the chromatic aberration correction factors for the VR post process.
  45420. */
  45421. chromaAbCorrection: number[];
  45422. /**
  45423. * Define the scale factor of the post process.
  45424. * The smaller the better but the slower.
  45425. */
  45426. postProcessScaleFactor: number;
  45427. /**
  45428. * Define an offset for the lens center.
  45429. */
  45430. lensCenterOffset: number;
  45431. /**
  45432. * Define if the current vr camera should compensate the distortion of the lense or not.
  45433. */
  45434. compensateDistortion: boolean;
  45435. /**
  45436. * Defines if multiview should be enabled when rendering (Default: false)
  45437. */
  45438. multiviewEnabled: boolean;
  45439. /**
  45440. * Gets the rendering aspect ratio based on the provided resolutions.
  45441. */
  45442. get aspectRatio(): number;
  45443. /**
  45444. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45445. */
  45446. get aspectRatioFov(): number;
  45447. /**
  45448. * @hidden
  45449. */
  45450. get leftHMatrix(): Matrix;
  45451. /**
  45452. * @hidden
  45453. */
  45454. get rightHMatrix(): Matrix;
  45455. /**
  45456. * @hidden
  45457. */
  45458. get leftPreViewMatrix(): Matrix;
  45459. /**
  45460. * @hidden
  45461. */
  45462. get rightPreViewMatrix(): Matrix;
  45463. /**
  45464. * Get the default VRMetrics based on the most generic setup.
  45465. * @returns the default vr metrics
  45466. */
  45467. static GetDefault(): VRCameraMetrics;
  45468. }
  45469. }
  45470. declare module BABYLON {
  45471. /** @hidden */
  45472. export var vrDistortionCorrectionPixelShader: {
  45473. name: string;
  45474. shader: string;
  45475. };
  45476. }
  45477. declare module BABYLON {
  45478. /**
  45479. * VRDistortionCorrectionPostProcess used for mobile VR
  45480. */
  45481. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45482. private _isRightEye;
  45483. private _distortionFactors;
  45484. private _postProcessScaleFactor;
  45485. private _lensCenterOffset;
  45486. private _scaleIn;
  45487. private _scaleFactor;
  45488. private _lensCenter;
  45489. /**
  45490. * Initializes the VRDistortionCorrectionPostProcess
  45491. * @param name The name of the effect.
  45492. * @param camera The camera to apply the render pass to.
  45493. * @param isRightEye If this is for the right eye distortion
  45494. * @param vrMetrics All the required metrics for the VR camera
  45495. */
  45496. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45497. }
  45498. }
  45499. declare module BABYLON {
  45500. /**
  45501. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45502. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45503. */
  45504. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45505. /**
  45506. * Creates a new VRDeviceOrientationArcRotateCamera
  45507. * @param name defines camera name
  45508. * @param alpha defines the camera rotation along the logitudinal axis
  45509. * @param beta defines the camera rotation along the latitudinal axis
  45510. * @param radius defines the camera distance from its target
  45511. * @param target defines the camera target
  45512. * @param scene defines the scene the camera belongs to
  45513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45515. */
  45516. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45517. /**
  45518. * Gets camera class name
  45519. * @returns VRDeviceOrientationArcRotateCamera
  45520. */
  45521. getClassName(): string;
  45522. }
  45523. }
  45524. declare module BABYLON {
  45525. /**
  45526. * Camera used to simulate VR rendering (based on FreeCamera)
  45527. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45528. */
  45529. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45530. /**
  45531. * Creates a new VRDeviceOrientationFreeCamera
  45532. * @param name defines camera name
  45533. * @param position defines the start position of the camera
  45534. * @param scene defines the scene the camera belongs to
  45535. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45536. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45537. */
  45538. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45539. /**
  45540. * Gets camera class name
  45541. * @returns VRDeviceOrientationFreeCamera
  45542. */
  45543. getClassName(): string;
  45544. }
  45545. }
  45546. declare module BABYLON {
  45547. /**
  45548. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45549. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45550. */
  45551. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45552. /**
  45553. * Creates a new VRDeviceOrientationGamepadCamera
  45554. * @param name defines camera name
  45555. * @param position defines the start position of the camera
  45556. * @param scene defines the scene the camera belongs to
  45557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45559. */
  45560. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45561. /**
  45562. * Gets camera class name
  45563. * @returns VRDeviceOrientationGamepadCamera
  45564. */
  45565. getClassName(): string;
  45566. }
  45567. }
  45568. declare module BABYLON {
  45569. /**
  45570. * A class extending Texture allowing drawing on a texture
  45571. * @see https://doc.babylonjs.com/how_to/dynamictexture
  45572. */
  45573. export class DynamicTexture extends Texture {
  45574. private _generateMipMaps;
  45575. private _canvas;
  45576. private _context;
  45577. /**
  45578. * Creates a DynamicTexture
  45579. * @param name defines the name of the texture
  45580. * @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
  45581. * @param scene defines the scene where you want the texture
  45582. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45583. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45584. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45585. */
  45586. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45587. /**
  45588. * Get the current class name of the texture useful for serialization or dynamic coding.
  45589. * @returns "DynamicTexture"
  45590. */
  45591. getClassName(): string;
  45592. /**
  45593. * Gets the current state of canRescale
  45594. */
  45595. get canRescale(): boolean;
  45596. private _recreate;
  45597. /**
  45598. * Scales the texture
  45599. * @param ratio the scale factor to apply to both width and height
  45600. */
  45601. scale(ratio: number): void;
  45602. /**
  45603. * Resizes the texture
  45604. * @param width the new width
  45605. * @param height the new height
  45606. */
  45607. scaleTo(width: number, height: number): void;
  45608. /**
  45609. * Gets the context of the canvas used by the texture
  45610. * @returns the canvas context of the dynamic texture
  45611. */
  45612. getContext(): CanvasRenderingContext2D;
  45613. /**
  45614. * Clears the texture
  45615. */
  45616. clear(): void;
  45617. /**
  45618. * Updates the texture
  45619. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45620. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45621. */
  45622. update(invertY?: boolean, premulAlpha?: boolean): void;
  45623. /**
  45624. * Draws text onto the texture
  45625. * @param text defines the text to be drawn
  45626. * @param x defines the placement of the text from the left
  45627. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45628. * @param font defines the font to be used with font-style, font-size, font-name
  45629. * @param color defines the color used for the text
  45630. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45631. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45632. * @param update defines whether texture is immediately update (default is true)
  45633. */
  45634. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45635. /**
  45636. * Clones the texture
  45637. * @returns the clone of the texture.
  45638. */
  45639. clone(): DynamicTexture;
  45640. /**
  45641. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45642. * @returns a serialized dynamic texture object
  45643. */
  45644. serialize(): any;
  45645. private _IsCanvasElement;
  45646. /** @hidden */
  45647. _rebuild(): void;
  45648. }
  45649. }
  45650. declare module BABYLON {
  45651. /** @hidden */
  45652. export var imageProcessingPixelShader: {
  45653. name: string;
  45654. shader: string;
  45655. };
  45656. }
  45657. declare module BABYLON {
  45658. /**
  45659. * ImageProcessingPostProcess
  45660. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45661. */
  45662. export class ImageProcessingPostProcess extends PostProcess {
  45663. /**
  45664. * Default configuration related to image processing available in the PBR Material.
  45665. */
  45666. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45667. /**
  45668. * Gets the image processing configuration used either in this material.
  45669. */
  45670. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45671. /**
  45672. * Sets the Default image processing configuration used either in the this material.
  45673. *
  45674. * If sets to null, the scene one is in use.
  45675. */
  45676. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45677. /**
  45678. * Keep track of the image processing observer to allow dispose and replace.
  45679. */
  45680. private _imageProcessingObserver;
  45681. /**
  45682. * Attaches a new image processing configuration to the PBR Material.
  45683. * @param configuration
  45684. */
  45685. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45686. /**
  45687. * If the post process is supported.
  45688. */
  45689. get isSupported(): boolean;
  45690. /**
  45691. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45692. */
  45693. get colorCurves(): Nullable<ColorCurves>;
  45694. /**
  45695. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45696. */
  45697. set colorCurves(value: Nullable<ColorCurves>);
  45698. /**
  45699. * Gets wether the color curves effect is enabled.
  45700. */
  45701. get colorCurvesEnabled(): boolean;
  45702. /**
  45703. * Sets wether the color curves effect is enabled.
  45704. */
  45705. set colorCurvesEnabled(value: boolean);
  45706. /**
  45707. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45708. */
  45709. get colorGradingTexture(): Nullable<BaseTexture>;
  45710. /**
  45711. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45712. */
  45713. set colorGradingTexture(value: Nullable<BaseTexture>);
  45714. /**
  45715. * Gets wether the color grading effect is enabled.
  45716. */
  45717. get colorGradingEnabled(): boolean;
  45718. /**
  45719. * Gets wether the color grading effect is enabled.
  45720. */
  45721. set colorGradingEnabled(value: boolean);
  45722. /**
  45723. * Gets exposure used in the effect.
  45724. */
  45725. get exposure(): number;
  45726. /**
  45727. * Sets exposure used in the effect.
  45728. */
  45729. set exposure(value: number);
  45730. /**
  45731. * Gets wether tonemapping is enabled or not.
  45732. */
  45733. get toneMappingEnabled(): boolean;
  45734. /**
  45735. * Sets wether tonemapping is enabled or not
  45736. */
  45737. set toneMappingEnabled(value: boolean);
  45738. /**
  45739. * Gets the type of tone mapping effect.
  45740. */
  45741. get toneMappingType(): number;
  45742. /**
  45743. * Sets the type of tone mapping effect.
  45744. */
  45745. set toneMappingType(value: number);
  45746. /**
  45747. * Gets contrast used in the effect.
  45748. */
  45749. get contrast(): number;
  45750. /**
  45751. * Sets contrast used in the effect.
  45752. */
  45753. set contrast(value: number);
  45754. /**
  45755. * Gets Vignette stretch size.
  45756. */
  45757. get vignetteStretch(): number;
  45758. /**
  45759. * Sets Vignette stretch size.
  45760. */
  45761. set vignetteStretch(value: number);
  45762. /**
  45763. * Gets Vignette centre X Offset.
  45764. */
  45765. get vignetteCentreX(): number;
  45766. /**
  45767. * Sets Vignette centre X Offset.
  45768. */
  45769. set vignetteCentreX(value: number);
  45770. /**
  45771. * Gets Vignette centre Y Offset.
  45772. */
  45773. get vignetteCentreY(): number;
  45774. /**
  45775. * Sets Vignette centre Y Offset.
  45776. */
  45777. set vignetteCentreY(value: number);
  45778. /**
  45779. * Gets Vignette weight or intensity of the vignette effect.
  45780. */
  45781. get vignetteWeight(): number;
  45782. /**
  45783. * Sets Vignette weight or intensity of the vignette effect.
  45784. */
  45785. set vignetteWeight(value: number);
  45786. /**
  45787. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45788. * if vignetteEnabled is set to true.
  45789. */
  45790. get vignetteColor(): Color4;
  45791. /**
  45792. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45793. * if vignetteEnabled is set to true.
  45794. */
  45795. set vignetteColor(value: Color4);
  45796. /**
  45797. * Gets Camera field of view used by the Vignette effect.
  45798. */
  45799. get vignetteCameraFov(): number;
  45800. /**
  45801. * Sets Camera field of view used by the Vignette effect.
  45802. */
  45803. set vignetteCameraFov(value: number);
  45804. /**
  45805. * Gets the vignette blend mode allowing different kind of effect.
  45806. */
  45807. get vignetteBlendMode(): number;
  45808. /**
  45809. * Sets the vignette blend mode allowing different kind of effect.
  45810. */
  45811. set vignetteBlendMode(value: number);
  45812. /**
  45813. * Gets wether the vignette effect is enabled.
  45814. */
  45815. get vignetteEnabled(): boolean;
  45816. /**
  45817. * Sets wether the vignette effect is enabled.
  45818. */
  45819. set vignetteEnabled(value: boolean);
  45820. private _fromLinearSpace;
  45821. /**
  45822. * Gets wether the input of the processing is in Gamma or Linear Space.
  45823. */
  45824. get fromLinearSpace(): boolean;
  45825. /**
  45826. * Sets wether the input of the processing is in Gamma or Linear Space.
  45827. */
  45828. set fromLinearSpace(value: boolean);
  45829. /**
  45830. * Defines cache preventing GC.
  45831. */
  45832. private _defines;
  45833. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45834. /**
  45835. * "ImageProcessingPostProcess"
  45836. * @returns "ImageProcessingPostProcess"
  45837. */
  45838. getClassName(): string;
  45839. protected _updateParameters(): void;
  45840. dispose(camera?: Camera): void;
  45841. }
  45842. }
  45843. declare module BABYLON {
  45844. /**
  45845. * Class containing static functions to help procedurally build meshes
  45846. */
  45847. export class GroundBuilder {
  45848. /**
  45849. * Creates a ground mesh
  45850. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45851. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45852. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45853. * @param name defines the name of the mesh
  45854. * @param options defines the options used to create the mesh
  45855. * @param scene defines the hosting scene
  45856. * @returns the ground mesh
  45857. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45858. */
  45859. static CreateGround(name: string, options: {
  45860. width?: number;
  45861. height?: number;
  45862. subdivisions?: number;
  45863. subdivisionsX?: number;
  45864. subdivisionsY?: number;
  45865. updatable?: boolean;
  45866. }, scene: any): Mesh;
  45867. /**
  45868. * Creates a tiled ground mesh
  45869. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45870. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45871. * * 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
  45872. * * 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
  45873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45874. * @param name defines the name of the mesh
  45875. * @param options defines the options used to create the mesh
  45876. * @param scene defines the hosting scene
  45877. * @returns the tiled ground mesh
  45878. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45879. */
  45880. static CreateTiledGround(name: string, options: {
  45881. xmin: number;
  45882. zmin: number;
  45883. xmax: number;
  45884. zmax: number;
  45885. subdivisions?: {
  45886. w: number;
  45887. h: number;
  45888. };
  45889. precision?: {
  45890. w: number;
  45891. h: number;
  45892. };
  45893. updatable?: boolean;
  45894. }, scene?: Nullable<Scene>): Mesh;
  45895. /**
  45896. * Creates a ground mesh from a height map
  45897. * * The parameter `url` sets the URL of the height map image resource.
  45898. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45899. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45900. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45901. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45902. * * 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.
  45903. * * 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).
  45904. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45906. * @param name defines the name of the mesh
  45907. * @param url defines the url to the height map
  45908. * @param options defines the options used to create the mesh
  45909. * @param scene defines the hosting scene
  45910. * @returns the ground mesh
  45911. * @see https://doc.babylonjs.com/babylon101/height_map
  45912. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45913. */
  45914. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45915. width?: number;
  45916. height?: number;
  45917. subdivisions?: number;
  45918. minHeight?: number;
  45919. maxHeight?: number;
  45920. colorFilter?: Color3;
  45921. alphaFilter?: number;
  45922. updatable?: boolean;
  45923. onReady?: (mesh: GroundMesh) => void;
  45924. }, scene?: Nullable<Scene>): GroundMesh;
  45925. }
  45926. }
  45927. declare module BABYLON {
  45928. /**
  45929. * Class containing static functions to help procedurally build meshes
  45930. */
  45931. export class TorusBuilder {
  45932. /**
  45933. * Creates a torus mesh
  45934. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45935. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45936. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45938. * * 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
  45939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45940. * @param name defines the name of the mesh
  45941. * @param options defines the options used to create the mesh
  45942. * @param scene defines the hosting scene
  45943. * @returns the torus mesh
  45944. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45945. */
  45946. static CreateTorus(name: string, options: {
  45947. diameter?: number;
  45948. thickness?: number;
  45949. tessellation?: number;
  45950. updatable?: boolean;
  45951. sideOrientation?: number;
  45952. frontUVs?: Vector4;
  45953. backUVs?: Vector4;
  45954. }, scene: any): Mesh;
  45955. }
  45956. }
  45957. declare module BABYLON {
  45958. /**
  45959. * Class containing static functions to help procedurally build meshes
  45960. */
  45961. export class CylinderBuilder {
  45962. /**
  45963. * Creates a cylinder or a cone mesh
  45964. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45965. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45966. * * 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.
  45967. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45968. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45969. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45970. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45971. * * 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).
  45972. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45973. * * 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).
  45974. * * 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
  45975. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45976. * * 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
  45977. * * 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.
  45978. * * If `enclose` is false, a ring surface is one element.
  45979. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45980. * * 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
  45981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45982. * * 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
  45983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45984. * @param name defines the name of the mesh
  45985. * @param options defines the options used to create the mesh
  45986. * @param scene defines the hosting scene
  45987. * @returns the cylinder mesh
  45988. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45989. */
  45990. static CreateCylinder(name: string, options: {
  45991. height?: number;
  45992. diameterTop?: number;
  45993. diameterBottom?: number;
  45994. diameter?: number;
  45995. tessellation?: number;
  45996. subdivisions?: number;
  45997. arc?: number;
  45998. faceColors?: Color4[];
  45999. faceUV?: Vector4[];
  46000. updatable?: boolean;
  46001. hasRings?: boolean;
  46002. enclose?: boolean;
  46003. cap?: number;
  46004. sideOrientation?: number;
  46005. frontUVs?: Vector4;
  46006. backUVs?: Vector4;
  46007. }, scene: any): Mesh;
  46008. }
  46009. }
  46010. declare module BABYLON {
  46011. /**
  46012. * States of the webXR experience
  46013. */
  46014. export enum WebXRState {
  46015. /**
  46016. * Transitioning to being in XR mode
  46017. */
  46018. ENTERING_XR = 0,
  46019. /**
  46020. * Transitioning to non XR mode
  46021. */
  46022. EXITING_XR = 1,
  46023. /**
  46024. * In XR mode and presenting
  46025. */
  46026. IN_XR = 2,
  46027. /**
  46028. * Not entered XR mode
  46029. */
  46030. NOT_IN_XR = 3
  46031. }
  46032. /**
  46033. * Abstraction of the XR render target
  46034. */
  46035. export interface WebXRRenderTarget extends IDisposable {
  46036. /**
  46037. * xrpresent context of the canvas which can be used to display/mirror xr content
  46038. */
  46039. canvasContext: WebGLRenderingContext;
  46040. /**
  46041. * xr layer for the canvas
  46042. */
  46043. xrLayer: Nullable<XRWebGLLayer>;
  46044. /**
  46045. * Initializes the xr layer for the session
  46046. * @param xrSession xr session
  46047. * @returns a promise that will resolve once the XR Layer has been created
  46048. */
  46049. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46050. }
  46051. }
  46052. declare module BABYLON {
  46053. /**
  46054. * COnfiguration object for WebXR output canvas
  46055. */
  46056. export class WebXRManagedOutputCanvasOptions {
  46057. /**
  46058. * An optional canvas in case you wish to create it yourself and provide it here.
  46059. * If not provided, a new canvas will be created
  46060. */
  46061. canvasElement?: HTMLCanvasElement;
  46062. /**
  46063. * Options for this XR Layer output
  46064. */
  46065. canvasOptions?: XRWebGLLayerOptions;
  46066. /**
  46067. * CSS styling for a newly created canvas (if not provided)
  46068. */
  46069. newCanvasCssStyle?: string;
  46070. /**
  46071. * Get the default values of the configuration object
  46072. * @returns default values of this configuration object
  46073. */
  46074. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46075. }
  46076. /**
  46077. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46078. */
  46079. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46080. private _options;
  46081. private _canvas;
  46082. private _engine;
  46083. private _originalCanvasSize;
  46084. /**
  46085. * Rendering context of the canvas which can be used to display/mirror xr content
  46086. */
  46087. canvasContext: WebGLRenderingContext;
  46088. /**
  46089. * xr layer for the canvas
  46090. */
  46091. xrLayer: Nullable<XRWebGLLayer>;
  46092. /**
  46093. * Obseervers registered here will be triggered when the xr layer was initialized
  46094. */
  46095. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46096. /**
  46097. * Initializes the canvas to be added/removed upon entering/exiting xr
  46098. * @param _xrSessionManager The XR Session manager
  46099. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46100. */
  46101. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46102. /**
  46103. * Disposes of the object
  46104. */
  46105. dispose(): void;
  46106. /**
  46107. * Initializes the xr layer for the session
  46108. * @param xrSession xr session
  46109. * @returns a promise that will resolve once the XR Layer has been created
  46110. */
  46111. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46112. private _addCanvas;
  46113. private _removeCanvas;
  46114. private _setCanvasSize;
  46115. private _setManagedOutputCanvas;
  46116. }
  46117. }
  46118. declare module BABYLON {
  46119. /**
  46120. * Manages an XRSession to work with Babylon's engine
  46121. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46122. */
  46123. export class WebXRSessionManager implements IDisposable {
  46124. /** The scene which the session should be created for */
  46125. scene: Scene;
  46126. private _referenceSpace;
  46127. private _rttProvider;
  46128. private _sessionEnded;
  46129. private _xrNavigator;
  46130. private baseLayer;
  46131. /**
  46132. * The base reference space from which the session started. good if you want to reset your
  46133. * reference space
  46134. */
  46135. baseReferenceSpace: XRReferenceSpace;
  46136. /**
  46137. * Current XR frame
  46138. */
  46139. currentFrame: Nullable<XRFrame>;
  46140. /** WebXR timestamp updated every frame */
  46141. currentTimestamp: number;
  46142. /**
  46143. * Used just in case of a failure to initialize an immersive session.
  46144. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46145. */
  46146. defaultHeightCompensation: number;
  46147. /**
  46148. * Fires every time a new xrFrame arrives which can be used to update the camera
  46149. */
  46150. onXRFrameObservable: Observable<XRFrame>;
  46151. /**
  46152. * Fires when the reference space changed
  46153. */
  46154. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46155. /**
  46156. * Fires when the xr session is ended either by the device or manually done
  46157. */
  46158. onXRSessionEnded: Observable<any>;
  46159. /**
  46160. * Fires when the xr session is ended either by the device or manually done
  46161. */
  46162. onXRSessionInit: Observable<XRSession>;
  46163. /**
  46164. * Underlying xr session
  46165. */
  46166. session: XRSession;
  46167. /**
  46168. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46169. * or get the offset the player is currently at.
  46170. */
  46171. viewerReferenceSpace: XRReferenceSpace;
  46172. /**
  46173. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46174. * @param scene The scene which the session should be created for
  46175. */
  46176. constructor(
  46177. /** The scene which the session should be created for */
  46178. scene: Scene);
  46179. /**
  46180. * The current reference space used in this session. This reference space can constantly change!
  46181. * It is mainly used to offset the camera's position.
  46182. */
  46183. get referenceSpace(): XRReferenceSpace;
  46184. /**
  46185. * Set a new reference space and triggers the observable
  46186. */
  46187. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46188. /**
  46189. * Disposes of the session manager
  46190. */
  46191. dispose(): void;
  46192. /**
  46193. * Stops the xrSession and restores the render loop
  46194. * @returns Promise which resolves after it exits XR
  46195. */
  46196. exitXRAsync(): Promise<void>;
  46197. /**
  46198. * Gets the correct render target texture to be rendered this frame for this eye
  46199. * @param eye the eye for which to get the render target
  46200. * @returns the render target for the specified eye
  46201. */
  46202. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46203. /**
  46204. * Creates a WebXRRenderTarget object for the XR session
  46205. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46206. * @param options optional options to provide when creating a new render target
  46207. * @returns a WebXR render target to which the session can render
  46208. */
  46209. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46210. /**
  46211. * Initializes the manager
  46212. * After initialization enterXR can be called to start an XR session
  46213. * @returns Promise which resolves after it is initialized
  46214. */
  46215. initializeAsync(): Promise<void>;
  46216. /**
  46217. * Initializes an xr session
  46218. * @param xrSessionMode mode to initialize
  46219. * @param xrSessionInit defines optional and required values to pass to the session builder
  46220. * @returns a promise which will resolve once the session has been initialized
  46221. */
  46222. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46223. /**
  46224. * Checks if a session would be supported for the creation options specified
  46225. * @param sessionMode session mode to check if supported eg. immersive-vr
  46226. * @returns A Promise that resolves to true if supported and false if not
  46227. */
  46228. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46229. /**
  46230. * Resets the reference space to the one started the session
  46231. */
  46232. resetReferenceSpace(): void;
  46233. /**
  46234. * Starts rendering to the xr layer
  46235. */
  46236. runXRRenderLoop(): void;
  46237. /**
  46238. * Sets the reference space on the xr session
  46239. * @param referenceSpaceType space to set
  46240. * @returns a promise that will resolve once the reference space has been set
  46241. */
  46242. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46243. /**
  46244. * Updates the render state of the session
  46245. * @param state state to set
  46246. * @returns a promise that resolves once the render state has been updated
  46247. */
  46248. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46249. /**
  46250. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46251. * @param sessionMode defines the session to test
  46252. * @returns a promise with boolean as final value
  46253. */
  46254. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46255. private _createRenderTargetTexture;
  46256. }
  46257. }
  46258. declare module BABYLON {
  46259. /**
  46260. * WebXR Camera which holds the views for the xrSession
  46261. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46262. */
  46263. export class WebXRCamera extends FreeCamera {
  46264. private _xrSessionManager;
  46265. private _firstFrame;
  46266. private _referenceQuaternion;
  46267. private _referencedPosition;
  46268. private _xrInvPositionCache;
  46269. private _xrInvQuaternionCache;
  46270. /**
  46271. * Should position compensation execute on first frame.
  46272. * This is used when copying the position from a native (non XR) camera
  46273. */
  46274. compensateOnFirstFrame: boolean;
  46275. /**
  46276. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46277. * @param name the name of the camera
  46278. * @param scene the scene to add the camera to
  46279. * @param _xrSessionManager a constructed xr session manager
  46280. */
  46281. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46282. /**
  46283. * Return the user's height, unrelated to the current ground.
  46284. * This will be the y position of this camera, when ground level is 0.
  46285. */
  46286. get realWorldHeight(): number;
  46287. /** @hidden */
  46288. _updateForDualEyeDebugging(): void;
  46289. /**
  46290. * Sets this camera's transformation based on a non-vr camera
  46291. * @param otherCamera the non-vr camera to copy the transformation from
  46292. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46293. */
  46294. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46295. /**
  46296. * Gets the current instance class name ("WebXRCamera").
  46297. * @returns the class name
  46298. */
  46299. getClassName(): string;
  46300. private _rotate180;
  46301. private _updateFromXRSession;
  46302. private _updateNumberOfRigCameras;
  46303. private _updateReferenceSpace;
  46304. private _updateReferenceSpaceOffset;
  46305. }
  46306. }
  46307. declare module BABYLON {
  46308. /**
  46309. * Defining the interface required for a (webxr) feature
  46310. */
  46311. export interface IWebXRFeature extends IDisposable {
  46312. /**
  46313. * Is this feature attached
  46314. */
  46315. attached: boolean;
  46316. /**
  46317. * Should auto-attach be disabled?
  46318. */
  46319. disableAutoAttach: boolean;
  46320. /**
  46321. * Attach the feature to the session
  46322. * Will usually be called by the features manager
  46323. *
  46324. * @param force should attachment be forced (even when already attached)
  46325. * @returns true if successful.
  46326. */
  46327. attach(force?: boolean): boolean;
  46328. /**
  46329. * Detach the feature from the session
  46330. * Will usually be called by the features manager
  46331. *
  46332. * @returns true if successful.
  46333. */
  46334. detach(): boolean;
  46335. }
  46336. /**
  46337. * A list of the currently available features without referencing them
  46338. */
  46339. export class WebXRFeatureName {
  46340. /**
  46341. * The name of the anchor system feature
  46342. */
  46343. static ANCHOR_SYSTEM: string;
  46344. /**
  46345. * The name of the background remover feature
  46346. */
  46347. static BACKGROUND_REMOVER: string;
  46348. /**
  46349. * The name of the hit test feature
  46350. */
  46351. static HIT_TEST: string;
  46352. /**
  46353. * physics impostors for xr controllers feature
  46354. */
  46355. static PHYSICS_CONTROLLERS: string;
  46356. /**
  46357. * The name of the plane detection feature
  46358. */
  46359. static PLANE_DETECTION: string;
  46360. /**
  46361. * The name of the pointer selection feature
  46362. */
  46363. static POINTER_SELECTION: string;
  46364. /**
  46365. * The name of the teleportation feature
  46366. */
  46367. static TELEPORTATION: string;
  46368. }
  46369. /**
  46370. * Defining the constructor of a feature. Used to register the modules.
  46371. */
  46372. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46373. /**
  46374. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46375. * It is mainly used in AR sessions.
  46376. *
  46377. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46378. */
  46379. export class WebXRFeaturesManager implements IDisposable {
  46380. private _xrSessionManager;
  46381. private static readonly _AvailableFeatures;
  46382. private _features;
  46383. /**
  46384. * constructs a new features manages.
  46385. *
  46386. * @param _xrSessionManager an instance of WebXRSessionManager
  46387. */
  46388. constructor(_xrSessionManager: WebXRSessionManager);
  46389. /**
  46390. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46391. * Mainly used internally.
  46392. *
  46393. * @param featureName the name of the feature to register
  46394. * @param constructorFunction the function used to construct the module
  46395. * @param version the (babylon) version of the module
  46396. * @param stable is that a stable version of this module
  46397. */
  46398. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46399. /**
  46400. * Returns a constructor of a specific feature.
  46401. *
  46402. * @param featureName the name of the feature to construct
  46403. * @param version the version of the feature to load
  46404. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46405. * @param options optional options provided to the module.
  46406. * @returns a function that, when called, will return a new instance of this feature
  46407. */
  46408. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46409. /**
  46410. * Can be used to return the list of features currently registered
  46411. *
  46412. * @returns an Array of available features
  46413. */
  46414. static GetAvailableFeatures(): string[];
  46415. /**
  46416. * Gets the versions available for a specific feature
  46417. * @param featureName the name of the feature
  46418. * @returns an array with the available versions
  46419. */
  46420. static GetAvailableVersions(featureName: string): string[];
  46421. /**
  46422. * Return the latest unstable version of this feature
  46423. * @param featureName the name of the feature to search
  46424. * @returns the version number. if not found will return -1
  46425. */
  46426. static GetLatestVersionOfFeature(featureName: string): number;
  46427. /**
  46428. * Return the latest stable version of this feature
  46429. * @param featureName the name of the feature to search
  46430. * @returns the version number. if not found will return -1
  46431. */
  46432. static GetStableVersionOfFeature(featureName: string): number;
  46433. /**
  46434. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46435. * Can be used during a session to start a feature
  46436. * @param featureName the name of feature to attach
  46437. */
  46438. attachFeature(featureName: string): void;
  46439. /**
  46440. * Can be used inside a session or when the session ends to detach a specific feature
  46441. * @param featureName the name of the feature to detach
  46442. */
  46443. detachFeature(featureName: string): void;
  46444. /**
  46445. * Used to disable an already-enabled feature
  46446. * The feature will be disposed and will be recreated once enabled.
  46447. * @param featureName the feature to disable
  46448. * @returns true if disable was successful
  46449. */
  46450. disableFeature(featureName: string | {
  46451. Name: string;
  46452. }): boolean;
  46453. /**
  46454. * dispose this features manager
  46455. */
  46456. dispose(): void;
  46457. /**
  46458. * 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.
  46459. * 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.
  46460. *
  46461. * @param featureName the name of the feature to load or the class of the feature
  46462. * @param version optional version to load. if not provided the latest version will be enabled
  46463. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46464. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46465. * @returns a new constructed feature or throws an error if feature not found.
  46466. */
  46467. enableFeature(featureName: string | {
  46468. Name: string;
  46469. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46470. /**
  46471. * get the implementation of an enabled feature.
  46472. * @param featureName the name of the feature to load
  46473. * @returns the feature class, if found
  46474. */
  46475. getEnabledFeature(featureName: string): IWebXRFeature;
  46476. /**
  46477. * Get the list of enabled features
  46478. * @returns an array of enabled features
  46479. */
  46480. getEnabledFeatures(): string[];
  46481. }
  46482. }
  46483. declare module BABYLON {
  46484. /**
  46485. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46486. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46487. */
  46488. export class WebXRExperienceHelper implements IDisposable {
  46489. private scene;
  46490. private _nonVRCamera;
  46491. private _originalSceneAutoClear;
  46492. private _supported;
  46493. /**
  46494. * Camera used to render xr content
  46495. */
  46496. camera: WebXRCamera;
  46497. /** A features manager for this xr session */
  46498. featuresManager: WebXRFeaturesManager;
  46499. /**
  46500. * Observers registered here will be triggered after the camera's initial transformation is set
  46501. * This can be used to set a different ground level or an extra rotation.
  46502. *
  46503. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46504. * to the position set after this observable is done executing.
  46505. */
  46506. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46507. /**
  46508. * Fires when the state of the experience helper has changed
  46509. */
  46510. onStateChangedObservable: Observable<WebXRState>;
  46511. /** Session manager used to keep track of xr session */
  46512. sessionManager: WebXRSessionManager;
  46513. /**
  46514. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46515. */
  46516. state: WebXRState;
  46517. /**
  46518. * Creates a WebXRExperienceHelper
  46519. * @param scene The scene the helper should be created in
  46520. */
  46521. private constructor();
  46522. /**
  46523. * Creates the experience helper
  46524. * @param scene the scene to attach the experience helper to
  46525. * @returns a promise for the experience helper
  46526. */
  46527. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46528. /**
  46529. * Disposes of the experience helper
  46530. */
  46531. dispose(): void;
  46532. /**
  46533. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46534. * @param sessionMode options for the XR session
  46535. * @param referenceSpaceType frame of reference of the XR session
  46536. * @param renderTarget the output canvas that will be used to enter XR mode
  46537. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46538. * @returns promise that resolves after xr mode has entered
  46539. */
  46540. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46541. /**
  46542. * Exits XR mode and returns the scene to its original state
  46543. * @returns promise that resolves after xr mode has exited
  46544. */
  46545. exitXRAsync(): Promise<void>;
  46546. private _nonXRToXRCamera;
  46547. private _setState;
  46548. }
  46549. }
  46550. declare module BABYLON {
  46551. /**
  46552. * X-Y values for axes in WebXR
  46553. */
  46554. export interface IWebXRMotionControllerAxesValue {
  46555. /**
  46556. * The value of the x axis
  46557. */
  46558. x: number;
  46559. /**
  46560. * The value of the y-axis
  46561. */
  46562. y: number;
  46563. }
  46564. /**
  46565. * changed / previous values for the values of this component
  46566. */
  46567. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46568. /**
  46569. * current (this frame) value
  46570. */
  46571. current: T;
  46572. /**
  46573. * previous (last change) value
  46574. */
  46575. previous: T;
  46576. }
  46577. /**
  46578. * Represents changes in the component between current frame and last values recorded
  46579. */
  46580. export interface IWebXRMotionControllerComponentChanges {
  46581. /**
  46582. * will be populated with previous and current values if axes changed
  46583. */
  46584. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46585. /**
  46586. * will be populated with previous and current values if pressed changed
  46587. */
  46588. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46589. /**
  46590. * will be populated with previous and current values if touched changed
  46591. */
  46592. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46593. /**
  46594. * will be populated with previous and current values if value changed
  46595. */
  46596. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46597. }
  46598. /**
  46599. * This class represents a single component (for example button or thumbstick) of a motion controller
  46600. */
  46601. export class WebXRControllerComponent implements IDisposable {
  46602. /**
  46603. * the id of this component
  46604. */
  46605. id: string;
  46606. /**
  46607. * the type of the component
  46608. */
  46609. type: MotionControllerComponentType;
  46610. private _buttonIndex;
  46611. private _axesIndices;
  46612. private _axes;
  46613. private _changes;
  46614. private _currentValue;
  46615. private _hasChanges;
  46616. private _pressed;
  46617. private _touched;
  46618. /**
  46619. * button component type
  46620. */
  46621. static BUTTON_TYPE: MotionControllerComponentType;
  46622. /**
  46623. * squeeze component type
  46624. */
  46625. static SQUEEZE_TYPE: MotionControllerComponentType;
  46626. /**
  46627. * Thumbstick component type
  46628. */
  46629. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46630. /**
  46631. * Touchpad component type
  46632. */
  46633. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46634. /**
  46635. * trigger component type
  46636. */
  46637. static TRIGGER_TYPE: MotionControllerComponentType;
  46638. /**
  46639. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46640. * the axes data changes
  46641. */
  46642. onAxisValueChangedObservable: Observable<{
  46643. x: number;
  46644. y: number;
  46645. }>;
  46646. /**
  46647. * Observers registered here will be triggered when the state of a button changes
  46648. * State change is either pressed / touched / value
  46649. */
  46650. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46651. /**
  46652. * Creates a new component for a motion controller.
  46653. * It is created by the motion controller itself
  46654. *
  46655. * @param id the id of this component
  46656. * @param type the type of the component
  46657. * @param _buttonIndex index in the buttons array of the gamepad
  46658. * @param _axesIndices indices of the values in the axes array of the gamepad
  46659. */
  46660. constructor(
  46661. /**
  46662. * the id of this component
  46663. */
  46664. id: string,
  46665. /**
  46666. * the type of the component
  46667. */
  46668. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46669. /**
  46670. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46671. */
  46672. get axes(): IWebXRMotionControllerAxesValue;
  46673. /**
  46674. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46675. */
  46676. get changes(): IWebXRMotionControllerComponentChanges;
  46677. /**
  46678. * Return whether or not the component changed the last frame
  46679. */
  46680. get hasChanges(): boolean;
  46681. /**
  46682. * is the button currently pressed
  46683. */
  46684. get pressed(): boolean;
  46685. /**
  46686. * is the button currently touched
  46687. */
  46688. get touched(): boolean;
  46689. /**
  46690. * Get the current value of this component
  46691. */
  46692. get value(): number;
  46693. /**
  46694. * Dispose this component
  46695. */
  46696. dispose(): void;
  46697. /**
  46698. * Are there axes correlating to this component
  46699. * @return true is axes data is available
  46700. */
  46701. isAxes(): boolean;
  46702. /**
  46703. * Is this component a button (hence - pressable)
  46704. * @returns true if can be pressed
  46705. */
  46706. isButton(): boolean;
  46707. /**
  46708. * update this component using the gamepad object it is in. Called on every frame
  46709. * @param nativeController the native gamepad controller object
  46710. */
  46711. update(nativeController: IMinimalMotionControllerObject): void;
  46712. }
  46713. }
  46714. declare module BABYLON {
  46715. /**
  46716. * Interface used to represent data loading progression
  46717. */
  46718. export interface ISceneLoaderProgressEvent {
  46719. /**
  46720. * Defines if data length to load can be evaluated
  46721. */
  46722. readonly lengthComputable: boolean;
  46723. /**
  46724. * Defines the loaded data length
  46725. */
  46726. readonly loaded: number;
  46727. /**
  46728. * Defines the data length to load
  46729. */
  46730. readonly total: number;
  46731. }
  46732. /**
  46733. * Interface used by SceneLoader plugins to define supported file extensions
  46734. */
  46735. export interface ISceneLoaderPluginExtensions {
  46736. /**
  46737. * Defines the list of supported extensions
  46738. */
  46739. [extension: string]: {
  46740. isBinary: boolean;
  46741. };
  46742. }
  46743. /**
  46744. * Interface used by SceneLoader plugin factory
  46745. */
  46746. export interface ISceneLoaderPluginFactory {
  46747. /**
  46748. * Defines the name of the factory
  46749. */
  46750. name: string;
  46751. /**
  46752. * Function called to create a new plugin
  46753. * @return the new plugin
  46754. */
  46755. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46756. /**
  46757. * The callback that returns true if the data can be directly loaded.
  46758. * @param data string containing the file data
  46759. * @returns if the data can be loaded directly
  46760. */
  46761. canDirectLoad?(data: string): boolean;
  46762. }
  46763. /**
  46764. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46765. */
  46766. export interface ISceneLoaderPluginBase {
  46767. /**
  46768. * The friendly name of this plugin.
  46769. */
  46770. name: string;
  46771. /**
  46772. * The file extensions supported by this plugin.
  46773. */
  46774. extensions: string | ISceneLoaderPluginExtensions;
  46775. /**
  46776. * The callback called when loading from a url.
  46777. * @param scene scene loading this url
  46778. * @param url url to load
  46779. * @param onSuccess callback called when the file successfully loads
  46780. * @param onProgress callback called while file is loading (if the server supports this mode)
  46781. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46782. * @param onError callback called when the file fails to load
  46783. * @returns a file request object
  46784. */
  46785. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46786. /**
  46787. * The callback called when loading from a file object.
  46788. * @param scene scene loading this file
  46789. * @param file defines the file to load
  46790. * @param onSuccess defines the callback to call when data is loaded
  46791. * @param onProgress defines the callback to call during loading process
  46792. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46793. * @param onError defines the callback to call when an error occurs
  46794. * @returns a file request object
  46795. */
  46796. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46797. /**
  46798. * The callback that returns true if the data can be directly loaded.
  46799. * @param data string containing the file data
  46800. * @returns if the data can be loaded directly
  46801. */
  46802. canDirectLoad?(data: string): boolean;
  46803. /**
  46804. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46805. * @param scene scene loading this data
  46806. * @param data string containing the data
  46807. * @returns data to pass to the plugin
  46808. */
  46809. directLoad?(scene: Scene, data: string): any;
  46810. /**
  46811. * The callback that allows custom handling of the root url based on the response url.
  46812. * @param rootUrl the original root url
  46813. * @param responseURL the response url if available
  46814. * @returns the new root url
  46815. */
  46816. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46817. }
  46818. /**
  46819. * Interface used to define a SceneLoader plugin
  46820. */
  46821. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46822. /**
  46823. * Import meshes into a scene.
  46824. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46825. * @param scene The scene to import into
  46826. * @param data The data to import
  46827. * @param rootUrl The root url for scene and resources
  46828. * @param meshes The meshes array to import into
  46829. * @param particleSystems The particle systems array to import into
  46830. * @param skeletons The skeletons array to import into
  46831. * @param onError The callback when import fails
  46832. * @returns True if successful or false otherwise
  46833. */
  46834. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46835. /**
  46836. * Load into a scene.
  46837. * @param scene The scene to load into
  46838. * @param data The data to import
  46839. * @param rootUrl The root url for scene and resources
  46840. * @param onError The callback when import fails
  46841. * @returns True if successful or false otherwise
  46842. */
  46843. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46844. /**
  46845. * Load into an asset container.
  46846. * @param scene The scene to load into
  46847. * @param data The data to import
  46848. * @param rootUrl The root url for scene and resources
  46849. * @param onError The callback when import fails
  46850. * @returns The loaded asset container
  46851. */
  46852. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46853. }
  46854. /**
  46855. * Interface used to define an async SceneLoader plugin
  46856. */
  46857. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46858. /**
  46859. * Import meshes into a scene.
  46860. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46861. * @param scene The scene to import into
  46862. * @param data The data to import
  46863. * @param rootUrl The root url for scene and resources
  46864. * @param onProgress The callback when the load progresses
  46865. * @param fileName Defines the name of the file to load
  46866. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46867. */
  46868. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46869. meshes: AbstractMesh[];
  46870. particleSystems: IParticleSystem[];
  46871. skeletons: Skeleton[];
  46872. animationGroups: AnimationGroup[];
  46873. }>;
  46874. /**
  46875. * Load into a scene.
  46876. * @param scene The scene to load into
  46877. * @param data The data to import
  46878. * @param rootUrl The root url for scene and resources
  46879. * @param onProgress The callback when the load progresses
  46880. * @param fileName Defines the name of the file to load
  46881. * @returns Nothing
  46882. */
  46883. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46884. /**
  46885. * Load into an asset container.
  46886. * @param scene The scene to load into
  46887. * @param data The data to import
  46888. * @param rootUrl The root url for scene and resources
  46889. * @param onProgress The callback when the load progresses
  46890. * @param fileName Defines the name of the file to load
  46891. * @returns The loaded asset container
  46892. */
  46893. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46894. }
  46895. /**
  46896. * Mode that determines how to handle old animation groups before loading new ones.
  46897. */
  46898. export enum SceneLoaderAnimationGroupLoadingMode {
  46899. /**
  46900. * Reset all old animations to initial state then dispose them.
  46901. */
  46902. Clean = 0,
  46903. /**
  46904. * Stop all old animations.
  46905. */
  46906. Stop = 1,
  46907. /**
  46908. * Restart old animations from first frame.
  46909. */
  46910. Sync = 2,
  46911. /**
  46912. * Old animations remains untouched.
  46913. */
  46914. NoSync = 3
  46915. }
  46916. /**
  46917. * Class used to load scene from various file formats using registered plugins
  46918. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  46919. */
  46920. export class SceneLoader {
  46921. /**
  46922. * No logging while loading
  46923. */
  46924. static readonly NO_LOGGING: number;
  46925. /**
  46926. * Minimal logging while loading
  46927. */
  46928. static readonly MINIMAL_LOGGING: number;
  46929. /**
  46930. * Summary logging while loading
  46931. */
  46932. static readonly SUMMARY_LOGGING: number;
  46933. /**
  46934. * Detailled logging while loading
  46935. */
  46936. static readonly DETAILED_LOGGING: number;
  46937. /**
  46938. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46939. */
  46940. static get ForceFullSceneLoadingForIncremental(): boolean;
  46941. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46942. /**
  46943. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46944. */
  46945. static get ShowLoadingScreen(): boolean;
  46946. static set ShowLoadingScreen(value: boolean);
  46947. /**
  46948. * Defines the current logging level (while loading the scene)
  46949. * @ignorenaming
  46950. */
  46951. static get loggingLevel(): number;
  46952. static set loggingLevel(value: number);
  46953. /**
  46954. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46955. */
  46956. static get CleanBoneMatrixWeights(): boolean;
  46957. static set CleanBoneMatrixWeights(value: boolean);
  46958. /**
  46959. * Event raised when a plugin is used to load a scene
  46960. */
  46961. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46962. private static _registeredPlugins;
  46963. private static _getDefaultPlugin;
  46964. private static _getPluginForExtension;
  46965. private static _getPluginForDirectLoad;
  46966. private static _getPluginForFilename;
  46967. private static _getDirectLoad;
  46968. private static _loadData;
  46969. private static _getFileInfo;
  46970. /**
  46971. * Gets a plugin that can load the given extension
  46972. * @param extension defines the extension to load
  46973. * @returns a plugin or null if none works
  46974. */
  46975. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46976. /**
  46977. * Gets a boolean indicating that the given extension can be loaded
  46978. * @param extension defines the extension to load
  46979. * @returns true if the extension is supported
  46980. */
  46981. static IsPluginForExtensionAvailable(extension: string): boolean;
  46982. /**
  46983. * Adds a new plugin to the list of registered plugins
  46984. * @param plugin defines the plugin to add
  46985. */
  46986. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46987. /**
  46988. * Import meshes into a scene
  46989. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46990. * @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)
  46991. * @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)
  46992. * @param scene the instance of BABYLON.Scene to append to
  46993. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46994. * @param onProgress a callback with a progress event for each file being loaded
  46995. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46996. * @param pluginExtension the extension used to determine the plugin
  46997. * @returns The loaded plugin
  46998. */
  46999. 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>;
  47000. /**
  47001. * Import meshes into a scene
  47002. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47003. * @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)
  47004. * @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)
  47005. * @param scene the instance of BABYLON.Scene to append to
  47006. * @param onProgress a callback with a progress event for each file being loaded
  47007. * @param pluginExtension the extension used to determine the plugin
  47008. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47009. */
  47010. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47011. meshes: AbstractMesh[];
  47012. particleSystems: IParticleSystem[];
  47013. skeletons: Skeleton[];
  47014. animationGroups: AnimationGroup[];
  47015. }>;
  47016. /**
  47017. * Load a scene
  47018. * @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)
  47019. * @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)
  47020. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47021. * @param onSuccess a callback with the scene when import succeeds
  47022. * @param onProgress a callback with a progress event for each file being loaded
  47023. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47024. * @param pluginExtension the extension used to determine the plugin
  47025. * @returns The loaded plugin
  47026. */
  47027. 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>;
  47028. /**
  47029. * Load a scene
  47030. * @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)
  47031. * @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)
  47032. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47033. * @param onProgress a callback with a progress event for each file being loaded
  47034. * @param pluginExtension the extension used to determine the plugin
  47035. * @returns The loaded scene
  47036. */
  47037. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47038. /**
  47039. * Append a scene
  47040. * @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)
  47041. * @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)
  47042. * @param scene is the instance of BABYLON.Scene to append to
  47043. * @param onSuccess a callback with the scene when import succeeds
  47044. * @param onProgress a callback with a progress event for each file being loaded
  47045. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47046. * @param pluginExtension the extension used to determine the plugin
  47047. * @returns The loaded plugin
  47048. */
  47049. 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>;
  47050. /**
  47051. * Append a scene
  47052. * @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)
  47053. * @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)
  47054. * @param scene is the instance of BABYLON.Scene to append to
  47055. * @param onProgress a callback with a progress event for each file being loaded
  47056. * @param pluginExtension the extension used to determine the plugin
  47057. * @returns The given scene
  47058. */
  47059. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47060. /**
  47061. * Load a scene into an asset container
  47062. * @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)
  47063. * @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)
  47064. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47065. * @param onSuccess a callback with the scene when import succeeds
  47066. * @param onProgress a callback with a progress event for each file being loaded
  47067. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47068. * @param pluginExtension the extension used to determine the plugin
  47069. * @returns The loaded plugin
  47070. */
  47071. 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>;
  47072. /**
  47073. * Load a scene into an asset container
  47074. * @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)
  47075. * @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)
  47076. * @param scene is the instance of Scene to append to
  47077. * @param onProgress a callback with a progress event for each file being loaded
  47078. * @param pluginExtension the extension used to determine the plugin
  47079. * @returns The loaded asset container
  47080. */
  47081. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47082. /**
  47083. * Import animations from a file into a scene
  47084. * @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)
  47085. * @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)
  47086. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47087. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47088. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47089. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47090. * @param onSuccess a callback with the scene when import succeeds
  47091. * @param onProgress a callback with a progress event for each file being loaded
  47092. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47093. * @param pluginExtension the extension used to determine the plugin
  47094. */
  47095. 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;
  47096. /**
  47097. * Import animations from a file into a scene
  47098. * @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)
  47099. * @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)
  47100. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47101. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47102. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47103. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47104. * @param onSuccess a callback with the scene when import succeeds
  47105. * @param onProgress a callback with a progress event for each file being loaded
  47106. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47107. * @param pluginExtension the extension used to determine the plugin
  47108. * @returns the updated scene with imported animations
  47109. */
  47110. 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>;
  47111. }
  47112. }
  47113. declare module BABYLON {
  47114. /**
  47115. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47116. */
  47117. export type MotionControllerHandedness = "none" | "left" | "right";
  47118. /**
  47119. * The type of components available in motion controllers.
  47120. * This is not the name of the component.
  47121. */
  47122. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47123. /**
  47124. * The state of a controller component
  47125. */
  47126. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47127. /**
  47128. * The schema of motion controller layout.
  47129. * No object will be initialized using this interface
  47130. * This is used just to define the profile.
  47131. */
  47132. export interface IMotionControllerLayout {
  47133. /**
  47134. * Path to load the assets. Usually relative to the base path
  47135. */
  47136. assetPath: string;
  47137. /**
  47138. * Available components (unsorted)
  47139. */
  47140. components: {
  47141. /**
  47142. * A map of component Ids
  47143. */
  47144. [componentId: string]: {
  47145. /**
  47146. * The type of input the component outputs
  47147. */
  47148. type: MotionControllerComponentType;
  47149. /**
  47150. * The indices of this component in the gamepad object
  47151. */
  47152. gamepadIndices: {
  47153. /**
  47154. * Index of button
  47155. */
  47156. button?: number;
  47157. /**
  47158. * If available, index of x-axis
  47159. */
  47160. xAxis?: number;
  47161. /**
  47162. * If available, index of y-axis
  47163. */
  47164. yAxis?: number;
  47165. };
  47166. /**
  47167. * The mesh's root node name
  47168. */
  47169. rootNodeName: string;
  47170. /**
  47171. * Animation definitions for this model
  47172. */
  47173. visualResponses: {
  47174. [stateKey: string]: {
  47175. /**
  47176. * What property will be animated
  47177. */
  47178. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47179. /**
  47180. * What states influence this visual response
  47181. */
  47182. states: MotionControllerComponentStateType[];
  47183. /**
  47184. * Type of animation - movement or visibility
  47185. */
  47186. valueNodeProperty: "transform" | "visibility";
  47187. /**
  47188. * Base node name to move. Its position will be calculated according to the min and max nodes
  47189. */
  47190. valueNodeName?: string;
  47191. /**
  47192. * Minimum movement node
  47193. */
  47194. minNodeName?: string;
  47195. /**
  47196. * Max movement node
  47197. */
  47198. maxNodeName?: string;
  47199. };
  47200. };
  47201. /**
  47202. * If touch enabled, what is the name of node to display user feedback
  47203. */
  47204. touchPointNodeName?: string;
  47205. };
  47206. };
  47207. /**
  47208. * Is it xr standard mapping or not
  47209. */
  47210. gamepadMapping: "" | "xr-standard";
  47211. /**
  47212. * Base root node of this entire model
  47213. */
  47214. rootNodeName: string;
  47215. /**
  47216. * Defines the main button component id
  47217. */
  47218. selectComponentId: string;
  47219. }
  47220. /**
  47221. * A definition for the layout map in the input profile
  47222. */
  47223. export interface IMotionControllerLayoutMap {
  47224. /**
  47225. * Layouts with handedness type as a key
  47226. */
  47227. [handedness: string]: IMotionControllerLayout;
  47228. }
  47229. /**
  47230. * The XR Input profile schema
  47231. * Profiles can be found here:
  47232. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47233. */
  47234. export interface IMotionControllerProfile {
  47235. /**
  47236. * fallback profiles for this profileId
  47237. */
  47238. fallbackProfileIds: string[];
  47239. /**
  47240. * The layout map, with handedness as key
  47241. */
  47242. layouts: IMotionControllerLayoutMap;
  47243. /**
  47244. * The id of this profile
  47245. * correlates to the profile(s) in the xrInput.profiles array
  47246. */
  47247. profileId: string;
  47248. }
  47249. /**
  47250. * A helper-interface for the 3 meshes needed for controller button animation
  47251. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47252. */
  47253. export interface IMotionControllerButtonMeshMap {
  47254. /**
  47255. * the mesh that defines the pressed value mesh position.
  47256. * This is used to find the max-position of this button
  47257. */
  47258. pressedMesh: AbstractMesh;
  47259. /**
  47260. * the mesh that defines the unpressed value mesh position.
  47261. * This is used to find the min (or initial) position of this button
  47262. */
  47263. unpressedMesh: AbstractMesh;
  47264. /**
  47265. * The mesh that will be changed when value changes
  47266. */
  47267. valueMesh: AbstractMesh;
  47268. }
  47269. /**
  47270. * A helper-interface for the 3 meshes needed for controller axis animation.
  47271. * This will be expanded when touchpad animations are fully supported
  47272. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47273. */
  47274. export interface IMotionControllerMeshMap {
  47275. /**
  47276. * the mesh that defines the maximum value mesh position.
  47277. */
  47278. maxMesh?: AbstractMesh;
  47279. /**
  47280. * the mesh that defines the minimum value mesh position.
  47281. */
  47282. minMesh?: AbstractMesh;
  47283. /**
  47284. * The mesh that will be changed when axis value changes
  47285. */
  47286. valueMesh: AbstractMesh;
  47287. }
  47288. /**
  47289. * The elements needed for change-detection of the gamepad objects in motion controllers
  47290. */
  47291. export interface IMinimalMotionControllerObject {
  47292. /**
  47293. * Available axes of this controller
  47294. */
  47295. axes: number[];
  47296. /**
  47297. * An array of available buttons
  47298. */
  47299. buttons: Array<{
  47300. /**
  47301. * Value of the button/trigger
  47302. */
  47303. value: number;
  47304. /**
  47305. * If the button/trigger is currently touched
  47306. */
  47307. touched: boolean;
  47308. /**
  47309. * If the button/trigger is currently pressed
  47310. */
  47311. pressed: boolean;
  47312. }>;
  47313. /**
  47314. * EXPERIMENTAL haptic support.
  47315. */
  47316. hapticActuators?: Array<{
  47317. pulse: (value: number, duration: number) => Promise<boolean>;
  47318. }>;
  47319. }
  47320. /**
  47321. * An Abstract Motion controller
  47322. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47323. * Each component has an observable to check for changes in value and state
  47324. */
  47325. export abstract class WebXRAbstractMotionController implements IDisposable {
  47326. protected scene: Scene;
  47327. protected layout: IMotionControllerLayout;
  47328. /**
  47329. * The gamepad object correlating to this controller
  47330. */
  47331. gamepadObject: IMinimalMotionControllerObject;
  47332. /**
  47333. * handedness (left/right/none) of this controller
  47334. */
  47335. handedness: MotionControllerHandedness;
  47336. private _initComponent;
  47337. private _modelReady;
  47338. /**
  47339. * A map of components (WebXRControllerComponent) in this motion controller
  47340. * Components have a ComponentType and can also have both button and axis definitions
  47341. */
  47342. readonly components: {
  47343. [id: string]: WebXRControllerComponent;
  47344. };
  47345. /**
  47346. * Disable the model's animation. Can be set at any time.
  47347. */
  47348. disableAnimation: boolean;
  47349. /**
  47350. * Observers registered here will be triggered when the model of this controller is done loading
  47351. */
  47352. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47353. /**
  47354. * The profile id of this motion controller
  47355. */
  47356. abstract profileId: string;
  47357. /**
  47358. * The root mesh of the model. It is null if the model was not yet initialized
  47359. */
  47360. rootMesh: Nullable<AbstractMesh>;
  47361. /**
  47362. * constructs a new abstract motion controller
  47363. * @param scene the scene to which the model of the controller will be added
  47364. * @param layout The profile layout to load
  47365. * @param gamepadObject The gamepad object correlating to this controller
  47366. * @param handedness handedness (left/right/none) of this controller
  47367. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47368. */
  47369. constructor(scene: Scene, layout: IMotionControllerLayout,
  47370. /**
  47371. * The gamepad object correlating to this controller
  47372. */
  47373. gamepadObject: IMinimalMotionControllerObject,
  47374. /**
  47375. * handedness (left/right/none) of this controller
  47376. */
  47377. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47378. /**
  47379. * Dispose this controller, the model mesh and all its components
  47380. */
  47381. dispose(): void;
  47382. /**
  47383. * Returns all components of specific type
  47384. * @param type the type to search for
  47385. * @return an array of components with this type
  47386. */
  47387. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47388. /**
  47389. * get a component based an its component id as defined in layout.components
  47390. * @param id the id of the component
  47391. * @returns the component correlates to the id or undefined if not found
  47392. */
  47393. getComponent(id: string): WebXRControllerComponent;
  47394. /**
  47395. * Get the list of components available in this motion controller
  47396. * @returns an array of strings correlating to available components
  47397. */
  47398. getComponentIds(): string[];
  47399. /**
  47400. * Get the first component of specific type
  47401. * @param type type of component to find
  47402. * @return a controller component or null if not found
  47403. */
  47404. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47405. /**
  47406. * Get the main (Select) component of this controller as defined in the layout
  47407. * @returns the main component of this controller
  47408. */
  47409. getMainComponent(): WebXRControllerComponent;
  47410. /**
  47411. * Loads the model correlating to this controller
  47412. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47413. * @returns A promise fulfilled with the result of the model loading
  47414. */
  47415. loadModel(): Promise<boolean>;
  47416. /**
  47417. * Update this model using the current XRFrame
  47418. * @param xrFrame the current xr frame to use and update the model
  47419. */
  47420. updateFromXRFrame(xrFrame: XRFrame): void;
  47421. /**
  47422. * Backwards compatibility due to a deeply-integrated typo
  47423. */
  47424. get handness(): XREye;
  47425. /**
  47426. * Pulse (vibrate) this controller
  47427. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47428. * Consecutive calls to this function will cancel the last pulse call
  47429. *
  47430. * @param value the strength of the pulse in 0.0...1.0 range
  47431. * @param duration Duration of the pulse in milliseconds
  47432. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47433. * @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
  47434. */
  47435. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47436. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47437. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47438. /**
  47439. * Moves the axis on the controller mesh based on its current state
  47440. * @param axis the index of the axis
  47441. * @param axisValue the value of the axis which determines the meshes new position
  47442. * @hidden
  47443. */
  47444. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47445. /**
  47446. * Update the model itself with the current frame data
  47447. * @param xrFrame the frame to use for updating the model mesh
  47448. */
  47449. protected updateModel(xrFrame: XRFrame): void;
  47450. /**
  47451. * Get the filename and path for this controller's model
  47452. * @returns a map of filename and path
  47453. */
  47454. protected abstract _getFilenameAndPath(): {
  47455. filename: string;
  47456. path: string;
  47457. };
  47458. /**
  47459. * This function is called before the mesh is loaded. It checks for loading constraints.
  47460. * For example, this function can check if the GLB loader is available
  47461. * If this function returns false, the generic controller will be loaded instead
  47462. * @returns Is the client ready to load the mesh
  47463. */
  47464. protected abstract _getModelLoadingConstraints(): boolean;
  47465. /**
  47466. * This function will be called after the model was successfully loaded and can be used
  47467. * for mesh transformations before it is available for the user
  47468. * @param meshes the loaded meshes
  47469. */
  47470. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47471. /**
  47472. * Set the root mesh for this controller. Important for the WebXR controller class
  47473. * @param meshes the loaded meshes
  47474. */
  47475. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47476. /**
  47477. * A function executed each frame that updates the mesh (if needed)
  47478. * @param xrFrame the current xrFrame
  47479. */
  47480. protected abstract _updateModel(xrFrame: XRFrame): void;
  47481. private _getGenericFilenameAndPath;
  47482. private _getGenericParentMesh;
  47483. }
  47484. }
  47485. declare module BABYLON {
  47486. /**
  47487. * A generic trigger-only motion controller for WebXR
  47488. */
  47489. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47490. /**
  47491. * Static version of the profile id of this controller
  47492. */
  47493. static ProfileId: string;
  47494. profileId: string;
  47495. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47496. protected _getFilenameAndPath(): {
  47497. filename: string;
  47498. path: string;
  47499. };
  47500. protected _getModelLoadingConstraints(): boolean;
  47501. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47502. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47503. protected _updateModel(): void;
  47504. }
  47505. }
  47506. declare module BABYLON {
  47507. /**
  47508. * Class containing static functions to help procedurally build meshes
  47509. */
  47510. export class SphereBuilder {
  47511. /**
  47512. * Creates a sphere mesh
  47513. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47514. * * 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`)
  47515. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47516. * * 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
  47517. * * 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)
  47518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47519. * * 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
  47520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47521. * @param name defines the name of the mesh
  47522. * @param options defines the options used to create the mesh
  47523. * @param scene defines the hosting scene
  47524. * @returns the sphere mesh
  47525. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47526. */
  47527. static CreateSphere(name: string, options: {
  47528. segments?: number;
  47529. diameter?: number;
  47530. diameterX?: number;
  47531. diameterY?: number;
  47532. diameterZ?: number;
  47533. arc?: number;
  47534. slice?: number;
  47535. sideOrientation?: number;
  47536. frontUVs?: Vector4;
  47537. backUVs?: Vector4;
  47538. updatable?: boolean;
  47539. }, scene?: Nullable<Scene>): Mesh;
  47540. }
  47541. }
  47542. declare module BABYLON {
  47543. /**
  47544. * A profiled motion controller has its profile loaded from an online repository.
  47545. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47546. */
  47547. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47548. private _repositoryUrl;
  47549. private _buttonMeshMapping;
  47550. private _touchDots;
  47551. /**
  47552. * The profile ID of this controller. Will be populated when the controller initializes.
  47553. */
  47554. profileId: string;
  47555. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47556. dispose(): void;
  47557. protected _getFilenameAndPath(): {
  47558. filename: string;
  47559. path: string;
  47560. };
  47561. protected _getModelLoadingConstraints(): boolean;
  47562. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47563. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47564. protected _updateModel(_xrFrame: XRFrame): void;
  47565. }
  47566. }
  47567. declare module BABYLON {
  47568. /**
  47569. * A construction function type to create a new controller based on an xrInput object
  47570. */
  47571. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47572. /**
  47573. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47574. *
  47575. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47576. * it should be replaced with auto-loaded controllers.
  47577. *
  47578. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47579. */
  47580. export class WebXRMotionControllerManager {
  47581. private static _AvailableControllers;
  47582. private static _Fallbacks;
  47583. private static _ProfileLoadingPromises;
  47584. private static _ProfilesList;
  47585. /**
  47586. * The base URL of the online controller repository. Can be changed at any time.
  47587. */
  47588. static BaseRepositoryUrl: string;
  47589. /**
  47590. * Which repository gets priority - local or online
  47591. */
  47592. static PrioritizeOnlineRepository: boolean;
  47593. /**
  47594. * Use the online repository, or use only locally-defined controllers
  47595. */
  47596. static UseOnlineRepository: boolean;
  47597. /**
  47598. * Clear the cache used for profile loading and reload when requested again
  47599. */
  47600. static ClearProfilesCache(): void;
  47601. /**
  47602. * Register the default fallbacks.
  47603. * This function is called automatically when this file is imported.
  47604. */
  47605. static DefaultFallbacks(): void;
  47606. /**
  47607. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47608. * @param profileId the profile to which a fallback needs to be found
  47609. * @return an array with corresponding fallback profiles
  47610. */
  47611. static FindFallbackWithProfileId(profileId: string): string[];
  47612. /**
  47613. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47614. * The order of search:
  47615. *
  47616. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47617. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47618. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47619. * 4) return the generic trigger controller if none were found
  47620. *
  47621. * @param xrInput the xrInput to which a new controller is initialized
  47622. * @param scene the scene to which the model will be added
  47623. * @param forceProfile force a certain profile for this controller
  47624. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47625. */
  47626. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47627. /**
  47628. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47629. *
  47630. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47631. *
  47632. * @param type the profile type to register
  47633. * @param constructFunction the function to be called when loading this profile
  47634. */
  47635. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47636. /**
  47637. * Register a fallback to a specific profile.
  47638. * @param profileId the profileId that will receive the fallbacks
  47639. * @param fallbacks A list of fallback profiles
  47640. */
  47641. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47642. /**
  47643. * Will update the list of profiles available in the repository
  47644. * @return a promise that resolves to a map of profiles available online
  47645. */
  47646. static UpdateProfilesList(): Promise<{
  47647. [profile: string]: string;
  47648. }>;
  47649. private static _LoadProfileFromRepository;
  47650. private static _LoadProfilesFromAvailableControllers;
  47651. }
  47652. }
  47653. declare module BABYLON {
  47654. /**
  47655. * Configuration options for the WebXR controller creation
  47656. */
  47657. export interface IWebXRControllerOptions {
  47658. /**
  47659. * Should the controller mesh be animated when a user interacts with it
  47660. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47661. */
  47662. disableMotionControllerAnimation?: boolean;
  47663. /**
  47664. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47665. */
  47666. doNotLoadControllerMesh?: boolean;
  47667. /**
  47668. * Force a specific controller type for this controller.
  47669. * This can be used when creating your own profile or when testing different controllers
  47670. */
  47671. forceControllerProfile?: string;
  47672. /**
  47673. * Defines a rendering group ID for meshes that will be loaded.
  47674. * This is for the default controllers only.
  47675. */
  47676. renderingGroupId?: number;
  47677. }
  47678. /**
  47679. * Represents an XR controller
  47680. */
  47681. export class WebXRInputSource {
  47682. private _scene;
  47683. /** The underlying input source for the controller */
  47684. inputSource: XRInputSource;
  47685. private _options;
  47686. private _tmpVector;
  47687. private _uniqueId;
  47688. /**
  47689. * 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
  47690. */
  47691. grip?: AbstractMesh;
  47692. /**
  47693. * If available, this is the gamepad object related to this controller.
  47694. * Using this object it is possible to get click events and trackpad changes of the
  47695. * webxr controller that is currently being used.
  47696. */
  47697. motionController?: WebXRAbstractMotionController;
  47698. /**
  47699. * Event that fires when the controller is removed/disposed.
  47700. * The object provided as event data is this controller, after associated assets were disposed.
  47701. * uniqueId is still available.
  47702. */
  47703. onDisposeObservable: Observable<WebXRInputSource>;
  47704. /**
  47705. * Will be triggered when the mesh associated with the motion controller is done loading.
  47706. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47707. * A shortened version of controller -> motion controller -> on mesh loaded.
  47708. */
  47709. onMeshLoadedObservable: Observable<AbstractMesh>;
  47710. /**
  47711. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47712. */
  47713. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47714. /**
  47715. * Pointer which can be used to select objects or attach a visible laser to
  47716. */
  47717. pointer: AbstractMesh;
  47718. /**
  47719. * Creates the input source object
  47720. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  47721. * @param _scene the scene which the controller should be associated to
  47722. * @param inputSource the underlying input source for the controller
  47723. * @param _options options for this controller creation
  47724. */
  47725. constructor(_scene: Scene,
  47726. /** The underlying input source for the controller */
  47727. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47728. /**
  47729. * Get this controllers unique id
  47730. */
  47731. get uniqueId(): string;
  47732. /**
  47733. * Disposes of the object
  47734. */
  47735. dispose(): void;
  47736. /**
  47737. * Gets a world space ray coming from the pointer or grip
  47738. * @param result the resulting ray
  47739. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47740. */
  47741. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47742. /**
  47743. * Updates the controller pose based on the given XRFrame
  47744. * @param xrFrame xr frame to update the pose with
  47745. * @param referenceSpace reference space to use
  47746. */
  47747. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47748. }
  47749. }
  47750. declare module BABYLON {
  47751. /**
  47752. * The schema for initialization options of the XR Input class
  47753. */
  47754. export interface IWebXRInputOptions {
  47755. /**
  47756. * If set to true no model will be automatically loaded
  47757. */
  47758. doNotLoadControllerMeshes?: boolean;
  47759. /**
  47760. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47761. * If not found, the xr input profile data will be used.
  47762. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47763. */
  47764. forceInputProfile?: string;
  47765. /**
  47766. * Do not send a request to the controller repository to load the profile.
  47767. *
  47768. * Instead, use the controllers available in babylon itself.
  47769. */
  47770. disableOnlineControllerRepository?: boolean;
  47771. /**
  47772. * A custom URL for the controllers repository
  47773. */
  47774. customControllersRepositoryURL?: string;
  47775. /**
  47776. * Should the controller model's components not move according to the user input
  47777. */
  47778. disableControllerAnimation?: boolean;
  47779. /**
  47780. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47781. */
  47782. controllerOptions?: IWebXRControllerOptions;
  47783. }
  47784. /**
  47785. * XR input used to track XR inputs such as controllers/rays
  47786. */
  47787. export class WebXRInput implements IDisposable {
  47788. /**
  47789. * the xr session manager for this session
  47790. */
  47791. xrSessionManager: WebXRSessionManager;
  47792. /**
  47793. * the WebXR camera for this session. Mainly used for teleportation
  47794. */
  47795. xrCamera: WebXRCamera;
  47796. private readonly options;
  47797. /**
  47798. * XR controllers being tracked
  47799. */
  47800. controllers: Array<WebXRInputSource>;
  47801. private _frameObserver;
  47802. private _sessionEndedObserver;
  47803. private _sessionInitObserver;
  47804. /**
  47805. * Event when a controller has been connected/added
  47806. */
  47807. onControllerAddedObservable: Observable<WebXRInputSource>;
  47808. /**
  47809. * Event when a controller has been removed/disconnected
  47810. */
  47811. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47812. /**
  47813. * Initializes the WebXRInput
  47814. * @param xrSessionManager the xr session manager for this session
  47815. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47816. * @param options = initialization options for this xr input
  47817. */
  47818. constructor(
  47819. /**
  47820. * the xr session manager for this session
  47821. */
  47822. xrSessionManager: WebXRSessionManager,
  47823. /**
  47824. * the WebXR camera for this session. Mainly used for teleportation
  47825. */
  47826. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47827. private _onInputSourcesChange;
  47828. private _addAndRemoveControllers;
  47829. /**
  47830. * Disposes of the object
  47831. */
  47832. dispose(): void;
  47833. }
  47834. }
  47835. declare module BABYLON {
  47836. /**
  47837. * This is the base class for all WebXR features.
  47838. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47839. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47840. */
  47841. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47842. protected _xrSessionManager: WebXRSessionManager;
  47843. private _attached;
  47844. private _removeOnDetach;
  47845. /**
  47846. * Should auto-attach be disabled?
  47847. */
  47848. disableAutoAttach: boolean;
  47849. /**
  47850. * Construct a new (abstract) WebXR feature
  47851. * @param _xrSessionManager the xr session manager for this feature
  47852. */
  47853. constructor(_xrSessionManager: WebXRSessionManager);
  47854. /**
  47855. * Is this feature attached
  47856. */
  47857. get attached(): boolean;
  47858. /**
  47859. * attach this feature
  47860. *
  47861. * @param force should attachment be forced (even when already attached)
  47862. * @returns true if successful, false is failed or already attached
  47863. */
  47864. attach(force?: boolean): boolean;
  47865. /**
  47866. * detach this feature.
  47867. *
  47868. * @returns true if successful, false if failed or already detached
  47869. */
  47870. detach(): boolean;
  47871. /**
  47872. * Dispose this feature and all of the resources attached
  47873. */
  47874. dispose(): void;
  47875. /**
  47876. * This is used to register callbacks that will automatically be removed when detach is called.
  47877. * @param observable the observable to which the observer will be attached
  47878. * @param callback the callback to register
  47879. */
  47880. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47881. /**
  47882. * Code in this function will be executed on each xrFrame received from the browser.
  47883. * This function will not execute after the feature is detached.
  47884. * @param _xrFrame the current frame
  47885. */
  47886. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47887. }
  47888. }
  47889. declare module BABYLON {
  47890. /**
  47891. * Renders a layer on top of an existing scene
  47892. */
  47893. export class UtilityLayerRenderer implements IDisposable {
  47894. /** the original scene that will be rendered on top of */
  47895. originalScene: Scene;
  47896. private _pointerCaptures;
  47897. private _lastPointerEvents;
  47898. private static _DefaultUtilityLayer;
  47899. private static _DefaultKeepDepthUtilityLayer;
  47900. private _sharedGizmoLight;
  47901. private _renderCamera;
  47902. /**
  47903. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47904. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47905. * @returns the camera that is used when rendering the utility layer
  47906. */
  47907. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47908. /**
  47909. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47910. * @param cam the camera that should be used when rendering the utility layer
  47911. */
  47912. setRenderCamera(cam: Nullable<Camera>): void;
  47913. /**
  47914. * @hidden
  47915. * Light which used by gizmos to get light shading
  47916. */
  47917. _getSharedGizmoLight(): HemisphericLight;
  47918. /**
  47919. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47920. */
  47921. pickUtilitySceneFirst: boolean;
  47922. /**
  47923. * 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)
  47924. */
  47925. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47926. /**
  47927. * 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)
  47928. */
  47929. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47930. /**
  47931. * The scene that is rendered on top of the original scene
  47932. */
  47933. utilityLayerScene: Scene;
  47934. /**
  47935. * If the utility layer should automatically be rendered on top of existing scene
  47936. */
  47937. shouldRender: boolean;
  47938. /**
  47939. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47940. */
  47941. onlyCheckPointerDownEvents: boolean;
  47942. /**
  47943. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47944. */
  47945. processAllEvents: boolean;
  47946. /**
  47947. * Observable raised when the pointer move from the utility layer scene to the main scene
  47948. */
  47949. onPointerOutObservable: Observable<number>;
  47950. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47951. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47952. private _afterRenderObserver;
  47953. private _sceneDisposeObserver;
  47954. private _originalPointerObserver;
  47955. /**
  47956. * Instantiates a UtilityLayerRenderer
  47957. * @param originalScene the original scene that will be rendered on top of
  47958. * @param handleEvents boolean indicating if the utility layer should handle events
  47959. */
  47960. constructor(
  47961. /** the original scene that will be rendered on top of */
  47962. originalScene: Scene, handleEvents?: boolean);
  47963. private _notifyObservers;
  47964. /**
  47965. * Renders the utility layers scene on top of the original scene
  47966. */
  47967. render(): void;
  47968. /**
  47969. * Disposes of the renderer
  47970. */
  47971. dispose(): void;
  47972. private _updateCamera;
  47973. }
  47974. }
  47975. declare module BABYLON {
  47976. /**
  47977. * Options interface for the pointer selection module
  47978. */
  47979. export interface IWebXRControllerPointerSelectionOptions {
  47980. /**
  47981. * if provided, this scene will be used to render meshes.
  47982. */
  47983. customUtilityLayerScene?: Scene;
  47984. /**
  47985. * 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)
  47986. * If not disabled, the last picked point will be used to execute a pointer up event
  47987. * If disabled, pointer up event will be triggered right after the pointer down event.
  47988. * Used in screen and gaze target ray mode only
  47989. */
  47990. disablePointerUpOnTouchOut: boolean;
  47991. /**
  47992. * For gaze mode (time to select instead of press)
  47993. */
  47994. forceGazeMode: boolean;
  47995. /**
  47996. * 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
  47997. * to start a new countdown to the pointer down event.
  47998. * Defaults to 1.
  47999. */
  48000. gazeModePointerMovedFactor?: number;
  48001. /**
  48002. * Different button type to use instead of the main component
  48003. */
  48004. overrideButtonId?: string;
  48005. /**
  48006. * use this rendering group id for the meshes (optional)
  48007. */
  48008. renderingGroupId?: number;
  48009. /**
  48010. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48011. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48012. * 3000 means 3 seconds between pointing at something and selecting it
  48013. */
  48014. timeToSelect?: number;
  48015. /**
  48016. * Should meshes created here be added to a utility layer or the main scene
  48017. */
  48018. useUtilityLayer?: boolean;
  48019. /**
  48020. * the xr input to use with this pointer selection
  48021. */
  48022. xrInput: WebXRInput;
  48023. }
  48024. /**
  48025. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48026. */
  48027. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48028. private readonly _options;
  48029. private static _idCounter;
  48030. private _attachController;
  48031. private _controllers;
  48032. private _scene;
  48033. private _tmpVectorForPickCompare;
  48034. /**
  48035. * The module's name
  48036. */
  48037. static readonly Name: string;
  48038. /**
  48039. * The (Babylon) version of this module.
  48040. * This is an integer representing the implementation version.
  48041. * This number does not correspond to the WebXR specs version
  48042. */
  48043. static readonly Version: number;
  48044. /**
  48045. * Disable lighting on the laser pointer (so it will always be visible)
  48046. */
  48047. disablePointerLighting: boolean;
  48048. /**
  48049. * Disable lighting on the selection mesh (so it will always be visible)
  48050. */
  48051. disableSelectionMeshLighting: boolean;
  48052. /**
  48053. * Should the laser pointer be displayed
  48054. */
  48055. displayLaserPointer: boolean;
  48056. /**
  48057. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48058. */
  48059. displaySelectionMesh: boolean;
  48060. /**
  48061. * This color will be set to the laser pointer when selection is triggered
  48062. */
  48063. laserPointerPickedColor: Color3;
  48064. /**
  48065. * Default color of the laser pointer
  48066. */
  48067. laserPointerDefaultColor: Color3;
  48068. /**
  48069. * default color of the selection ring
  48070. */
  48071. selectionMeshDefaultColor: Color3;
  48072. /**
  48073. * This color will be applied to the selection ring when selection is triggered
  48074. */
  48075. selectionMeshPickedColor: Color3;
  48076. /**
  48077. * Optional filter to be used for ray selection. This predicate shares behavior with
  48078. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48079. */
  48080. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48081. /**
  48082. * constructs a new background remover module
  48083. * @param _xrSessionManager the session manager for this module
  48084. * @param _options read-only options to be used in this module
  48085. */
  48086. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48087. /**
  48088. * attach this feature
  48089. * Will usually be called by the features manager
  48090. *
  48091. * @returns true if successful.
  48092. */
  48093. attach(): boolean;
  48094. /**
  48095. * detach this feature.
  48096. * Will usually be called by the features manager
  48097. *
  48098. * @returns true if successful.
  48099. */
  48100. detach(): boolean;
  48101. /**
  48102. * Will get the mesh under a specific pointer.
  48103. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48104. * @param controllerId the controllerId to check
  48105. * @returns The mesh under pointer or null if no mesh is under the pointer
  48106. */
  48107. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48108. /**
  48109. * Get the xr controller that correlates to the pointer id in the pointer event
  48110. *
  48111. * @param id the pointer id to search for
  48112. * @returns the controller that correlates to this id or null if not found
  48113. */
  48114. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48115. protected _onXRFrame(_xrFrame: XRFrame): void;
  48116. private _attachGazeMode;
  48117. private _attachScreenRayMode;
  48118. private _attachTrackedPointerRayMode;
  48119. private _convertNormalToDirectionOfRay;
  48120. private _detachController;
  48121. private _generateNewMeshPair;
  48122. private _pickingMoved;
  48123. private _updatePointerDistance;
  48124. /** @hidden */
  48125. get lasterPointerDefaultColor(): Color3;
  48126. }
  48127. }
  48128. declare module BABYLON {
  48129. /**
  48130. * Button which can be used to enter a different mode of XR
  48131. */
  48132. export class WebXREnterExitUIButton {
  48133. /** button element */
  48134. element: HTMLElement;
  48135. /** XR initialization options for the button */
  48136. sessionMode: XRSessionMode;
  48137. /** Reference space type */
  48138. referenceSpaceType: XRReferenceSpaceType;
  48139. /**
  48140. * Creates a WebXREnterExitUIButton
  48141. * @param element button element
  48142. * @param sessionMode XR initialization session mode
  48143. * @param referenceSpaceType the type of reference space to be used
  48144. */
  48145. constructor(
  48146. /** button element */
  48147. element: HTMLElement,
  48148. /** XR initialization options for the button */
  48149. sessionMode: XRSessionMode,
  48150. /** Reference space type */
  48151. referenceSpaceType: XRReferenceSpaceType);
  48152. /**
  48153. * Extendable function which can be used to update the button's visuals when the state changes
  48154. * @param activeButton the current active button in the UI
  48155. */
  48156. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48157. }
  48158. /**
  48159. * Options to create the webXR UI
  48160. */
  48161. export class WebXREnterExitUIOptions {
  48162. /**
  48163. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48164. */
  48165. customButtons?: Array<WebXREnterExitUIButton>;
  48166. /**
  48167. * A reference space type to use when creating the default button.
  48168. * Default is local-floor
  48169. */
  48170. referenceSpaceType?: XRReferenceSpaceType;
  48171. /**
  48172. * Context to enter xr with
  48173. */
  48174. renderTarget?: Nullable<WebXRRenderTarget>;
  48175. /**
  48176. * A session mode to use when creating the default button.
  48177. * Default is immersive-vr
  48178. */
  48179. sessionMode?: XRSessionMode;
  48180. /**
  48181. * A list of optional features to init the session with
  48182. */
  48183. optionalFeatures?: string[];
  48184. /**
  48185. * A list of optional features to init the session with
  48186. */
  48187. requiredFeatures?: string[];
  48188. }
  48189. /**
  48190. * UI to allow the user to enter/exit XR mode
  48191. */
  48192. export class WebXREnterExitUI implements IDisposable {
  48193. private scene;
  48194. /** version of the options passed to this UI */
  48195. options: WebXREnterExitUIOptions;
  48196. private _activeButton;
  48197. private _buttons;
  48198. private _overlay;
  48199. /**
  48200. * Fired every time the active button is changed.
  48201. *
  48202. * When xr is entered via a button that launches xr that button will be the callback parameter
  48203. *
  48204. * When exiting xr the callback parameter will be null)
  48205. */
  48206. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48207. /**
  48208. *
  48209. * @param scene babylon scene object to use
  48210. * @param options (read-only) version of the options passed to this UI
  48211. */
  48212. private constructor();
  48213. /**
  48214. * Creates UI to allow the user to enter/exit XR mode
  48215. * @param scene the scene to add the ui to
  48216. * @param helper the xr experience helper to enter/exit xr with
  48217. * @param options options to configure the UI
  48218. * @returns the created ui
  48219. */
  48220. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48221. /**
  48222. * Disposes of the XR UI component
  48223. */
  48224. dispose(): void;
  48225. private _updateButtons;
  48226. }
  48227. }
  48228. declare module BABYLON {
  48229. /**
  48230. * Class containing static functions to help procedurally build meshes
  48231. */
  48232. export class LinesBuilder {
  48233. /**
  48234. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48235. * * 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
  48236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48237. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48238. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48239. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48240. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48241. * * 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
  48242. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48244. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48245. * @param name defines the name of the new line system
  48246. * @param options defines the options used to create the line system
  48247. * @param scene defines the hosting scene
  48248. * @returns a new line system mesh
  48249. */
  48250. static CreateLineSystem(name: string, options: {
  48251. lines: Vector3[][];
  48252. updatable?: boolean;
  48253. instance?: Nullable<LinesMesh>;
  48254. colors?: Nullable<Color4[][]>;
  48255. useVertexAlpha?: boolean;
  48256. }, scene: Nullable<Scene>): LinesMesh;
  48257. /**
  48258. * Creates a line mesh
  48259. * 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
  48260. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48261. * * The parameter `points` is an array successive Vector3
  48262. * * 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
  48263. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48264. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48265. * * When updating an instance, remember that only point positions can change, not the number of points
  48266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48267. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48268. * @param name defines the name of the new line system
  48269. * @param options defines the options used to create the line system
  48270. * @param scene defines the hosting scene
  48271. * @returns a new line mesh
  48272. */
  48273. static CreateLines(name: string, options: {
  48274. points: Vector3[];
  48275. updatable?: boolean;
  48276. instance?: Nullable<LinesMesh>;
  48277. colors?: Color4[];
  48278. useVertexAlpha?: boolean;
  48279. }, scene?: Nullable<Scene>): LinesMesh;
  48280. /**
  48281. * Creates a dashed line mesh
  48282. * * 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
  48283. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48284. * * The parameter `points` is an array successive Vector3
  48285. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48286. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48287. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48288. * * 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
  48289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48290. * * When updating an instance, remember that only point positions can change, not the number of points
  48291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48292. * @param name defines the name of the mesh
  48293. * @param options defines the options used to create the mesh
  48294. * @param scene defines the hosting scene
  48295. * @returns the dashed line mesh
  48296. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48297. */
  48298. static CreateDashedLines(name: string, options: {
  48299. points: Vector3[];
  48300. dashSize?: number;
  48301. gapSize?: number;
  48302. dashNb?: number;
  48303. updatable?: boolean;
  48304. instance?: LinesMesh;
  48305. useVertexAlpha?: boolean;
  48306. }, scene?: Nullable<Scene>): LinesMesh;
  48307. }
  48308. }
  48309. declare module BABYLON {
  48310. /**
  48311. * Construction options for a timer
  48312. */
  48313. export interface ITimerOptions<T> {
  48314. /**
  48315. * Time-to-end
  48316. */
  48317. timeout: number;
  48318. /**
  48319. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48320. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48321. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48322. */
  48323. contextObservable: Observable<T>;
  48324. /**
  48325. * Optional parameters when adding an observer to the observable
  48326. */
  48327. observableParameters?: {
  48328. mask?: number;
  48329. insertFirst?: boolean;
  48330. scope?: any;
  48331. };
  48332. /**
  48333. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48334. */
  48335. breakCondition?: (data?: ITimerData<T>) => boolean;
  48336. /**
  48337. * Will be triggered when the time condition has met
  48338. */
  48339. onEnded?: (data: ITimerData<any>) => void;
  48340. /**
  48341. * Will be triggered when the break condition has met (prematurely ended)
  48342. */
  48343. onAborted?: (data: ITimerData<any>) => void;
  48344. /**
  48345. * Optional function to execute on each tick (or count)
  48346. */
  48347. onTick?: (data: ITimerData<any>) => void;
  48348. }
  48349. /**
  48350. * An interface defining the data sent by the timer
  48351. */
  48352. export interface ITimerData<T> {
  48353. /**
  48354. * When did it start
  48355. */
  48356. startTime: number;
  48357. /**
  48358. * Time now
  48359. */
  48360. currentTime: number;
  48361. /**
  48362. * Time passed since started
  48363. */
  48364. deltaTime: number;
  48365. /**
  48366. * How much is completed, in [0.0...1.0].
  48367. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48368. */
  48369. completeRate: number;
  48370. /**
  48371. * What the registered observable sent in the last count
  48372. */
  48373. payload: T;
  48374. }
  48375. /**
  48376. * The current state of the timer
  48377. */
  48378. export enum TimerState {
  48379. /**
  48380. * Timer initialized, not yet started
  48381. */
  48382. INIT = 0,
  48383. /**
  48384. * Timer started and counting
  48385. */
  48386. STARTED = 1,
  48387. /**
  48388. * Timer ended (whether aborted or time reached)
  48389. */
  48390. ENDED = 2
  48391. }
  48392. /**
  48393. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48394. *
  48395. * @param options options with which to initialize this timer
  48396. */
  48397. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48398. /**
  48399. * An advanced implementation of a timer class
  48400. */
  48401. export class AdvancedTimer<T = any> implements IDisposable {
  48402. /**
  48403. * Will notify each time the timer calculates the remaining time
  48404. */
  48405. onEachCountObservable: Observable<ITimerData<T>>;
  48406. /**
  48407. * Will trigger when the timer was aborted due to the break condition
  48408. */
  48409. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48410. /**
  48411. * Will trigger when the timer ended successfully
  48412. */
  48413. onTimerEndedObservable: Observable<ITimerData<T>>;
  48414. /**
  48415. * Will trigger when the timer state has changed
  48416. */
  48417. onStateChangedObservable: Observable<TimerState>;
  48418. private _observer;
  48419. private _contextObservable;
  48420. private _observableParameters;
  48421. private _startTime;
  48422. private _timer;
  48423. private _state;
  48424. private _breakCondition;
  48425. private _timeToEnd;
  48426. private _breakOnNextTick;
  48427. /**
  48428. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48429. * @param options construction options for this advanced timer
  48430. */
  48431. constructor(options: ITimerOptions<T>);
  48432. /**
  48433. * set a breaking condition for this timer. Default is to never break during count
  48434. * @param predicate the new break condition. Returns true to break, false otherwise
  48435. */
  48436. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48437. /**
  48438. * Reset ALL associated observables in this advanced timer
  48439. */
  48440. clearObservables(): void;
  48441. /**
  48442. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48443. *
  48444. * @param timeToEnd how much time to measure until timer ended
  48445. */
  48446. start(timeToEnd?: number): void;
  48447. /**
  48448. * Will force a stop on the next tick.
  48449. */
  48450. stop(): void;
  48451. /**
  48452. * Dispose this timer, clearing all resources
  48453. */
  48454. dispose(): void;
  48455. private _setState;
  48456. private _tick;
  48457. private _stop;
  48458. }
  48459. }
  48460. declare module BABYLON {
  48461. /**
  48462. * The options container for the teleportation module
  48463. */
  48464. export interface IWebXRTeleportationOptions {
  48465. /**
  48466. * if provided, this scene will be used to render meshes.
  48467. */
  48468. customUtilityLayerScene?: Scene;
  48469. /**
  48470. * Values to configure the default target mesh
  48471. */
  48472. defaultTargetMeshOptions?: {
  48473. /**
  48474. * Fill color of the teleportation area
  48475. */
  48476. teleportationFillColor?: string;
  48477. /**
  48478. * Border color for the teleportation area
  48479. */
  48480. teleportationBorderColor?: string;
  48481. /**
  48482. * Disable the mesh's animation sequence
  48483. */
  48484. disableAnimation?: boolean;
  48485. /**
  48486. * Disable lighting on the material or the ring and arrow
  48487. */
  48488. disableLighting?: boolean;
  48489. /**
  48490. * Override the default material of the torus and arrow
  48491. */
  48492. torusArrowMaterial?: Material;
  48493. };
  48494. /**
  48495. * A list of meshes to use as floor meshes.
  48496. * Meshes can be added and removed after initializing the feature using the
  48497. * addFloorMesh and removeFloorMesh functions
  48498. * If empty, rotation will still work
  48499. */
  48500. floorMeshes?: AbstractMesh[];
  48501. /**
  48502. * use this rendering group id for the meshes (optional)
  48503. */
  48504. renderingGroupId?: number;
  48505. /**
  48506. * Should teleportation move only to snap points
  48507. */
  48508. snapPointsOnly?: boolean;
  48509. /**
  48510. * An array of points to which the teleportation will snap to.
  48511. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48512. */
  48513. snapPositions?: Vector3[];
  48514. /**
  48515. * How close should the teleportation ray be in order to snap to position.
  48516. * Default to 0.8 units (meters)
  48517. */
  48518. snapToPositionRadius?: number;
  48519. /**
  48520. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48521. * If you want to support rotation, make sure your mesh has a direction indicator.
  48522. *
  48523. * When left untouched, the default mesh will be initialized.
  48524. */
  48525. teleportationTargetMesh?: AbstractMesh;
  48526. /**
  48527. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48528. */
  48529. timeToTeleport?: number;
  48530. /**
  48531. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48532. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48533. */
  48534. useMainComponentOnly?: boolean;
  48535. /**
  48536. * Should meshes created here be added to a utility layer or the main scene
  48537. */
  48538. useUtilityLayer?: boolean;
  48539. /**
  48540. * Babylon XR Input class for controller
  48541. */
  48542. xrInput: WebXRInput;
  48543. }
  48544. /**
  48545. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48546. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48547. * the input of the attached controllers.
  48548. */
  48549. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48550. private _options;
  48551. private _controllers;
  48552. private _currentTeleportationControllerId;
  48553. private _floorMeshes;
  48554. private _quadraticBezierCurve;
  48555. private _selectionFeature;
  48556. private _snapToPositions;
  48557. private _snappedToPoint;
  48558. private _teleportationRingMaterial?;
  48559. private _tmpRay;
  48560. private _tmpVector;
  48561. /**
  48562. * The module's name
  48563. */
  48564. static readonly Name: string;
  48565. /**
  48566. * The (Babylon) version of this module.
  48567. * This is an integer representing the implementation version.
  48568. * This number does not correspond to the webxr specs version
  48569. */
  48570. static readonly Version: number;
  48571. /**
  48572. * Is movement backwards enabled
  48573. */
  48574. backwardsMovementEnabled: boolean;
  48575. /**
  48576. * Distance to travel when moving backwards
  48577. */
  48578. backwardsTeleportationDistance: number;
  48579. /**
  48580. * The distance from the user to the inspection point in the direction of the controller
  48581. * A higher number will allow the user to move further
  48582. * defaults to 5 (meters, in xr units)
  48583. */
  48584. parabolicCheckRadius: number;
  48585. /**
  48586. * Should the module support parabolic ray on top of direct ray
  48587. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48588. * Very helpful when moving between floors / different heights
  48589. */
  48590. parabolicRayEnabled: boolean;
  48591. /**
  48592. * How much rotation should be applied when rotating right and left
  48593. */
  48594. rotationAngle: number;
  48595. /**
  48596. * Is rotation enabled when moving forward?
  48597. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48598. */
  48599. rotationEnabled: boolean;
  48600. /**
  48601. * constructs a new anchor system
  48602. * @param _xrSessionManager an instance of WebXRSessionManager
  48603. * @param _options configuration object for this feature
  48604. */
  48605. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48606. /**
  48607. * Get the snapPointsOnly flag
  48608. */
  48609. get snapPointsOnly(): boolean;
  48610. /**
  48611. * Sets the snapPointsOnly flag
  48612. * @param snapToPoints should teleportation be exclusively to snap points
  48613. */
  48614. set snapPointsOnly(snapToPoints: boolean);
  48615. /**
  48616. * Add a new mesh to the floor meshes array
  48617. * @param mesh the mesh to use as floor mesh
  48618. */
  48619. addFloorMesh(mesh: AbstractMesh): void;
  48620. /**
  48621. * Add a new snap-to point to fix teleportation to this position
  48622. * @param newSnapPoint The new Snap-To point
  48623. */
  48624. addSnapPoint(newSnapPoint: Vector3): void;
  48625. attach(): boolean;
  48626. detach(): boolean;
  48627. dispose(): void;
  48628. /**
  48629. * Remove a mesh from the floor meshes array
  48630. * @param mesh the mesh to remove
  48631. */
  48632. removeFloorMesh(mesh: AbstractMesh): void;
  48633. /**
  48634. * Remove a mesh from the floor meshes array using its name
  48635. * @param name the mesh name to remove
  48636. */
  48637. removeFloorMeshByName(name: string): void;
  48638. /**
  48639. * 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
  48640. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48641. * @returns was the point found and removed or not
  48642. */
  48643. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48644. /**
  48645. * This function sets a selection feature that will be disabled when
  48646. * the forward ray is shown and will be reattached when hidden.
  48647. * This is used to remove the selection rays when moving.
  48648. * @param selectionFeature the feature to disable when forward movement is enabled
  48649. */
  48650. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48651. protected _onXRFrame(_xrFrame: XRFrame): void;
  48652. private _attachController;
  48653. private _createDefaultTargetMesh;
  48654. private _detachController;
  48655. private _findClosestSnapPointWithRadius;
  48656. private _setTargetMeshPosition;
  48657. private _setTargetMeshVisibility;
  48658. private _showParabolicPath;
  48659. private _teleportForward;
  48660. }
  48661. }
  48662. declare module BABYLON {
  48663. /**
  48664. * Options for the default xr helper
  48665. */
  48666. export class WebXRDefaultExperienceOptions {
  48667. /**
  48668. * Enable or disable default UI to enter XR
  48669. */
  48670. disableDefaultUI?: boolean;
  48671. /**
  48672. * Should teleportation not initialize. defaults to false.
  48673. */
  48674. disableTeleportation?: boolean;
  48675. /**
  48676. * Floor meshes that will be used for teleport
  48677. */
  48678. floorMeshes?: Array<AbstractMesh>;
  48679. /**
  48680. * If set to true, the first frame will not be used to reset position
  48681. * The first frame is mainly used when copying transformation from the old camera
  48682. * Mainly used in AR
  48683. */
  48684. ignoreNativeCameraTransformation?: boolean;
  48685. /**
  48686. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48687. */
  48688. inputOptions?: IWebXRInputOptions;
  48689. /**
  48690. * optional configuration for the output canvas
  48691. */
  48692. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48693. /**
  48694. * optional UI options. This can be used among other to change session mode and reference space type
  48695. */
  48696. uiOptions?: WebXREnterExitUIOptions;
  48697. /**
  48698. * When loading teleportation and pointer select, use stable versions instead of latest.
  48699. */
  48700. useStablePlugins?: boolean;
  48701. /**
  48702. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48703. */
  48704. renderingGroupId?: number;
  48705. /**
  48706. * A list of optional features to init the session with
  48707. * If set to true, all features we support will be added
  48708. */
  48709. optionalFeatures?: boolean | string[];
  48710. }
  48711. /**
  48712. * Default experience which provides a similar setup to the previous webVRExperience
  48713. */
  48714. export class WebXRDefaultExperience {
  48715. /**
  48716. * Base experience
  48717. */
  48718. baseExperience: WebXRExperienceHelper;
  48719. /**
  48720. * Enables ui for entering/exiting xr
  48721. */
  48722. enterExitUI: WebXREnterExitUI;
  48723. /**
  48724. * Input experience extension
  48725. */
  48726. input: WebXRInput;
  48727. /**
  48728. * Enables laser pointer and selection
  48729. */
  48730. pointerSelection: WebXRControllerPointerSelection;
  48731. /**
  48732. * Default target xr should render to
  48733. */
  48734. renderTarget: WebXRRenderTarget;
  48735. /**
  48736. * Enables teleportation
  48737. */
  48738. teleportation: WebXRMotionControllerTeleportation;
  48739. private constructor();
  48740. /**
  48741. * Creates the default xr experience
  48742. * @param scene scene
  48743. * @param options options for basic configuration
  48744. * @returns resulting WebXRDefaultExperience
  48745. */
  48746. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48747. /**
  48748. * DIsposes of the experience helper
  48749. */
  48750. dispose(): void;
  48751. }
  48752. }
  48753. declare module BABYLON {
  48754. /**
  48755. * Options to modify the vr teleportation behavior.
  48756. */
  48757. export interface VRTeleportationOptions {
  48758. /**
  48759. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48760. */
  48761. floorMeshName?: string;
  48762. /**
  48763. * A list of meshes to be used as the teleportation floor. (default: empty)
  48764. */
  48765. floorMeshes?: Mesh[];
  48766. /**
  48767. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48768. */
  48769. teleportationMode?: number;
  48770. /**
  48771. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48772. */
  48773. teleportationTime?: number;
  48774. /**
  48775. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48776. */
  48777. teleportationSpeed?: number;
  48778. /**
  48779. * The easing function used in the animation or null for Linear. (default CircleEase)
  48780. */
  48781. easingFunction?: EasingFunction;
  48782. }
  48783. /**
  48784. * Options to modify the vr experience helper's behavior.
  48785. */
  48786. export interface VRExperienceHelperOptions extends WebVROptions {
  48787. /**
  48788. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48789. */
  48790. createDeviceOrientationCamera?: boolean;
  48791. /**
  48792. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48793. */
  48794. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48795. /**
  48796. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48797. */
  48798. laserToggle?: boolean;
  48799. /**
  48800. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48801. */
  48802. floorMeshes?: Mesh[];
  48803. /**
  48804. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48805. */
  48806. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48807. /**
  48808. * Defines if WebXR should be used instead of WebVR (if available)
  48809. */
  48810. useXR?: boolean;
  48811. }
  48812. /**
  48813. * Event containing information after VR has been entered
  48814. */
  48815. export class OnAfterEnteringVRObservableEvent {
  48816. /**
  48817. * If entering vr was successful
  48818. */
  48819. success: boolean;
  48820. }
  48821. /**
  48822. * Helps to quickly add VR support to an existing scene.
  48823. * See https://doc.babylonjs.com/how_to/webvr_helper
  48824. */
  48825. export class VRExperienceHelper {
  48826. /** Options to modify the vr experience helper's behavior. */
  48827. webVROptions: VRExperienceHelperOptions;
  48828. private _scene;
  48829. private _position;
  48830. private _btnVR;
  48831. private _btnVRDisplayed;
  48832. private _webVRsupported;
  48833. private _webVRready;
  48834. private _webVRrequesting;
  48835. private _webVRpresenting;
  48836. private _hasEnteredVR;
  48837. private _fullscreenVRpresenting;
  48838. private _inputElement;
  48839. private _webVRCamera;
  48840. private _vrDeviceOrientationCamera;
  48841. private _deviceOrientationCamera;
  48842. private _existingCamera;
  48843. private _onKeyDown;
  48844. private _onVrDisplayPresentChange;
  48845. private _onVRDisplayChanged;
  48846. private _onVRRequestPresentStart;
  48847. private _onVRRequestPresentComplete;
  48848. /**
  48849. * 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)
  48850. */
  48851. enableGazeEvenWhenNoPointerLock: boolean;
  48852. /**
  48853. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48854. */
  48855. exitVROnDoubleTap: boolean;
  48856. /**
  48857. * Observable raised right before entering VR.
  48858. */
  48859. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48860. /**
  48861. * Observable raised when entering VR has completed.
  48862. */
  48863. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48864. /**
  48865. * Observable raised when exiting VR.
  48866. */
  48867. onExitingVRObservable: Observable<VRExperienceHelper>;
  48868. /**
  48869. * Observable raised when controller mesh is loaded.
  48870. */
  48871. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48872. /** Return this.onEnteringVRObservable
  48873. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48874. */
  48875. get onEnteringVR(): Observable<VRExperienceHelper>;
  48876. /** Return this.onExitingVRObservable
  48877. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48878. */
  48879. get onExitingVR(): Observable<VRExperienceHelper>;
  48880. /** Return this.onControllerMeshLoadedObservable
  48881. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48882. */
  48883. get onControllerMeshLoaded(): Observable<WebVRController>;
  48884. private _rayLength;
  48885. private _useCustomVRButton;
  48886. private _teleportationRequested;
  48887. private _teleportActive;
  48888. private _floorMeshName;
  48889. private _floorMeshesCollection;
  48890. private _teleportationMode;
  48891. private _teleportationTime;
  48892. private _teleportationSpeed;
  48893. private _teleportationEasing;
  48894. private _rotationAllowed;
  48895. private _teleportBackwardsVector;
  48896. private _teleportationTarget;
  48897. private _isDefaultTeleportationTarget;
  48898. private _postProcessMove;
  48899. private _teleportationFillColor;
  48900. private _teleportationBorderColor;
  48901. private _rotationAngle;
  48902. private _haloCenter;
  48903. private _cameraGazer;
  48904. private _padSensibilityUp;
  48905. private _padSensibilityDown;
  48906. private _leftController;
  48907. private _rightController;
  48908. private _gazeColor;
  48909. private _laserColor;
  48910. private _pickedLaserColor;
  48911. private _pickedGazeColor;
  48912. /**
  48913. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48914. */
  48915. onNewMeshSelected: Observable<AbstractMesh>;
  48916. /**
  48917. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48918. * This observable will provide the mesh and the controller used to select the mesh
  48919. */
  48920. onMeshSelectedWithController: Observable<{
  48921. mesh: AbstractMesh;
  48922. controller: WebVRController;
  48923. }>;
  48924. /**
  48925. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48926. */
  48927. onNewMeshPicked: Observable<PickingInfo>;
  48928. private _circleEase;
  48929. /**
  48930. * Observable raised before camera teleportation
  48931. */
  48932. onBeforeCameraTeleport: Observable<Vector3>;
  48933. /**
  48934. * Observable raised after camera teleportation
  48935. */
  48936. onAfterCameraTeleport: Observable<Vector3>;
  48937. /**
  48938. * Observable raised when current selected mesh gets unselected
  48939. */
  48940. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48941. private _raySelectionPredicate;
  48942. /**
  48943. * To be optionaly changed by user to define custom ray selection
  48944. */
  48945. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48946. /**
  48947. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48948. */
  48949. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48950. /**
  48951. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48952. */
  48953. teleportationEnabled: boolean;
  48954. private _defaultHeight;
  48955. private _teleportationInitialized;
  48956. private _interactionsEnabled;
  48957. private _interactionsRequested;
  48958. private _displayGaze;
  48959. private _displayLaserPointer;
  48960. /**
  48961. * The mesh used to display where the user is going to teleport.
  48962. */
  48963. get teleportationTarget(): Mesh;
  48964. /**
  48965. * Sets the mesh to be used to display where the user is going to teleport.
  48966. */
  48967. set teleportationTarget(value: Mesh);
  48968. /**
  48969. * 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
  48970. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48971. * See https://doc.babylonjs.com/resources/baking_transformations
  48972. */
  48973. get gazeTrackerMesh(): Mesh;
  48974. set gazeTrackerMesh(value: Mesh);
  48975. /**
  48976. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48977. */
  48978. updateGazeTrackerScale: boolean;
  48979. /**
  48980. * If the gaze trackers color should be updated when selecting meshes
  48981. */
  48982. updateGazeTrackerColor: boolean;
  48983. /**
  48984. * If the controller laser color should be updated when selecting meshes
  48985. */
  48986. updateControllerLaserColor: boolean;
  48987. /**
  48988. * The gaze tracking mesh corresponding to the left controller
  48989. */
  48990. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48991. /**
  48992. * The gaze tracking mesh corresponding to the right controller
  48993. */
  48994. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48995. /**
  48996. * If the ray of the gaze should be displayed.
  48997. */
  48998. get displayGaze(): boolean;
  48999. /**
  49000. * Sets if the ray of the gaze should be displayed.
  49001. */
  49002. set displayGaze(value: boolean);
  49003. /**
  49004. * If the ray of the LaserPointer should be displayed.
  49005. */
  49006. get displayLaserPointer(): boolean;
  49007. /**
  49008. * Sets if the ray of the LaserPointer should be displayed.
  49009. */
  49010. set displayLaserPointer(value: boolean);
  49011. /**
  49012. * The deviceOrientationCamera used as the camera when not in VR.
  49013. */
  49014. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49015. /**
  49016. * Based on the current WebVR support, returns the current VR camera used.
  49017. */
  49018. get currentVRCamera(): Nullable<Camera>;
  49019. /**
  49020. * The webVRCamera which is used when in VR.
  49021. */
  49022. get webVRCamera(): WebVRFreeCamera;
  49023. /**
  49024. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49025. */
  49026. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49027. /**
  49028. * The html button that is used to trigger entering into VR.
  49029. */
  49030. get vrButton(): Nullable<HTMLButtonElement>;
  49031. private get _teleportationRequestInitiated();
  49032. /**
  49033. * Defines whether or not Pointer lock should be requested when switching to
  49034. * full screen.
  49035. */
  49036. requestPointerLockOnFullScreen: boolean;
  49037. /**
  49038. * If asking to force XR, this will be populated with the default xr experience
  49039. */
  49040. xr: WebXRDefaultExperience;
  49041. /**
  49042. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49043. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49044. */
  49045. xrTestDone: boolean;
  49046. /**
  49047. * Instantiates a VRExperienceHelper.
  49048. * Helps to quickly add VR support to an existing scene.
  49049. * @param scene The scene the VRExperienceHelper belongs to.
  49050. * @param webVROptions Options to modify the vr experience helper's behavior.
  49051. */
  49052. constructor(scene: Scene,
  49053. /** Options to modify the vr experience helper's behavior. */
  49054. webVROptions?: VRExperienceHelperOptions);
  49055. private completeVRInit;
  49056. private _onDefaultMeshLoaded;
  49057. private _onResize;
  49058. private _onFullscreenChange;
  49059. /**
  49060. * Gets a value indicating if we are currently in VR mode.
  49061. */
  49062. get isInVRMode(): boolean;
  49063. private onVrDisplayPresentChange;
  49064. private onVRDisplayChanged;
  49065. private moveButtonToBottomRight;
  49066. private displayVRButton;
  49067. private updateButtonVisibility;
  49068. private _cachedAngularSensibility;
  49069. /**
  49070. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49071. * Otherwise, will use the fullscreen API.
  49072. */
  49073. enterVR(): void;
  49074. /**
  49075. * Attempt to exit VR, or fullscreen.
  49076. */
  49077. exitVR(): void;
  49078. /**
  49079. * The position of the vr experience helper.
  49080. */
  49081. get position(): Vector3;
  49082. /**
  49083. * Sets the position of the vr experience helper.
  49084. */
  49085. set position(value: Vector3);
  49086. /**
  49087. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49088. */
  49089. enableInteractions(): void;
  49090. private get _noControllerIsActive();
  49091. private beforeRender;
  49092. private _isTeleportationFloor;
  49093. /**
  49094. * Adds a floor mesh to be used for teleportation.
  49095. * @param floorMesh the mesh to be used for teleportation.
  49096. */
  49097. addFloorMesh(floorMesh: Mesh): void;
  49098. /**
  49099. * Removes a floor mesh from being used for teleportation.
  49100. * @param floorMesh the mesh to be removed.
  49101. */
  49102. removeFloorMesh(floorMesh: Mesh): void;
  49103. /**
  49104. * Enables interactions and teleportation using the VR controllers and gaze.
  49105. * @param vrTeleportationOptions options to modify teleportation behavior.
  49106. */
  49107. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49108. private _onNewGamepadConnected;
  49109. private _tryEnableInteractionOnController;
  49110. private _onNewGamepadDisconnected;
  49111. private _enableInteractionOnController;
  49112. private _checkTeleportWithRay;
  49113. private _checkRotate;
  49114. private _checkTeleportBackwards;
  49115. private _enableTeleportationOnController;
  49116. private _createTeleportationCircles;
  49117. private _displayTeleportationTarget;
  49118. private _hideTeleportationTarget;
  49119. private _rotateCamera;
  49120. private _moveTeleportationSelectorTo;
  49121. private _workingVector;
  49122. private _workingQuaternion;
  49123. private _workingMatrix;
  49124. /**
  49125. * Time Constant Teleportation Mode
  49126. */
  49127. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49128. /**
  49129. * Speed Constant Teleportation Mode
  49130. */
  49131. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49132. /**
  49133. * Teleports the users feet to the desired location
  49134. * @param location The location where the user's feet should be placed
  49135. */
  49136. teleportCamera(location: Vector3): void;
  49137. private _convertNormalToDirectionOfRay;
  49138. private _castRayAndSelectObject;
  49139. private _notifySelectedMeshUnselected;
  49140. /**
  49141. * Permanently set new colors for the laser pointer
  49142. * @param color the new laser color
  49143. * @param pickedColor the new laser color when picked mesh detected
  49144. */
  49145. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49146. /**
  49147. * Set lighting enabled / disabled on the laser pointer of both controllers
  49148. * @param enabled should the lighting be enabled on the laser pointer
  49149. */
  49150. setLaserLightingState(enabled?: boolean): void;
  49151. /**
  49152. * Permanently set new colors for the gaze pointer
  49153. * @param color the new gaze color
  49154. * @param pickedColor the new gaze color when picked mesh detected
  49155. */
  49156. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49157. /**
  49158. * Sets the color of the laser ray from the vr controllers.
  49159. * @param color new color for the ray.
  49160. */
  49161. changeLaserColor(color: Color3): void;
  49162. /**
  49163. * Sets the color of the ray from the vr headsets gaze.
  49164. * @param color new color for the ray.
  49165. */
  49166. changeGazeColor(color: Color3): void;
  49167. /**
  49168. * Exits VR and disposes of the vr experience helper
  49169. */
  49170. dispose(): void;
  49171. /**
  49172. * Gets the name of the VRExperienceHelper class
  49173. * @returns "VRExperienceHelper"
  49174. */
  49175. getClassName(): string;
  49176. }
  49177. }
  49178. declare module BABYLON {
  49179. /**
  49180. * Contains an array of blocks representing the octree
  49181. */
  49182. export interface IOctreeContainer<T> {
  49183. /**
  49184. * Blocks within the octree
  49185. */
  49186. blocks: Array<OctreeBlock<T>>;
  49187. }
  49188. /**
  49189. * Class used to store a cell in an octree
  49190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49191. */
  49192. export class OctreeBlock<T> {
  49193. /**
  49194. * Gets the content of the current block
  49195. */
  49196. entries: T[];
  49197. /**
  49198. * Gets the list of block children
  49199. */
  49200. blocks: Array<OctreeBlock<T>>;
  49201. private _depth;
  49202. private _maxDepth;
  49203. private _capacity;
  49204. private _minPoint;
  49205. private _maxPoint;
  49206. private _boundingVectors;
  49207. private _creationFunc;
  49208. /**
  49209. * Creates a new block
  49210. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49211. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49212. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49213. * @param depth defines the current depth of this block in the octree
  49214. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49215. * @param creationFunc defines a callback to call when an element is added to the block
  49216. */
  49217. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49218. /**
  49219. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49220. */
  49221. get capacity(): number;
  49222. /**
  49223. * Gets the minimum vector (in world space) of the block's bounding box
  49224. */
  49225. get minPoint(): Vector3;
  49226. /**
  49227. * Gets the maximum vector (in world space) of the block's bounding box
  49228. */
  49229. get maxPoint(): Vector3;
  49230. /**
  49231. * Add a new element to this block
  49232. * @param entry defines the element to add
  49233. */
  49234. addEntry(entry: T): void;
  49235. /**
  49236. * Remove an element from this block
  49237. * @param entry defines the element to remove
  49238. */
  49239. removeEntry(entry: T): void;
  49240. /**
  49241. * Add an array of elements to this block
  49242. * @param entries defines the array of elements to add
  49243. */
  49244. addEntries(entries: T[]): void;
  49245. /**
  49246. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49247. * @param frustumPlanes defines the frustum planes to test
  49248. * @param selection defines the array to store current content if selection is positive
  49249. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49250. */
  49251. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49252. /**
  49253. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49254. * @param sphereCenter defines the bounding sphere center
  49255. * @param sphereRadius defines the bounding sphere radius
  49256. * @param selection defines the array to store current content if selection is positive
  49257. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49258. */
  49259. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49260. /**
  49261. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49262. * @param ray defines the ray to test with
  49263. * @param selection defines the array to store current content if selection is positive
  49264. */
  49265. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49266. /**
  49267. * Subdivide the content into child blocks (this block will then be empty)
  49268. */
  49269. createInnerBlocks(): void;
  49270. /**
  49271. * @hidden
  49272. */
  49273. 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;
  49274. }
  49275. }
  49276. declare module BABYLON {
  49277. /**
  49278. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49279. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49280. */
  49281. export class Octree<T> {
  49282. /** 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.) */
  49283. maxDepth: number;
  49284. /**
  49285. * Blocks within the octree containing objects
  49286. */
  49287. blocks: Array<OctreeBlock<T>>;
  49288. /**
  49289. * Content stored in the octree
  49290. */
  49291. dynamicContent: T[];
  49292. private _maxBlockCapacity;
  49293. private _selectionContent;
  49294. private _creationFunc;
  49295. /**
  49296. * Creates a octree
  49297. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49298. * @param creationFunc function to be used to instatiate the octree
  49299. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49300. * @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.)
  49301. */
  49302. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49303. /** 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.) */
  49304. maxDepth?: number);
  49305. /**
  49306. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49307. * @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);
  49308. * @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);
  49309. * @param entries meshes to be added to the octree blocks
  49310. */
  49311. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49312. /**
  49313. * Adds a mesh to the octree
  49314. * @param entry Mesh to add to the octree
  49315. */
  49316. addMesh(entry: T): void;
  49317. /**
  49318. * Remove an element from the octree
  49319. * @param entry defines the element to remove
  49320. */
  49321. removeMesh(entry: T): void;
  49322. /**
  49323. * Selects an array of meshes within the frustum
  49324. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49325. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49326. * @returns array of meshes within the frustum
  49327. */
  49328. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49329. /**
  49330. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49331. * @param sphereCenter defines the bounding sphere center
  49332. * @param sphereRadius defines the bounding sphere radius
  49333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49334. * @returns an array of objects that intersect the sphere
  49335. */
  49336. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49337. /**
  49338. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49339. * @param ray defines the ray to test with
  49340. * @returns array of intersected objects
  49341. */
  49342. intersectsRay(ray: Ray): SmartArray<T>;
  49343. /**
  49344. * Adds a mesh into the octree block if it intersects the block
  49345. */
  49346. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49347. /**
  49348. * Adds a submesh into the octree block if it intersects the block
  49349. */
  49350. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49351. }
  49352. }
  49353. declare module BABYLON {
  49354. interface Scene {
  49355. /**
  49356. * @hidden
  49357. * Backing Filed
  49358. */
  49359. _selectionOctree: Octree<AbstractMesh>;
  49360. /**
  49361. * Gets the octree used to boost mesh selection (picking)
  49362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49363. */
  49364. selectionOctree: Octree<AbstractMesh>;
  49365. /**
  49366. * Creates or updates the octree used to boost selection (picking)
  49367. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49368. * @param maxCapacity defines the maximum capacity per leaf
  49369. * @param maxDepth defines the maximum depth of the octree
  49370. * @returns an octree of AbstractMesh
  49371. */
  49372. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49373. }
  49374. interface AbstractMesh {
  49375. /**
  49376. * @hidden
  49377. * Backing Field
  49378. */
  49379. _submeshesOctree: Octree<SubMesh>;
  49380. /**
  49381. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49382. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49383. * @param maxCapacity defines the maximum size of each block (64 by default)
  49384. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49385. * @returns the new octree
  49386. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49387. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49388. */
  49389. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49390. }
  49391. /**
  49392. * Defines the octree scene component responsible to manage any octrees
  49393. * in a given scene.
  49394. */
  49395. export class OctreeSceneComponent {
  49396. /**
  49397. * The component name help to identify the component in the list of scene components.
  49398. */
  49399. readonly name: string;
  49400. /**
  49401. * The scene the component belongs to.
  49402. */
  49403. scene: Scene;
  49404. /**
  49405. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49406. */
  49407. readonly checksIsEnabled: boolean;
  49408. /**
  49409. * Creates a new instance of the component for the given scene
  49410. * @param scene Defines the scene to register the component in
  49411. */
  49412. constructor(scene: Scene);
  49413. /**
  49414. * Registers the component in a given scene
  49415. */
  49416. register(): void;
  49417. /**
  49418. * Return the list of active meshes
  49419. * @returns the list of active meshes
  49420. */
  49421. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49422. /**
  49423. * Return the list of active sub meshes
  49424. * @param mesh The mesh to get the candidates sub meshes from
  49425. * @returns the list of active sub meshes
  49426. */
  49427. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49428. private _tempRay;
  49429. /**
  49430. * Return the list of sub meshes intersecting with a given local ray
  49431. * @param mesh defines the mesh to find the submesh for
  49432. * @param localRay defines the ray in local space
  49433. * @returns the list of intersecting sub meshes
  49434. */
  49435. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49436. /**
  49437. * Return the list of sub meshes colliding with a collider
  49438. * @param mesh defines the mesh to find the submesh for
  49439. * @param collider defines the collider to evaluate the collision against
  49440. * @returns the list of colliding sub meshes
  49441. */
  49442. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49443. /**
  49444. * Rebuilds the elements related to this component in case of
  49445. * context lost for instance.
  49446. */
  49447. rebuild(): void;
  49448. /**
  49449. * Disposes the component and the associated ressources.
  49450. */
  49451. dispose(): void;
  49452. }
  49453. }
  49454. declare module BABYLON {
  49455. /**
  49456. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49457. */
  49458. export class Gizmo implements IDisposable {
  49459. /** The utility layer the gizmo will be added to */
  49460. gizmoLayer: UtilityLayerRenderer;
  49461. /**
  49462. * The root mesh of the gizmo
  49463. */
  49464. _rootMesh: Mesh;
  49465. private _attachedMesh;
  49466. /**
  49467. * Ratio for the scale of the gizmo (Default: 1)
  49468. */
  49469. scaleRatio: number;
  49470. /**
  49471. * If a custom mesh has been set (Default: false)
  49472. */
  49473. protected _customMeshSet: boolean;
  49474. /**
  49475. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49476. * * When set, interactions will be enabled
  49477. */
  49478. get attachedMesh(): Nullable<AbstractMesh>;
  49479. set attachedMesh(value: Nullable<AbstractMesh>);
  49480. /**
  49481. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49482. * @param mesh The mesh to replace the default mesh of the gizmo
  49483. */
  49484. setCustomMesh(mesh: Mesh): void;
  49485. /**
  49486. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49487. */
  49488. updateGizmoRotationToMatchAttachedMesh: boolean;
  49489. /**
  49490. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49491. */
  49492. updateGizmoPositionToMatchAttachedMesh: boolean;
  49493. /**
  49494. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49495. */
  49496. updateScale: boolean;
  49497. protected _interactionsEnabled: boolean;
  49498. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49499. private _beforeRenderObserver;
  49500. private _tempVector;
  49501. /**
  49502. * Creates a gizmo
  49503. * @param gizmoLayer The utility layer the gizmo will be added to
  49504. */
  49505. constructor(
  49506. /** The utility layer the gizmo will be added to */
  49507. gizmoLayer?: UtilityLayerRenderer);
  49508. /**
  49509. * Updates the gizmo to match the attached mesh's position/rotation
  49510. */
  49511. protected _update(): void;
  49512. /**
  49513. * Disposes of the gizmo
  49514. */
  49515. dispose(): void;
  49516. }
  49517. }
  49518. declare module BABYLON {
  49519. /**
  49520. * Single plane drag gizmo
  49521. */
  49522. export class PlaneDragGizmo extends Gizmo {
  49523. /**
  49524. * Drag behavior responsible for the gizmos dragging interactions
  49525. */
  49526. dragBehavior: PointerDragBehavior;
  49527. private _pointerObserver;
  49528. /**
  49529. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49530. */
  49531. snapDistance: number;
  49532. /**
  49533. * Event that fires each time the gizmo snaps to a new location.
  49534. * * snapDistance is the the change in distance
  49535. */
  49536. onSnapObservable: Observable<{
  49537. snapDistance: number;
  49538. }>;
  49539. private _plane;
  49540. private _coloredMaterial;
  49541. private _hoverMaterial;
  49542. private _isEnabled;
  49543. private _parent;
  49544. /** @hidden */
  49545. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49546. /** @hidden */
  49547. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49548. /**
  49549. * Creates a PlaneDragGizmo
  49550. * @param gizmoLayer The utility layer the gizmo will be added to
  49551. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49552. * @param color The color of the gizmo
  49553. */
  49554. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49555. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49556. /**
  49557. * If the gizmo is enabled
  49558. */
  49559. set isEnabled(value: boolean);
  49560. get isEnabled(): boolean;
  49561. /**
  49562. * Disposes of the gizmo
  49563. */
  49564. dispose(): void;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. /**
  49569. * Gizmo that enables dragging a mesh along 3 axis
  49570. */
  49571. export class PositionGizmo extends Gizmo {
  49572. /**
  49573. * Internal gizmo used for interactions on the x axis
  49574. */
  49575. xGizmo: AxisDragGizmo;
  49576. /**
  49577. * Internal gizmo used for interactions on the y axis
  49578. */
  49579. yGizmo: AxisDragGizmo;
  49580. /**
  49581. * Internal gizmo used for interactions on the z axis
  49582. */
  49583. zGizmo: AxisDragGizmo;
  49584. /**
  49585. * Internal gizmo used for interactions on the yz plane
  49586. */
  49587. xPlaneGizmo: PlaneDragGizmo;
  49588. /**
  49589. * Internal gizmo used for interactions on the xz plane
  49590. */
  49591. yPlaneGizmo: PlaneDragGizmo;
  49592. /**
  49593. * Internal gizmo used for interactions on the xy plane
  49594. */
  49595. zPlaneGizmo: PlaneDragGizmo;
  49596. /**
  49597. * private variables
  49598. */
  49599. private _meshAttached;
  49600. private _updateGizmoRotationToMatchAttachedMesh;
  49601. private _snapDistance;
  49602. private _scaleRatio;
  49603. /** Fires an event when any of it's sub gizmos are dragged */
  49604. onDragStartObservable: Observable<unknown>;
  49605. /** Fires an event when any of it's sub gizmos are released from dragging */
  49606. onDragEndObservable: Observable<unknown>;
  49607. /**
  49608. * If set to true, planar drag is enabled
  49609. */
  49610. private _planarGizmoEnabled;
  49611. get attachedMesh(): Nullable<AbstractMesh>;
  49612. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49613. /**
  49614. * Creates a PositionGizmo
  49615. * @param gizmoLayer The utility layer the gizmo will be added to
  49616. */
  49617. constructor(gizmoLayer?: UtilityLayerRenderer);
  49618. /**
  49619. * If the planar drag gizmo is enabled
  49620. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49621. */
  49622. set planarGizmoEnabled(value: boolean);
  49623. get planarGizmoEnabled(): boolean;
  49624. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49625. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49626. /**
  49627. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49628. */
  49629. set snapDistance(value: number);
  49630. get snapDistance(): number;
  49631. /**
  49632. * Ratio for the scale of the gizmo (Default: 1)
  49633. */
  49634. set scaleRatio(value: number);
  49635. get scaleRatio(): number;
  49636. /**
  49637. * Disposes of the gizmo
  49638. */
  49639. dispose(): void;
  49640. /**
  49641. * CustomMeshes are not supported by this gizmo
  49642. * @param mesh The mesh to replace the default mesh of the gizmo
  49643. */
  49644. setCustomMesh(mesh: Mesh): void;
  49645. }
  49646. }
  49647. declare module BABYLON {
  49648. /**
  49649. * Single axis drag gizmo
  49650. */
  49651. export class AxisDragGizmo extends Gizmo {
  49652. /**
  49653. * Drag behavior responsible for the gizmos dragging interactions
  49654. */
  49655. dragBehavior: PointerDragBehavior;
  49656. private _pointerObserver;
  49657. /**
  49658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49659. */
  49660. snapDistance: number;
  49661. /**
  49662. * Event that fires each time the gizmo snaps to a new location.
  49663. * * snapDistance is the the change in distance
  49664. */
  49665. onSnapObservable: Observable<{
  49666. snapDistance: number;
  49667. }>;
  49668. private _isEnabled;
  49669. private _parent;
  49670. private _arrow;
  49671. private _coloredMaterial;
  49672. private _hoverMaterial;
  49673. /** @hidden */
  49674. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49675. /** @hidden */
  49676. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49677. /**
  49678. * Creates an AxisDragGizmo
  49679. * @param gizmoLayer The utility layer the gizmo will be added to
  49680. * @param dragAxis The axis which the gizmo will be able to drag on
  49681. * @param color The color of the gizmo
  49682. */
  49683. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49684. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49685. /**
  49686. * If the gizmo is enabled
  49687. */
  49688. set isEnabled(value: boolean);
  49689. get isEnabled(): boolean;
  49690. /**
  49691. * Disposes of the gizmo
  49692. */
  49693. dispose(): void;
  49694. }
  49695. }
  49696. declare module BABYLON.Debug {
  49697. /**
  49698. * The Axes viewer will show 3 axes in a specific point in space
  49699. */
  49700. export class AxesViewer {
  49701. private _xAxis;
  49702. private _yAxis;
  49703. private _zAxis;
  49704. private _scaleLinesFactor;
  49705. private _instanced;
  49706. /**
  49707. * Gets the hosting scene
  49708. */
  49709. scene: Scene;
  49710. /**
  49711. * Gets or sets a number used to scale line length
  49712. */
  49713. scaleLines: number;
  49714. /** Gets the node hierarchy used to render x-axis */
  49715. get xAxis(): TransformNode;
  49716. /** Gets the node hierarchy used to render y-axis */
  49717. get yAxis(): TransformNode;
  49718. /** Gets the node hierarchy used to render z-axis */
  49719. get zAxis(): TransformNode;
  49720. /**
  49721. * Creates a new AxesViewer
  49722. * @param scene defines the hosting scene
  49723. * @param scaleLines defines a number used to scale line length (1 by default)
  49724. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49725. * @param xAxis defines the node hierarchy used to render the x-axis
  49726. * @param yAxis defines the node hierarchy used to render the y-axis
  49727. * @param zAxis defines the node hierarchy used to render the z-axis
  49728. */
  49729. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49730. /**
  49731. * Force the viewer to update
  49732. * @param position defines the position of the viewer
  49733. * @param xaxis defines the x axis of the viewer
  49734. * @param yaxis defines the y axis of the viewer
  49735. * @param zaxis defines the z axis of the viewer
  49736. */
  49737. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49738. /**
  49739. * Creates an instance of this axes viewer.
  49740. * @returns a new axes viewer with instanced meshes
  49741. */
  49742. createInstance(): AxesViewer;
  49743. /** Releases resources */
  49744. dispose(): void;
  49745. private static _SetRenderingGroupId;
  49746. }
  49747. }
  49748. declare module BABYLON.Debug {
  49749. /**
  49750. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49751. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49752. */
  49753. export class BoneAxesViewer extends AxesViewer {
  49754. /**
  49755. * Gets or sets the target mesh where to display the axes viewer
  49756. */
  49757. mesh: Nullable<Mesh>;
  49758. /**
  49759. * Gets or sets the target bone where to display the axes viewer
  49760. */
  49761. bone: Nullable<Bone>;
  49762. /** Gets current position */
  49763. pos: Vector3;
  49764. /** Gets direction of X axis */
  49765. xaxis: Vector3;
  49766. /** Gets direction of Y axis */
  49767. yaxis: Vector3;
  49768. /** Gets direction of Z axis */
  49769. zaxis: Vector3;
  49770. /**
  49771. * Creates a new BoneAxesViewer
  49772. * @param scene defines the hosting scene
  49773. * @param bone defines the target bone
  49774. * @param mesh defines the target mesh
  49775. * @param scaleLines defines a scaling factor for line length (1 by default)
  49776. */
  49777. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49778. /**
  49779. * Force the viewer to update
  49780. */
  49781. update(): void;
  49782. /** Releases resources */
  49783. dispose(): void;
  49784. }
  49785. }
  49786. declare module BABYLON {
  49787. /**
  49788. * Interface used to define scene explorer extensibility option
  49789. */
  49790. export interface IExplorerExtensibilityOption {
  49791. /**
  49792. * Define the option label
  49793. */
  49794. label: string;
  49795. /**
  49796. * Defines the action to execute on click
  49797. */
  49798. action: (entity: any) => void;
  49799. }
  49800. /**
  49801. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49802. */
  49803. export interface IExplorerExtensibilityGroup {
  49804. /**
  49805. * Defines a predicate to test if a given type mut be extended
  49806. */
  49807. predicate: (entity: any) => boolean;
  49808. /**
  49809. * Gets the list of options added to a type
  49810. */
  49811. entries: IExplorerExtensibilityOption[];
  49812. }
  49813. /**
  49814. * Interface used to define the options to use to create the Inspector
  49815. */
  49816. export interface IInspectorOptions {
  49817. /**
  49818. * Display in overlay mode (default: false)
  49819. */
  49820. overlay?: boolean;
  49821. /**
  49822. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49823. */
  49824. globalRoot?: HTMLElement;
  49825. /**
  49826. * Display the Scene explorer
  49827. */
  49828. showExplorer?: boolean;
  49829. /**
  49830. * Display the property inspector
  49831. */
  49832. showInspector?: boolean;
  49833. /**
  49834. * Display in embed mode (both panes on the right)
  49835. */
  49836. embedMode?: boolean;
  49837. /**
  49838. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49839. */
  49840. handleResize?: boolean;
  49841. /**
  49842. * Allow the panes to popup (default: true)
  49843. */
  49844. enablePopup?: boolean;
  49845. /**
  49846. * Allow the panes to be closed by users (default: true)
  49847. */
  49848. enableClose?: boolean;
  49849. /**
  49850. * Optional list of extensibility entries
  49851. */
  49852. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49853. /**
  49854. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49855. */
  49856. inspectorURL?: string;
  49857. /**
  49858. * Optional initial tab (default to DebugLayerTab.Properties)
  49859. */
  49860. initialTab?: DebugLayerTab;
  49861. }
  49862. interface Scene {
  49863. /**
  49864. * @hidden
  49865. * Backing field
  49866. */
  49867. _debugLayer: DebugLayer;
  49868. /**
  49869. * Gets the debug layer (aka Inspector) associated with the scene
  49870. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49871. */
  49872. debugLayer: DebugLayer;
  49873. }
  49874. /**
  49875. * Enum of inspector action tab
  49876. */
  49877. export enum DebugLayerTab {
  49878. /**
  49879. * Properties tag (default)
  49880. */
  49881. Properties = 0,
  49882. /**
  49883. * Debug tab
  49884. */
  49885. Debug = 1,
  49886. /**
  49887. * Statistics tab
  49888. */
  49889. Statistics = 2,
  49890. /**
  49891. * Tools tab
  49892. */
  49893. Tools = 3,
  49894. /**
  49895. * Settings tab
  49896. */
  49897. Settings = 4
  49898. }
  49899. /**
  49900. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49901. * what is happening in your scene
  49902. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49903. */
  49904. export class DebugLayer {
  49905. /**
  49906. * Define the url to get the inspector script from.
  49907. * By default it uses the babylonjs CDN.
  49908. * @ignoreNaming
  49909. */
  49910. static InspectorURL: string;
  49911. private _scene;
  49912. private BJSINSPECTOR;
  49913. private _onPropertyChangedObservable?;
  49914. /**
  49915. * Observable triggered when a property is changed through the inspector.
  49916. */
  49917. get onPropertyChangedObservable(): any;
  49918. /**
  49919. * Instantiates a new debug layer.
  49920. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49921. * what is happening in your scene
  49922. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49923. * @param scene Defines the scene to inspect
  49924. */
  49925. constructor(scene: Scene);
  49926. /** Creates the inspector window. */
  49927. private _createInspector;
  49928. /**
  49929. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49930. * @param entity defines the entity to select
  49931. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49932. */
  49933. select(entity: any, lineContainerTitles?: string | string[]): void;
  49934. /** Get the inspector from bundle or global */
  49935. private _getGlobalInspector;
  49936. /**
  49937. * Get if the inspector is visible or not.
  49938. * @returns true if visible otherwise, false
  49939. */
  49940. isVisible(): boolean;
  49941. /**
  49942. * Hide the inspector and close its window.
  49943. */
  49944. hide(): void;
  49945. /**
  49946. * Update the scene in the inspector
  49947. */
  49948. setAsActiveScene(): void;
  49949. /**
  49950. * Launch the debugLayer.
  49951. * @param config Define the configuration of the inspector
  49952. * @return a promise fulfilled when the debug layer is visible
  49953. */
  49954. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49955. }
  49956. }
  49957. declare module BABYLON {
  49958. /**
  49959. * Class containing static functions to help procedurally build meshes
  49960. */
  49961. export class BoxBuilder {
  49962. /**
  49963. * Creates a box mesh
  49964. * * The parameter `size` sets the size (float) of each box side (default 1)
  49965. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49966. * * 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)
  49967. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49969. * * 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
  49970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49971. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49972. * @param name defines the name of the mesh
  49973. * @param options defines the options used to create the mesh
  49974. * @param scene defines the hosting scene
  49975. * @returns the box mesh
  49976. */
  49977. static CreateBox(name: string, options: {
  49978. size?: number;
  49979. width?: number;
  49980. height?: number;
  49981. depth?: number;
  49982. faceUV?: Vector4[];
  49983. faceColors?: Color4[];
  49984. sideOrientation?: number;
  49985. frontUVs?: Vector4;
  49986. backUVs?: Vector4;
  49987. wrap?: boolean;
  49988. topBaseAt?: number;
  49989. bottomBaseAt?: number;
  49990. updatable?: boolean;
  49991. }, scene?: Nullable<Scene>): Mesh;
  49992. }
  49993. }
  49994. declare module BABYLON.Debug {
  49995. /**
  49996. * Used to show the physics impostor around the specific mesh
  49997. */
  49998. export class PhysicsViewer {
  49999. /** @hidden */
  50000. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50001. /** @hidden */
  50002. protected _meshes: Array<Nullable<AbstractMesh>>;
  50003. /** @hidden */
  50004. protected _scene: Nullable<Scene>;
  50005. /** @hidden */
  50006. protected _numMeshes: number;
  50007. /** @hidden */
  50008. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50009. private _renderFunction;
  50010. private _utilityLayer;
  50011. private _debugBoxMesh;
  50012. private _debugSphereMesh;
  50013. private _debugCylinderMesh;
  50014. private _debugMaterial;
  50015. private _debugMeshMeshes;
  50016. /**
  50017. * Creates a new PhysicsViewer
  50018. * @param scene defines the hosting scene
  50019. */
  50020. constructor(scene: Scene);
  50021. /** @hidden */
  50022. protected _updateDebugMeshes(): void;
  50023. /**
  50024. * Renders a specified physic impostor
  50025. * @param impostor defines the impostor to render
  50026. * @param targetMesh defines the mesh represented by the impostor
  50027. * @returns the new debug mesh used to render the impostor
  50028. */
  50029. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50030. /**
  50031. * Hides a specified physic impostor
  50032. * @param impostor defines the impostor to hide
  50033. */
  50034. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50035. private _getDebugMaterial;
  50036. private _getDebugBoxMesh;
  50037. private _getDebugSphereMesh;
  50038. private _getDebugCylinderMesh;
  50039. private _getDebugMeshMesh;
  50040. private _getDebugMesh;
  50041. /** Releases all resources */
  50042. dispose(): void;
  50043. }
  50044. }
  50045. declare module BABYLON {
  50046. /**
  50047. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50048. * in order to better appreciate the issue one might have.
  50049. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50050. */
  50051. export class RayHelper {
  50052. /**
  50053. * Defines the ray we are currently tryin to visualize.
  50054. */
  50055. ray: Nullable<Ray>;
  50056. private _renderPoints;
  50057. private _renderLine;
  50058. private _renderFunction;
  50059. private _scene;
  50060. private _updateToMeshFunction;
  50061. private _attachedToMesh;
  50062. private _meshSpaceDirection;
  50063. private _meshSpaceOrigin;
  50064. /**
  50065. * Helper function to create a colored helper in a scene in one line.
  50066. * @param ray Defines the ray we are currently tryin to visualize
  50067. * @param scene Defines the scene the ray is used in
  50068. * @param color Defines the color we want to see the ray in
  50069. * @returns The newly created ray helper.
  50070. */
  50071. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50072. /**
  50073. * Instantiate a new ray helper.
  50074. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50075. * in order to better appreciate the issue one might have.
  50076. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50077. * @param ray Defines the ray we are currently tryin to visualize
  50078. */
  50079. constructor(ray: Ray);
  50080. /**
  50081. * Shows the ray we are willing to debug.
  50082. * @param scene Defines the scene the ray needs to be rendered in
  50083. * @param color Defines the color the ray needs to be rendered in
  50084. */
  50085. show(scene: Scene, color?: Color3): void;
  50086. /**
  50087. * Hides the ray we are debugging.
  50088. */
  50089. hide(): void;
  50090. private _render;
  50091. /**
  50092. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50093. * @param mesh Defines the mesh we want the helper attached to
  50094. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50095. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50096. * @param length Defines the length of the ray
  50097. */
  50098. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50099. /**
  50100. * Detach the ray helper from the mesh it has previously been attached to.
  50101. */
  50102. detachFromMesh(): void;
  50103. private _updateToMesh;
  50104. /**
  50105. * Dispose the helper and release its associated resources.
  50106. */
  50107. dispose(): void;
  50108. }
  50109. }
  50110. declare module BABYLON.Debug {
  50111. /**
  50112. * Class used to render a debug view of a given skeleton
  50113. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50114. */
  50115. export class SkeletonViewer {
  50116. /** defines the skeleton to render */
  50117. skeleton: Skeleton;
  50118. /** defines the mesh attached to the skeleton */
  50119. mesh: AbstractMesh;
  50120. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50121. autoUpdateBonesMatrices: boolean;
  50122. /** defines the rendering group id to use with the viewer */
  50123. renderingGroupId: number;
  50124. /** Gets or sets the color used to render the skeleton */
  50125. color: Color3;
  50126. private _scene;
  50127. private _debugLines;
  50128. private _debugMesh;
  50129. private _isEnabled;
  50130. private _renderFunction;
  50131. private _utilityLayer;
  50132. /**
  50133. * Returns the mesh used to render the bones
  50134. */
  50135. get debugMesh(): Nullable<LinesMesh>;
  50136. /**
  50137. * Creates a new SkeletonViewer
  50138. * @param skeleton defines the skeleton to render
  50139. * @param mesh defines the mesh attached to the skeleton
  50140. * @param scene defines the hosting scene
  50141. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50142. * @param renderingGroupId defines the rendering group id to use with the viewer
  50143. */
  50144. constructor(
  50145. /** defines the skeleton to render */
  50146. skeleton: Skeleton,
  50147. /** defines the mesh attached to the skeleton */
  50148. mesh: AbstractMesh, scene: Scene,
  50149. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50150. autoUpdateBonesMatrices?: boolean,
  50151. /** defines the rendering group id to use with the viewer */
  50152. renderingGroupId?: number);
  50153. /** Gets or sets a boolean indicating if the viewer is enabled */
  50154. set isEnabled(value: boolean);
  50155. get isEnabled(): boolean;
  50156. private _getBonePosition;
  50157. private _getLinesForBonesWithLength;
  50158. private _getLinesForBonesNoLength;
  50159. /** Update the viewer to sync with current skeleton state */
  50160. update(): void;
  50161. /** Release associated resources */
  50162. dispose(): void;
  50163. }
  50164. }
  50165. declare module BABYLON {
  50166. /**
  50167. * Enum for Device Types
  50168. */
  50169. export enum DeviceType {
  50170. /** Generic */
  50171. Generic = 0,
  50172. /** Keyboard */
  50173. Keyboard = 1,
  50174. /** Mouse */
  50175. Mouse = 2,
  50176. /** Touch Pointers */
  50177. Touch = 3,
  50178. /** PS4 Dual Shock */
  50179. DualShock = 4,
  50180. /** Xbox */
  50181. Xbox = 5,
  50182. /** Switch Controller */
  50183. Switch = 6
  50184. }
  50185. /**
  50186. * Enum for All Pointers (Touch/Mouse)
  50187. */
  50188. export enum PointerInput {
  50189. /** Horizontal Axis */
  50190. Horizontal = 0,
  50191. /** Vertical Axis */
  50192. Vertical = 1,
  50193. /** Left Click or Touch */
  50194. LeftClick = 2,
  50195. /** Middle Click */
  50196. MiddleClick = 3,
  50197. /** Right Click */
  50198. RightClick = 4,
  50199. /** Browser Back */
  50200. BrowserBack = 5,
  50201. /** Browser Forward */
  50202. BrowserForward = 6
  50203. }
  50204. /**
  50205. * Enum for Dual Shock Gamepad
  50206. */
  50207. export enum DualShockInput {
  50208. /** Cross */
  50209. Cross = 0,
  50210. /** Circle */
  50211. Circle = 1,
  50212. /** Square */
  50213. Square = 2,
  50214. /** Triangle */
  50215. Triangle = 3,
  50216. /** L1 */
  50217. L1 = 4,
  50218. /** R1 */
  50219. R1 = 5,
  50220. /** L2 */
  50221. L2 = 6,
  50222. /** R2 */
  50223. R2 = 7,
  50224. /** Share */
  50225. Share = 8,
  50226. /** Options */
  50227. Options = 9,
  50228. /** L3 */
  50229. L3 = 10,
  50230. /** R3 */
  50231. R3 = 11,
  50232. /** DPadUp */
  50233. DPadUp = 12,
  50234. /** DPadDown */
  50235. DPadDown = 13,
  50236. /** DPadLeft */
  50237. DPadLeft = 14,
  50238. /** DRight */
  50239. DPadRight = 15,
  50240. /** Home */
  50241. Home = 16,
  50242. /** TouchPad */
  50243. TouchPad = 17,
  50244. /** LStickXAxis */
  50245. LStickXAxis = 18,
  50246. /** LStickYAxis */
  50247. LStickYAxis = 19,
  50248. /** RStickXAxis */
  50249. RStickXAxis = 20,
  50250. /** RStickYAxis */
  50251. RStickYAxis = 21
  50252. }
  50253. /**
  50254. * Enum for Xbox Gamepad
  50255. */
  50256. export enum XboxInput {
  50257. /** A */
  50258. A = 0,
  50259. /** B */
  50260. B = 1,
  50261. /** X */
  50262. X = 2,
  50263. /** Y */
  50264. Y = 3,
  50265. /** LB */
  50266. LB = 4,
  50267. /** RB */
  50268. RB = 5,
  50269. /** LT */
  50270. LT = 6,
  50271. /** RT */
  50272. RT = 7,
  50273. /** Back */
  50274. Back = 8,
  50275. /** Start */
  50276. Start = 9,
  50277. /** LS */
  50278. LS = 10,
  50279. /** RS */
  50280. RS = 11,
  50281. /** DPadUp */
  50282. DPadUp = 12,
  50283. /** DPadDown */
  50284. DPadDown = 13,
  50285. /** DPadLeft */
  50286. DPadLeft = 14,
  50287. /** DRight */
  50288. DPadRight = 15,
  50289. /** Home */
  50290. Home = 16,
  50291. /** LStickXAxis */
  50292. LStickXAxis = 17,
  50293. /** LStickYAxis */
  50294. LStickYAxis = 18,
  50295. /** RStickXAxis */
  50296. RStickXAxis = 19,
  50297. /** RStickYAxis */
  50298. RStickYAxis = 20
  50299. }
  50300. /**
  50301. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50302. */
  50303. export enum SwitchInput {
  50304. /** B */
  50305. B = 0,
  50306. /** A */
  50307. A = 1,
  50308. /** Y */
  50309. Y = 2,
  50310. /** X */
  50311. X = 3,
  50312. /** L */
  50313. L = 4,
  50314. /** R */
  50315. R = 5,
  50316. /** ZL */
  50317. ZL = 6,
  50318. /** ZR */
  50319. ZR = 7,
  50320. /** Minus */
  50321. Minus = 8,
  50322. /** Plus */
  50323. Plus = 9,
  50324. /** LS */
  50325. LS = 10,
  50326. /** RS */
  50327. RS = 11,
  50328. /** DPadUp */
  50329. DPadUp = 12,
  50330. /** DPadDown */
  50331. DPadDown = 13,
  50332. /** DPadLeft */
  50333. DPadLeft = 14,
  50334. /** DRight */
  50335. DPadRight = 15,
  50336. /** Home */
  50337. Home = 16,
  50338. /** Capture */
  50339. Capture = 17,
  50340. /** LStickXAxis */
  50341. LStickXAxis = 18,
  50342. /** LStickYAxis */
  50343. LStickYAxis = 19,
  50344. /** RStickXAxis */
  50345. RStickXAxis = 20,
  50346. /** RStickYAxis */
  50347. RStickYAxis = 21
  50348. }
  50349. }
  50350. declare module BABYLON {
  50351. /**
  50352. * This class will take all inputs from Keyboard, Pointer, and
  50353. * any Gamepads and provide a polling system that all devices
  50354. * will use. This class assumes that there will only be one
  50355. * pointer device and one keyboard.
  50356. */
  50357. export class DeviceInputSystem implements IDisposable {
  50358. /**
  50359. * Callback to be triggered when a device is connected
  50360. */
  50361. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50362. /**
  50363. * Callback to be triggered when a device is disconnected
  50364. */
  50365. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50366. /**
  50367. * Callback to be triggered when event driven input is updated
  50368. */
  50369. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50370. private _inputs;
  50371. private _gamepads;
  50372. private _keyboardActive;
  50373. private _pointerActive;
  50374. private _elementToAttachTo;
  50375. private _keyboardDownEvent;
  50376. private _keyboardUpEvent;
  50377. private _pointerMoveEvent;
  50378. private _pointerDownEvent;
  50379. private _pointerUpEvent;
  50380. private _gamepadConnectedEvent;
  50381. private _gamepadDisconnectedEvent;
  50382. private static _MAX_KEYCODES;
  50383. private static _MAX_POINTER_INPUTS;
  50384. private constructor();
  50385. /**
  50386. * Creates a new DeviceInputSystem instance
  50387. * @param engine Engine to pull input element from
  50388. * @returns The new instance
  50389. */
  50390. static Create(engine: Engine): DeviceInputSystem;
  50391. /**
  50392. * Checks for current device input value, given an id and input index
  50393. * @param deviceName Id of connected device
  50394. * @param inputIndex Index of device input
  50395. * @returns Current value of input
  50396. */
  50397. /**
  50398. * Checks for current device input value, given an id and input index
  50399. * @param deviceType Enum specifiying device type
  50400. * @param deviceSlot "Slot" or index that device is referenced in
  50401. * @param inputIndex Id of input to be checked
  50402. * @returns Current value of input
  50403. */
  50404. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50405. /**
  50406. * Dispose of all the eventlisteners
  50407. */
  50408. dispose(): void;
  50409. /**
  50410. * Add device and inputs to device array
  50411. * @param deviceType Enum specifiying device type
  50412. * @param deviceSlot "Slot" or index that device is referenced in
  50413. * @param numberOfInputs Number of input entries to create for given device
  50414. */
  50415. private _registerDevice;
  50416. /**
  50417. * Given a specific device name, remove that device from the device map
  50418. * @param deviceType Enum specifiying device type
  50419. * @param deviceSlot "Slot" or index that device is referenced in
  50420. */
  50421. private _unregisterDevice;
  50422. /**
  50423. * Handle all actions that come from keyboard interaction
  50424. */
  50425. private _handleKeyActions;
  50426. /**
  50427. * Handle all actions that come from pointer interaction
  50428. */
  50429. private _handlePointerActions;
  50430. /**
  50431. * Handle all actions that come from gamepad interaction
  50432. */
  50433. private _handleGamepadActions;
  50434. /**
  50435. * Update all non-event based devices with each frame
  50436. * @param deviceType Enum specifiying device type
  50437. * @param deviceSlot "Slot" or index that device is referenced in
  50438. * @param inputIndex Id of input to be checked
  50439. */
  50440. private _updateDevice;
  50441. /**
  50442. * Gets DeviceType from the device name
  50443. * @param deviceName Name of Device from DeviceInputSystem
  50444. * @returns DeviceType enum value
  50445. */
  50446. private _getGamepadDeviceType;
  50447. }
  50448. }
  50449. declare module BABYLON {
  50450. /**
  50451. * Type to handle enforcement of inputs
  50452. */
  50453. 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;
  50454. }
  50455. declare module BABYLON {
  50456. /**
  50457. * Class that handles all input for a specific device
  50458. */
  50459. export class DeviceSource<T extends DeviceType> {
  50460. /** Type of device */
  50461. readonly deviceType: DeviceType;
  50462. /** "Slot" or index that device is referenced in */
  50463. readonly deviceSlot: number;
  50464. /**
  50465. * Observable to handle device input changes per device
  50466. */
  50467. readonly onInputChangedObservable: Observable<{
  50468. inputIndex: DeviceInput<T>;
  50469. previousState: Nullable<number>;
  50470. currentState: Nullable<number>;
  50471. }>;
  50472. private readonly _deviceInputSystem;
  50473. /**
  50474. * Default Constructor
  50475. * @param deviceInputSystem Reference to DeviceInputSystem
  50476. * @param deviceType Type of device
  50477. * @param deviceSlot "Slot" or index that device is referenced in
  50478. */
  50479. constructor(deviceInputSystem: DeviceInputSystem,
  50480. /** Type of device */
  50481. deviceType: DeviceType,
  50482. /** "Slot" or index that device is referenced in */
  50483. deviceSlot?: number);
  50484. /**
  50485. * Get input for specific input
  50486. * @param inputIndex index of specific input on device
  50487. * @returns Input value from DeviceInputSystem
  50488. */
  50489. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50490. }
  50491. /**
  50492. * Class to keep track of devices
  50493. */
  50494. export class DeviceSourceManager implements IDisposable {
  50495. /**
  50496. * Observable to be triggered when before a device is connected
  50497. */
  50498. readonly onBeforeDeviceConnectedObservable: Observable<{
  50499. deviceType: DeviceType;
  50500. deviceSlot: number;
  50501. }>;
  50502. /**
  50503. * Observable to be triggered when before a device is disconnected
  50504. */
  50505. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50506. deviceType: DeviceType;
  50507. deviceSlot: number;
  50508. }>;
  50509. /**
  50510. * Observable to be triggered when after a device is connected
  50511. */
  50512. readonly onAfterDeviceConnectedObservable: Observable<{
  50513. deviceType: DeviceType;
  50514. deviceSlot: number;
  50515. }>;
  50516. /**
  50517. * Observable to be triggered when after a device is disconnected
  50518. */
  50519. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50520. deviceType: DeviceType;
  50521. deviceSlot: number;
  50522. }>;
  50523. private readonly _devices;
  50524. private readonly _firstDevice;
  50525. private readonly _deviceInputSystem;
  50526. /**
  50527. * Default Constructor
  50528. * @param engine engine to pull input element from
  50529. */
  50530. constructor(engine: Engine);
  50531. /**
  50532. * Gets a DeviceSource, given a type and slot
  50533. * @param deviceType Enum specifying device type
  50534. * @param deviceSlot "Slot" or index that device is referenced in
  50535. * @returns DeviceSource object
  50536. */
  50537. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50538. /**
  50539. * Gets an array of DeviceSource objects for a given device type
  50540. * @param deviceType Enum specifying device type
  50541. * @returns Array of DeviceSource objects
  50542. */
  50543. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50544. /**
  50545. * Dispose of DeviceInputSystem and other parts
  50546. */
  50547. dispose(): void;
  50548. /**
  50549. * Function to add device name to device list
  50550. * @param deviceType Enum specifying device type
  50551. * @param deviceSlot "Slot" or index that device is referenced in
  50552. */
  50553. private _addDevice;
  50554. /**
  50555. * Function to remove device name to device list
  50556. * @param deviceType Enum specifying device type
  50557. * @param deviceSlot "Slot" or index that device is referenced in
  50558. */
  50559. private _removeDevice;
  50560. /**
  50561. * Updates array storing first connected device of each type
  50562. * @param type Type of Device
  50563. */
  50564. private _updateFirstDevices;
  50565. }
  50566. }
  50567. declare module BABYLON {
  50568. /**
  50569. * Options to create the null engine
  50570. */
  50571. export class NullEngineOptions {
  50572. /**
  50573. * Render width (Default: 512)
  50574. */
  50575. renderWidth: number;
  50576. /**
  50577. * Render height (Default: 256)
  50578. */
  50579. renderHeight: number;
  50580. /**
  50581. * Texture size (Default: 512)
  50582. */
  50583. textureSize: number;
  50584. /**
  50585. * If delta time between frames should be constant
  50586. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50587. */
  50588. deterministicLockstep: boolean;
  50589. /**
  50590. * Maximum about of steps between frames (Default: 4)
  50591. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50592. */
  50593. lockstepMaxSteps: number;
  50594. }
  50595. /**
  50596. * The null engine class provides support for headless version of babylon.js.
  50597. * This can be used in server side scenario or for testing purposes
  50598. */
  50599. export class NullEngine extends Engine {
  50600. private _options;
  50601. /**
  50602. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50603. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50604. * @returns true if engine is in deterministic lock step mode
  50605. */
  50606. isDeterministicLockStep(): boolean;
  50607. /**
  50608. * Gets the max steps when engine is running in deterministic lock step
  50609. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50610. * @returns the max steps
  50611. */
  50612. getLockstepMaxSteps(): number;
  50613. /**
  50614. * Gets the current hardware scaling level.
  50615. * By default the hardware scaling level is computed from the window device ratio.
  50616. * 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.
  50617. * @returns a number indicating the current hardware scaling level
  50618. */
  50619. getHardwareScalingLevel(): number;
  50620. constructor(options?: NullEngineOptions);
  50621. /**
  50622. * Creates a vertex buffer
  50623. * @param vertices the data for the vertex buffer
  50624. * @returns the new WebGL static buffer
  50625. */
  50626. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50627. /**
  50628. * Creates a new index buffer
  50629. * @param indices defines the content of the index buffer
  50630. * @param updatable defines if the index buffer must be updatable
  50631. * @returns a new webGL buffer
  50632. */
  50633. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50634. /**
  50635. * Clear the current render buffer or the current render target (if any is set up)
  50636. * @param color defines the color to use
  50637. * @param backBuffer defines if the back buffer must be cleared
  50638. * @param depth defines if the depth buffer must be cleared
  50639. * @param stencil defines if the stencil buffer must be cleared
  50640. */
  50641. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50642. /**
  50643. * Gets the current render width
  50644. * @param useScreen defines if screen size must be used (or the current render target if any)
  50645. * @returns a number defining the current render width
  50646. */
  50647. getRenderWidth(useScreen?: boolean): number;
  50648. /**
  50649. * Gets the current render height
  50650. * @param useScreen defines if screen size must be used (or the current render target if any)
  50651. * @returns a number defining the current render height
  50652. */
  50653. getRenderHeight(useScreen?: boolean): number;
  50654. /**
  50655. * Set the WebGL's viewport
  50656. * @param viewport defines the viewport element to be used
  50657. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50658. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50659. */
  50660. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50661. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50662. /**
  50663. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50664. * @param pipelineContext defines the pipeline context to use
  50665. * @param uniformsNames defines the list of uniform names
  50666. * @returns an array of webGL uniform locations
  50667. */
  50668. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50669. /**
  50670. * Gets the lsit of active attributes for a given webGL program
  50671. * @param pipelineContext defines the pipeline context to use
  50672. * @param attributesNames defines the list of attribute names to get
  50673. * @returns an array of indices indicating the offset of each attribute
  50674. */
  50675. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50676. /**
  50677. * Binds an effect to the webGL context
  50678. * @param effect defines the effect to bind
  50679. */
  50680. bindSamplers(effect: Effect): void;
  50681. /**
  50682. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50683. * @param effect defines the effect to activate
  50684. */
  50685. enableEffect(effect: Effect): void;
  50686. /**
  50687. * Set various states to the webGL context
  50688. * @param culling defines backface culling state
  50689. * @param zOffset defines the value to apply to zOffset (0 by default)
  50690. * @param force defines if states must be applied even if cache is up to date
  50691. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50692. */
  50693. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50694. /**
  50695. * Set the value of an uniform to an array of int32
  50696. * @param uniform defines the webGL uniform location where to store the value
  50697. * @param array defines the array of int32 to store
  50698. */
  50699. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50700. /**
  50701. * Set the value of an uniform to an array of int32 (stored as vec2)
  50702. * @param uniform defines the webGL uniform location where to store the value
  50703. * @param array defines the array of int32 to store
  50704. */
  50705. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50706. /**
  50707. * Set the value of an uniform to an array of int32 (stored as vec3)
  50708. * @param uniform defines the webGL uniform location where to store the value
  50709. * @param array defines the array of int32 to store
  50710. */
  50711. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50712. /**
  50713. * Set the value of an uniform to an array of int32 (stored as vec4)
  50714. * @param uniform defines the webGL uniform location where to store the value
  50715. * @param array defines the array of int32 to store
  50716. */
  50717. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50718. /**
  50719. * Set the value of an uniform to an array of float32
  50720. * @param uniform defines the webGL uniform location where to store the value
  50721. * @param array defines the array of float32 to store
  50722. */
  50723. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50724. /**
  50725. * Set the value of an uniform to an array of float32 (stored as vec2)
  50726. * @param uniform defines the webGL uniform location where to store the value
  50727. * @param array defines the array of float32 to store
  50728. */
  50729. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50730. /**
  50731. * Set the value of an uniform to an array of float32 (stored as vec3)
  50732. * @param uniform defines the webGL uniform location where to store the value
  50733. * @param array defines the array of float32 to store
  50734. */
  50735. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50736. /**
  50737. * Set the value of an uniform to an array of float32 (stored as vec4)
  50738. * @param uniform defines the webGL uniform location where to store the value
  50739. * @param array defines the array of float32 to store
  50740. */
  50741. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50742. /**
  50743. * Set the value of an uniform to an array of number
  50744. * @param uniform defines the webGL uniform location where to store the value
  50745. * @param array defines the array of number to store
  50746. */
  50747. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50748. /**
  50749. * Set the value of an uniform to an array of number (stored as vec2)
  50750. * @param uniform defines the webGL uniform location where to store the value
  50751. * @param array defines the array of number to store
  50752. */
  50753. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50754. /**
  50755. * Set the value of an uniform to an array of number (stored as vec3)
  50756. * @param uniform defines the webGL uniform location where to store the value
  50757. * @param array defines the array of number to store
  50758. */
  50759. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50760. /**
  50761. * Set the value of an uniform to an array of number (stored as vec4)
  50762. * @param uniform defines the webGL uniform location where to store the value
  50763. * @param array defines the array of number to store
  50764. */
  50765. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50766. /**
  50767. * Set the value of an uniform to an array of float32 (stored as matrices)
  50768. * @param uniform defines the webGL uniform location where to store the value
  50769. * @param matrices defines the array of float32 to store
  50770. */
  50771. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50772. /**
  50773. * Set the value of an uniform to a matrix (3x3)
  50774. * @param uniform defines the webGL uniform location where to store the value
  50775. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50776. */
  50777. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50778. /**
  50779. * Set the value of an uniform to a matrix (2x2)
  50780. * @param uniform defines the webGL uniform location where to store the value
  50781. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50782. */
  50783. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50784. /**
  50785. * Set the value of an uniform to a number (float)
  50786. * @param uniform defines the webGL uniform location where to store the value
  50787. * @param value defines the float number to store
  50788. */
  50789. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50790. /**
  50791. * Set the value of an uniform to a vec2
  50792. * @param uniform defines the webGL uniform location where to store the value
  50793. * @param x defines the 1st component of the value
  50794. * @param y defines the 2nd component of the value
  50795. */
  50796. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50797. /**
  50798. * Set the value of an uniform to a vec3
  50799. * @param uniform defines the webGL uniform location where to store the value
  50800. * @param x defines the 1st component of the value
  50801. * @param y defines the 2nd component of the value
  50802. * @param z defines the 3rd component of the value
  50803. */
  50804. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50805. /**
  50806. * Set the value of an uniform to a boolean
  50807. * @param uniform defines the webGL uniform location where to store the value
  50808. * @param bool defines the boolean to store
  50809. */
  50810. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50811. /**
  50812. * Set the value of an uniform to a vec4
  50813. * @param uniform defines the webGL uniform location where to store the value
  50814. * @param x defines the 1st component of the value
  50815. * @param y defines the 2nd component of the value
  50816. * @param z defines the 3rd component of the value
  50817. * @param w defines the 4th component of the value
  50818. */
  50819. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50820. /**
  50821. * Sets the current alpha mode
  50822. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50823. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50824. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50825. */
  50826. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50827. /**
  50828. * Bind webGl buffers directly to the webGL context
  50829. * @param vertexBuffers defines the vertex buffer to bind
  50830. * @param indexBuffer defines the index buffer to bind
  50831. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50832. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50833. * @param effect defines the effect associated with the vertex buffer
  50834. */
  50835. bindBuffers(vertexBuffers: {
  50836. [key: string]: VertexBuffer;
  50837. }, indexBuffer: DataBuffer, effect: Effect): void;
  50838. /**
  50839. * Force the entire cache to be cleared
  50840. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50841. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50842. */
  50843. wipeCaches(bruteForce?: boolean): void;
  50844. /**
  50845. * Send a draw order
  50846. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50847. * @param indexStart defines the starting index
  50848. * @param indexCount defines the number of index to draw
  50849. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50850. */
  50851. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50852. /**
  50853. * Draw a list of indexed primitives
  50854. * @param fillMode defines the primitive to use
  50855. * @param indexStart defines the starting index
  50856. * @param indexCount defines the number of index to draw
  50857. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50858. */
  50859. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50860. /**
  50861. * Draw a list of unindexed primitives
  50862. * @param fillMode defines the primitive to use
  50863. * @param verticesStart defines the index of first vertex to draw
  50864. * @param verticesCount defines the count of vertices to draw
  50865. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50866. */
  50867. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50868. /** @hidden */
  50869. _createTexture(): WebGLTexture;
  50870. /** @hidden */
  50871. _releaseTexture(texture: InternalTexture): void;
  50872. /**
  50873. * Usually called from Texture.ts.
  50874. * Passed information to create a WebGLTexture
  50875. * @param urlArg defines a value which contains one of the following:
  50876. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50877. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50878. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50880. * @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)
  50881. * @param scene needed for loading to the correct scene
  50882. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50883. * @param onLoad optional callback to be called upon successful completion
  50884. * @param onError optional callback to be called upon failure
  50885. * @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
  50886. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50887. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50888. * @param forcedExtension defines the extension to use to pick the right loader
  50889. * @param mimeType defines an optional mime type
  50890. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50891. */
  50892. 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;
  50893. /**
  50894. * Creates a new render target texture
  50895. * @param size defines the size of the texture
  50896. * @param options defines the options used to create the texture
  50897. * @returns a new render target texture stored in an InternalTexture
  50898. */
  50899. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50900. /**
  50901. * Update the sampling mode of a given texture
  50902. * @param samplingMode defines the required sampling mode
  50903. * @param texture defines the texture to update
  50904. */
  50905. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50906. /**
  50907. * Binds the frame buffer to the specified texture.
  50908. * @param texture The texture to render to or null for the default canvas
  50909. * @param faceIndex The face of the texture to render to in case of cube texture
  50910. * @param requiredWidth The width of the target to render to
  50911. * @param requiredHeight The height of the target to render to
  50912. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50913. * @param lodLevel defines le lod level to bind to the frame buffer
  50914. */
  50915. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50916. /**
  50917. * Unbind the current render target texture from the webGL context
  50918. * @param texture defines the render target texture to unbind
  50919. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50920. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50921. */
  50922. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50923. /**
  50924. * Creates a dynamic vertex buffer
  50925. * @param vertices the data for the dynamic vertex buffer
  50926. * @returns the new WebGL dynamic buffer
  50927. */
  50928. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50929. /**
  50930. * Update the content of a dynamic texture
  50931. * @param texture defines the texture to update
  50932. * @param canvas defines the canvas containing the source
  50933. * @param invertY defines if data must be stored with Y axis inverted
  50934. * @param premulAlpha defines if alpha is stored as premultiplied
  50935. * @param format defines the format of the data
  50936. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50937. */
  50938. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50939. /**
  50940. * Gets a boolean indicating if all created effects are ready
  50941. * @returns true if all effects are ready
  50942. */
  50943. areAllEffectsReady(): boolean;
  50944. /**
  50945. * @hidden
  50946. * Get the current error code of the webGL context
  50947. * @returns the error code
  50948. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50949. */
  50950. getError(): number;
  50951. /** @hidden */
  50952. _getUnpackAlignement(): number;
  50953. /** @hidden */
  50954. _unpackFlipY(value: boolean): void;
  50955. /**
  50956. * Update a dynamic index buffer
  50957. * @param indexBuffer defines the target index buffer
  50958. * @param indices defines the data to update
  50959. * @param offset defines the offset in the target index buffer where update should start
  50960. */
  50961. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50962. /**
  50963. * Updates a dynamic vertex buffer.
  50964. * @param vertexBuffer the vertex buffer to update
  50965. * @param vertices the data used to update the vertex buffer
  50966. * @param byteOffset the byte offset of the data (optional)
  50967. * @param byteLength the byte length of the data (optional)
  50968. */
  50969. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50970. /** @hidden */
  50971. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50972. /** @hidden */
  50973. _bindTexture(channel: number, texture: InternalTexture): void;
  50974. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50975. /**
  50976. * 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
  50977. */
  50978. releaseEffects(): void;
  50979. displayLoadingUI(): void;
  50980. hideLoadingUI(): void;
  50981. /** @hidden */
  50982. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50983. /** @hidden */
  50984. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50985. /** @hidden */
  50986. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50987. /** @hidden */
  50988. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * @hidden
  50994. **/
  50995. export class _TimeToken {
  50996. _startTimeQuery: Nullable<WebGLQuery>;
  50997. _endTimeQuery: Nullable<WebGLQuery>;
  50998. _timeElapsedQuery: Nullable<WebGLQuery>;
  50999. _timeElapsedQueryEnded: boolean;
  51000. }
  51001. }
  51002. declare module BABYLON {
  51003. /** @hidden */
  51004. export class _OcclusionDataStorage {
  51005. /** @hidden */
  51006. occlusionInternalRetryCounter: number;
  51007. /** @hidden */
  51008. isOcclusionQueryInProgress: boolean;
  51009. /** @hidden */
  51010. isOccluded: boolean;
  51011. /** @hidden */
  51012. occlusionRetryCount: number;
  51013. /** @hidden */
  51014. occlusionType: number;
  51015. /** @hidden */
  51016. occlusionQueryAlgorithmType: number;
  51017. }
  51018. interface Engine {
  51019. /**
  51020. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51021. * @return the new query
  51022. */
  51023. createQuery(): WebGLQuery;
  51024. /**
  51025. * Delete and release a webGL query
  51026. * @param query defines the query to delete
  51027. * @return the current engine
  51028. */
  51029. deleteQuery(query: WebGLQuery): Engine;
  51030. /**
  51031. * Check if a given query has resolved and got its value
  51032. * @param query defines the query to check
  51033. * @returns true if the query got its value
  51034. */
  51035. isQueryResultAvailable(query: WebGLQuery): boolean;
  51036. /**
  51037. * Gets the value of a given query
  51038. * @param query defines the query to check
  51039. * @returns the value of the query
  51040. */
  51041. getQueryResult(query: WebGLQuery): number;
  51042. /**
  51043. * Initiates an occlusion query
  51044. * @param algorithmType defines the algorithm to use
  51045. * @param query defines the query to use
  51046. * @returns the current engine
  51047. * @see https://doc.babylonjs.com/features/occlusionquery
  51048. */
  51049. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51050. /**
  51051. * Ends an occlusion query
  51052. * @see https://doc.babylonjs.com/features/occlusionquery
  51053. * @param algorithmType defines the algorithm to use
  51054. * @returns the current engine
  51055. */
  51056. endOcclusionQuery(algorithmType: number): Engine;
  51057. /**
  51058. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51059. * Please note that only one query can be issued at a time
  51060. * @returns a time token used to track the time span
  51061. */
  51062. startTimeQuery(): Nullable<_TimeToken>;
  51063. /**
  51064. * Ends a time query
  51065. * @param token defines the token used to measure the time span
  51066. * @returns the time spent (in ns)
  51067. */
  51068. endTimeQuery(token: _TimeToken): int;
  51069. /** @hidden */
  51070. _currentNonTimestampToken: Nullable<_TimeToken>;
  51071. /** @hidden */
  51072. _createTimeQuery(): WebGLQuery;
  51073. /** @hidden */
  51074. _deleteTimeQuery(query: WebGLQuery): void;
  51075. /** @hidden */
  51076. _getGlAlgorithmType(algorithmType: number): number;
  51077. /** @hidden */
  51078. _getTimeQueryResult(query: WebGLQuery): any;
  51079. /** @hidden */
  51080. _getTimeQueryAvailability(query: WebGLQuery): any;
  51081. }
  51082. interface AbstractMesh {
  51083. /**
  51084. * Backing filed
  51085. * @hidden
  51086. */
  51087. __occlusionDataStorage: _OcclusionDataStorage;
  51088. /**
  51089. * Access property
  51090. * @hidden
  51091. */
  51092. _occlusionDataStorage: _OcclusionDataStorage;
  51093. /**
  51094. * 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.
  51095. * The default value is -1 which means don't break the query and wait till the result
  51096. * @see https://doc.babylonjs.com/features/occlusionquery
  51097. */
  51098. occlusionRetryCount: number;
  51099. /**
  51100. * 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:
  51101. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51102. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51103. * * 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.
  51104. * @see https://doc.babylonjs.com/features/occlusionquery
  51105. */
  51106. occlusionType: number;
  51107. /**
  51108. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51109. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51110. * * 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.
  51111. * @see https://doc.babylonjs.com/features/occlusionquery
  51112. */
  51113. occlusionQueryAlgorithmType: number;
  51114. /**
  51115. * 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
  51116. * @see https://doc.babylonjs.com/features/occlusionquery
  51117. */
  51118. isOccluded: boolean;
  51119. /**
  51120. * Flag to check the progress status of the query
  51121. * @see https://doc.babylonjs.com/features/occlusionquery
  51122. */
  51123. isOcclusionQueryInProgress: boolean;
  51124. }
  51125. }
  51126. declare module BABYLON {
  51127. /** @hidden */
  51128. export var _forceTransformFeedbackToBundle: boolean;
  51129. interface Engine {
  51130. /**
  51131. * Creates a webGL transform feedback object
  51132. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51133. * @returns the webGL transform feedback object
  51134. */
  51135. createTransformFeedback(): WebGLTransformFeedback;
  51136. /**
  51137. * Delete a webGL transform feedback object
  51138. * @param value defines the webGL transform feedback object to delete
  51139. */
  51140. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51141. /**
  51142. * Bind a webGL transform feedback object to the webgl context
  51143. * @param value defines the webGL transform feedback object to bind
  51144. */
  51145. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51146. /**
  51147. * Begins a transform feedback operation
  51148. * @param usePoints defines if points or triangles must be used
  51149. */
  51150. beginTransformFeedback(usePoints: boolean): void;
  51151. /**
  51152. * Ends a transform feedback operation
  51153. */
  51154. endTransformFeedback(): void;
  51155. /**
  51156. * Specify the varyings to use with transform feedback
  51157. * @param program defines the associated webGL program
  51158. * @param value defines the list of strings representing the varying names
  51159. */
  51160. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51161. /**
  51162. * Bind a webGL buffer for a transform feedback operation
  51163. * @param value defines the webGL buffer to bind
  51164. */
  51165. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51166. }
  51167. }
  51168. declare module BABYLON {
  51169. /**
  51170. * Creation options of the multi render target texture.
  51171. */
  51172. export interface IMultiRenderTargetOptions {
  51173. /**
  51174. * Define if the texture needs to create mip maps after render.
  51175. */
  51176. generateMipMaps?: boolean;
  51177. /**
  51178. * Define the types of all the draw buffers we want to create
  51179. */
  51180. types?: number[];
  51181. /**
  51182. * Define the sampling modes of all the draw buffers we want to create
  51183. */
  51184. samplingModes?: number[];
  51185. /**
  51186. * Define if a depth buffer is required
  51187. */
  51188. generateDepthBuffer?: boolean;
  51189. /**
  51190. * Define if a stencil buffer is required
  51191. */
  51192. generateStencilBuffer?: boolean;
  51193. /**
  51194. * Define if a depth texture is required instead of a depth buffer
  51195. */
  51196. generateDepthTexture?: boolean;
  51197. /**
  51198. * Define the number of desired draw buffers
  51199. */
  51200. textureCount?: number;
  51201. /**
  51202. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51203. */
  51204. doNotChangeAspectRatio?: boolean;
  51205. /**
  51206. * Define the default type of the buffers we are creating
  51207. */
  51208. defaultType?: number;
  51209. }
  51210. /**
  51211. * A multi render target, like a render target provides the ability to render to a texture.
  51212. * Unlike the render target, it can render to several draw buffers in one draw.
  51213. * This is specially interesting in deferred rendering or for any effects requiring more than
  51214. * just one color from a single pass.
  51215. */
  51216. export class MultiRenderTarget extends RenderTargetTexture {
  51217. private _internalTextures;
  51218. private _textures;
  51219. private _multiRenderTargetOptions;
  51220. private _count;
  51221. /**
  51222. * Get if draw buffers are currently supported by the used hardware and browser.
  51223. */
  51224. get isSupported(): boolean;
  51225. /**
  51226. * Get the list of textures generated by the multi render target.
  51227. */
  51228. get textures(): Texture[];
  51229. /**
  51230. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  51231. */
  51232. get count(): number;
  51233. /**
  51234. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51235. */
  51236. get depthTexture(): Texture;
  51237. /**
  51238. * Set the wrapping mode on U of all the textures we are rendering to.
  51239. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51240. */
  51241. set wrapU(wrap: number);
  51242. /**
  51243. * Set the wrapping mode on V of all the textures we are rendering to.
  51244. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51245. */
  51246. set wrapV(wrap: number);
  51247. /**
  51248. * Instantiate a new multi render target texture.
  51249. * A multi render target, like a render target provides the ability to render to a texture.
  51250. * Unlike the render target, it can render to several draw buffers in one draw.
  51251. * This is specially interesting in deferred rendering or for any effects requiring more than
  51252. * just one color from a single pass.
  51253. * @param name Define the name of the texture
  51254. * @param size Define the size of the buffers to render to
  51255. * @param count Define the number of target we are rendering into
  51256. * @param scene Define the scene the texture belongs to
  51257. * @param options Define the options used to create the multi render target
  51258. */
  51259. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51260. /** @hidden */
  51261. _rebuild(): void;
  51262. private _createInternalTextures;
  51263. private _createTextures;
  51264. /**
  51265. * Define the number of samples used if MSAA is enabled.
  51266. */
  51267. get samples(): number;
  51268. set samples(value: number);
  51269. /**
  51270. * Resize all the textures in the multi render target.
  51271. * Be carrefull as it will recreate all the data in the new texture.
  51272. * @param size Define the new size
  51273. */
  51274. resize(size: any): void;
  51275. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51276. /**
  51277. * Dispose the render targets and their associated resources
  51278. */
  51279. dispose(): void;
  51280. /**
  51281. * Release all the underlying texture used as draw buffers.
  51282. */
  51283. releaseInternalTextures(): void;
  51284. }
  51285. }
  51286. declare module BABYLON {
  51287. interface ThinEngine {
  51288. /**
  51289. * Unbind a list of render target textures from the webGL context
  51290. * This is used only when drawBuffer extension or webGL2 are active
  51291. * @param textures defines the render target textures to unbind
  51292. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51293. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51294. */
  51295. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51296. /**
  51297. * Create a multi render target texture
  51298. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  51299. * @param size defines the size of the texture
  51300. * @param options defines the creation options
  51301. * @returns the cube texture as an InternalTexture
  51302. */
  51303. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51304. /**
  51305. * Update the sample count for a given multiple render target texture
  51306. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51307. * @param textures defines the textures to update
  51308. * @param samples defines the sample count to set
  51309. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51310. */
  51311. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51312. /**
  51313. * Select a subsets of attachments to draw to.
  51314. * @param attachments gl attachments
  51315. */
  51316. bindAttachments(attachments: number[]): void;
  51317. }
  51318. }
  51319. declare module BABYLON {
  51320. /**
  51321. * Class used to define an additional view for the engine
  51322. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51323. */
  51324. export class EngineView {
  51325. /** Defines the canvas where to render the view */
  51326. target: HTMLCanvasElement;
  51327. /** Defines an optional camera used to render the view (will use active camera else) */
  51328. camera?: Camera;
  51329. }
  51330. interface Engine {
  51331. /**
  51332. * Gets or sets the HTML element to use for attaching events
  51333. */
  51334. inputElement: Nullable<HTMLElement>;
  51335. /**
  51336. * Gets the current engine view
  51337. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51338. */
  51339. activeView: Nullable<EngineView>;
  51340. /** Gets or sets the list of views */
  51341. views: EngineView[];
  51342. /**
  51343. * Register a new child canvas
  51344. * @param canvas defines the canvas to register
  51345. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51346. * @returns the associated view
  51347. */
  51348. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51349. /**
  51350. * Remove a registered child canvas
  51351. * @param canvas defines the canvas to remove
  51352. * @returns the current engine
  51353. */
  51354. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51355. }
  51356. }
  51357. declare module BABYLON {
  51358. interface Engine {
  51359. /** @hidden */
  51360. _excludedCompressedTextures: string[];
  51361. /** @hidden */
  51362. _textureFormatInUse: string;
  51363. /**
  51364. * Gets the list of texture formats supported
  51365. */
  51366. readonly texturesSupported: Array<string>;
  51367. /**
  51368. * Gets the texture format in use
  51369. */
  51370. readonly textureFormatInUse: Nullable<string>;
  51371. /**
  51372. * Set the compressed texture extensions or file names to skip.
  51373. *
  51374. * @param skippedFiles defines the list of those texture files you want to skip
  51375. * Example: [".dds", ".env", "myfile.png"]
  51376. */
  51377. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51378. /**
  51379. * Set the compressed texture format to use, based on the formats you have, and the formats
  51380. * supported by the hardware / browser.
  51381. *
  51382. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51383. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51384. * to API arguments needed to compressed textures. This puts the burden on the container
  51385. * generator to house the arcane code for determining these for current & future formats.
  51386. *
  51387. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51388. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51389. *
  51390. * Note: The result of this call is not taken into account when a texture is base64.
  51391. *
  51392. * @param formatsAvailable defines the list of those format families you have created
  51393. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51394. *
  51395. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51396. * @returns The extension selected.
  51397. */
  51398. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51404. */
  51405. export interface CubeMapInfo {
  51406. /**
  51407. * The pixel array for the front face.
  51408. * This is stored in format, left to right, up to down format.
  51409. */
  51410. front: Nullable<ArrayBufferView>;
  51411. /**
  51412. * The pixel array for the back face.
  51413. * This is stored in format, left to right, up to down format.
  51414. */
  51415. back: Nullable<ArrayBufferView>;
  51416. /**
  51417. * The pixel array for the left face.
  51418. * This is stored in format, left to right, up to down format.
  51419. */
  51420. left: Nullable<ArrayBufferView>;
  51421. /**
  51422. * The pixel array for the right face.
  51423. * This is stored in format, left to right, up to down format.
  51424. */
  51425. right: Nullable<ArrayBufferView>;
  51426. /**
  51427. * The pixel array for the up face.
  51428. * This is stored in format, left to right, up to down format.
  51429. */
  51430. up: Nullable<ArrayBufferView>;
  51431. /**
  51432. * The pixel array for the down face.
  51433. * This is stored in format, left to right, up to down format.
  51434. */
  51435. down: Nullable<ArrayBufferView>;
  51436. /**
  51437. * The size of the cubemap stored.
  51438. *
  51439. * Each faces will be size * size pixels.
  51440. */
  51441. size: number;
  51442. /**
  51443. * The format of the texture.
  51444. *
  51445. * RGBA, RGB.
  51446. */
  51447. format: number;
  51448. /**
  51449. * The type of the texture data.
  51450. *
  51451. * UNSIGNED_INT, FLOAT.
  51452. */
  51453. type: number;
  51454. /**
  51455. * Specifies whether the texture is in gamma space.
  51456. */
  51457. gammaSpace: boolean;
  51458. }
  51459. /**
  51460. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51461. */
  51462. export class PanoramaToCubeMapTools {
  51463. private static FACE_LEFT;
  51464. private static FACE_RIGHT;
  51465. private static FACE_FRONT;
  51466. private static FACE_BACK;
  51467. private static FACE_DOWN;
  51468. private static FACE_UP;
  51469. /**
  51470. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51471. *
  51472. * @param float32Array The source data.
  51473. * @param inputWidth The width of the input panorama.
  51474. * @param inputHeight The height of the input panorama.
  51475. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51476. * @return The cubemap data
  51477. */
  51478. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51479. private static CreateCubemapTexture;
  51480. private static CalcProjectionSpherical;
  51481. }
  51482. }
  51483. declare module BABYLON {
  51484. /**
  51485. * Helper class dealing with the extraction of spherical polynomial dataArray
  51486. * from a cube map.
  51487. */
  51488. export class CubeMapToSphericalPolynomialTools {
  51489. private static FileFaces;
  51490. /**
  51491. * Converts a texture to the according Spherical Polynomial data.
  51492. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51493. *
  51494. * @param texture The texture to extract the information from.
  51495. * @return The Spherical Polynomial data.
  51496. */
  51497. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51498. /**
  51499. * Converts a cubemap to the according Spherical Polynomial data.
  51500. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51501. *
  51502. * @param cubeInfo The Cube map to extract the information from.
  51503. * @return The Spherical Polynomial data.
  51504. */
  51505. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51506. }
  51507. }
  51508. declare module BABYLON {
  51509. interface BaseTexture {
  51510. /**
  51511. * Get the polynomial representation of the texture data.
  51512. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51513. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51514. */
  51515. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51516. }
  51517. }
  51518. declare module BABYLON {
  51519. /** @hidden */
  51520. export var rgbdEncodePixelShader: {
  51521. name: string;
  51522. shader: string;
  51523. };
  51524. }
  51525. declare module BABYLON {
  51526. /** @hidden */
  51527. export var rgbdDecodePixelShader: {
  51528. name: string;
  51529. shader: string;
  51530. };
  51531. }
  51532. declare module BABYLON {
  51533. /**
  51534. * Raw texture data and descriptor sufficient for WebGL texture upload
  51535. */
  51536. export interface EnvironmentTextureInfo {
  51537. /**
  51538. * Version of the environment map
  51539. */
  51540. version: number;
  51541. /**
  51542. * Width of image
  51543. */
  51544. width: number;
  51545. /**
  51546. * Irradiance information stored in the file.
  51547. */
  51548. irradiance: any;
  51549. /**
  51550. * Specular information stored in the file.
  51551. */
  51552. specular: any;
  51553. }
  51554. /**
  51555. * Defines One Image in the file. It requires only the position in the file
  51556. * as well as the length.
  51557. */
  51558. interface BufferImageData {
  51559. /**
  51560. * Length of the image data.
  51561. */
  51562. length: number;
  51563. /**
  51564. * Position of the data from the null terminator delimiting the end of the JSON.
  51565. */
  51566. position: number;
  51567. }
  51568. /**
  51569. * Defines the specular data enclosed in the file.
  51570. * This corresponds to the version 1 of the data.
  51571. */
  51572. export interface EnvironmentTextureSpecularInfoV1 {
  51573. /**
  51574. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51575. */
  51576. specularDataPosition?: number;
  51577. /**
  51578. * This contains all the images data needed to reconstruct the cubemap.
  51579. */
  51580. mipmaps: Array<BufferImageData>;
  51581. /**
  51582. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51583. */
  51584. lodGenerationScale: number;
  51585. }
  51586. /**
  51587. * Sets of helpers addressing the serialization and deserialization of environment texture
  51588. * stored in a BabylonJS env file.
  51589. * Those files are usually stored as .env files.
  51590. */
  51591. export class EnvironmentTextureTools {
  51592. /**
  51593. * Magic number identifying the env file.
  51594. */
  51595. private static _MagicBytes;
  51596. /**
  51597. * Gets the environment info from an env file.
  51598. * @param data The array buffer containing the .env bytes.
  51599. * @returns the environment file info (the json header) if successfully parsed.
  51600. */
  51601. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51602. /**
  51603. * Creates an environment texture from a loaded cube texture.
  51604. * @param texture defines the cube texture to convert in env file
  51605. * @return a promise containing the environment data if succesfull.
  51606. */
  51607. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51608. /**
  51609. * Creates a JSON representation of the spherical data.
  51610. * @param texture defines the texture containing the polynomials
  51611. * @return the JSON representation of the spherical info
  51612. */
  51613. private static _CreateEnvTextureIrradiance;
  51614. /**
  51615. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51616. * @param data the image data
  51617. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51618. * @return the views described by info providing access to the underlying buffer
  51619. */
  51620. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51621. /**
  51622. * Uploads the texture info contained in the env file to the GPU.
  51623. * @param texture defines the internal texture to upload to
  51624. * @param data defines the data to load
  51625. * @param info defines the texture info retrieved through the GetEnvInfo method
  51626. * @returns a promise
  51627. */
  51628. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51629. private static _OnImageReadyAsync;
  51630. /**
  51631. * Uploads the levels of image data to the GPU.
  51632. * @param texture defines the internal texture to upload to
  51633. * @param imageData defines the array buffer views of image data [mipmap][face]
  51634. * @returns a promise
  51635. */
  51636. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51637. /**
  51638. * Uploads spherical polynomials information to the texture.
  51639. * @param texture defines the texture we are trying to upload the information to
  51640. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51641. */
  51642. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51643. /** @hidden */
  51644. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. /**
  51649. * Class used to inline functions in shader code
  51650. */
  51651. export class ShaderCodeInliner {
  51652. private static readonly _RegexpFindFunctionNameAndType;
  51653. private _sourceCode;
  51654. private _functionDescr;
  51655. private _numMaxIterations;
  51656. /** Gets or sets the token used to mark the functions to inline */
  51657. inlineToken: string;
  51658. /** Gets or sets the debug mode */
  51659. debug: boolean;
  51660. /** Gets the code after the inlining process */
  51661. get code(): string;
  51662. /**
  51663. * Initializes the inliner
  51664. * @param sourceCode shader code source to inline
  51665. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51666. */
  51667. constructor(sourceCode: string, numMaxIterations?: number);
  51668. /**
  51669. * Start the processing of the shader code
  51670. */
  51671. processCode(): void;
  51672. private _collectFunctions;
  51673. private _processInlining;
  51674. private _extractBetweenMarkers;
  51675. private _skipWhitespaces;
  51676. private _removeComments;
  51677. private _replaceFunctionCallsByCode;
  51678. private _findBackward;
  51679. private _escapeRegExp;
  51680. private _replaceNames;
  51681. }
  51682. }
  51683. declare module BABYLON {
  51684. /**
  51685. * Container for accessors for natively-stored mesh data buffers.
  51686. */
  51687. class NativeDataBuffer extends DataBuffer {
  51688. /**
  51689. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51690. */
  51691. nativeIndexBuffer?: any;
  51692. /**
  51693. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51694. */
  51695. nativeVertexBuffer?: any;
  51696. }
  51697. /** @hidden */
  51698. class NativeTexture extends InternalTexture {
  51699. getInternalTexture(): InternalTexture;
  51700. getViewCount(): number;
  51701. }
  51702. /** @hidden */
  51703. export class NativeEngine extends Engine {
  51704. private readonly _native;
  51705. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51706. private readonly INVALID_HANDLE;
  51707. getHardwareScalingLevel(): number;
  51708. constructor();
  51709. dispose(): void;
  51710. /**
  51711. * Can be used to override the current requestAnimationFrame requester.
  51712. * @hidden
  51713. */
  51714. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51715. /**
  51716. * Override default engine behavior.
  51717. * @param color
  51718. * @param backBuffer
  51719. * @param depth
  51720. * @param stencil
  51721. */
  51722. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51723. /**
  51724. * Gets host document
  51725. * @returns the host document object
  51726. */
  51727. getHostDocument(): Nullable<Document>;
  51728. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51729. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51730. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51731. recordVertexArrayObject(vertexBuffers: {
  51732. [key: string]: VertexBuffer;
  51733. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51734. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51735. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51736. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51737. /**
  51738. * Draw a list of indexed primitives
  51739. * @param fillMode defines the primitive to use
  51740. * @param indexStart defines the starting index
  51741. * @param indexCount defines the number of index to draw
  51742. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51743. */
  51744. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51745. /**
  51746. * Draw a list of unindexed primitives
  51747. * @param fillMode defines the primitive to use
  51748. * @param verticesStart defines the index of first vertex to draw
  51749. * @param verticesCount defines the count of vertices to draw
  51750. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51751. */
  51752. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51753. createPipelineContext(): IPipelineContext;
  51754. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51755. /** @hidden */
  51756. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51757. /** @hidden */
  51758. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51759. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51761. protected _setProgram(program: WebGLProgram): void;
  51762. _releaseEffect(effect: Effect): void;
  51763. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51764. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51765. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51766. bindSamplers(effect: Effect): void;
  51767. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51768. getRenderWidth(useScreen?: boolean): number;
  51769. getRenderHeight(useScreen?: boolean): number;
  51770. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51772. /**
  51773. * Set the z offset to apply to current rendering
  51774. * @param value defines the offset to apply
  51775. */
  51776. setZOffset(value: number): void;
  51777. /**
  51778. * Gets the current value of the zOffset
  51779. * @returns the current zOffset state
  51780. */
  51781. getZOffset(): number;
  51782. /**
  51783. * Enable or disable depth buffering
  51784. * @param enable defines the state to set
  51785. */
  51786. setDepthBuffer(enable: boolean): void;
  51787. /**
  51788. * Gets a boolean indicating if depth writing is enabled
  51789. * @returns the current depth writing state
  51790. */
  51791. getDepthWrite(): boolean;
  51792. /**
  51793. * Enable or disable depth writing
  51794. * @param enable defines the state to set
  51795. */
  51796. setDepthWrite(enable: boolean): void;
  51797. /**
  51798. * Enable or disable color writing
  51799. * @param enable defines the state to set
  51800. */
  51801. setColorWrite(enable: boolean): void;
  51802. /**
  51803. * Gets a boolean indicating if color writing is enabled
  51804. * @returns the current color writing state
  51805. */
  51806. getColorWrite(): boolean;
  51807. /**
  51808. * Sets alpha constants used by some alpha blending modes
  51809. * @param r defines the red component
  51810. * @param g defines the green component
  51811. * @param b defines the blue component
  51812. * @param a defines the alpha component
  51813. */
  51814. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51815. /**
  51816. * Sets the current alpha mode
  51817. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51818. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51820. */
  51821. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51822. /**
  51823. * Gets the current alpha mode
  51824. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51825. * @returns the current alpha mode
  51826. */
  51827. getAlphaMode(): number;
  51828. setInt(uniform: WebGLUniformLocation, int: number): void;
  51829. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51830. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51831. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51832. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51833. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51834. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51835. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51836. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51837. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51838. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51839. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51840. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51841. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51842. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51843. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51844. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51845. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51846. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51847. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51848. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51849. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51850. wipeCaches(bruteForce?: boolean): void;
  51851. _createTexture(): WebGLTexture;
  51852. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51853. /**
  51854. * Usually called from Texture.ts.
  51855. * Passed information to create a WebGLTexture
  51856. * @param url defines a value which contains one of the following:
  51857. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51858. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51859. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51860. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51861. * @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)
  51862. * @param scene needed for loading to the correct scene
  51863. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51864. * @param onLoad optional callback to be called upon successful completion
  51865. * @param onError optional callback to be called upon failure
  51866. * @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
  51867. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51868. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51869. * @param forcedExtension defines the extension to use to pick the right loader
  51870. * @param mimeType defines an optional mime type
  51871. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51872. */
  51873. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  51874. /**
  51875. * Creates a cube texture
  51876. * @param rootUrl defines the url where the files to load is located
  51877. * @param scene defines the current scene
  51878. * @param files defines the list of files to load (1 per face)
  51879. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51880. * @param onLoad defines an optional callback raised when the texture is loaded
  51881. * @param onError defines an optional callback raised if there is an issue to load the texture
  51882. * @param format defines the format of the data
  51883. * @param forcedExtension defines the extension to use to pick the right loader
  51884. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51885. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51886. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51887. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51888. * @returns the cube texture as an InternalTexture
  51889. */
  51890. 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;
  51891. private _getSamplingFilter;
  51892. private static _GetNativeTextureFormat;
  51893. createRenderTargetTexture(size: number | {
  51894. width: number;
  51895. height: number;
  51896. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51897. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51898. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51899. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51900. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51901. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51902. /**
  51903. * Updates a dynamic vertex buffer.
  51904. * @param vertexBuffer the vertex buffer to update
  51905. * @param data the data used to update the vertex buffer
  51906. * @param byteOffset the byte offset of the data (optional)
  51907. * @param byteLength the byte length of the data (optional)
  51908. */
  51909. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51910. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51911. private _updateAnisotropicLevel;
  51912. private _getAddressMode;
  51913. /** @hidden */
  51914. _bindTexture(channel: number, texture: InternalTexture): void;
  51915. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51916. releaseEffects(): void;
  51917. /** @hidden */
  51918. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51919. /** @hidden */
  51920. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51921. /** @hidden */
  51922. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51923. /** @hidden */
  51924. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51925. }
  51926. }
  51927. declare module BABYLON {
  51928. /**
  51929. * Gather the list of clipboard event types as constants.
  51930. */
  51931. export class ClipboardEventTypes {
  51932. /**
  51933. * The clipboard event is fired when a copy command is active (pressed).
  51934. */
  51935. static readonly COPY: number;
  51936. /**
  51937. * The clipboard event is fired when a cut command is active (pressed).
  51938. */
  51939. static readonly CUT: number;
  51940. /**
  51941. * The clipboard event is fired when a paste command is active (pressed).
  51942. */
  51943. static readonly PASTE: number;
  51944. }
  51945. /**
  51946. * This class is used to store clipboard related info for the onClipboardObservable event.
  51947. */
  51948. export class ClipboardInfo {
  51949. /**
  51950. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51951. */
  51952. type: number;
  51953. /**
  51954. * Defines the related dom event
  51955. */
  51956. event: ClipboardEvent;
  51957. /**
  51958. *Creates an instance of ClipboardInfo.
  51959. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51960. * @param event Defines the related dom event
  51961. */
  51962. constructor(
  51963. /**
  51964. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51965. */
  51966. type: number,
  51967. /**
  51968. * Defines the related dom event
  51969. */
  51970. event: ClipboardEvent);
  51971. /**
  51972. * Get the clipboard event's type from the keycode.
  51973. * @param keyCode Defines the keyCode for the current keyboard event.
  51974. * @return {number}
  51975. */
  51976. static GetTypeFromCharacter(keyCode: number): number;
  51977. }
  51978. }
  51979. declare module BABYLON {
  51980. /**
  51981. * Google Daydream controller
  51982. */
  51983. export class DaydreamController extends WebVRController {
  51984. /**
  51985. * Base Url for the controller model.
  51986. */
  51987. static MODEL_BASE_URL: string;
  51988. /**
  51989. * File name for the controller model.
  51990. */
  51991. static MODEL_FILENAME: string;
  51992. /**
  51993. * Gamepad Id prefix used to identify Daydream Controller.
  51994. */
  51995. static readonly GAMEPAD_ID_PREFIX: string;
  51996. /**
  51997. * Creates a new DaydreamController from a gamepad
  51998. * @param vrGamepad the gamepad that the controller should be created from
  51999. */
  52000. constructor(vrGamepad: any);
  52001. /**
  52002. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52003. * @param scene scene in which to add meshes
  52004. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52005. */
  52006. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52007. /**
  52008. * Called once for each button that changed state since the last frame
  52009. * @param buttonIdx Which button index changed
  52010. * @param state New state of the button
  52011. * @param changes Which properties on the state changed since last frame
  52012. */
  52013. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52014. }
  52015. }
  52016. declare module BABYLON {
  52017. /**
  52018. * Gear VR Controller
  52019. */
  52020. export class GearVRController extends WebVRController {
  52021. /**
  52022. * Base Url for the controller model.
  52023. */
  52024. static MODEL_BASE_URL: string;
  52025. /**
  52026. * File name for the controller model.
  52027. */
  52028. static MODEL_FILENAME: string;
  52029. /**
  52030. * Gamepad Id prefix used to identify this controller.
  52031. */
  52032. static readonly GAMEPAD_ID_PREFIX: string;
  52033. private readonly _buttonIndexToObservableNameMap;
  52034. /**
  52035. * Creates a new GearVRController from a gamepad
  52036. * @param vrGamepad the gamepad that the controller should be created from
  52037. */
  52038. constructor(vrGamepad: any);
  52039. /**
  52040. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52041. * @param scene scene in which to add meshes
  52042. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52043. */
  52044. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52045. /**
  52046. * Called once for each button that changed state since the last frame
  52047. * @param buttonIdx Which button index changed
  52048. * @param state New state of the button
  52049. * @param changes Which properties on the state changed since last frame
  52050. */
  52051. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52052. }
  52053. }
  52054. declare module BABYLON {
  52055. /**
  52056. * Generic Controller
  52057. */
  52058. export class GenericController extends WebVRController {
  52059. /**
  52060. * Base Url for the controller model.
  52061. */
  52062. static readonly MODEL_BASE_URL: string;
  52063. /**
  52064. * File name for the controller model.
  52065. */
  52066. static readonly MODEL_FILENAME: string;
  52067. /**
  52068. * Creates a new GenericController from a gamepad
  52069. * @param vrGamepad the gamepad that the controller should be created from
  52070. */
  52071. constructor(vrGamepad: any);
  52072. /**
  52073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52074. * @param scene scene in which to add meshes
  52075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52076. */
  52077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52078. /**
  52079. * Called once for each button that changed state since the last frame
  52080. * @param buttonIdx Which button index changed
  52081. * @param state New state of the button
  52082. * @param changes Which properties on the state changed since last frame
  52083. */
  52084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52085. }
  52086. }
  52087. declare module BABYLON {
  52088. /**
  52089. * Oculus Touch Controller
  52090. */
  52091. export class OculusTouchController extends WebVRController {
  52092. /**
  52093. * Base Url for the controller model.
  52094. */
  52095. static MODEL_BASE_URL: string;
  52096. /**
  52097. * File name for the left controller model.
  52098. */
  52099. static MODEL_LEFT_FILENAME: string;
  52100. /**
  52101. * File name for the right controller model.
  52102. */
  52103. static MODEL_RIGHT_FILENAME: string;
  52104. /**
  52105. * Base Url for the Quest controller model.
  52106. */
  52107. static QUEST_MODEL_BASE_URL: string;
  52108. /**
  52109. * @hidden
  52110. * If the controllers are running on a device that needs the updated Quest controller models
  52111. */
  52112. static _IsQuest: boolean;
  52113. /**
  52114. * Fired when the secondary trigger on this controller is modified
  52115. */
  52116. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52117. /**
  52118. * Fired when the thumb rest on this controller is modified
  52119. */
  52120. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52121. /**
  52122. * Creates a new OculusTouchController from a gamepad
  52123. * @param vrGamepad the gamepad that the controller should be created from
  52124. */
  52125. constructor(vrGamepad: any);
  52126. /**
  52127. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52128. * @param scene scene in which to add meshes
  52129. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52130. */
  52131. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52132. /**
  52133. * Fired when the A button on this controller is modified
  52134. */
  52135. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52136. /**
  52137. * Fired when the B button on this controller is modified
  52138. */
  52139. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52140. /**
  52141. * Fired when the X button on this controller is modified
  52142. */
  52143. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52144. /**
  52145. * Fired when the Y button on this controller is modified
  52146. */
  52147. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52148. /**
  52149. * Called once for each button that changed state since the last frame
  52150. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52151. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52152. * 2) secondary trigger (same)
  52153. * 3) A (right) X (left), touch, pressed = value
  52154. * 4) B / Y
  52155. * 5) thumb rest
  52156. * @param buttonIdx Which button index changed
  52157. * @param state New state of the button
  52158. * @param changes Which properties on the state changed since last frame
  52159. */
  52160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52161. }
  52162. }
  52163. declare module BABYLON {
  52164. /**
  52165. * Vive Controller
  52166. */
  52167. export class ViveController extends WebVRController {
  52168. /**
  52169. * Base Url for the controller model.
  52170. */
  52171. static MODEL_BASE_URL: string;
  52172. /**
  52173. * File name for the controller model.
  52174. */
  52175. static MODEL_FILENAME: string;
  52176. /**
  52177. * Creates a new ViveController from a gamepad
  52178. * @param vrGamepad the gamepad that the controller should be created from
  52179. */
  52180. constructor(vrGamepad: any);
  52181. /**
  52182. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52183. * @param scene scene in which to add meshes
  52184. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52185. */
  52186. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52187. /**
  52188. * Fired when the left button on this controller is modified
  52189. */
  52190. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52191. /**
  52192. * Fired when the right button on this controller is modified
  52193. */
  52194. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52195. /**
  52196. * Fired when the menu button on this controller is modified
  52197. */
  52198. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52199. /**
  52200. * Called once for each button that changed state since the last frame
  52201. * Vive mapping:
  52202. * 0: touchpad
  52203. * 1: trigger
  52204. * 2: left AND right buttons
  52205. * 3: menu button
  52206. * @param buttonIdx Which button index changed
  52207. * @param state New state of the button
  52208. * @param changes Which properties on the state changed since last frame
  52209. */
  52210. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52211. }
  52212. }
  52213. declare module BABYLON {
  52214. /**
  52215. * Defines the WindowsMotionController object that the state of the windows motion controller
  52216. */
  52217. export class WindowsMotionController extends WebVRController {
  52218. /**
  52219. * The base url used to load the left and right controller models
  52220. */
  52221. static MODEL_BASE_URL: string;
  52222. /**
  52223. * The name of the left controller model file
  52224. */
  52225. static MODEL_LEFT_FILENAME: string;
  52226. /**
  52227. * The name of the right controller model file
  52228. */
  52229. static MODEL_RIGHT_FILENAME: string;
  52230. /**
  52231. * The controller name prefix for this controller type
  52232. */
  52233. static readonly GAMEPAD_ID_PREFIX: string;
  52234. /**
  52235. * The controller id pattern for this controller type
  52236. */
  52237. private static readonly GAMEPAD_ID_PATTERN;
  52238. private _loadedMeshInfo;
  52239. protected readonly _mapping: {
  52240. buttons: string[];
  52241. buttonMeshNames: {
  52242. trigger: string;
  52243. menu: string;
  52244. grip: string;
  52245. thumbstick: string;
  52246. trackpad: string;
  52247. };
  52248. buttonObservableNames: {
  52249. trigger: string;
  52250. menu: string;
  52251. grip: string;
  52252. thumbstick: string;
  52253. trackpad: string;
  52254. };
  52255. axisMeshNames: string[];
  52256. pointingPoseMeshName: string;
  52257. };
  52258. /**
  52259. * Fired when the trackpad on this controller is clicked
  52260. */
  52261. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52262. /**
  52263. * Fired when the trackpad on this controller is modified
  52264. */
  52265. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52266. /**
  52267. * The current x and y values of this controller's trackpad
  52268. */
  52269. trackpad: StickValues;
  52270. /**
  52271. * Creates a new WindowsMotionController from a gamepad
  52272. * @param vrGamepad the gamepad that the controller should be created from
  52273. */
  52274. constructor(vrGamepad: any);
  52275. /**
  52276. * Fired when the trigger on this controller is modified
  52277. */
  52278. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52279. /**
  52280. * Fired when the menu button on this controller is modified
  52281. */
  52282. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52283. /**
  52284. * Fired when the grip button on this controller is modified
  52285. */
  52286. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52287. /**
  52288. * Fired when the thumbstick button on this controller is modified
  52289. */
  52290. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52291. /**
  52292. * Fired when the touchpad button on this controller is modified
  52293. */
  52294. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52295. /**
  52296. * Fired when the touchpad values on this controller are modified
  52297. */
  52298. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52299. protected _updateTrackpad(): void;
  52300. /**
  52301. * Called once per frame by the engine.
  52302. */
  52303. update(): void;
  52304. /**
  52305. * Called once for each button that changed state since the last frame
  52306. * @param buttonIdx Which button index changed
  52307. * @param state New state of the button
  52308. * @param changes Which properties on the state changed since last frame
  52309. */
  52310. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52311. /**
  52312. * Moves the buttons on the controller mesh based on their current state
  52313. * @param buttonName the name of the button to move
  52314. * @param buttonValue the value of the button which determines the buttons new position
  52315. */
  52316. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52317. /**
  52318. * Moves the axis on the controller mesh based on its current state
  52319. * @param axis the index of the axis
  52320. * @param axisValue the value of the axis which determines the meshes new position
  52321. * @hidden
  52322. */
  52323. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52324. /**
  52325. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52326. * @param scene scene in which to add meshes
  52327. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52328. */
  52329. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52330. /**
  52331. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52332. * can be transformed by button presses and axes values, based on this._mapping.
  52333. *
  52334. * @param scene scene in which the meshes exist
  52335. * @param meshes list of meshes that make up the controller model to process
  52336. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52337. */
  52338. private processModel;
  52339. private createMeshInfo;
  52340. /**
  52341. * Gets the ray of the controller in the direction the controller is pointing
  52342. * @param length the length the resulting ray should be
  52343. * @returns a ray in the direction the controller is pointing
  52344. */
  52345. getForwardRay(length?: number): Ray;
  52346. /**
  52347. * Disposes of the controller
  52348. */
  52349. dispose(): void;
  52350. }
  52351. /**
  52352. * This class represents a new windows motion controller in XR.
  52353. */
  52354. export class XRWindowsMotionController extends WindowsMotionController {
  52355. /**
  52356. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52357. */
  52358. protected readonly _mapping: {
  52359. buttons: string[];
  52360. buttonMeshNames: {
  52361. trigger: string;
  52362. menu: string;
  52363. grip: string;
  52364. thumbstick: string;
  52365. trackpad: string;
  52366. };
  52367. buttonObservableNames: {
  52368. trigger: string;
  52369. menu: string;
  52370. grip: string;
  52371. thumbstick: string;
  52372. trackpad: string;
  52373. };
  52374. axisMeshNames: string[];
  52375. pointingPoseMeshName: string;
  52376. };
  52377. /**
  52378. * Construct a new XR-Based windows motion controller
  52379. *
  52380. * @param gamepadInfo the gamepad object from the browser
  52381. */
  52382. constructor(gamepadInfo: any);
  52383. /**
  52384. * holds the thumbstick values (X,Y)
  52385. */
  52386. thumbstickValues: StickValues;
  52387. /**
  52388. * Fired when the thumbstick on this controller is clicked
  52389. */
  52390. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52391. /**
  52392. * Fired when the thumbstick on this controller is modified
  52393. */
  52394. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52395. /**
  52396. * Fired when the touchpad button on this controller is modified
  52397. */
  52398. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52399. /**
  52400. * Fired when the touchpad values on this controller are modified
  52401. */
  52402. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52403. /**
  52404. * Fired when the thumbstick button on this controller is modified
  52405. * here to prevent breaking changes
  52406. */
  52407. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52408. /**
  52409. * updating the thumbstick(!) and not the trackpad.
  52410. * This is named this way due to the difference between WebVR and XR and to avoid
  52411. * changing the parent class.
  52412. */
  52413. protected _updateTrackpad(): void;
  52414. /**
  52415. * Disposes the class with joy
  52416. */
  52417. dispose(): void;
  52418. }
  52419. }
  52420. declare module BABYLON {
  52421. /**
  52422. * Class containing static functions to help procedurally build meshes
  52423. */
  52424. export class PolyhedronBuilder {
  52425. /**
  52426. * Creates a polyhedron mesh
  52427. * * 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
  52428. * * The parameter `size` (positive float, default 1) sets the polygon size
  52429. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52430. * * 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`
  52431. * * 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
  52432. * * 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)`)
  52433. * * 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
  52434. * * 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
  52435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52436. * * 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
  52437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52438. * @param name defines the name of the mesh
  52439. * @param options defines the options used to create the mesh
  52440. * @param scene defines the hosting scene
  52441. * @returns the polyhedron mesh
  52442. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52443. */
  52444. static CreatePolyhedron(name: string, options: {
  52445. type?: number;
  52446. size?: number;
  52447. sizeX?: number;
  52448. sizeY?: number;
  52449. sizeZ?: number;
  52450. custom?: any;
  52451. faceUV?: Vector4[];
  52452. faceColors?: Color4[];
  52453. flat?: boolean;
  52454. updatable?: boolean;
  52455. sideOrientation?: number;
  52456. frontUVs?: Vector4;
  52457. backUVs?: Vector4;
  52458. }, scene?: Nullable<Scene>): Mesh;
  52459. }
  52460. }
  52461. declare module BABYLON {
  52462. /**
  52463. * Gizmo that enables scaling a mesh along 3 axis
  52464. */
  52465. export class ScaleGizmo extends Gizmo {
  52466. /**
  52467. * Internal gizmo used for interactions on the x axis
  52468. */
  52469. xGizmo: AxisScaleGizmo;
  52470. /**
  52471. * Internal gizmo used for interactions on the y axis
  52472. */
  52473. yGizmo: AxisScaleGizmo;
  52474. /**
  52475. * Internal gizmo used for interactions on the z axis
  52476. */
  52477. zGizmo: AxisScaleGizmo;
  52478. /**
  52479. * Internal gizmo used to scale all axis equally
  52480. */
  52481. uniformScaleGizmo: AxisScaleGizmo;
  52482. private _meshAttached;
  52483. private _updateGizmoRotationToMatchAttachedMesh;
  52484. private _snapDistance;
  52485. private _scaleRatio;
  52486. private _uniformScalingMesh;
  52487. private _octahedron;
  52488. private _sensitivity;
  52489. /** Fires an event when any of it's sub gizmos are dragged */
  52490. onDragStartObservable: Observable<unknown>;
  52491. /** Fires an event when any of it's sub gizmos are released from dragging */
  52492. onDragEndObservable: Observable<unknown>;
  52493. get attachedMesh(): Nullable<AbstractMesh>;
  52494. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52495. /**
  52496. * Creates a ScaleGizmo
  52497. * @param gizmoLayer The utility layer the gizmo will be added to
  52498. */
  52499. constructor(gizmoLayer?: UtilityLayerRenderer);
  52500. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52501. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52502. /**
  52503. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52504. */
  52505. set snapDistance(value: number);
  52506. get snapDistance(): number;
  52507. /**
  52508. * Ratio for the scale of the gizmo (Default: 1)
  52509. */
  52510. set scaleRatio(value: number);
  52511. get scaleRatio(): number;
  52512. /**
  52513. * Sensitivity factor for dragging (Default: 1)
  52514. */
  52515. set sensitivity(value: number);
  52516. get sensitivity(): number;
  52517. /**
  52518. * Disposes of the gizmo
  52519. */
  52520. dispose(): void;
  52521. }
  52522. }
  52523. declare module BABYLON {
  52524. /**
  52525. * Single axis scale gizmo
  52526. */
  52527. export class AxisScaleGizmo extends Gizmo {
  52528. /**
  52529. * Drag behavior responsible for the gizmos dragging interactions
  52530. */
  52531. dragBehavior: PointerDragBehavior;
  52532. private _pointerObserver;
  52533. /**
  52534. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52535. */
  52536. snapDistance: number;
  52537. /**
  52538. * Event that fires each time the gizmo snaps to a new location.
  52539. * * snapDistance is the the change in distance
  52540. */
  52541. onSnapObservable: Observable<{
  52542. snapDistance: number;
  52543. }>;
  52544. /**
  52545. * If the scaling operation should be done on all axis (default: false)
  52546. */
  52547. uniformScaling: boolean;
  52548. /**
  52549. * Custom sensitivity value for the drag strength
  52550. */
  52551. sensitivity: number;
  52552. private _isEnabled;
  52553. private _parent;
  52554. private _arrow;
  52555. private _coloredMaterial;
  52556. private _hoverMaterial;
  52557. /**
  52558. * Creates an AxisScaleGizmo
  52559. * @param gizmoLayer The utility layer the gizmo will be added to
  52560. * @param dragAxis The axis which the gizmo will be able to scale on
  52561. * @param color The color of the gizmo
  52562. */
  52563. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52564. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52565. /**
  52566. * If the gizmo is enabled
  52567. */
  52568. set isEnabled(value: boolean);
  52569. get isEnabled(): boolean;
  52570. /**
  52571. * Disposes of the gizmo
  52572. */
  52573. dispose(): void;
  52574. /**
  52575. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52576. * @param mesh The mesh to replace the default mesh of the gizmo
  52577. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52578. */
  52579. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52580. }
  52581. }
  52582. declare module BABYLON {
  52583. /**
  52584. * Bounding box gizmo
  52585. */
  52586. export class BoundingBoxGizmo extends Gizmo {
  52587. private _lineBoundingBox;
  52588. private _rotateSpheresParent;
  52589. private _scaleBoxesParent;
  52590. private _boundingDimensions;
  52591. private _renderObserver;
  52592. private _pointerObserver;
  52593. private _scaleDragSpeed;
  52594. private _tmpQuaternion;
  52595. private _tmpVector;
  52596. private _tmpRotationMatrix;
  52597. /**
  52598. * 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)
  52599. */
  52600. ignoreChildren: boolean;
  52601. /**
  52602. * 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)
  52603. */
  52604. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52605. /**
  52606. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52607. */
  52608. rotationSphereSize: number;
  52609. /**
  52610. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52611. */
  52612. scaleBoxSize: number;
  52613. /**
  52614. * 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)
  52615. */
  52616. fixedDragMeshScreenSize: boolean;
  52617. /**
  52618. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52619. */
  52620. fixedDragMeshScreenSizeDistanceFactor: number;
  52621. /**
  52622. * Fired when a rotation sphere or scale box is dragged
  52623. */
  52624. onDragStartObservable: Observable<{}>;
  52625. /**
  52626. * Fired when a scale box is dragged
  52627. */
  52628. onScaleBoxDragObservable: Observable<{}>;
  52629. /**
  52630. * Fired when a scale box drag is ended
  52631. */
  52632. onScaleBoxDragEndObservable: Observable<{}>;
  52633. /**
  52634. * Fired when a rotation sphere is dragged
  52635. */
  52636. onRotationSphereDragObservable: Observable<{}>;
  52637. /**
  52638. * Fired when a rotation sphere drag is ended
  52639. */
  52640. onRotationSphereDragEndObservable: Observable<{}>;
  52641. /**
  52642. * Relative bounding box pivot used when scaling the attached mesh. 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)
  52643. */
  52644. scalePivot: Nullable<Vector3>;
  52645. /**
  52646. * Mesh used as a pivot to rotate the attached mesh
  52647. */
  52648. private _anchorMesh;
  52649. private _existingMeshScale;
  52650. private _dragMesh;
  52651. private pointerDragBehavior;
  52652. private coloredMaterial;
  52653. private hoverColoredMaterial;
  52654. /**
  52655. * Sets the color of the bounding box gizmo
  52656. * @param color the color to set
  52657. */
  52658. setColor(color: Color3): void;
  52659. /**
  52660. * Creates an BoundingBoxGizmo
  52661. * @param gizmoLayer The utility layer the gizmo will be added to
  52662. * @param color The color of the gizmo
  52663. */
  52664. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52665. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52666. private _selectNode;
  52667. /**
  52668. * Updates the bounding box information for the Gizmo
  52669. */
  52670. updateBoundingBox(): void;
  52671. private _updateRotationSpheres;
  52672. private _updateScaleBoxes;
  52673. /**
  52674. * Enables rotation on the specified axis and disables rotation on the others
  52675. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52676. */
  52677. setEnabledRotationAxis(axis: string): void;
  52678. /**
  52679. * Enables/disables scaling
  52680. * @param enable if scaling should be enabled
  52681. * @param homogeneousScaling defines if scaling should only be homogeneous
  52682. */
  52683. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52684. private _updateDummy;
  52685. /**
  52686. * Enables a pointer drag behavior on the bounding box of the gizmo
  52687. */
  52688. enableDragBehavior(): void;
  52689. /**
  52690. * Disposes of the gizmo
  52691. */
  52692. dispose(): void;
  52693. /**
  52694. * 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)
  52695. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52696. * @returns the bounding box mesh with the passed in mesh as a child
  52697. */
  52698. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52699. /**
  52700. * CustomMeshes are not supported by this gizmo
  52701. * @param mesh The mesh to replace the default mesh of the gizmo
  52702. */
  52703. setCustomMesh(mesh: Mesh): void;
  52704. }
  52705. }
  52706. declare module BABYLON {
  52707. /**
  52708. * Single plane rotation gizmo
  52709. */
  52710. export class PlaneRotationGizmo extends Gizmo {
  52711. /**
  52712. * Drag behavior responsible for the gizmos dragging interactions
  52713. */
  52714. dragBehavior: PointerDragBehavior;
  52715. private _pointerObserver;
  52716. /**
  52717. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52718. */
  52719. snapDistance: number;
  52720. /**
  52721. * Event that fires each time the gizmo snaps to a new location.
  52722. * * snapDistance is the the change in distance
  52723. */
  52724. onSnapObservable: Observable<{
  52725. snapDistance: number;
  52726. }>;
  52727. private _isEnabled;
  52728. private _parent;
  52729. /**
  52730. * Creates a PlaneRotationGizmo
  52731. * @param gizmoLayer The utility layer the gizmo will be added to
  52732. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52733. * @param color The color of the gizmo
  52734. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52735. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52736. */
  52737. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52738. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52739. /**
  52740. * If the gizmo is enabled
  52741. */
  52742. set isEnabled(value: boolean);
  52743. get isEnabled(): boolean;
  52744. /**
  52745. * Disposes of the gizmo
  52746. */
  52747. dispose(): void;
  52748. }
  52749. }
  52750. declare module BABYLON {
  52751. /**
  52752. * Gizmo that enables rotating a mesh along 3 axis
  52753. */
  52754. export class RotationGizmo extends Gizmo {
  52755. /**
  52756. * Internal gizmo used for interactions on the x axis
  52757. */
  52758. xGizmo: PlaneRotationGizmo;
  52759. /**
  52760. * Internal gizmo used for interactions on the y axis
  52761. */
  52762. yGizmo: PlaneRotationGizmo;
  52763. /**
  52764. * Internal gizmo used for interactions on the z axis
  52765. */
  52766. zGizmo: PlaneRotationGizmo;
  52767. /** Fires an event when any of it's sub gizmos are dragged */
  52768. onDragStartObservable: Observable<unknown>;
  52769. /** Fires an event when any of it's sub gizmos are released from dragging */
  52770. onDragEndObservable: Observable<unknown>;
  52771. private _meshAttached;
  52772. get attachedMesh(): Nullable<AbstractMesh>;
  52773. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52774. /**
  52775. * Creates a RotationGizmo
  52776. * @param gizmoLayer The utility layer the gizmo will be added to
  52777. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52778. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52779. */
  52780. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52781. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52782. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52783. /**
  52784. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52785. */
  52786. set snapDistance(value: number);
  52787. get snapDistance(): number;
  52788. /**
  52789. * Ratio for the scale of the gizmo (Default: 1)
  52790. */
  52791. set scaleRatio(value: number);
  52792. get scaleRatio(): number;
  52793. /**
  52794. * Disposes of the gizmo
  52795. */
  52796. dispose(): void;
  52797. /**
  52798. * CustomMeshes are not supported by this gizmo
  52799. * @param mesh The mesh to replace the default mesh of the gizmo
  52800. */
  52801. setCustomMesh(mesh: Mesh): void;
  52802. }
  52803. }
  52804. declare module BABYLON {
  52805. /**
  52806. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52807. */
  52808. export class GizmoManager implements IDisposable {
  52809. private scene;
  52810. /**
  52811. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52812. */
  52813. gizmos: {
  52814. positionGizmo: Nullable<PositionGizmo>;
  52815. rotationGizmo: Nullable<RotationGizmo>;
  52816. scaleGizmo: Nullable<ScaleGizmo>;
  52817. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52818. };
  52819. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52820. clearGizmoOnEmptyPointerEvent: boolean;
  52821. /** Fires an event when the manager is attached to a mesh */
  52822. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52823. private _gizmosEnabled;
  52824. private _pointerObserver;
  52825. private _attachedMesh;
  52826. private _boundingBoxColor;
  52827. private _defaultUtilityLayer;
  52828. private _defaultKeepDepthUtilityLayer;
  52829. /**
  52830. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52831. */
  52832. boundingBoxDragBehavior: SixDofDragBehavior;
  52833. /**
  52834. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52835. */
  52836. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52837. /**
  52838. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52839. */
  52840. usePointerToAttachGizmos: boolean;
  52841. /**
  52842. * Utility layer that the bounding box gizmo belongs to
  52843. */
  52844. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52845. /**
  52846. * Utility layer that all gizmos besides bounding box belong to
  52847. */
  52848. get utilityLayer(): UtilityLayerRenderer;
  52849. /**
  52850. * Instatiates a gizmo manager
  52851. * @param scene the scene to overlay the gizmos on top of
  52852. */
  52853. constructor(scene: Scene);
  52854. /**
  52855. * Attaches a set of gizmos to the specified mesh
  52856. * @param mesh The mesh the gizmo's should be attached to
  52857. */
  52858. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52859. /**
  52860. * If the position gizmo is enabled
  52861. */
  52862. set positionGizmoEnabled(value: boolean);
  52863. get positionGizmoEnabled(): boolean;
  52864. /**
  52865. * If the rotation gizmo is enabled
  52866. */
  52867. set rotationGizmoEnabled(value: boolean);
  52868. get rotationGizmoEnabled(): boolean;
  52869. /**
  52870. * If the scale gizmo is enabled
  52871. */
  52872. set scaleGizmoEnabled(value: boolean);
  52873. get scaleGizmoEnabled(): boolean;
  52874. /**
  52875. * If the boundingBox gizmo is enabled
  52876. */
  52877. set boundingBoxGizmoEnabled(value: boolean);
  52878. get boundingBoxGizmoEnabled(): boolean;
  52879. /**
  52880. * Disposes of the gizmo manager
  52881. */
  52882. dispose(): void;
  52883. }
  52884. }
  52885. declare module BABYLON {
  52886. /**
  52887. * A directional light is defined by a direction (what a surprise!).
  52888. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52889. * 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.
  52890. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52891. */
  52892. export class DirectionalLight extends ShadowLight {
  52893. private _shadowFrustumSize;
  52894. /**
  52895. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52896. */
  52897. get shadowFrustumSize(): number;
  52898. /**
  52899. * Specifies a fix frustum size for the shadow generation.
  52900. */
  52901. set shadowFrustumSize(value: number);
  52902. private _shadowOrthoScale;
  52903. /**
  52904. * Gets the shadow projection scale against the optimal computed one.
  52905. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52906. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52907. */
  52908. get shadowOrthoScale(): number;
  52909. /**
  52910. * Sets the shadow projection scale against the optimal computed one.
  52911. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52912. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52913. */
  52914. set shadowOrthoScale(value: number);
  52915. /**
  52916. * Automatically compute the projection matrix to best fit (including all the casters)
  52917. * on each frame.
  52918. */
  52919. autoUpdateExtends: boolean;
  52920. /**
  52921. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52922. * on each frame. autoUpdateExtends must be set to true for this to work
  52923. */
  52924. autoCalcShadowZBounds: boolean;
  52925. private _orthoLeft;
  52926. private _orthoRight;
  52927. private _orthoTop;
  52928. private _orthoBottom;
  52929. /**
  52930. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52931. * The directional light is emitted from everywhere in the given direction.
  52932. * It can cast shadows.
  52933. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52934. * @param name The friendly name of the light
  52935. * @param direction The direction of the light
  52936. * @param scene The scene the light belongs to
  52937. */
  52938. constructor(name: string, direction: Vector3, scene: Scene);
  52939. /**
  52940. * Returns the string "DirectionalLight".
  52941. * @return The class name
  52942. */
  52943. getClassName(): string;
  52944. /**
  52945. * Returns the integer 1.
  52946. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52947. */
  52948. getTypeID(): number;
  52949. /**
  52950. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52951. * Returns the DirectionalLight Shadow projection matrix.
  52952. */
  52953. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52954. /**
  52955. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52956. * Returns the DirectionalLight Shadow projection matrix.
  52957. */
  52958. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52959. /**
  52960. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52961. * Returns the DirectionalLight Shadow projection matrix.
  52962. */
  52963. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52964. protected _buildUniformLayout(): void;
  52965. /**
  52966. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52967. * @param effect The effect to update
  52968. * @param lightIndex The index of the light in the effect to update
  52969. * @returns The directional light
  52970. */
  52971. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52972. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52973. /**
  52974. * Gets the minZ used for shadow according to both the scene and the light.
  52975. *
  52976. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52977. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52978. * @param activeCamera The camera we are returning the min for
  52979. * @returns the depth min z
  52980. */
  52981. getDepthMinZ(activeCamera: Camera): number;
  52982. /**
  52983. * Gets the maxZ used for shadow according to both the scene and the light.
  52984. *
  52985. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52986. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52987. * @param activeCamera The camera we are returning the max for
  52988. * @returns the depth max z
  52989. */
  52990. getDepthMaxZ(activeCamera: Camera): number;
  52991. /**
  52992. * Prepares the list of defines specific to the light type.
  52993. * @param defines the list of defines
  52994. * @param lightIndex defines the index of the light for the effect
  52995. */
  52996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52997. }
  52998. }
  52999. declare module BABYLON {
  53000. /**
  53001. * Class containing static functions to help procedurally build meshes
  53002. */
  53003. export class HemisphereBuilder {
  53004. /**
  53005. * Creates a hemisphere mesh
  53006. * @param name defines the name of the mesh
  53007. * @param options defines the options used to create the mesh
  53008. * @param scene defines the hosting scene
  53009. * @returns the hemisphere mesh
  53010. */
  53011. static CreateHemisphere(name: string, options: {
  53012. segments?: number;
  53013. diameter?: number;
  53014. sideOrientation?: number;
  53015. }, scene: any): Mesh;
  53016. }
  53017. }
  53018. declare module BABYLON {
  53019. /**
  53020. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53021. * These values define a cone of light starting from the position, emitting toward the direction.
  53022. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53023. * and the exponent defines the speed of the decay of the light with distance (reach).
  53024. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53025. */
  53026. export class SpotLight extends ShadowLight {
  53027. private _angle;
  53028. private _innerAngle;
  53029. private _cosHalfAngle;
  53030. private _lightAngleScale;
  53031. private _lightAngleOffset;
  53032. /**
  53033. * Gets the cone angle of the spot light in Radians.
  53034. */
  53035. get angle(): number;
  53036. /**
  53037. * Sets the cone angle of the spot light in Radians.
  53038. */
  53039. set angle(value: number);
  53040. /**
  53041. * Only used in gltf falloff mode, this defines the angle where
  53042. * the directional falloff will start before cutting at angle which could be seen
  53043. * as outer angle.
  53044. */
  53045. get innerAngle(): number;
  53046. /**
  53047. * Only used in gltf falloff mode, this defines the angle where
  53048. * the directional falloff will start before cutting at angle which could be seen
  53049. * as outer angle.
  53050. */
  53051. set innerAngle(value: number);
  53052. private _shadowAngleScale;
  53053. /**
  53054. * Allows scaling the angle of the light for shadow generation only.
  53055. */
  53056. get shadowAngleScale(): number;
  53057. /**
  53058. * Allows scaling the angle of the light for shadow generation only.
  53059. */
  53060. set shadowAngleScale(value: number);
  53061. /**
  53062. * The light decay speed with the distance from the emission spot.
  53063. */
  53064. exponent: number;
  53065. private _projectionTextureMatrix;
  53066. /**
  53067. * Allows reading the projecton texture
  53068. */
  53069. get projectionTextureMatrix(): Matrix;
  53070. protected _projectionTextureLightNear: number;
  53071. /**
  53072. * Gets the near clip of the Spotlight for texture projection.
  53073. */
  53074. get projectionTextureLightNear(): number;
  53075. /**
  53076. * Sets the near clip of the Spotlight for texture projection.
  53077. */
  53078. set projectionTextureLightNear(value: number);
  53079. protected _projectionTextureLightFar: number;
  53080. /**
  53081. * Gets the far clip of the Spotlight for texture projection.
  53082. */
  53083. get projectionTextureLightFar(): number;
  53084. /**
  53085. * Sets the far clip of the Spotlight for texture projection.
  53086. */
  53087. set projectionTextureLightFar(value: number);
  53088. protected _projectionTextureUpDirection: Vector3;
  53089. /**
  53090. * Gets the Up vector of the Spotlight for texture projection.
  53091. */
  53092. get projectionTextureUpDirection(): Vector3;
  53093. /**
  53094. * Sets the Up vector of the Spotlight for texture projection.
  53095. */
  53096. set projectionTextureUpDirection(value: Vector3);
  53097. private _projectionTexture;
  53098. /**
  53099. * Gets the projection texture of the light.
  53100. */
  53101. get projectionTexture(): Nullable<BaseTexture>;
  53102. /**
  53103. * Sets the projection texture of the light.
  53104. */
  53105. set projectionTexture(value: Nullable<BaseTexture>);
  53106. private _projectionTextureViewLightDirty;
  53107. private _projectionTextureProjectionLightDirty;
  53108. private _projectionTextureDirty;
  53109. private _projectionTextureViewTargetVector;
  53110. private _projectionTextureViewLightMatrix;
  53111. private _projectionTextureProjectionLightMatrix;
  53112. private _projectionTextureScalingMatrix;
  53113. /**
  53114. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53115. * It can cast shadows.
  53116. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53117. * @param name The light friendly name
  53118. * @param position The position of the spot light in the scene
  53119. * @param direction The direction of the light in the scene
  53120. * @param angle The cone angle of the light in Radians
  53121. * @param exponent The light decay speed with the distance from the emission spot
  53122. * @param scene The scene the lights belongs to
  53123. */
  53124. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53125. /**
  53126. * Returns the string "SpotLight".
  53127. * @returns the class name
  53128. */
  53129. getClassName(): string;
  53130. /**
  53131. * Returns the integer 2.
  53132. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53133. */
  53134. getTypeID(): number;
  53135. /**
  53136. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53137. */
  53138. protected _setDirection(value: Vector3): void;
  53139. /**
  53140. * Overrides the position setter to recompute the projection texture view light Matrix.
  53141. */
  53142. protected _setPosition(value: Vector3): void;
  53143. /**
  53144. * 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.
  53145. * Returns the SpotLight.
  53146. */
  53147. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53148. protected _computeProjectionTextureViewLightMatrix(): void;
  53149. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53150. /**
  53151. * Main function for light texture projection matrix computing.
  53152. */
  53153. protected _computeProjectionTextureMatrix(): void;
  53154. protected _buildUniformLayout(): void;
  53155. private _computeAngleValues;
  53156. /**
  53157. * Sets the passed Effect "effect" with the Light textures.
  53158. * @param effect The effect to update
  53159. * @param lightIndex The index of the light in the effect to update
  53160. * @returns The light
  53161. */
  53162. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53163. /**
  53164. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53165. * @param effect The effect to update
  53166. * @param lightIndex The index of the light in the effect to update
  53167. * @returns The spot light
  53168. */
  53169. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53170. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53171. /**
  53172. * Disposes the light and the associated resources.
  53173. */
  53174. dispose(): void;
  53175. /**
  53176. * Prepares the list of defines specific to the light type.
  53177. * @param defines the list of defines
  53178. * @param lightIndex defines the index of the light for the effect
  53179. */
  53180. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /**
  53185. * Gizmo that enables viewing a light
  53186. */
  53187. export class LightGizmo extends Gizmo {
  53188. private _lightMesh;
  53189. private _material;
  53190. private _cachedPosition;
  53191. private _cachedForward;
  53192. private _attachedMeshParent;
  53193. /**
  53194. * Creates a LightGizmo
  53195. * @param gizmoLayer The utility layer the gizmo will be added to
  53196. */
  53197. constructor(gizmoLayer?: UtilityLayerRenderer);
  53198. private _light;
  53199. /**
  53200. * The light that the gizmo is attached to
  53201. */
  53202. set light(light: Nullable<Light>);
  53203. get light(): Nullable<Light>;
  53204. /**
  53205. * Gets the material used to render the light gizmo
  53206. */
  53207. get material(): StandardMaterial;
  53208. /**
  53209. * @hidden
  53210. * Updates the gizmo to match the attached mesh's position/rotation
  53211. */
  53212. protected _update(): void;
  53213. private static _Scale;
  53214. /**
  53215. * Creates the lines for a light mesh
  53216. */
  53217. private static _CreateLightLines;
  53218. /**
  53219. * Disposes of the light gizmo
  53220. */
  53221. dispose(): void;
  53222. private static _CreateHemisphericLightMesh;
  53223. private static _CreatePointLightMesh;
  53224. private static _CreateSpotLightMesh;
  53225. private static _CreateDirectionalLightMesh;
  53226. }
  53227. }
  53228. declare module BABYLON {
  53229. /** @hidden */
  53230. export var backgroundFragmentDeclaration: {
  53231. name: string;
  53232. shader: string;
  53233. };
  53234. }
  53235. declare module BABYLON {
  53236. /** @hidden */
  53237. export var backgroundUboDeclaration: {
  53238. name: string;
  53239. shader: string;
  53240. };
  53241. }
  53242. declare module BABYLON {
  53243. /** @hidden */
  53244. export var backgroundPixelShader: {
  53245. name: string;
  53246. shader: string;
  53247. };
  53248. }
  53249. declare module BABYLON {
  53250. /** @hidden */
  53251. export var backgroundVertexDeclaration: {
  53252. name: string;
  53253. shader: string;
  53254. };
  53255. }
  53256. declare module BABYLON {
  53257. /** @hidden */
  53258. export var backgroundVertexShader: {
  53259. name: string;
  53260. shader: string;
  53261. };
  53262. }
  53263. declare module BABYLON {
  53264. /**
  53265. * Background material used to create an efficient environement around your scene.
  53266. */
  53267. export class BackgroundMaterial extends PushMaterial {
  53268. /**
  53269. * Standard reflectance value at parallel view angle.
  53270. */
  53271. static StandardReflectance0: number;
  53272. /**
  53273. * Standard reflectance value at grazing angle.
  53274. */
  53275. static StandardReflectance90: number;
  53276. protected _primaryColor: Color3;
  53277. /**
  53278. * Key light Color (multiply against the environement texture)
  53279. */
  53280. primaryColor: Color3;
  53281. protected __perceptualColor: Nullable<Color3>;
  53282. /**
  53283. * Experimental Internal Use Only.
  53284. *
  53285. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53286. * This acts as a helper to set the primary color to a more "human friendly" value.
  53287. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53288. * output color as close as possible from the chosen value.
  53289. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53290. * part of lighting setup.)
  53291. */
  53292. get _perceptualColor(): Nullable<Color3>;
  53293. set _perceptualColor(value: Nullable<Color3>);
  53294. protected _primaryColorShadowLevel: float;
  53295. /**
  53296. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53297. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53298. */
  53299. get primaryColorShadowLevel(): float;
  53300. set primaryColorShadowLevel(value: float);
  53301. protected _primaryColorHighlightLevel: float;
  53302. /**
  53303. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53304. * The primary color is used at the level chosen to define what the white area would look.
  53305. */
  53306. get primaryColorHighlightLevel(): float;
  53307. set primaryColorHighlightLevel(value: float);
  53308. protected _reflectionTexture: Nullable<BaseTexture>;
  53309. /**
  53310. * Reflection Texture used in the material.
  53311. * Should be author in a specific way for the best result (refer to the documentation).
  53312. */
  53313. reflectionTexture: Nullable<BaseTexture>;
  53314. protected _reflectionBlur: float;
  53315. /**
  53316. * Reflection Texture level of blur.
  53317. *
  53318. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53319. * texture twice.
  53320. */
  53321. reflectionBlur: float;
  53322. protected _diffuseTexture: Nullable<BaseTexture>;
  53323. /**
  53324. * Diffuse Texture used in the material.
  53325. * Should be author in a specific way for the best result (refer to the documentation).
  53326. */
  53327. diffuseTexture: Nullable<BaseTexture>;
  53328. protected _shadowLights: Nullable<IShadowLight[]>;
  53329. /**
  53330. * Specify the list of lights casting shadow on the material.
  53331. * All scene shadow lights will be included if null.
  53332. */
  53333. shadowLights: Nullable<IShadowLight[]>;
  53334. protected _shadowLevel: float;
  53335. /**
  53336. * Helps adjusting the shadow to a softer level if required.
  53337. * 0 means black shadows and 1 means no shadows.
  53338. */
  53339. shadowLevel: float;
  53340. protected _sceneCenter: Vector3;
  53341. /**
  53342. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53343. * It is usually zero but might be interesting to modify according to your setup.
  53344. */
  53345. sceneCenter: Vector3;
  53346. protected _opacityFresnel: boolean;
  53347. /**
  53348. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53349. * This helps ensuring a nice transition when the camera goes under the ground.
  53350. */
  53351. opacityFresnel: boolean;
  53352. protected _reflectionFresnel: boolean;
  53353. /**
  53354. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53355. * This helps adding a mirror texture on the ground.
  53356. */
  53357. reflectionFresnel: boolean;
  53358. protected _reflectionFalloffDistance: number;
  53359. /**
  53360. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53361. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53362. */
  53363. reflectionFalloffDistance: number;
  53364. protected _reflectionAmount: number;
  53365. /**
  53366. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53367. */
  53368. reflectionAmount: number;
  53369. protected _reflectionReflectance0: number;
  53370. /**
  53371. * This specifies the weight of the reflection at grazing angle.
  53372. */
  53373. reflectionReflectance0: number;
  53374. protected _reflectionReflectance90: number;
  53375. /**
  53376. * This specifies the weight of the reflection at a perpendicular point of view.
  53377. */
  53378. reflectionReflectance90: number;
  53379. /**
  53380. * Sets the reflection reflectance fresnel values according to the default standard
  53381. * empirically know to work well :-)
  53382. */
  53383. set reflectionStandardFresnelWeight(value: number);
  53384. protected _useRGBColor: boolean;
  53385. /**
  53386. * Helps to directly use the maps channels instead of their level.
  53387. */
  53388. useRGBColor: boolean;
  53389. protected _enableNoise: boolean;
  53390. /**
  53391. * This helps reducing the banding effect that could occur on the background.
  53392. */
  53393. enableNoise: boolean;
  53394. /**
  53395. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53396. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53397. * Recommended to be keep at 1.0 except for special cases.
  53398. */
  53399. get fovMultiplier(): number;
  53400. set fovMultiplier(value: number);
  53401. private _fovMultiplier;
  53402. /**
  53403. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53404. */
  53405. useEquirectangularFOV: boolean;
  53406. private _maxSimultaneousLights;
  53407. /**
  53408. * Number of Simultaneous lights allowed on the material.
  53409. */
  53410. maxSimultaneousLights: int;
  53411. private _shadowOnly;
  53412. /**
  53413. * Make the material only render shadows
  53414. */
  53415. shadowOnly: boolean;
  53416. /**
  53417. * Default configuration related to image processing available in the Background Material.
  53418. */
  53419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53420. /**
  53421. * Keep track of the image processing observer to allow dispose and replace.
  53422. */
  53423. private _imageProcessingObserver;
  53424. /**
  53425. * Attaches a new image processing configuration to the PBR Material.
  53426. * @param configuration (if null the scene configuration will be use)
  53427. */
  53428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53429. /**
  53430. * Gets the image processing configuration used either in this material.
  53431. */
  53432. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53433. /**
  53434. * Sets the Default image processing configuration used either in the this material.
  53435. *
  53436. * If sets to null, the scene one is in use.
  53437. */
  53438. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53439. /**
  53440. * Gets wether the color curves effect is enabled.
  53441. */
  53442. get cameraColorCurvesEnabled(): boolean;
  53443. /**
  53444. * Sets wether the color curves effect is enabled.
  53445. */
  53446. set cameraColorCurvesEnabled(value: boolean);
  53447. /**
  53448. * Gets wether the color grading effect is enabled.
  53449. */
  53450. get cameraColorGradingEnabled(): boolean;
  53451. /**
  53452. * Gets wether the color grading effect is enabled.
  53453. */
  53454. set cameraColorGradingEnabled(value: boolean);
  53455. /**
  53456. * Gets wether tonemapping is enabled or not.
  53457. */
  53458. get cameraToneMappingEnabled(): boolean;
  53459. /**
  53460. * Sets wether tonemapping is enabled or not
  53461. */
  53462. set cameraToneMappingEnabled(value: boolean);
  53463. /**
  53464. * The camera exposure used on this material.
  53465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53466. * This corresponds to a photographic exposure.
  53467. */
  53468. get cameraExposure(): float;
  53469. /**
  53470. * The camera exposure used on this material.
  53471. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53472. * This corresponds to a photographic exposure.
  53473. */
  53474. set cameraExposure(value: float);
  53475. /**
  53476. * Gets The camera contrast used on this material.
  53477. */
  53478. get cameraContrast(): float;
  53479. /**
  53480. * Sets The camera contrast used on this material.
  53481. */
  53482. set cameraContrast(value: float);
  53483. /**
  53484. * Gets the Color Grading 2D Lookup Texture.
  53485. */
  53486. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53487. /**
  53488. * Sets the Color Grading 2D Lookup Texture.
  53489. */
  53490. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53491. /**
  53492. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53493. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53494. * 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;
  53495. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53496. */
  53497. get cameraColorCurves(): Nullable<ColorCurves>;
  53498. /**
  53499. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53500. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53501. * 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;
  53502. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53503. */
  53504. set cameraColorCurves(value: Nullable<ColorCurves>);
  53505. /**
  53506. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53507. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53508. */
  53509. switchToBGR: boolean;
  53510. private _renderTargets;
  53511. private _reflectionControls;
  53512. private _white;
  53513. private _primaryShadowColor;
  53514. private _primaryHighlightColor;
  53515. /**
  53516. * Instantiates a Background Material in the given scene
  53517. * @param name The friendly name of the material
  53518. * @param scene The scene to add the material to
  53519. */
  53520. constructor(name: string, scene: Scene);
  53521. /**
  53522. * Gets a boolean indicating that current material needs to register RTT
  53523. */
  53524. get hasRenderTargetTextures(): boolean;
  53525. /**
  53526. * The entire material has been created in order to prevent overdraw.
  53527. * @returns false
  53528. */
  53529. needAlphaTesting(): boolean;
  53530. /**
  53531. * The entire material has been created in order to prevent overdraw.
  53532. * @returns true if blending is enable
  53533. */
  53534. needAlphaBlending(): boolean;
  53535. /**
  53536. * Checks wether the material is ready to be rendered for a given mesh.
  53537. * @param mesh The mesh to render
  53538. * @param subMesh The submesh to check against
  53539. * @param useInstances Specify wether or not the material is used with instances
  53540. * @returns true if all the dependencies are ready (Textures, Effects...)
  53541. */
  53542. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53543. /**
  53544. * Compute the primary color according to the chosen perceptual color.
  53545. */
  53546. private _computePrimaryColorFromPerceptualColor;
  53547. /**
  53548. * Compute the highlights and shadow colors according to their chosen levels.
  53549. */
  53550. private _computePrimaryColors;
  53551. /**
  53552. * Build the uniform buffer used in the material.
  53553. */
  53554. buildUniformLayout(): void;
  53555. /**
  53556. * Unbind the material.
  53557. */
  53558. unbind(): void;
  53559. /**
  53560. * Bind only the world matrix to the material.
  53561. * @param world The world matrix to bind.
  53562. */
  53563. bindOnlyWorldMatrix(world: Matrix): void;
  53564. /**
  53565. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53566. * @param world The world matrix to bind.
  53567. * @param subMesh The submesh to bind for.
  53568. */
  53569. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53570. /**
  53571. * Checks to see if a texture is used in the material.
  53572. * @param texture - Base texture to use.
  53573. * @returns - Boolean specifying if a texture is used in the material.
  53574. */
  53575. hasTexture(texture: BaseTexture): boolean;
  53576. /**
  53577. * Dispose the material.
  53578. * @param forceDisposeEffect Force disposal of the associated effect.
  53579. * @param forceDisposeTextures Force disposal of the associated textures.
  53580. */
  53581. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53582. /**
  53583. * Clones the material.
  53584. * @param name The cloned name.
  53585. * @returns The cloned material.
  53586. */
  53587. clone(name: string): BackgroundMaterial;
  53588. /**
  53589. * Serializes the current material to its JSON representation.
  53590. * @returns The JSON representation.
  53591. */
  53592. serialize(): any;
  53593. /**
  53594. * Gets the class name of the material
  53595. * @returns "BackgroundMaterial"
  53596. */
  53597. getClassName(): string;
  53598. /**
  53599. * Parse a JSON input to create back a background material.
  53600. * @param source The JSON data to parse
  53601. * @param scene The scene to create the parsed material in
  53602. * @param rootUrl The root url of the assets the material depends upon
  53603. * @returns the instantiated BackgroundMaterial.
  53604. */
  53605. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53606. }
  53607. }
  53608. declare module BABYLON {
  53609. /**
  53610. * Represents the different options available during the creation of
  53611. * a Environment helper.
  53612. *
  53613. * This can control the default ground, skybox and image processing setup of your scene.
  53614. */
  53615. export interface IEnvironmentHelperOptions {
  53616. /**
  53617. * Specifies whether or not to create a ground.
  53618. * True by default.
  53619. */
  53620. createGround: boolean;
  53621. /**
  53622. * Specifies the ground size.
  53623. * 15 by default.
  53624. */
  53625. groundSize: number;
  53626. /**
  53627. * The texture used on the ground for the main color.
  53628. * Comes from the BabylonJS CDN by default.
  53629. *
  53630. * Remarks: Can be either a texture or a url.
  53631. */
  53632. groundTexture: string | BaseTexture;
  53633. /**
  53634. * The color mixed in the ground texture by default.
  53635. * BabylonJS clearColor by default.
  53636. */
  53637. groundColor: Color3;
  53638. /**
  53639. * Specifies the ground opacity.
  53640. * 1 by default.
  53641. */
  53642. groundOpacity: number;
  53643. /**
  53644. * Enables the ground to receive shadows.
  53645. * True by default.
  53646. */
  53647. enableGroundShadow: boolean;
  53648. /**
  53649. * Helps preventing the shadow to be fully black on the ground.
  53650. * 0.5 by default.
  53651. */
  53652. groundShadowLevel: number;
  53653. /**
  53654. * Creates a mirror texture attach to the ground.
  53655. * false by default.
  53656. */
  53657. enableGroundMirror: boolean;
  53658. /**
  53659. * Specifies the ground mirror size ratio.
  53660. * 0.3 by default as the default kernel is 64.
  53661. */
  53662. groundMirrorSizeRatio: number;
  53663. /**
  53664. * Specifies the ground mirror blur kernel size.
  53665. * 64 by default.
  53666. */
  53667. groundMirrorBlurKernel: number;
  53668. /**
  53669. * Specifies the ground mirror visibility amount.
  53670. * 1 by default
  53671. */
  53672. groundMirrorAmount: number;
  53673. /**
  53674. * Specifies the ground mirror reflectance weight.
  53675. * This uses the standard weight of the background material to setup the fresnel effect
  53676. * of the mirror.
  53677. * 1 by default.
  53678. */
  53679. groundMirrorFresnelWeight: number;
  53680. /**
  53681. * Specifies the ground mirror Falloff distance.
  53682. * This can helps reducing the size of the reflection.
  53683. * 0 by Default.
  53684. */
  53685. groundMirrorFallOffDistance: number;
  53686. /**
  53687. * Specifies the ground mirror texture type.
  53688. * Unsigned Int by Default.
  53689. */
  53690. groundMirrorTextureType: number;
  53691. /**
  53692. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53693. * the shown objects.
  53694. */
  53695. groundYBias: number;
  53696. /**
  53697. * Specifies whether or not to create a skybox.
  53698. * True by default.
  53699. */
  53700. createSkybox: boolean;
  53701. /**
  53702. * Specifies the skybox size.
  53703. * 20 by default.
  53704. */
  53705. skyboxSize: number;
  53706. /**
  53707. * The texture used on the skybox for the main color.
  53708. * Comes from the BabylonJS CDN by default.
  53709. *
  53710. * Remarks: Can be either a texture or a url.
  53711. */
  53712. skyboxTexture: string | BaseTexture;
  53713. /**
  53714. * The color mixed in the skybox texture by default.
  53715. * BabylonJS clearColor by default.
  53716. */
  53717. skyboxColor: Color3;
  53718. /**
  53719. * The background rotation around the Y axis of the scene.
  53720. * This helps aligning the key lights of your scene with the background.
  53721. * 0 by default.
  53722. */
  53723. backgroundYRotation: number;
  53724. /**
  53725. * Compute automatically the size of the elements to best fit with the scene.
  53726. */
  53727. sizeAuto: boolean;
  53728. /**
  53729. * Default position of the rootMesh if autoSize is not true.
  53730. */
  53731. rootPosition: Vector3;
  53732. /**
  53733. * Sets up the image processing in the scene.
  53734. * true by default.
  53735. */
  53736. setupImageProcessing: boolean;
  53737. /**
  53738. * The texture used as your environment texture in the scene.
  53739. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53740. *
  53741. * Remarks: Can be either a texture or a url.
  53742. */
  53743. environmentTexture: string | BaseTexture;
  53744. /**
  53745. * The value of the exposure to apply to the scene.
  53746. * 0.6 by default if setupImageProcessing is true.
  53747. */
  53748. cameraExposure: number;
  53749. /**
  53750. * The value of the contrast to apply to the scene.
  53751. * 1.6 by default if setupImageProcessing is true.
  53752. */
  53753. cameraContrast: number;
  53754. /**
  53755. * Specifies whether or not tonemapping should be enabled in the scene.
  53756. * true by default if setupImageProcessing is true.
  53757. */
  53758. toneMappingEnabled: boolean;
  53759. }
  53760. /**
  53761. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53762. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53763. * It also helps with the default setup of your imageProcessing configuration.
  53764. */
  53765. export class EnvironmentHelper {
  53766. /**
  53767. * Default ground texture URL.
  53768. */
  53769. private static _groundTextureCDNUrl;
  53770. /**
  53771. * Default skybox texture URL.
  53772. */
  53773. private static _skyboxTextureCDNUrl;
  53774. /**
  53775. * Default environment texture URL.
  53776. */
  53777. private static _environmentTextureCDNUrl;
  53778. /**
  53779. * Creates the default options for the helper.
  53780. */
  53781. private static _getDefaultOptions;
  53782. private _rootMesh;
  53783. /**
  53784. * Gets the root mesh created by the helper.
  53785. */
  53786. get rootMesh(): Mesh;
  53787. private _skybox;
  53788. /**
  53789. * Gets the skybox created by the helper.
  53790. */
  53791. get skybox(): Nullable<Mesh>;
  53792. private _skyboxTexture;
  53793. /**
  53794. * Gets the skybox texture created by the helper.
  53795. */
  53796. get skyboxTexture(): Nullable<BaseTexture>;
  53797. private _skyboxMaterial;
  53798. /**
  53799. * Gets the skybox material created by the helper.
  53800. */
  53801. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53802. private _ground;
  53803. /**
  53804. * Gets the ground mesh created by the helper.
  53805. */
  53806. get ground(): Nullable<Mesh>;
  53807. private _groundTexture;
  53808. /**
  53809. * Gets the ground texture created by the helper.
  53810. */
  53811. get groundTexture(): Nullable<BaseTexture>;
  53812. private _groundMirror;
  53813. /**
  53814. * Gets the ground mirror created by the helper.
  53815. */
  53816. get groundMirror(): Nullable<MirrorTexture>;
  53817. /**
  53818. * Gets the ground mirror render list to helps pushing the meshes
  53819. * you wish in the ground reflection.
  53820. */
  53821. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53822. private _groundMaterial;
  53823. /**
  53824. * Gets the ground material created by the helper.
  53825. */
  53826. get groundMaterial(): Nullable<BackgroundMaterial>;
  53827. /**
  53828. * Stores the creation options.
  53829. */
  53830. private readonly _scene;
  53831. private _options;
  53832. /**
  53833. * This observable will be notified with any error during the creation of the environment,
  53834. * mainly texture creation errors.
  53835. */
  53836. onErrorObservable: Observable<{
  53837. message?: string;
  53838. exception?: any;
  53839. }>;
  53840. /**
  53841. * constructor
  53842. * @param options Defines the options we want to customize the helper
  53843. * @param scene The scene to add the material to
  53844. */
  53845. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53846. /**
  53847. * Updates the background according to the new options
  53848. * @param options
  53849. */
  53850. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53851. /**
  53852. * Sets the primary color of all the available elements.
  53853. * @param color the main color to affect to the ground and the background
  53854. */
  53855. setMainColor(color: Color3): void;
  53856. /**
  53857. * Setup the image processing according to the specified options.
  53858. */
  53859. private _setupImageProcessing;
  53860. /**
  53861. * Setup the environment texture according to the specified options.
  53862. */
  53863. private _setupEnvironmentTexture;
  53864. /**
  53865. * Setup the background according to the specified options.
  53866. */
  53867. private _setupBackground;
  53868. /**
  53869. * Get the scene sizes according to the setup.
  53870. */
  53871. private _getSceneSize;
  53872. /**
  53873. * Setup the ground according to the specified options.
  53874. */
  53875. private _setupGround;
  53876. /**
  53877. * Setup the ground material according to the specified options.
  53878. */
  53879. private _setupGroundMaterial;
  53880. /**
  53881. * Setup the ground diffuse texture according to the specified options.
  53882. */
  53883. private _setupGroundDiffuseTexture;
  53884. /**
  53885. * Setup the ground mirror texture according to the specified options.
  53886. */
  53887. private _setupGroundMirrorTexture;
  53888. /**
  53889. * Setup the ground to receive the mirror texture.
  53890. */
  53891. private _setupMirrorInGroundMaterial;
  53892. /**
  53893. * Setup the skybox according to the specified options.
  53894. */
  53895. private _setupSkybox;
  53896. /**
  53897. * Setup the skybox material according to the specified options.
  53898. */
  53899. private _setupSkyboxMaterial;
  53900. /**
  53901. * Setup the skybox reflection texture according to the specified options.
  53902. */
  53903. private _setupSkyboxReflectionTexture;
  53904. private _errorHandler;
  53905. /**
  53906. * Dispose all the elements created by the Helper.
  53907. */
  53908. dispose(): void;
  53909. }
  53910. }
  53911. declare module BABYLON {
  53912. /**
  53913. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53914. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53915. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53916. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53917. */
  53918. export class PhotoDome extends TransformNode {
  53919. /**
  53920. * Define the image as a Monoscopic panoramic 360 image.
  53921. */
  53922. static readonly MODE_MONOSCOPIC: number;
  53923. /**
  53924. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53925. */
  53926. static readonly MODE_TOPBOTTOM: number;
  53927. /**
  53928. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53929. */
  53930. static readonly MODE_SIDEBYSIDE: number;
  53931. private _useDirectMapping;
  53932. /**
  53933. * The texture being displayed on the sphere
  53934. */
  53935. protected _photoTexture: Texture;
  53936. /**
  53937. * Gets or sets the texture being displayed on the sphere
  53938. */
  53939. get photoTexture(): Texture;
  53940. set photoTexture(value: Texture);
  53941. /**
  53942. * Observable raised when an error occured while loading the 360 image
  53943. */
  53944. onLoadErrorObservable: Observable<string>;
  53945. /**
  53946. * The skybox material
  53947. */
  53948. protected _material: BackgroundMaterial;
  53949. /**
  53950. * The surface used for the skybox
  53951. */
  53952. protected _mesh: Mesh;
  53953. /**
  53954. * Gets the mesh used for the skybox.
  53955. */
  53956. get mesh(): Mesh;
  53957. /**
  53958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53959. * Also see the options.resolution property.
  53960. */
  53961. get fovMultiplier(): number;
  53962. set fovMultiplier(value: number);
  53963. private _imageMode;
  53964. /**
  53965. * Gets or set the current video mode for the video. It can be:
  53966. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53967. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53968. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53969. */
  53970. get imageMode(): number;
  53971. set imageMode(value: number);
  53972. /**
  53973. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53974. * @param name Element's name, child elements will append suffixes for their own names.
  53975. * @param urlsOfPhoto defines the url of the photo to display
  53976. * @param options defines an object containing optional or exposed sub element properties
  53977. * @param onError defines a callback called when an error occured while loading the texture
  53978. */
  53979. constructor(name: string, urlOfPhoto: string, options: {
  53980. resolution?: number;
  53981. size?: number;
  53982. useDirectMapping?: boolean;
  53983. faceForward?: boolean;
  53984. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53985. private _onBeforeCameraRenderObserver;
  53986. private _changeImageMode;
  53987. /**
  53988. * Releases resources associated with this node.
  53989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53991. */
  53992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53993. }
  53994. }
  53995. declare module BABYLON {
  53996. /**
  53997. * Class used to host RGBD texture specific utilities
  53998. */
  53999. export class RGBDTextureTools {
  54000. /**
  54001. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54002. * @param texture the texture to expand.
  54003. */
  54004. static ExpandRGBDTexture(texture: Texture): void;
  54005. }
  54006. }
  54007. declare module BABYLON {
  54008. /**
  54009. * Class used to host texture specific utilities
  54010. */
  54011. export class BRDFTextureTools {
  54012. /**
  54013. * Prevents texture cache collision
  54014. */
  54015. private static _instanceNumber;
  54016. /**
  54017. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54018. * @param scene defines the hosting scene
  54019. * @returns the environment BRDF texture
  54020. */
  54021. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54022. private static _environmentBRDFBase64Texture;
  54023. }
  54024. }
  54025. declare module BABYLON {
  54026. /**
  54027. * @hidden
  54028. */
  54029. export interface IMaterialClearCoatDefines {
  54030. CLEARCOAT: boolean;
  54031. CLEARCOAT_DEFAULTIOR: boolean;
  54032. CLEARCOAT_TEXTURE: boolean;
  54033. CLEARCOAT_TEXTUREDIRECTUV: number;
  54034. CLEARCOAT_BUMP: boolean;
  54035. CLEARCOAT_BUMPDIRECTUV: number;
  54036. CLEARCOAT_TINT: boolean;
  54037. CLEARCOAT_TINT_TEXTURE: boolean;
  54038. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54039. /** @hidden */
  54040. _areTexturesDirty: boolean;
  54041. }
  54042. /**
  54043. * Define the code related to the clear coat parameters of the pbr material.
  54044. */
  54045. export class PBRClearCoatConfiguration {
  54046. /**
  54047. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54048. * The default fits with a polyurethane material.
  54049. */
  54050. private static readonly _DefaultIndexOfRefraction;
  54051. private _isEnabled;
  54052. /**
  54053. * Defines if the clear coat is enabled in the material.
  54054. */
  54055. isEnabled: boolean;
  54056. /**
  54057. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54058. */
  54059. intensity: number;
  54060. /**
  54061. * Defines the clear coat layer roughness.
  54062. */
  54063. roughness: number;
  54064. private _indexOfRefraction;
  54065. /**
  54066. * Defines the index of refraction of the clear coat.
  54067. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54068. * The default fits with a polyurethane material.
  54069. * Changing the default value is more performance intensive.
  54070. */
  54071. indexOfRefraction: number;
  54072. private _texture;
  54073. /**
  54074. * Stores the clear coat values in a texture.
  54075. */
  54076. texture: Nullable<BaseTexture>;
  54077. private _bumpTexture;
  54078. /**
  54079. * Define the clear coat specific bump texture.
  54080. */
  54081. bumpTexture: Nullable<BaseTexture>;
  54082. private _isTintEnabled;
  54083. /**
  54084. * Defines if the clear coat tint is enabled in the material.
  54085. */
  54086. isTintEnabled: boolean;
  54087. /**
  54088. * Defines the clear coat tint of the material.
  54089. * This is only use if tint is enabled
  54090. */
  54091. tintColor: Color3;
  54092. /**
  54093. * Defines the distance at which the tint color should be found in the
  54094. * clear coat media.
  54095. * This is only use if tint is enabled
  54096. */
  54097. tintColorAtDistance: number;
  54098. /**
  54099. * Defines the clear coat layer thickness.
  54100. * This is only use if tint is enabled
  54101. */
  54102. tintThickness: number;
  54103. private _tintTexture;
  54104. /**
  54105. * Stores the clear tint values in a texture.
  54106. * rgb is tint
  54107. * a is a thickness factor
  54108. */
  54109. tintTexture: Nullable<BaseTexture>;
  54110. /** @hidden */
  54111. private _internalMarkAllSubMeshesAsTexturesDirty;
  54112. /** @hidden */
  54113. _markAllSubMeshesAsTexturesDirty(): void;
  54114. /**
  54115. * Instantiate a new istance of clear coat configuration.
  54116. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54117. */
  54118. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54119. /**
  54120. * Gets wehter the submesh is ready to be used or not.
  54121. * @param defines the list of "defines" to update.
  54122. * @param scene defines the scene the material belongs to.
  54123. * @param engine defines the engine the material belongs to.
  54124. * @param disableBumpMap defines wether the material disables bump or not.
  54125. * @returns - boolean indicating that the submesh is ready or not.
  54126. */
  54127. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54128. /**
  54129. * Checks to see if a texture is used in the material.
  54130. * @param defines the list of "defines" to update.
  54131. * @param scene defines the scene to the material belongs to.
  54132. */
  54133. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54134. /**
  54135. * Binds the material data.
  54136. * @param uniformBuffer defines the Uniform buffer to fill in.
  54137. * @param scene defines the scene the material belongs to.
  54138. * @param engine defines the engine the material belongs to.
  54139. * @param disableBumpMap defines wether the material disables bump or not.
  54140. * @param isFrozen defines wether the material is frozen or not.
  54141. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54142. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54143. */
  54144. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54145. /**
  54146. * Checks to see if a texture is used in the material.
  54147. * @param texture - Base texture to use.
  54148. * @returns - Boolean specifying if a texture is used in the material.
  54149. */
  54150. hasTexture(texture: BaseTexture): boolean;
  54151. /**
  54152. * Returns an array of the actively used textures.
  54153. * @param activeTextures Array of BaseTextures
  54154. */
  54155. getActiveTextures(activeTextures: BaseTexture[]): void;
  54156. /**
  54157. * Returns the animatable textures.
  54158. * @param animatables Array of animatable textures.
  54159. */
  54160. getAnimatables(animatables: IAnimatable[]): void;
  54161. /**
  54162. * Disposes the resources of the material.
  54163. * @param forceDisposeTextures - Forces the disposal of all textures.
  54164. */
  54165. dispose(forceDisposeTextures?: boolean): void;
  54166. /**
  54167. * Get the current class name of the texture useful for serialization or dynamic coding.
  54168. * @returns "PBRClearCoatConfiguration"
  54169. */
  54170. getClassName(): string;
  54171. /**
  54172. * Add fallbacks to the effect fallbacks list.
  54173. * @param defines defines the Base texture to use.
  54174. * @param fallbacks defines the current fallback list.
  54175. * @param currentRank defines the current fallback rank.
  54176. * @returns the new fallback rank.
  54177. */
  54178. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54179. /**
  54180. * Add the required uniforms to the current list.
  54181. * @param uniforms defines the current uniform list.
  54182. */
  54183. static AddUniforms(uniforms: string[]): void;
  54184. /**
  54185. * Add the required samplers to the current list.
  54186. * @param samplers defines the current sampler list.
  54187. */
  54188. static AddSamplers(samplers: string[]): void;
  54189. /**
  54190. * Add the required uniforms to the current buffer.
  54191. * @param uniformBuffer defines the current uniform buffer.
  54192. */
  54193. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54194. /**
  54195. * Makes a duplicate of the current configuration into another one.
  54196. * @param clearCoatConfiguration define the config where to copy the info
  54197. */
  54198. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54199. /**
  54200. * Serializes this clear coat configuration.
  54201. * @returns - An object with the serialized config.
  54202. */
  54203. serialize(): any;
  54204. /**
  54205. * Parses a anisotropy Configuration from a serialized object.
  54206. * @param source - Serialized object.
  54207. * @param scene Defines the scene we are parsing for
  54208. * @param rootUrl Defines the rootUrl to load from
  54209. */
  54210. parse(source: any, scene: Scene, rootUrl: string): void;
  54211. }
  54212. }
  54213. declare module BABYLON {
  54214. /**
  54215. * @hidden
  54216. */
  54217. export interface IMaterialAnisotropicDefines {
  54218. ANISOTROPIC: boolean;
  54219. ANISOTROPIC_TEXTURE: boolean;
  54220. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54221. MAINUV1: boolean;
  54222. _areTexturesDirty: boolean;
  54223. _needUVs: boolean;
  54224. }
  54225. /**
  54226. * Define the code related to the anisotropic parameters of the pbr material.
  54227. */
  54228. export class PBRAnisotropicConfiguration {
  54229. private _isEnabled;
  54230. /**
  54231. * Defines if the anisotropy is enabled in the material.
  54232. */
  54233. isEnabled: boolean;
  54234. /**
  54235. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54236. */
  54237. intensity: number;
  54238. /**
  54239. * Defines if the effect is along the tangents, bitangents or in between.
  54240. * By default, the effect is "strectching" the highlights along the tangents.
  54241. */
  54242. direction: Vector2;
  54243. private _texture;
  54244. /**
  54245. * Stores the anisotropy values in a texture.
  54246. * rg is direction (like normal from -1 to 1)
  54247. * b is a intensity
  54248. */
  54249. texture: Nullable<BaseTexture>;
  54250. /** @hidden */
  54251. private _internalMarkAllSubMeshesAsTexturesDirty;
  54252. /** @hidden */
  54253. _markAllSubMeshesAsTexturesDirty(): void;
  54254. /**
  54255. * Instantiate a new istance of anisotropy configuration.
  54256. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54257. */
  54258. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54259. /**
  54260. * Specifies that the submesh is ready to be used.
  54261. * @param defines the list of "defines" to update.
  54262. * @param scene defines the scene the material belongs to.
  54263. * @returns - boolean indicating that the submesh is ready or not.
  54264. */
  54265. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54266. /**
  54267. * Checks to see if a texture is used in the material.
  54268. * @param defines the list of "defines" to update.
  54269. * @param mesh the mesh we are preparing the defines for.
  54270. * @param scene defines the scene the material belongs to.
  54271. */
  54272. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54273. /**
  54274. * Binds the material data.
  54275. * @param uniformBuffer defines the Uniform buffer to fill in.
  54276. * @param scene defines the scene the material belongs to.
  54277. * @param isFrozen defines wether the material is frozen or not.
  54278. */
  54279. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54280. /**
  54281. * Checks to see if a texture is used in the material.
  54282. * @param texture - Base texture to use.
  54283. * @returns - Boolean specifying if a texture is used in the material.
  54284. */
  54285. hasTexture(texture: BaseTexture): boolean;
  54286. /**
  54287. * Returns an array of the actively used textures.
  54288. * @param activeTextures Array of BaseTextures
  54289. */
  54290. getActiveTextures(activeTextures: BaseTexture[]): void;
  54291. /**
  54292. * Returns the animatable textures.
  54293. * @param animatables Array of animatable textures.
  54294. */
  54295. getAnimatables(animatables: IAnimatable[]): void;
  54296. /**
  54297. * Disposes the resources of the material.
  54298. * @param forceDisposeTextures - Forces the disposal of all textures.
  54299. */
  54300. dispose(forceDisposeTextures?: boolean): void;
  54301. /**
  54302. * Get the current class name of the texture useful for serialization or dynamic coding.
  54303. * @returns "PBRAnisotropicConfiguration"
  54304. */
  54305. getClassName(): string;
  54306. /**
  54307. * Add fallbacks to the effect fallbacks list.
  54308. * @param defines defines the Base texture to use.
  54309. * @param fallbacks defines the current fallback list.
  54310. * @param currentRank defines the current fallback rank.
  54311. * @returns the new fallback rank.
  54312. */
  54313. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54314. /**
  54315. * Add the required uniforms to the current list.
  54316. * @param uniforms defines the current uniform list.
  54317. */
  54318. static AddUniforms(uniforms: string[]): void;
  54319. /**
  54320. * Add the required uniforms to the current buffer.
  54321. * @param uniformBuffer defines the current uniform buffer.
  54322. */
  54323. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54324. /**
  54325. * Add the required samplers to the current list.
  54326. * @param samplers defines the current sampler list.
  54327. */
  54328. static AddSamplers(samplers: string[]): void;
  54329. /**
  54330. * Makes a duplicate of the current configuration into another one.
  54331. * @param anisotropicConfiguration define the config where to copy the info
  54332. */
  54333. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54334. /**
  54335. * Serializes this anisotropy configuration.
  54336. * @returns - An object with the serialized config.
  54337. */
  54338. serialize(): any;
  54339. /**
  54340. * Parses a anisotropy Configuration from a serialized object.
  54341. * @param source - Serialized object.
  54342. * @param scene Defines the scene we are parsing for
  54343. * @param rootUrl Defines the rootUrl to load from
  54344. */
  54345. parse(source: any, scene: Scene, rootUrl: string): void;
  54346. }
  54347. }
  54348. declare module BABYLON {
  54349. /**
  54350. * @hidden
  54351. */
  54352. export interface IMaterialBRDFDefines {
  54353. BRDF_V_HEIGHT_CORRELATED: boolean;
  54354. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54355. SPHERICAL_HARMONICS: boolean;
  54356. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54357. /** @hidden */
  54358. _areMiscDirty: boolean;
  54359. }
  54360. /**
  54361. * Define the code related to the BRDF parameters of the pbr material.
  54362. */
  54363. export class PBRBRDFConfiguration {
  54364. /**
  54365. * Default value used for the energy conservation.
  54366. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54367. */
  54368. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54369. /**
  54370. * Default value used for the Smith Visibility Height Correlated mode.
  54371. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54372. */
  54373. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54374. /**
  54375. * Default value used for the IBL diffuse part.
  54376. * This can help switching back to the polynomials mode globally which is a tiny bit
  54377. * less GPU intensive at the drawback of a lower quality.
  54378. */
  54379. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54380. /**
  54381. * Default value used for activating energy conservation for the specular workflow.
  54382. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54383. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54384. */
  54385. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54386. private _useEnergyConservation;
  54387. /**
  54388. * Defines if the material uses energy conservation.
  54389. */
  54390. useEnergyConservation: boolean;
  54391. private _useSmithVisibilityHeightCorrelated;
  54392. /**
  54393. * LEGACY Mode set to false
  54394. * Defines if the material uses height smith correlated visibility term.
  54395. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54396. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54397. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54398. * Not relying on height correlated will also disable energy conservation.
  54399. */
  54400. useSmithVisibilityHeightCorrelated: boolean;
  54401. private _useSphericalHarmonics;
  54402. /**
  54403. * LEGACY Mode set to false
  54404. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54405. * diffuse part of the IBL.
  54406. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54407. * to the ground truth.
  54408. */
  54409. useSphericalHarmonics: boolean;
  54410. private _useSpecularGlossinessInputEnergyConservation;
  54411. /**
  54412. * Defines if the material uses energy conservation, when the specular workflow is active.
  54413. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54414. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54415. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54416. */
  54417. useSpecularGlossinessInputEnergyConservation: boolean;
  54418. /** @hidden */
  54419. private _internalMarkAllSubMeshesAsMiscDirty;
  54420. /** @hidden */
  54421. _markAllSubMeshesAsMiscDirty(): void;
  54422. /**
  54423. * Instantiate a new istance of clear coat configuration.
  54424. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54425. */
  54426. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54427. /**
  54428. * Checks to see if a texture is used in the material.
  54429. * @param defines the list of "defines" to update.
  54430. */
  54431. prepareDefines(defines: IMaterialBRDFDefines): void;
  54432. /**
  54433. * Get the current class name of the texture useful for serialization or dynamic coding.
  54434. * @returns "PBRClearCoatConfiguration"
  54435. */
  54436. getClassName(): string;
  54437. /**
  54438. * Makes a duplicate of the current configuration into another one.
  54439. * @param brdfConfiguration define the config where to copy the info
  54440. */
  54441. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54442. /**
  54443. * Serializes this BRDF configuration.
  54444. * @returns - An object with the serialized config.
  54445. */
  54446. serialize(): any;
  54447. /**
  54448. * Parses a anisotropy Configuration from a serialized object.
  54449. * @param source - Serialized object.
  54450. * @param scene Defines the scene we are parsing for
  54451. * @param rootUrl Defines the rootUrl to load from
  54452. */
  54453. parse(source: any, scene: Scene, rootUrl: string): void;
  54454. }
  54455. }
  54456. declare module BABYLON {
  54457. /**
  54458. * @hidden
  54459. */
  54460. export interface IMaterialSheenDefines {
  54461. SHEEN: boolean;
  54462. SHEEN_TEXTURE: boolean;
  54463. SHEEN_TEXTUREDIRECTUV: number;
  54464. SHEEN_LINKWITHALBEDO: boolean;
  54465. SHEEN_ROUGHNESS: boolean;
  54466. SHEEN_ALBEDOSCALING: boolean;
  54467. /** @hidden */
  54468. _areTexturesDirty: boolean;
  54469. }
  54470. /**
  54471. * Define the code related to the Sheen parameters of the pbr material.
  54472. */
  54473. export class PBRSheenConfiguration {
  54474. private _isEnabled;
  54475. /**
  54476. * Defines if the material uses sheen.
  54477. */
  54478. isEnabled: boolean;
  54479. private _linkSheenWithAlbedo;
  54480. /**
  54481. * Defines if the sheen is linked to the sheen color.
  54482. */
  54483. linkSheenWithAlbedo: boolean;
  54484. /**
  54485. * Defines the sheen intensity.
  54486. */
  54487. intensity: number;
  54488. /**
  54489. * Defines the sheen color.
  54490. */
  54491. color: Color3;
  54492. private _texture;
  54493. /**
  54494. * Stores the sheen tint values in a texture.
  54495. * rgb is tint
  54496. * a is a intensity or roughness if roughness has been defined
  54497. */
  54498. texture: Nullable<BaseTexture>;
  54499. private _roughness;
  54500. /**
  54501. * Defines the sheen roughness.
  54502. * It is not taken into account if linkSheenWithAlbedo is true.
  54503. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54504. */
  54505. roughness: Nullable<number>;
  54506. private _albedoScaling;
  54507. /**
  54508. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54509. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54510. * making it easier to setup and tweak the effect
  54511. */
  54512. albedoScaling: boolean;
  54513. /** @hidden */
  54514. private _internalMarkAllSubMeshesAsTexturesDirty;
  54515. /** @hidden */
  54516. _markAllSubMeshesAsTexturesDirty(): void;
  54517. /**
  54518. * Instantiate a new istance of clear coat configuration.
  54519. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54520. */
  54521. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54522. /**
  54523. * Specifies that the submesh is ready to be used.
  54524. * @param defines the list of "defines" to update.
  54525. * @param scene defines the scene the material belongs to.
  54526. * @returns - boolean indicating that the submesh is ready or not.
  54527. */
  54528. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54529. /**
  54530. * Checks to see if a texture is used in the material.
  54531. * @param defines the list of "defines" to update.
  54532. * @param scene defines the scene the material belongs to.
  54533. */
  54534. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54535. /**
  54536. * Binds the material data.
  54537. * @param uniformBuffer defines the Uniform buffer to fill in.
  54538. * @param scene defines the scene the material belongs to.
  54539. * @param isFrozen defines wether the material is frozen or not.
  54540. */
  54541. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54542. /**
  54543. * Checks to see if a texture is used in the material.
  54544. * @param texture - Base texture to use.
  54545. * @returns - Boolean specifying if a texture is used in the material.
  54546. */
  54547. hasTexture(texture: BaseTexture): boolean;
  54548. /**
  54549. * Returns an array of the actively used textures.
  54550. * @param activeTextures Array of BaseTextures
  54551. */
  54552. getActiveTextures(activeTextures: BaseTexture[]): void;
  54553. /**
  54554. * Returns the animatable textures.
  54555. * @param animatables Array of animatable textures.
  54556. */
  54557. getAnimatables(animatables: IAnimatable[]): void;
  54558. /**
  54559. * Disposes the resources of the material.
  54560. * @param forceDisposeTextures - Forces the disposal of all textures.
  54561. */
  54562. dispose(forceDisposeTextures?: boolean): void;
  54563. /**
  54564. * Get the current class name of the texture useful for serialization or dynamic coding.
  54565. * @returns "PBRSheenConfiguration"
  54566. */
  54567. getClassName(): string;
  54568. /**
  54569. * Add fallbacks to the effect fallbacks list.
  54570. * @param defines defines the Base texture to use.
  54571. * @param fallbacks defines the current fallback list.
  54572. * @param currentRank defines the current fallback rank.
  54573. * @returns the new fallback rank.
  54574. */
  54575. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54576. /**
  54577. * Add the required uniforms to the current list.
  54578. * @param uniforms defines the current uniform list.
  54579. */
  54580. static AddUniforms(uniforms: string[]): void;
  54581. /**
  54582. * Add the required uniforms to the current buffer.
  54583. * @param uniformBuffer defines the current uniform buffer.
  54584. */
  54585. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54586. /**
  54587. * Add the required samplers to the current list.
  54588. * @param samplers defines the current sampler list.
  54589. */
  54590. static AddSamplers(samplers: string[]): void;
  54591. /**
  54592. * Makes a duplicate of the current configuration into another one.
  54593. * @param sheenConfiguration define the config where to copy the info
  54594. */
  54595. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54596. /**
  54597. * Serializes this BRDF configuration.
  54598. * @returns - An object with the serialized config.
  54599. */
  54600. serialize(): any;
  54601. /**
  54602. * Parses a anisotropy Configuration from a serialized object.
  54603. * @param source - Serialized object.
  54604. * @param scene Defines the scene we are parsing for
  54605. * @param rootUrl Defines the rootUrl to load from
  54606. */
  54607. parse(source: any, scene: Scene, rootUrl: string): void;
  54608. }
  54609. }
  54610. declare module BABYLON {
  54611. /**
  54612. * @hidden
  54613. */
  54614. export interface IMaterialSubSurfaceDefines {
  54615. SUBSURFACE: boolean;
  54616. SS_REFRACTION: boolean;
  54617. SS_TRANSLUCENCY: boolean;
  54618. SS_SCATTERING: boolean;
  54619. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54620. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54621. SS_REFRACTIONMAP_3D: boolean;
  54622. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54623. SS_LODINREFRACTIONALPHA: boolean;
  54624. SS_GAMMAREFRACTION: boolean;
  54625. SS_RGBDREFRACTION: boolean;
  54626. SS_LINEARSPECULARREFRACTION: boolean;
  54627. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54628. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54629. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54630. /** @hidden */
  54631. _areTexturesDirty: boolean;
  54632. }
  54633. /**
  54634. * Define the code related to the sub surface parameters of the pbr material.
  54635. */
  54636. export class PBRSubSurfaceConfiguration {
  54637. private _isRefractionEnabled;
  54638. /**
  54639. * Defines if the refraction is enabled in the material.
  54640. */
  54641. isRefractionEnabled: boolean;
  54642. private _isTranslucencyEnabled;
  54643. /**
  54644. * Defines if the translucency is enabled in the material.
  54645. */
  54646. isTranslucencyEnabled: boolean;
  54647. private _isScatteringEnabled;
  54648. /**
  54649. * Defines if the sub surface scattering is enabled in the material.
  54650. */
  54651. isScatteringEnabled: boolean;
  54652. private _scatteringDiffusionProfileIndex;
  54653. /**
  54654. * Diffusion profile for subsurface scattering.
  54655. * Useful for better scattering in the skins or foliages.
  54656. */
  54657. get scatteringDiffusionProfile(): Nullable<Color3>;
  54658. set scatteringDiffusionProfile(c: Nullable<Color3>);
  54659. /**
  54660. * Defines the refraction intensity of the material.
  54661. * The refraction when enabled replaces the Diffuse part of the material.
  54662. * The intensity helps transitionning between diffuse and refraction.
  54663. */
  54664. refractionIntensity: number;
  54665. /**
  54666. * Defines the translucency intensity of the material.
  54667. * When translucency has been enabled, this defines how much of the "translucency"
  54668. * is addded to the diffuse part of the material.
  54669. */
  54670. translucencyIntensity: number;
  54671. /**
  54672. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54673. */
  54674. useAlbedoToTintRefraction: boolean;
  54675. private _thicknessTexture;
  54676. /**
  54677. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54678. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54679. * 0 would mean minimumThickness
  54680. * 1 would mean maximumThickness
  54681. * The other channels might be use as a mask to vary the different effects intensity.
  54682. */
  54683. thicknessTexture: Nullable<BaseTexture>;
  54684. private _refractionTexture;
  54685. /**
  54686. * Defines the texture to use for refraction.
  54687. */
  54688. refractionTexture: Nullable<BaseTexture>;
  54689. private _indexOfRefraction;
  54690. /**
  54691. * Index of refraction of the material base layer.
  54692. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54693. *
  54694. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54695. *
  54696. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54697. */
  54698. indexOfRefraction: number;
  54699. private _volumeIndexOfRefraction;
  54700. /**
  54701. * Index of refraction of the material's volume.
  54702. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54703. *
  54704. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54705. * the volume will use the same IOR as the surface.
  54706. */
  54707. get volumeIndexOfRefraction(): number;
  54708. set volumeIndexOfRefraction(value: number);
  54709. private _invertRefractionY;
  54710. /**
  54711. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54712. */
  54713. invertRefractionY: boolean;
  54714. private _linkRefractionWithTransparency;
  54715. /**
  54716. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54717. * Materials half opaque for instance using refraction could benefit from this control.
  54718. */
  54719. linkRefractionWithTransparency: boolean;
  54720. /**
  54721. * Defines the minimum thickness stored in the thickness map.
  54722. * If no thickness map is defined, this value will be used to simulate thickness.
  54723. */
  54724. minimumThickness: number;
  54725. /**
  54726. * Defines the maximum thickness stored in the thickness map.
  54727. */
  54728. maximumThickness: number;
  54729. /**
  54730. * Defines the volume tint of the material.
  54731. * This is used for both translucency and scattering.
  54732. */
  54733. tintColor: Color3;
  54734. /**
  54735. * Defines the distance at which the tint color should be found in the media.
  54736. * This is used for refraction only.
  54737. */
  54738. tintColorAtDistance: number;
  54739. /**
  54740. * Defines how far each channel transmit through the media.
  54741. * It is defined as a color to simplify it selection.
  54742. */
  54743. diffusionDistance: Color3;
  54744. private _useMaskFromThicknessTexture;
  54745. /**
  54746. * Stores the intensity of the different subsurface effects in the thickness texture.
  54747. * * the green channel is the translucency intensity.
  54748. * * the blue channel is the scattering intensity.
  54749. * * the alpha channel is the refraction intensity.
  54750. */
  54751. useMaskFromThicknessTexture: boolean;
  54752. private _scene;
  54753. /** @hidden */
  54754. private _internalMarkAllSubMeshesAsTexturesDirty;
  54755. private _internalMarkScenePrePassDirty;
  54756. /** @hidden */
  54757. _markAllSubMeshesAsTexturesDirty(): void;
  54758. /** @hidden */
  54759. _markScenePrePassDirty(): void;
  54760. /**
  54761. * Instantiate a new istance of sub surface configuration.
  54762. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54763. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  54764. * @param scene The scene
  54765. */
  54766. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  54767. /**
  54768. * Gets wehter the submesh is ready to be used or not.
  54769. * @param defines the list of "defines" to update.
  54770. * @param scene defines the scene the material belongs to.
  54771. * @returns - boolean indicating that the submesh is ready or not.
  54772. */
  54773. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54774. /**
  54775. * Checks to see if a texture is used in the material.
  54776. * @param defines the list of "defines" to update.
  54777. * @param scene defines the scene to the material belongs to.
  54778. */
  54779. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54780. /**
  54781. * Binds the material data.
  54782. * @param uniformBuffer defines the Uniform buffer to fill in.
  54783. * @param scene defines the scene the material belongs to.
  54784. * @param engine defines the engine the material belongs to.
  54785. * @param isFrozen defines whether the material is frozen or not.
  54786. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54787. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54788. */
  54789. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54790. /**
  54791. * Unbinds the material from the mesh.
  54792. * @param activeEffect defines the effect that should be unbound from.
  54793. * @returns true if unbound, otherwise false
  54794. */
  54795. unbind(activeEffect: Effect): boolean;
  54796. /**
  54797. * Returns the texture used for refraction or null if none is used.
  54798. * @param scene defines the scene the material belongs to.
  54799. * @returns - Refraction texture if present. If no refraction texture and refraction
  54800. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54801. */
  54802. private _getRefractionTexture;
  54803. /**
  54804. * Returns true if alpha blending should be disabled.
  54805. */
  54806. get disableAlphaBlending(): boolean;
  54807. /**
  54808. * Fills the list of render target textures.
  54809. * @param renderTargets the list of render targets to update
  54810. */
  54811. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54812. /**
  54813. * Checks to see if a texture is used in the material.
  54814. * @param texture - Base texture to use.
  54815. * @returns - Boolean specifying if a texture is used in the material.
  54816. */
  54817. hasTexture(texture: BaseTexture): boolean;
  54818. /**
  54819. * Gets a boolean indicating that current material needs to register RTT
  54820. * @returns true if this uses a render target otherwise false.
  54821. */
  54822. hasRenderTargetTextures(): boolean;
  54823. /**
  54824. * Returns an array of the actively used textures.
  54825. * @param activeTextures Array of BaseTextures
  54826. */
  54827. getActiveTextures(activeTextures: BaseTexture[]): void;
  54828. /**
  54829. * Returns the animatable textures.
  54830. * @param animatables Array of animatable textures.
  54831. */
  54832. getAnimatables(animatables: IAnimatable[]): void;
  54833. /**
  54834. * Disposes the resources of the material.
  54835. * @param forceDisposeTextures - Forces the disposal of all textures.
  54836. */
  54837. dispose(forceDisposeTextures?: boolean): void;
  54838. /**
  54839. * Get the current class name of the texture useful for serialization or dynamic coding.
  54840. * @returns "PBRSubSurfaceConfiguration"
  54841. */
  54842. getClassName(): string;
  54843. /**
  54844. * Add fallbacks to the effect fallbacks list.
  54845. * @param defines defines the Base texture to use.
  54846. * @param fallbacks defines the current fallback list.
  54847. * @param currentRank defines the current fallback rank.
  54848. * @returns the new fallback rank.
  54849. */
  54850. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54851. /**
  54852. * Add the required uniforms to the current list.
  54853. * @param uniforms defines the current uniform list.
  54854. */
  54855. static AddUniforms(uniforms: string[]): void;
  54856. /**
  54857. * Add the required samplers to the current list.
  54858. * @param samplers defines the current sampler list.
  54859. */
  54860. static AddSamplers(samplers: string[]): void;
  54861. /**
  54862. * Add the required uniforms to the current buffer.
  54863. * @param uniformBuffer defines the current uniform buffer.
  54864. */
  54865. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54866. /**
  54867. * Makes a duplicate of the current configuration into another one.
  54868. * @param configuration define the config where to copy the info
  54869. */
  54870. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54871. /**
  54872. * Serializes this Sub Surface configuration.
  54873. * @returns - An object with the serialized config.
  54874. */
  54875. serialize(): any;
  54876. /**
  54877. * Parses a anisotropy Configuration from a serialized object.
  54878. * @param source - Serialized object.
  54879. * @param scene Defines the scene we are parsing for
  54880. * @param rootUrl Defines the rootUrl to load from
  54881. */
  54882. parse(source: any, scene: Scene, rootUrl: string): void;
  54883. }
  54884. }
  54885. declare module BABYLON {
  54886. /** @hidden */
  54887. export var pbrFragmentDeclaration: {
  54888. name: string;
  54889. shader: string;
  54890. };
  54891. }
  54892. declare module BABYLON {
  54893. /** @hidden */
  54894. export var pbrUboDeclaration: {
  54895. name: string;
  54896. shader: string;
  54897. };
  54898. }
  54899. declare module BABYLON {
  54900. /** @hidden */
  54901. export var pbrFragmentExtraDeclaration: {
  54902. name: string;
  54903. shader: string;
  54904. };
  54905. }
  54906. declare module BABYLON {
  54907. /** @hidden */
  54908. export var pbrFragmentSamplersDeclaration: {
  54909. name: string;
  54910. shader: string;
  54911. };
  54912. }
  54913. declare module BABYLON {
  54914. /** @hidden */
  54915. export var subSurfaceScatteringFunctions: {
  54916. name: string;
  54917. shader: string;
  54918. };
  54919. }
  54920. declare module BABYLON {
  54921. /** @hidden */
  54922. export var importanceSampling: {
  54923. name: string;
  54924. shader: string;
  54925. };
  54926. }
  54927. declare module BABYLON {
  54928. /** @hidden */
  54929. export var pbrHelperFunctions: {
  54930. name: string;
  54931. shader: string;
  54932. };
  54933. }
  54934. declare module BABYLON {
  54935. /** @hidden */
  54936. export var harmonicsFunctions: {
  54937. name: string;
  54938. shader: string;
  54939. };
  54940. }
  54941. declare module BABYLON {
  54942. /** @hidden */
  54943. export var pbrDirectLightingSetupFunctions: {
  54944. name: string;
  54945. shader: string;
  54946. };
  54947. }
  54948. declare module BABYLON {
  54949. /** @hidden */
  54950. export var pbrDirectLightingFalloffFunctions: {
  54951. name: string;
  54952. shader: string;
  54953. };
  54954. }
  54955. declare module BABYLON {
  54956. /** @hidden */
  54957. export var pbrBRDFFunctions: {
  54958. name: string;
  54959. shader: string;
  54960. };
  54961. }
  54962. declare module BABYLON {
  54963. /** @hidden */
  54964. export var hdrFilteringFunctions: {
  54965. name: string;
  54966. shader: string;
  54967. };
  54968. }
  54969. declare module BABYLON {
  54970. /** @hidden */
  54971. export var pbrDirectLightingFunctions: {
  54972. name: string;
  54973. shader: string;
  54974. };
  54975. }
  54976. declare module BABYLON {
  54977. /** @hidden */
  54978. export var pbrIBLFunctions: {
  54979. name: string;
  54980. shader: string;
  54981. };
  54982. }
  54983. declare module BABYLON {
  54984. /** @hidden */
  54985. export var pbrBlockAlbedoOpacity: {
  54986. name: string;
  54987. shader: string;
  54988. };
  54989. }
  54990. declare module BABYLON {
  54991. /** @hidden */
  54992. export var pbrBlockReflectivity: {
  54993. name: string;
  54994. shader: string;
  54995. };
  54996. }
  54997. declare module BABYLON {
  54998. /** @hidden */
  54999. export var pbrBlockAmbientOcclusion: {
  55000. name: string;
  55001. shader: string;
  55002. };
  55003. }
  55004. declare module BABYLON {
  55005. /** @hidden */
  55006. export var pbrBlockAlphaFresnel: {
  55007. name: string;
  55008. shader: string;
  55009. };
  55010. }
  55011. declare module BABYLON {
  55012. /** @hidden */
  55013. export var pbrBlockAnisotropic: {
  55014. name: string;
  55015. shader: string;
  55016. };
  55017. }
  55018. declare module BABYLON {
  55019. /** @hidden */
  55020. export var pbrBlockReflection: {
  55021. name: string;
  55022. shader: string;
  55023. };
  55024. }
  55025. declare module BABYLON {
  55026. /** @hidden */
  55027. export var pbrBlockSheen: {
  55028. name: string;
  55029. shader: string;
  55030. };
  55031. }
  55032. declare module BABYLON {
  55033. /** @hidden */
  55034. export var pbrBlockClearcoat: {
  55035. name: string;
  55036. shader: string;
  55037. };
  55038. }
  55039. declare module BABYLON {
  55040. /** @hidden */
  55041. export var pbrBlockSubSurface: {
  55042. name: string;
  55043. shader: string;
  55044. };
  55045. }
  55046. declare module BABYLON {
  55047. /** @hidden */
  55048. export var pbrBlockNormalGeometric: {
  55049. name: string;
  55050. shader: string;
  55051. };
  55052. }
  55053. declare module BABYLON {
  55054. /** @hidden */
  55055. export var pbrBlockNormalFinal: {
  55056. name: string;
  55057. shader: string;
  55058. };
  55059. }
  55060. declare module BABYLON {
  55061. /** @hidden */
  55062. export var pbrBlockGeometryInfo: {
  55063. name: string;
  55064. shader: string;
  55065. };
  55066. }
  55067. declare module BABYLON {
  55068. /** @hidden */
  55069. export var pbrBlockReflectance0: {
  55070. name: string;
  55071. shader: string;
  55072. };
  55073. }
  55074. declare module BABYLON {
  55075. /** @hidden */
  55076. export var pbrBlockReflectance: {
  55077. name: string;
  55078. shader: string;
  55079. };
  55080. }
  55081. declare module BABYLON {
  55082. /** @hidden */
  55083. export var pbrBlockDirectLighting: {
  55084. name: string;
  55085. shader: string;
  55086. };
  55087. }
  55088. declare module BABYLON {
  55089. /** @hidden */
  55090. export var pbrBlockFinalLitComponents: {
  55091. name: string;
  55092. shader: string;
  55093. };
  55094. }
  55095. declare module BABYLON {
  55096. /** @hidden */
  55097. export var pbrBlockFinalUnlitComponents: {
  55098. name: string;
  55099. shader: string;
  55100. };
  55101. }
  55102. declare module BABYLON {
  55103. /** @hidden */
  55104. export var pbrBlockFinalColorComposition: {
  55105. name: string;
  55106. shader: string;
  55107. };
  55108. }
  55109. declare module BABYLON {
  55110. /** @hidden */
  55111. export var pbrBlockImageProcessing: {
  55112. name: string;
  55113. shader: string;
  55114. };
  55115. }
  55116. declare module BABYLON {
  55117. /** @hidden */
  55118. export var pbrDebug: {
  55119. name: string;
  55120. shader: string;
  55121. };
  55122. }
  55123. declare module BABYLON {
  55124. /** @hidden */
  55125. export var pbrPixelShader: {
  55126. name: string;
  55127. shader: string;
  55128. };
  55129. }
  55130. declare module BABYLON {
  55131. /** @hidden */
  55132. export var pbrVertexDeclaration: {
  55133. name: string;
  55134. shader: string;
  55135. };
  55136. }
  55137. declare module BABYLON {
  55138. /** @hidden */
  55139. export var pbrVertexShader: {
  55140. name: string;
  55141. shader: string;
  55142. };
  55143. }
  55144. declare module BABYLON {
  55145. /**
  55146. * Manages the defines for the PBR Material.
  55147. * @hidden
  55148. */
  55149. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55150. PBR: boolean;
  55151. NUM_SAMPLES: string;
  55152. REALTIME_FILTERING: boolean;
  55153. MAINUV1: boolean;
  55154. MAINUV2: boolean;
  55155. UV1: boolean;
  55156. UV2: boolean;
  55157. ALBEDO: boolean;
  55158. GAMMAALBEDO: boolean;
  55159. ALBEDODIRECTUV: number;
  55160. VERTEXCOLOR: boolean;
  55161. DETAIL: boolean;
  55162. DETAILDIRECTUV: number;
  55163. DETAIL_NORMALBLENDMETHOD: number;
  55164. AMBIENT: boolean;
  55165. AMBIENTDIRECTUV: number;
  55166. AMBIENTINGRAYSCALE: boolean;
  55167. OPACITY: boolean;
  55168. VERTEXALPHA: boolean;
  55169. OPACITYDIRECTUV: number;
  55170. OPACITYRGB: boolean;
  55171. ALPHATEST: boolean;
  55172. DEPTHPREPASS: boolean;
  55173. ALPHABLEND: boolean;
  55174. ALPHAFROMALBEDO: boolean;
  55175. ALPHATESTVALUE: string;
  55176. SPECULAROVERALPHA: boolean;
  55177. RADIANCEOVERALPHA: boolean;
  55178. ALPHAFRESNEL: boolean;
  55179. LINEARALPHAFRESNEL: boolean;
  55180. PREMULTIPLYALPHA: boolean;
  55181. EMISSIVE: boolean;
  55182. EMISSIVEDIRECTUV: number;
  55183. REFLECTIVITY: boolean;
  55184. REFLECTIVITYDIRECTUV: number;
  55185. SPECULARTERM: boolean;
  55186. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55187. MICROSURFACEAUTOMATIC: boolean;
  55188. LODBASEDMICROSFURACE: boolean;
  55189. MICROSURFACEMAP: boolean;
  55190. MICROSURFACEMAPDIRECTUV: number;
  55191. METALLICWORKFLOW: boolean;
  55192. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55193. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55194. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55195. AOSTOREINMETALMAPRED: boolean;
  55196. METALLIC_REFLECTANCE: boolean;
  55197. METALLIC_REFLECTANCEDIRECTUV: number;
  55198. ENVIRONMENTBRDF: boolean;
  55199. ENVIRONMENTBRDF_RGBD: boolean;
  55200. NORMAL: boolean;
  55201. TANGENT: boolean;
  55202. BUMP: boolean;
  55203. BUMPDIRECTUV: number;
  55204. OBJECTSPACE_NORMALMAP: boolean;
  55205. PARALLAX: boolean;
  55206. PARALLAXOCCLUSION: boolean;
  55207. NORMALXYSCALE: boolean;
  55208. LIGHTMAP: boolean;
  55209. LIGHTMAPDIRECTUV: number;
  55210. USELIGHTMAPASSHADOWMAP: boolean;
  55211. GAMMALIGHTMAP: boolean;
  55212. RGBDLIGHTMAP: boolean;
  55213. REFLECTION: boolean;
  55214. REFLECTIONMAP_3D: boolean;
  55215. REFLECTIONMAP_SPHERICAL: boolean;
  55216. REFLECTIONMAP_PLANAR: boolean;
  55217. REFLECTIONMAP_CUBIC: boolean;
  55218. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55219. REFLECTIONMAP_PROJECTION: boolean;
  55220. REFLECTIONMAP_SKYBOX: boolean;
  55221. REFLECTIONMAP_EXPLICIT: boolean;
  55222. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55223. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55224. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55225. INVERTCUBICMAP: boolean;
  55226. USESPHERICALFROMREFLECTIONMAP: boolean;
  55227. USEIRRADIANCEMAP: boolean;
  55228. SPHERICAL_HARMONICS: boolean;
  55229. USESPHERICALINVERTEX: boolean;
  55230. REFLECTIONMAP_OPPOSITEZ: boolean;
  55231. LODINREFLECTIONALPHA: boolean;
  55232. GAMMAREFLECTION: boolean;
  55233. RGBDREFLECTION: boolean;
  55234. LINEARSPECULARREFLECTION: boolean;
  55235. RADIANCEOCCLUSION: boolean;
  55236. HORIZONOCCLUSION: boolean;
  55237. INSTANCES: boolean;
  55238. THIN_INSTANCES: boolean;
  55239. PREPASS: boolean;
  55240. SCENE_MRT_COUNT: number;
  55241. NUM_BONE_INFLUENCERS: number;
  55242. BonesPerMesh: number;
  55243. BONETEXTURE: boolean;
  55244. NONUNIFORMSCALING: boolean;
  55245. MORPHTARGETS: boolean;
  55246. MORPHTARGETS_NORMAL: boolean;
  55247. MORPHTARGETS_TANGENT: boolean;
  55248. MORPHTARGETS_UV: boolean;
  55249. NUM_MORPH_INFLUENCERS: number;
  55250. IMAGEPROCESSING: boolean;
  55251. VIGNETTE: boolean;
  55252. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55253. VIGNETTEBLENDMODEOPAQUE: boolean;
  55254. TONEMAPPING: boolean;
  55255. TONEMAPPING_ACES: boolean;
  55256. CONTRAST: boolean;
  55257. COLORCURVES: boolean;
  55258. COLORGRADING: boolean;
  55259. COLORGRADING3D: boolean;
  55260. SAMPLER3DGREENDEPTH: boolean;
  55261. SAMPLER3DBGRMAP: boolean;
  55262. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55263. EXPOSURE: boolean;
  55264. MULTIVIEW: boolean;
  55265. USEPHYSICALLIGHTFALLOFF: boolean;
  55266. USEGLTFLIGHTFALLOFF: boolean;
  55267. TWOSIDEDLIGHTING: boolean;
  55268. SHADOWFLOAT: boolean;
  55269. CLIPPLANE: boolean;
  55270. CLIPPLANE2: boolean;
  55271. CLIPPLANE3: boolean;
  55272. CLIPPLANE4: boolean;
  55273. CLIPPLANE5: boolean;
  55274. CLIPPLANE6: boolean;
  55275. POINTSIZE: boolean;
  55276. FOG: boolean;
  55277. LOGARITHMICDEPTH: boolean;
  55278. FORCENORMALFORWARD: boolean;
  55279. SPECULARAA: boolean;
  55280. CLEARCOAT: boolean;
  55281. CLEARCOAT_DEFAULTIOR: boolean;
  55282. CLEARCOAT_TEXTURE: boolean;
  55283. CLEARCOAT_TEXTUREDIRECTUV: number;
  55284. CLEARCOAT_BUMP: boolean;
  55285. CLEARCOAT_BUMPDIRECTUV: number;
  55286. CLEARCOAT_TINT: boolean;
  55287. CLEARCOAT_TINT_TEXTURE: boolean;
  55288. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55289. ANISOTROPIC: boolean;
  55290. ANISOTROPIC_TEXTURE: boolean;
  55291. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55292. BRDF_V_HEIGHT_CORRELATED: boolean;
  55293. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55294. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55295. SHEEN: boolean;
  55296. SHEEN_TEXTURE: boolean;
  55297. SHEEN_TEXTUREDIRECTUV: number;
  55298. SHEEN_LINKWITHALBEDO: boolean;
  55299. SHEEN_ROUGHNESS: boolean;
  55300. SHEEN_ALBEDOSCALING: boolean;
  55301. SUBSURFACE: boolean;
  55302. SS_REFRACTION: boolean;
  55303. SS_TRANSLUCENCY: boolean;
  55304. SS_SCATTERING: boolean;
  55305. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55306. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55307. SS_REFRACTIONMAP_3D: boolean;
  55308. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55309. SS_LODINREFRACTIONALPHA: boolean;
  55310. SS_GAMMAREFRACTION: boolean;
  55311. SS_RGBDREFRACTION: boolean;
  55312. SS_LINEARSPECULARREFRACTION: boolean;
  55313. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55314. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55315. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55316. UNLIT: boolean;
  55317. DEBUGMODE: number;
  55318. /**
  55319. * Initializes the PBR Material defines.
  55320. */
  55321. constructor();
  55322. /**
  55323. * Resets the PBR Material defines.
  55324. */
  55325. reset(): void;
  55326. }
  55327. /**
  55328. * The Physically based material base class of BJS.
  55329. *
  55330. * This offers the main features of a standard PBR material.
  55331. * For more information, please refer to the documentation :
  55332. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55333. */
  55334. export abstract class PBRBaseMaterial extends PushMaterial {
  55335. /**
  55336. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55337. */
  55338. static readonly PBRMATERIAL_OPAQUE: number;
  55339. /**
  55340. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55341. */
  55342. static readonly PBRMATERIAL_ALPHATEST: number;
  55343. /**
  55344. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55345. */
  55346. static readonly PBRMATERIAL_ALPHABLEND: number;
  55347. /**
  55348. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55349. * They are also discarded below the alpha cutoff threshold to improve performances.
  55350. */
  55351. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55352. /**
  55353. * Defines the default value of how much AO map is occluding the analytical lights
  55354. * (point spot...).
  55355. */
  55356. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55357. /**
  55358. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55359. */
  55360. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55361. /**
  55362. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55363. * to enhance interoperability with other engines.
  55364. */
  55365. static readonly LIGHTFALLOFF_GLTF: number;
  55366. /**
  55367. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55368. * to enhance interoperability with other materials.
  55369. */
  55370. static readonly LIGHTFALLOFF_STANDARD: number;
  55371. /**
  55372. * Intensity of the direct lights e.g. the four lights available in your scene.
  55373. * This impacts both the direct diffuse and specular highlights.
  55374. */
  55375. protected _directIntensity: number;
  55376. /**
  55377. * Intensity of the emissive part of the material.
  55378. * This helps controlling the emissive effect without modifying the emissive color.
  55379. */
  55380. protected _emissiveIntensity: number;
  55381. /**
  55382. * Intensity of the environment e.g. how much the environment will light the object
  55383. * either through harmonics for rough material or through the refelction for shiny ones.
  55384. */
  55385. protected _environmentIntensity: number;
  55386. /**
  55387. * This is a special control allowing the reduction of the specular highlights coming from the
  55388. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55389. */
  55390. protected _specularIntensity: number;
  55391. /**
  55392. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55393. */
  55394. private _lightingInfos;
  55395. /**
  55396. * Debug Control allowing disabling the bump map on this material.
  55397. */
  55398. protected _disableBumpMap: boolean;
  55399. /**
  55400. * AKA Diffuse Texture in standard nomenclature.
  55401. */
  55402. protected _albedoTexture: Nullable<BaseTexture>;
  55403. /**
  55404. * AKA Occlusion Texture in other nomenclature.
  55405. */
  55406. protected _ambientTexture: Nullable<BaseTexture>;
  55407. /**
  55408. * AKA Occlusion Texture Intensity in other nomenclature.
  55409. */
  55410. protected _ambientTextureStrength: number;
  55411. /**
  55412. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55413. * 1 means it completely occludes it
  55414. * 0 mean it has no impact
  55415. */
  55416. protected _ambientTextureImpactOnAnalyticalLights: number;
  55417. /**
  55418. * Stores the alpha values in a texture.
  55419. */
  55420. protected _opacityTexture: Nullable<BaseTexture>;
  55421. /**
  55422. * Stores the reflection values in a texture.
  55423. */
  55424. protected _reflectionTexture: Nullable<BaseTexture>;
  55425. /**
  55426. * Stores the emissive values in a texture.
  55427. */
  55428. protected _emissiveTexture: Nullable<BaseTexture>;
  55429. /**
  55430. * AKA Specular texture in other nomenclature.
  55431. */
  55432. protected _reflectivityTexture: Nullable<BaseTexture>;
  55433. /**
  55434. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55435. */
  55436. protected _metallicTexture: Nullable<BaseTexture>;
  55437. /**
  55438. * Specifies the metallic scalar of the metallic/roughness workflow.
  55439. * Can also be used to scale the metalness values of the metallic texture.
  55440. */
  55441. protected _metallic: Nullable<number>;
  55442. /**
  55443. * Specifies the roughness scalar of the metallic/roughness workflow.
  55444. * Can also be used to scale the roughness values of the metallic texture.
  55445. */
  55446. protected _roughness: Nullable<number>;
  55447. /**
  55448. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55449. * By default the indexOfrefraction is used to compute F0;
  55450. *
  55451. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55452. *
  55453. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55454. * F90 = metallicReflectanceColor;
  55455. */
  55456. protected _metallicF0Factor: number;
  55457. /**
  55458. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55459. * By default the F90 is always 1;
  55460. *
  55461. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55462. *
  55463. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55464. * F90 = metallicReflectanceColor;
  55465. */
  55466. protected _metallicReflectanceColor: Color3;
  55467. /**
  55468. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55469. * This is multiply against the scalar values defined in the material.
  55470. */
  55471. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55472. /**
  55473. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55474. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55475. */
  55476. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55477. /**
  55478. * Stores surface normal data used to displace a mesh in a texture.
  55479. */
  55480. protected _bumpTexture: Nullable<BaseTexture>;
  55481. /**
  55482. * Stores the pre-calculated light information of a mesh in a texture.
  55483. */
  55484. protected _lightmapTexture: Nullable<BaseTexture>;
  55485. /**
  55486. * The color of a material in ambient lighting.
  55487. */
  55488. protected _ambientColor: Color3;
  55489. /**
  55490. * AKA Diffuse Color in other nomenclature.
  55491. */
  55492. protected _albedoColor: Color3;
  55493. /**
  55494. * AKA Specular Color in other nomenclature.
  55495. */
  55496. protected _reflectivityColor: Color3;
  55497. /**
  55498. * The color applied when light is reflected from a material.
  55499. */
  55500. protected _reflectionColor: Color3;
  55501. /**
  55502. * The color applied when light is emitted from a material.
  55503. */
  55504. protected _emissiveColor: Color3;
  55505. /**
  55506. * AKA Glossiness in other nomenclature.
  55507. */
  55508. protected _microSurface: number;
  55509. /**
  55510. * Specifies that the material will use the light map as a show map.
  55511. */
  55512. protected _useLightmapAsShadowmap: boolean;
  55513. /**
  55514. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55515. * makes the reflect vector face the model (under horizon).
  55516. */
  55517. protected _useHorizonOcclusion: boolean;
  55518. /**
  55519. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55520. * too much the area relying on ambient texture to define their ambient occlusion.
  55521. */
  55522. protected _useRadianceOcclusion: boolean;
  55523. /**
  55524. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55525. */
  55526. protected _useAlphaFromAlbedoTexture: boolean;
  55527. /**
  55528. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55529. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55530. */
  55531. protected _useSpecularOverAlpha: boolean;
  55532. /**
  55533. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55534. */
  55535. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55536. /**
  55537. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55538. */
  55539. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55540. /**
  55541. * Specifies if the metallic texture contains the roughness information in its green channel.
  55542. */
  55543. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55544. /**
  55545. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55546. */
  55547. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55548. /**
  55549. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55550. */
  55551. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55552. /**
  55553. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55554. */
  55555. protected _useAmbientInGrayScale: boolean;
  55556. /**
  55557. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55558. * The material will try to infer what glossiness each pixel should be.
  55559. */
  55560. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55561. /**
  55562. * Defines the falloff type used in this material.
  55563. * It by default is Physical.
  55564. */
  55565. protected _lightFalloff: number;
  55566. /**
  55567. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55568. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55569. */
  55570. protected _useRadianceOverAlpha: boolean;
  55571. /**
  55572. * Allows using an object space normal map (instead of tangent space).
  55573. */
  55574. protected _useObjectSpaceNormalMap: boolean;
  55575. /**
  55576. * Allows using the bump map in parallax mode.
  55577. */
  55578. protected _useParallax: boolean;
  55579. /**
  55580. * Allows using the bump map in parallax occlusion mode.
  55581. */
  55582. protected _useParallaxOcclusion: boolean;
  55583. /**
  55584. * Controls the scale bias of the parallax mode.
  55585. */
  55586. protected _parallaxScaleBias: number;
  55587. /**
  55588. * If sets to true, disables all the lights affecting the material.
  55589. */
  55590. protected _disableLighting: boolean;
  55591. /**
  55592. * Number of Simultaneous lights allowed on the material.
  55593. */
  55594. protected _maxSimultaneousLights: number;
  55595. /**
  55596. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55597. */
  55598. protected _invertNormalMapX: boolean;
  55599. /**
  55600. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55601. */
  55602. protected _invertNormalMapY: boolean;
  55603. /**
  55604. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55605. */
  55606. protected _twoSidedLighting: boolean;
  55607. /**
  55608. * Defines the alpha limits in alpha test mode.
  55609. */
  55610. protected _alphaCutOff: number;
  55611. /**
  55612. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55613. */
  55614. protected _forceAlphaTest: boolean;
  55615. /**
  55616. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55617. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55618. */
  55619. protected _useAlphaFresnel: boolean;
  55620. /**
  55621. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55622. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55623. */
  55624. protected _useLinearAlphaFresnel: boolean;
  55625. /**
  55626. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55627. * from cos thetav and roughness:
  55628. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55629. */
  55630. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55631. /**
  55632. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55633. */
  55634. protected _forceIrradianceInFragment: boolean;
  55635. private _realTimeFiltering;
  55636. /**
  55637. * Enables realtime filtering on the texture.
  55638. */
  55639. get realTimeFiltering(): boolean;
  55640. set realTimeFiltering(b: boolean);
  55641. private _realTimeFilteringQuality;
  55642. /**
  55643. * Quality switch for realtime filtering
  55644. */
  55645. get realTimeFilteringQuality(): number;
  55646. set realTimeFilteringQuality(n: number);
  55647. /**
  55648. * Should this material render to several textures at once
  55649. */
  55650. get shouldRenderToMRT(): boolean;
  55651. /**
  55652. * Force normal to face away from face.
  55653. */
  55654. protected _forceNormalForward: boolean;
  55655. /**
  55656. * Enables specular anti aliasing in the PBR shader.
  55657. * It will both interacts on the Geometry for analytical and IBL lighting.
  55658. * It also prefilter the roughness map based on the bump values.
  55659. */
  55660. protected _enableSpecularAntiAliasing: boolean;
  55661. /**
  55662. * Default configuration related to image processing available in the PBR Material.
  55663. */
  55664. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55665. /**
  55666. * Keep track of the image processing observer to allow dispose and replace.
  55667. */
  55668. private _imageProcessingObserver;
  55669. /**
  55670. * Attaches a new image processing configuration to the PBR Material.
  55671. * @param configuration
  55672. */
  55673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55674. /**
  55675. * Stores the available render targets.
  55676. */
  55677. private _renderTargets;
  55678. /**
  55679. * Sets the global ambient color for the material used in lighting calculations.
  55680. */
  55681. private _globalAmbientColor;
  55682. /**
  55683. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55684. */
  55685. private _useLogarithmicDepth;
  55686. /**
  55687. * If set to true, no lighting calculations will be applied.
  55688. */
  55689. private _unlit;
  55690. private _debugMode;
  55691. /**
  55692. * @hidden
  55693. * This is reserved for the inspector.
  55694. * Defines the material debug mode.
  55695. * It helps seeing only some components of the material while troubleshooting.
  55696. */
  55697. debugMode: number;
  55698. /**
  55699. * @hidden
  55700. * This is reserved for the inspector.
  55701. * Specify from where on screen the debug mode should start.
  55702. * The value goes from -1 (full screen) to 1 (not visible)
  55703. * It helps with side by side comparison against the final render
  55704. * This defaults to -1
  55705. */
  55706. private debugLimit;
  55707. /**
  55708. * @hidden
  55709. * This is reserved for the inspector.
  55710. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55711. * You can use the factor to better multiply the final value.
  55712. */
  55713. private debugFactor;
  55714. /**
  55715. * Defines the clear coat layer parameters for the material.
  55716. */
  55717. readonly clearCoat: PBRClearCoatConfiguration;
  55718. /**
  55719. * Defines the anisotropic parameters for the material.
  55720. */
  55721. readonly anisotropy: PBRAnisotropicConfiguration;
  55722. /**
  55723. * Defines the BRDF parameters for the material.
  55724. */
  55725. readonly brdf: PBRBRDFConfiguration;
  55726. /**
  55727. * Defines the Sheen parameters for the material.
  55728. */
  55729. readonly sheen: PBRSheenConfiguration;
  55730. /**
  55731. * Defines the SubSurface parameters for the material.
  55732. */
  55733. readonly subSurface: PBRSubSurfaceConfiguration;
  55734. /**
  55735. * Defines the detail map parameters for the material.
  55736. */
  55737. readonly detailMap: DetailMapConfiguration;
  55738. protected _rebuildInParallel: boolean;
  55739. /**
  55740. * Instantiates a new PBRMaterial instance.
  55741. *
  55742. * @param name The material name
  55743. * @param scene The scene the material will be use in.
  55744. */
  55745. constructor(name: string, scene: Scene);
  55746. /**
  55747. * Gets a boolean indicating that current material needs to register RTT
  55748. */
  55749. get hasRenderTargetTextures(): boolean;
  55750. /**
  55751. * Gets the name of the material class.
  55752. */
  55753. getClassName(): string;
  55754. /**
  55755. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55756. */
  55757. get useLogarithmicDepth(): boolean;
  55758. /**
  55759. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55760. */
  55761. set useLogarithmicDepth(value: boolean);
  55762. /**
  55763. * Returns true if alpha blending should be disabled.
  55764. */
  55765. protected get _disableAlphaBlending(): boolean;
  55766. /**
  55767. * Specifies whether or not this material should be rendered in alpha blend mode.
  55768. */
  55769. needAlphaBlending(): boolean;
  55770. /**
  55771. * Specifies whether or not this material should be rendered in alpha test mode.
  55772. */
  55773. needAlphaTesting(): boolean;
  55774. /**
  55775. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55776. */
  55777. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55778. /**
  55779. * Gets the texture used for the alpha test.
  55780. */
  55781. getAlphaTestTexture(): Nullable<BaseTexture>;
  55782. /**
  55783. * Specifies that the submesh is ready to be used.
  55784. * @param mesh - BJS mesh.
  55785. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55786. * @param useInstances - Specifies that instances should be used.
  55787. * @returns - boolean indicating that the submesh is ready or not.
  55788. */
  55789. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55790. /**
  55791. * Specifies if the material uses metallic roughness workflow.
  55792. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55793. */
  55794. isMetallicWorkflow(): boolean;
  55795. private _prepareEffect;
  55796. private _prepareDefines;
  55797. /**
  55798. * Force shader compilation
  55799. */
  55800. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55801. /**
  55802. * Initializes the uniform buffer layout for the shader.
  55803. */
  55804. buildUniformLayout(): void;
  55805. /**
  55806. * Unbinds the material from the mesh
  55807. */
  55808. unbind(): void;
  55809. /**
  55810. * Binds the submesh data.
  55811. * @param world - The world matrix.
  55812. * @param mesh - The BJS mesh.
  55813. * @param subMesh - A submesh of the BJS mesh.
  55814. */
  55815. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55816. /**
  55817. * Returns the animatable textures.
  55818. * @returns - Array of animatable textures.
  55819. */
  55820. getAnimatables(): IAnimatable[];
  55821. /**
  55822. * Returns the texture used for reflections.
  55823. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55824. */
  55825. private _getReflectionTexture;
  55826. /**
  55827. * Returns an array of the actively used textures.
  55828. * @returns - Array of BaseTextures
  55829. */
  55830. getActiveTextures(): BaseTexture[];
  55831. /**
  55832. * Checks to see if a texture is used in the material.
  55833. * @param texture - Base texture to use.
  55834. * @returns - Boolean specifying if a texture is used in the material.
  55835. */
  55836. hasTexture(texture: BaseTexture): boolean;
  55837. /**
  55838. * Disposes the resources of the material.
  55839. * @param forceDisposeEffect - Forces the disposal of effects.
  55840. * @param forceDisposeTextures - Forces the disposal of all textures.
  55841. */
  55842. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55843. }
  55844. }
  55845. declare module BABYLON {
  55846. /**
  55847. * The Physically based material of BJS.
  55848. *
  55849. * This offers the main features of a standard PBR material.
  55850. * For more information, please refer to the documentation :
  55851. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55852. */
  55853. export class PBRMaterial extends PBRBaseMaterial {
  55854. /**
  55855. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55856. */
  55857. static readonly PBRMATERIAL_OPAQUE: number;
  55858. /**
  55859. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55860. */
  55861. static readonly PBRMATERIAL_ALPHATEST: number;
  55862. /**
  55863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55864. */
  55865. static readonly PBRMATERIAL_ALPHABLEND: number;
  55866. /**
  55867. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55868. * They are also discarded below the alpha cutoff threshold to improve performances.
  55869. */
  55870. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55871. /**
  55872. * Defines the default value of how much AO map is occluding the analytical lights
  55873. * (point spot...).
  55874. */
  55875. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55876. /**
  55877. * Intensity of the direct lights e.g. the four lights available in your scene.
  55878. * This impacts both the direct diffuse and specular highlights.
  55879. */
  55880. directIntensity: number;
  55881. /**
  55882. * Intensity of the emissive part of the material.
  55883. * This helps controlling the emissive effect without modifying the emissive color.
  55884. */
  55885. emissiveIntensity: number;
  55886. /**
  55887. * Intensity of the environment e.g. how much the environment will light the object
  55888. * either through harmonics for rough material or through the refelction for shiny ones.
  55889. */
  55890. environmentIntensity: number;
  55891. /**
  55892. * This is a special control allowing the reduction of the specular highlights coming from the
  55893. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55894. */
  55895. specularIntensity: number;
  55896. /**
  55897. * Debug Control allowing disabling the bump map on this material.
  55898. */
  55899. disableBumpMap: boolean;
  55900. /**
  55901. * AKA Diffuse Texture in standard nomenclature.
  55902. */
  55903. albedoTexture: BaseTexture;
  55904. /**
  55905. * AKA Occlusion Texture in other nomenclature.
  55906. */
  55907. ambientTexture: BaseTexture;
  55908. /**
  55909. * AKA Occlusion Texture Intensity in other nomenclature.
  55910. */
  55911. ambientTextureStrength: number;
  55912. /**
  55913. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55914. * 1 means it completely occludes it
  55915. * 0 mean it has no impact
  55916. */
  55917. ambientTextureImpactOnAnalyticalLights: number;
  55918. /**
  55919. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55920. */
  55921. opacityTexture: BaseTexture;
  55922. /**
  55923. * Stores the reflection values in a texture.
  55924. */
  55925. reflectionTexture: Nullable<BaseTexture>;
  55926. /**
  55927. * Stores the emissive values in a texture.
  55928. */
  55929. emissiveTexture: BaseTexture;
  55930. /**
  55931. * AKA Specular texture in other nomenclature.
  55932. */
  55933. reflectivityTexture: BaseTexture;
  55934. /**
  55935. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55936. */
  55937. metallicTexture: BaseTexture;
  55938. /**
  55939. * Specifies the metallic scalar of the metallic/roughness workflow.
  55940. * Can also be used to scale the metalness values of the metallic texture.
  55941. */
  55942. metallic: Nullable<number>;
  55943. /**
  55944. * Specifies the roughness scalar of the metallic/roughness workflow.
  55945. * Can also be used to scale the roughness values of the metallic texture.
  55946. */
  55947. roughness: Nullable<number>;
  55948. /**
  55949. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55950. * By default the indexOfrefraction is used to compute F0;
  55951. *
  55952. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55953. *
  55954. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55955. * F90 = metallicReflectanceColor;
  55956. */
  55957. metallicF0Factor: number;
  55958. /**
  55959. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55960. * By default the F90 is always 1;
  55961. *
  55962. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55963. *
  55964. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55965. * F90 = metallicReflectanceColor;
  55966. */
  55967. metallicReflectanceColor: Color3;
  55968. /**
  55969. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55970. * This is multiply against the scalar values defined in the material.
  55971. */
  55972. metallicReflectanceTexture: Nullable<BaseTexture>;
  55973. /**
  55974. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55975. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55976. */
  55977. microSurfaceTexture: BaseTexture;
  55978. /**
  55979. * Stores surface normal data used to displace a mesh in a texture.
  55980. */
  55981. bumpTexture: BaseTexture;
  55982. /**
  55983. * Stores the pre-calculated light information of a mesh in a texture.
  55984. */
  55985. lightmapTexture: BaseTexture;
  55986. /**
  55987. * Stores the refracted light information in a texture.
  55988. */
  55989. get refractionTexture(): Nullable<BaseTexture>;
  55990. set refractionTexture(value: Nullable<BaseTexture>);
  55991. /**
  55992. * The color of a material in ambient lighting.
  55993. */
  55994. ambientColor: Color3;
  55995. /**
  55996. * AKA Diffuse Color in other nomenclature.
  55997. */
  55998. albedoColor: Color3;
  55999. /**
  56000. * AKA Specular Color in other nomenclature.
  56001. */
  56002. reflectivityColor: Color3;
  56003. /**
  56004. * The color reflected from the material.
  56005. */
  56006. reflectionColor: Color3;
  56007. /**
  56008. * The color emitted from the material.
  56009. */
  56010. emissiveColor: Color3;
  56011. /**
  56012. * AKA Glossiness in other nomenclature.
  56013. */
  56014. microSurface: number;
  56015. /**
  56016. * Index of refraction of the material base layer.
  56017. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56018. *
  56019. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56020. *
  56021. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56022. */
  56023. get indexOfRefraction(): number;
  56024. set indexOfRefraction(value: number);
  56025. /**
  56026. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56027. */
  56028. get invertRefractionY(): boolean;
  56029. set invertRefractionY(value: boolean);
  56030. /**
  56031. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56032. * Materials half opaque for instance using refraction could benefit from this control.
  56033. */
  56034. get linkRefractionWithTransparency(): boolean;
  56035. set linkRefractionWithTransparency(value: boolean);
  56036. /**
  56037. * If true, the light map contains occlusion information instead of lighting info.
  56038. */
  56039. useLightmapAsShadowmap: boolean;
  56040. /**
  56041. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56042. */
  56043. useAlphaFromAlbedoTexture: boolean;
  56044. /**
  56045. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56046. */
  56047. forceAlphaTest: boolean;
  56048. /**
  56049. * Defines the alpha limits in alpha test mode.
  56050. */
  56051. alphaCutOff: number;
  56052. /**
  56053. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56054. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56055. */
  56056. useSpecularOverAlpha: boolean;
  56057. /**
  56058. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56059. */
  56060. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56061. /**
  56062. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56063. */
  56064. useRoughnessFromMetallicTextureAlpha: boolean;
  56065. /**
  56066. * Specifies if the metallic texture contains the roughness information in its green channel.
  56067. */
  56068. useRoughnessFromMetallicTextureGreen: boolean;
  56069. /**
  56070. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56071. */
  56072. useMetallnessFromMetallicTextureBlue: boolean;
  56073. /**
  56074. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56075. */
  56076. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56077. /**
  56078. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56079. */
  56080. useAmbientInGrayScale: boolean;
  56081. /**
  56082. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56083. * The material will try to infer what glossiness each pixel should be.
  56084. */
  56085. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56086. /**
  56087. * BJS is using an harcoded light falloff based on a manually sets up range.
  56088. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56089. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56090. */
  56091. get usePhysicalLightFalloff(): boolean;
  56092. /**
  56093. * BJS is using an harcoded light falloff based on a manually sets up range.
  56094. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56095. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56096. */
  56097. set usePhysicalLightFalloff(value: boolean);
  56098. /**
  56099. * In order to support the falloff compatibility with gltf, a special mode has been added
  56100. * to reproduce the gltf light falloff.
  56101. */
  56102. get useGLTFLightFalloff(): boolean;
  56103. /**
  56104. * In order to support the falloff compatibility with gltf, a special mode has been added
  56105. * to reproduce the gltf light falloff.
  56106. */
  56107. set useGLTFLightFalloff(value: boolean);
  56108. /**
  56109. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56110. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56111. */
  56112. useRadianceOverAlpha: boolean;
  56113. /**
  56114. * Allows using an object space normal map (instead of tangent space).
  56115. */
  56116. useObjectSpaceNormalMap: boolean;
  56117. /**
  56118. * Allows using the bump map in parallax mode.
  56119. */
  56120. useParallax: boolean;
  56121. /**
  56122. * Allows using the bump map in parallax occlusion mode.
  56123. */
  56124. useParallaxOcclusion: boolean;
  56125. /**
  56126. * Controls the scale bias of the parallax mode.
  56127. */
  56128. parallaxScaleBias: number;
  56129. /**
  56130. * If sets to true, disables all the lights affecting the material.
  56131. */
  56132. disableLighting: boolean;
  56133. /**
  56134. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56135. */
  56136. forceIrradianceInFragment: boolean;
  56137. /**
  56138. * Number of Simultaneous lights allowed on the material.
  56139. */
  56140. maxSimultaneousLights: number;
  56141. /**
  56142. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56143. */
  56144. invertNormalMapX: boolean;
  56145. /**
  56146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56147. */
  56148. invertNormalMapY: boolean;
  56149. /**
  56150. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56151. */
  56152. twoSidedLighting: boolean;
  56153. /**
  56154. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56155. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56156. */
  56157. useAlphaFresnel: boolean;
  56158. /**
  56159. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56160. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56161. */
  56162. useLinearAlphaFresnel: boolean;
  56163. /**
  56164. * Let user defines the brdf lookup texture used for IBL.
  56165. * A default 8bit version is embedded but you could point at :
  56166. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56167. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56168. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56169. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56170. */
  56171. environmentBRDFTexture: Nullable<BaseTexture>;
  56172. /**
  56173. * Force normal to face away from face.
  56174. */
  56175. forceNormalForward: boolean;
  56176. /**
  56177. * Enables specular anti aliasing in the PBR shader.
  56178. * It will both interacts on the Geometry for analytical and IBL lighting.
  56179. * It also prefilter the roughness map based on the bump values.
  56180. */
  56181. enableSpecularAntiAliasing: boolean;
  56182. /**
  56183. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56184. * makes the reflect vector face the model (under horizon).
  56185. */
  56186. useHorizonOcclusion: boolean;
  56187. /**
  56188. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56189. * too much the area relying on ambient texture to define their ambient occlusion.
  56190. */
  56191. useRadianceOcclusion: boolean;
  56192. /**
  56193. * If set to true, no lighting calculations will be applied.
  56194. */
  56195. unlit: boolean;
  56196. /**
  56197. * Gets the image processing configuration used either in this material.
  56198. */
  56199. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56200. /**
  56201. * Sets the Default image processing configuration used either in the this material.
  56202. *
  56203. * If sets to null, the scene one is in use.
  56204. */
  56205. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56206. /**
  56207. * Gets wether the color curves effect is enabled.
  56208. */
  56209. get cameraColorCurvesEnabled(): boolean;
  56210. /**
  56211. * Sets wether the color curves effect is enabled.
  56212. */
  56213. set cameraColorCurvesEnabled(value: boolean);
  56214. /**
  56215. * Gets wether the color grading effect is enabled.
  56216. */
  56217. get cameraColorGradingEnabled(): boolean;
  56218. /**
  56219. * Gets wether the color grading effect is enabled.
  56220. */
  56221. set cameraColorGradingEnabled(value: boolean);
  56222. /**
  56223. * Gets wether tonemapping is enabled or not.
  56224. */
  56225. get cameraToneMappingEnabled(): boolean;
  56226. /**
  56227. * Sets wether tonemapping is enabled or not
  56228. */
  56229. set cameraToneMappingEnabled(value: boolean);
  56230. /**
  56231. * The camera exposure used on this material.
  56232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56233. * This corresponds to a photographic exposure.
  56234. */
  56235. get cameraExposure(): number;
  56236. /**
  56237. * The camera exposure used on this material.
  56238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56239. * This corresponds to a photographic exposure.
  56240. */
  56241. set cameraExposure(value: number);
  56242. /**
  56243. * Gets The camera contrast used on this material.
  56244. */
  56245. get cameraContrast(): number;
  56246. /**
  56247. * Sets The camera contrast used on this material.
  56248. */
  56249. set cameraContrast(value: number);
  56250. /**
  56251. * Gets the Color Grading 2D Lookup Texture.
  56252. */
  56253. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56254. /**
  56255. * Sets the Color Grading 2D Lookup Texture.
  56256. */
  56257. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56258. /**
  56259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56261. * 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;
  56262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56263. */
  56264. get cameraColorCurves(): Nullable<ColorCurves>;
  56265. /**
  56266. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56267. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56268. * 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;
  56269. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56270. */
  56271. set cameraColorCurves(value: Nullable<ColorCurves>);
  56272. /**
  56273. * Instantiates a new PBRMaterial instance.
  56274. *
  56275. * @param name The material name
  56276. * @param scene The scene the material will be use in.
  56277. */
  56278. constructor(name: string, scene: Scene);
  56279. /**
  56280. * Returns the name of this material class.
  56281. */
  56282. getClassName(): string;
  56283. /**
  56284. * Makes a duplicate of the current material.
  56285. * @param name - name to use for the new material.
  56286. */
  56287. clone(name: string): PBRMaterial;
  56288. /**
  56289. * Serializes this PBR Material.
  56290. * @returns - An object with the serialized material.
  56291. */
  56292. serialize(): any;
  56293. /**
  56294. * Parses a PBR Material from a serialized object.
  56295. * @param source - Serialized object.
  56296. * @param scene - BJS scene instance.
  56297. * @param rootUrl - url for the scene object
  56298. * @returns - PBRMaterial
  56299. */
  56300. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56301. }
  56302. }
  56303. declare module BABYLON {
  56304. /**
  56305. * Direct draw surface info
  56306. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56307. */
  56308. export interface DDSInfo {
  56309. /**
  56310. * Width of the texture
  56311. */
  56312. width: number;
  56313. /**
  56314. * Width of the texture
  56315. */
  56316. height: number;
  56317. /**
  56318. * Number of Mipmaps for the texture
  56319. * @see https://en.wikipedia.org/wiki/Mipmap
  56320. */
  56321. mipmapCount: number;
  56322. /**
  56323. * If the textures format is a known fourCC format
  56324. * @see https://www.fourcc.org/
  56325. */
  56326. isFourCC: boolean;
  56327. /**
  56328. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56329. */
  56330. isRGB: boolean;
  56331. /**
  56332. * If the texture is a lumincance format
  56333. */
  56334. isLuminance: boolean;
  56335. /**
  56336. * If this is a cube texture
  56337. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56338. */
  56339. isCube: boolean;
  56340. /**
  56341. * If the texture is a compressed format eg. FOURCC_DXT1
  56342. */
  56343. isCompressed: boolean;
  56344. /**
  56345. * The dxgiFormat of the texture
  56346. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56347. */
  56348. dxgiFormat: number;
  56349. /**
  56350. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56351. */
  56352. textureType: number;
  56353. /**
  56354. * Sphericle polynomial created for the dds texture
  56355. */
  56356. sphericalPolynomial?: SphericalPolynomial;
  56357. }
  56358. /**
  56359. * Class used to provide DDS decompression tools
  56360. */
  56361. export class DDSTools {
  56362. /**
  56363. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56364. */
  56365. static StoreLODInAlphaChannel: boolean;
  56366. /**
  56367. * Gets DDS information from an array buffer
  56368. * @param data defines the array buffer view to read data from
  56369. * @returns the DDS information
  56370. */
  56371. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56372. private static _FloatView;
  56373. private static _Int32View;
  56374. private static _ToHalfFloat;
  56375. private static _FromHalfFloat;
  56376. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56377. private static _GetHalfFloatRGBAArrayBuffer;
  56378. private static _GetFloatRGBAArrayBuffer;
  56379. private static _GetFloatAsUIntRGBAArrayBuffer;
  56380. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56381. private static _GetRGBAArrayBuffer;
  56382. private static _ExtractLongWordOrder;
  56383. private static _GetRGBArrayBuffer;
  56384. private static _GetLuminanceArrayBuffer;
  56385. /**
  56386. * Uploads DDS Levels to a Babylon Texture
  56387. * @hidden
  56388. */
  56389. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56390. }
  56391. interface ThinEngine {
  56392. /**
  56393. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56394. * @param rootUrl defines the url where the file to load is located
  56395. * @param scene defines the current scene
  56396. * @param lodScale defines scale to apply to the mip map selection
  56397. * @param lodOffset defines offset to apply to the mip map selection
  56398. * @param onLoad defines an optional callback raised when the texture is loaded
  56399. * @param onError defines an optional callback raised if there is an issue to load the texture
  56400. * @param format defines the format of the data
  56401. * @param forcedExtension defines the extension to use to pick the right loader
  56402. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56403. * @returns the cube texture as an InternalTexture
  56404. */
  56405. 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;
  56406. }
  56407. }
  56408. declare module BABYLON {
  56409. /**
  56410. * Implementation of the DDS Texture Loader.
  56411. * @hidden
  56412. */
  56413. export class _DDSTextureLoader implements IInternalTextureLoader {
  56414. /**
  56415. * Defines wether the loader supports cascade loading the different faces.
  56416. */
  56417. readonly supportCascades: boolean;
  56418. /**
  56419. * This returns if the loader support the current file information.
  56420. * @param extension defines the file extension of the file being loaded
  56421. * @returns true if the loader can load the specified file
  56422. */
  56423. canLoad(extension: string): boolean;
  56424. /**
  56425. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56426. * @param data contains the texture data
  56427. * @param texture defines the BabylonJS internal texture
  56428. * @param createPolynomials will be true if polynomials have been requested
  56429. * @param onLoad defines the callback to trigger once the texture is ready
  56430. * @param onError defines the callback to trigger in case of error
  56431. */
  56432. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56433. /**
  56434. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56435. * @param data contains the texture data
  56436. * @param texture defines the BabylonJS internal texture
  56437. * @param callback defines the method to call once ready to upload
  56438. */
  56439. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56440. }
  56441. }
  56442. declare module BABYLON {
  56443. /**
  56444. * Implementation of the ENV Texture Loader.
  56445. * @hidden
  56446. */
  56447. export class _ENVTextureLoader implements IInternalTextureLoader {
  56448. /**
  56449. * Defines wether the loader supports cascade loading the different faces.
  56450. */
  56451. readonly supportCascades: boolean;
  56452. /**
  56453. * This returns if the loader support the current file information.
  56454. * @param extension defines the file extension of the file being loaded
  56455. * @returns true if the loader can load the specified file
  56456. */
  56457. canLoad(extension: string): boolean;
  56458. /**
  56459. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56460. * @param data contains the texture data
  56461. * @param texture defines the BabylonJS internal texture
  56462. * @param createPolynomials will be true if polynomials have been requested
  56463. * @param onLoad defines the callback to trigger once the texture is ready
  56464. * @param onError defines the callback to trigger in case of error
  56465. */
  56466. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56467. /**
  56468. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56469. * @param data contains the texture data
  56470. * @param texture defines the BabylonJS internal texture
  56471. * @param callback defines the method to call once ready to upload
  56472. */
  56473. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56474. }
  56475. }
  56476. declare module BABYLON {
  56477. /**
  56478. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56479. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56480. */
  56481. export class KhronosTextureContainer {
  56482. /** contents of the KTX container file */
  56483. data: ArrayBufferView;
  56484. private static HEADER_LEN;
  56485. private static COMPRESSED_2D;
  56486. private static COMPRESSED_3D;
  56487. private static TEX_2D;
  56488. private static TEX_3D;
  56489. /**
  56490. * Gets the openGL type
  56491. */
  56492. glType: number;
  56493. /**
  56494. * Gets the openGL type size
  56495. */
  56496. glTypeSize: number;
  56497. /**
  56498. * Gets the openGL format
  56499. */
  56500. glFormat: number;
  56501. /**
  56502. * Gets the openGL internal format
  56503. */
  56504. glInternalFormat: number;
  56505. /**
  56506. * Gets the base internal format
  56507. */
  56508. glBaseInternalFormat: number;
  56509. /**
  56510. * Gets image width in pixel
  56511. */
  56512. pixelWidth: number;
  56513. /**
  56514. * Gets image height in pixel
  56515. */
  56516. pixelHeight: number;
  56517. /**
  56518. * Gets image depth in pixels
  56519. */
  56520. pixelDepth: number;
  56521. /**
  56522. * Gets the number of array elements
  56523. */
  56524. numberOfArrayElements: number;
  56525. /**
  56526. * Gets the number of faces
  56527. */
  56528. numberOfFaces: number;
  56529. /**
  56530. * Gets the number of mipmap levels
  56531. */
  56532. numberOfMipmapLevels: number;
  56533. /**
  56534. * Gets the bytes of key value data
  56535. */
  56536. bytesOfKeyValueData: number;
  56537. /**
  56538. * Gets the load type
  56539. */
  56540. loadType: number;
  56541. /**
  56542. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56543. */
  56544. isInvalid: boolean;
  56545. /**
  56546. * Creates a new KhronosTextureContainer
  56547. * @param data contents of the KTX container file
  56548. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56549. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56550. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56551. */
  56552. constructor(
  56553. /** contents of the KTX container file */
  56554. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56555. /**
  56556. * Uploads KTX content to a Babylon Texture.
  56557. * It is assumed that the texture has already been created & is currently bound
  56558. * @hidden
  56559. */
  56560. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56561. private _upload2DCompressedLevels;
  56562. /**
  56563. * Checks if the given data starts with a KTX file identifier.
  56564. * @param data the data to check
  56565. * @returns true if the data is a KTX file or false otherwise
  56566. */
  56567. static IsValid(data: ArrayBufferView): boolean;
  56568. }
  56569. }
  56570. declare module BABYLON {
  56571. /**
  56572. * Class for loading KTX2 files
  56573. * !!! Experimental Extension Subject to Changes !!!
  56574. * @hidden
  56575. */
  56576. export class KhronosTextureContainer2 {
  56577. private static _ModulePromise;
  56578. private static _TranscodeFormat;
  56579. constructor(engine: ThinEngine);
  56580. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56581. private _determineTranscodeFormat;
  56582. /**
  56583. * Checks if the given data starts with a KTX2 file identifier.
  56584. * @param data the data to check
  56585. * @returns true if the data is a KTX2 file or false otherwise
  56586. */
  56587. static IsValid(data: ArrayBufferView): boolean;
  56588. }
  56589. }
  56590. declare module BABYLON {
  56591. /**
  56592. * Implementation of the KTX Texture Loader.
  56593. * @hidden
  56594. */
  56595. export class _KTXTextureLoader implements IInternalTextureLoader {
  56596. /**
  56597. * Defines wether the loader supports cascade loading the different faces.
  56598. */
  56599. readonly supportCascades: boolean;
  56600. /**
  56601. * This returns if the loader support the current file information.
  56602. * @param extension defines the file extension of the file being loaded
  56603. * @param mimeType defines the optional mime type of the file being loaded
  56604. * @returns true if the loader can load the specified file
  56605. */
  56606. canLoad(extension: string, mimeType?: string): boolean;
  56607. /**
  56608. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56609. * @param data contains the texture data
  56610. * @param texture defines the BabylonJS internal texture
  56611. * @param createPolynomials will be true if polynomials have been requested
  56612. * @param onLoad defines the callback to trigger once the texture is ready
  56613. * @param onError defines the callback to trigger in case of error
  56614. */
  56615. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56616. /**
  56617. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56618. * @param data contains the texture data
  56619. * @param texture defines the BabylonJS internal texture
  56620. * @param callback defines the method to call once ready to upload
  56621. */
  56622. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56623. }
  56624. }
  56625. declare module BABYLON {
  56626. /** @hidden */
  56627. export var _forceSceneHelpersToBundle: boolean;
  56628. interface Scene {
  56629. /**
  56630. * Creates a default light for the scene.
  56631. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56632. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56633. */
  56634. createDefaultLight(replace?: boolean): void;
  56635. /**
  56636. * Creates a default camera for the scene.
  56637. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56638. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56639. * @param replace has default false, when true replaces the active camera in the scene
  56640. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56641. */
  56642. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56643. /**
  56644. * Creates a default camera and a default light.
  56645. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56646. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56647. * @param replace has the default false, when true replaces the active camera/light in the scene
  56648. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56649. */
  56650. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56651. /**
  56652. * Creates a new sky box
  56653. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56654. * @param environmentTexture defines the texture to use as environment texture
  56655. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56656. * @param scale defines the overall scale of the skybox
  56657. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56658. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56659. * @returns a new mesh holding the sky box
  56660. */
  56661. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56662. /**
  56663. * Creates a new environment
  56664. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56665. * @param options defines the options you can use to configure the environment
  56666. * @returns the new EnvironmentHelper
  56667. */
  56668. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56669. /**
  56670. * Creates a new VREXperienceHelper
  56671. * @see https://doc.babylonjs.com/how_to/webvr_helper
  56672. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56673. * @returns a new VREXperienceHelper
  56674. */
  56675. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56676. /**
  56677. * Creates a new WebXRDefaultExperience
  56678. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  56679. * @param options experience options
  56680. * @returns a promise for a new WebXRDefaultExperience
  56681. */
  56682. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56683. }
  56684. }
  56685. declare module BABYLON {
  56686. /**
  56687. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56688. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56689. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56690. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56691. */
  56692. export class VideoDome extends TransformNode {
  56693. /**
  56694. * Define the video source as a Monoscopic panoramic 360 video.
  56695. */
  56696. static readonly MODE_MONOSCOPIC: number;
  56697. /**
  56698. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56699. */
  56700. static readonly MODE_TOPBOTTOM: number;
  56701. /**
  56702. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56703. */
  56704. static readonly MODE_SIDEBYSIDE: number;
  56705. private _halfDome;
  56706. private _useDirectMapping;
  56707. /**
  56708. * The video texture being displayed on the sphere
  56709. */
  56710. protected _videoTexture: VideoTexture;
  56711. /**
  56712. * Gets the video texture being displayed on the sphere
  56713. */
  56714. get videoTexture(): VideoTexture;
  56715. /**
  56716. * The skybox material
  56717. */
  56718. protected _material: BackgroundMaterial;
  56719. /**
  56720. * The surface used for the skybox
  56721. */
  56722. protected _mesh: Mesh;
  56723. /**
  56724. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56725. */
  56726. private _halfDomeMask;
  56727. /**
  56728. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56729. * Also see the options.resolution property.
  56730. */
  56731. get fovMultiplier(): number;
  56732. set fovMultiplier(value: number);
  56733. private _videoMode;
  56734. /**
  56735. * Gets or set the current video mode for the video. It can be:
  56736. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56737. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56738. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56739. */
  56740. get videoMode(): number;
  56741. set videoMode(value: number);
  56742. /**
  56743. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56744. *
  56745. */
  56746. get halfDome(): boolean;
  56747. /**
  56748. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56749. */
  56750. set halfDome(enabled: boolean);
  56751. /**
  56752. * Oberserver used in Stereoscopic VR Mode.
  56753. */
  56754. private _onBeforeCameraRenderObserver;
  56755. /**
  56756. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56757. * @param name Element's name, child elements will append suffixes for their own names.
  56758. * @param urlsOrVideo defines the url(s) or the video element to use
  56759. * @param options An object containing optional or exposed sub element properties
  56760. */
  56761. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56762. resolution?: number;
  56763. clickToPlay?: boolean;
  56764. autoPlay?: boolean;
  56765. loop?: boolean;
  56766. size?: number;
  56767. poster?: string;
  56768. faceForward?: boolean;
  56769. useDirectMapping?: boolean;
  56770. halfDomeMode?: boolean;
  56771. }, scene: Scene);
  56772. private _changeVideoMode;
  56773. /**
  56774. * Releases resources associated with this node.
  56775. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56776. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56777. */
  56778. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56779. }
  56780. }
  56781. declare module BABYLON {
  56782. /**
  56783. * This class can be used to get instrumentation data from a Babylon engine
  56784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56785. */
  56786. export class EngineInstrumentation implements IDisposable {
  56787. /**
  56788. * Define the instrumented engine.
  56789. */
  56790. engine: Engine;
  56791. private _captureGPUFrameTime;
  56792. private _gpuFrameTimeToken;
  56793. private _gpuFrameTime;
  56794. private _captureShaderCompilationTime;
  56795. private _shaderCompilationTime;
  56796. private _onBeginFrameObserver;
  56797. private _onEndFrameObserver;
  56798. private _onBeforeShaderCompilationObserver;
  56799. private _onAfterShaderCompilationObserver;
  56800. /**
  56801. * Gets the perf counter used for GPU frame time
  56802. */
  56803. get gpuFrameTimeCounter(): PerfCounter;
  56804. /**
  56805. * Gets the GPU frame time capture status
  56806. */
  56807. get captureGPUFrameTime(): boolean;
  56808. /**
  56809. * Enable or disable the GPU frame time capture
  56810. */
  56811. set captureGPUFrameTime(value: boolean);
  56812. /**
  56813. * Gets the perf counter used for shader compilation time
  56814. */
  56815. get shaderCompilationTimeCounter(): PerfCounter;
  56816. /**
  56817. * Gets the shader compilation time capture status
  56818. */
  56819. get captureShaderCompilationTime(): boolean;
  56820. /**
  56821. * Enable or disable the shader compilation time capture
  56822. */
  56823. set captureShaderCompilationTime(value: boolean);
  56824. /**
  56825. * Instantiates a new engine instrumentation.
  56826. * This class can be used to get instrumentation data from a Babylon engine
  56827. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56828. * @param engine Defines the engine to instrument
  56829. */
  56830. constructor(
  56831. /**
  56832. * Define the instrumented engine.
  56833. */
  56834. engine: Engine);
  56835. /**
  56836. * Dispose and release associated resources.
  56837. */
  56838. dispose(): void;
  56839. }
  56840. }
  56841. declare module BABYLON {
  56842. /**
  56843. * This class can be used to get instrumentation data from a Babylon engine
  56844. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56845. */
  56846. export class SceneInstrumentation implements IDisposable {
  56847. /**
  56848. * Defines the scene to instrument
  56849. */
  56850. scene: Scene;
  56851. private _captureActiveMeshesEvaluationTime;
  56852. private _activeMeshesEvaluationTime;
  56853. private _captureRenderTargetsRenderTime;
  56854. private _renderTargetsRenderTime;
  56855. private _captureFrameTime;
  56856. private _frameTime;
  56857. private _captureRenderTime;
  56858. private _renderTime;
  56859. private _captureInterFrameTime;
  56860. private _interFrameTime;
  56861. private _captureParticlesRenderTime;
  56862. private _particlesRenderTime;
  56863. private _captureSpritesRenderTime;
  56864. private _spritesRenderTime;
  56865. private _capturePhysicsTime;
  56866. private _physicsTime;
  56867. private _captureAnimationsTime;
  56868. private _animationsTime;
  56869. private _captureCameraRenderTime;
  56870. private _cameraRenderTime;
  56871. private _onBeforeActiveMeshesEvaluationObserver;
  56872. private _onAfterActiveMeshesEvaluationObserver;
  56873. private _onBeforeRenderTargetsRenderObserver;
  56874. private _onAfterRenderTargetsRenderObserver;
  56875. private _onAfterRenderObserver;
  56876. private _onBeforeDrawPhaseObserver;
  56877. private _onAfterDrawPhaseObserver;
  56878. private _onBeforeAnimationsObserver;
  56879. private _onBeforeParticlesRenderingObserver;
  56880. private _onAfterParticlesRenderingObserver;
  56881. private _onBeforeSpritesRenderingObserver;
  56882. private _onAfterSpritesRenderingObserver;
  56883. private _onBeforePhysicsObserver;
  56884. private _onAfterPhysicsObserver;
  56885. private _onAfterAnimationsObserver;
  56886. private _onBeforeCameraRenderObserver;
  56887. private _onAfterCameraRenderObserver;
  56888. /**
  56889. * Gets the perf counter used for active meshes evaluation time
  56890. */
  56891. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56892. /**
  56893. * Gets the active meshes evaluation time capture status
  56894. */
  56895. get captureActiveMeshesEvaluationTime(): boolean;
  56896. /**
  56897. * Enable or disable the active meshes evaluation time capture
  56898. */
  56899. set captureActiveMeshesEvaluationTime(value: boolean);
  56900. /**
  56901. * Gets the perf counter used for render targets render time
  56902. */
  56903. get renderTargetsRenderTimeCounter(): PerfCounter;
  56904. /**
  56905. * Gets the render targets render time capture status
  56906. */
  56907. get captureRenderTargetsRenderTime(): boolean;
  56908. /**
  56909. * Enable or disable the render targets render time capture
  56910. */
  56911. set captureRenderTargetsRenderTime(value: boolean);
  56912. /**
  56913. * Gets the perf counter used for particles render time
  56914. */
  56915. get particlesRenderTimeCounter(): PerfCounter;
  56916. /**
  56917. * Gets the particles render time capture status
  56918. */
  56919. get captureParticlesRenderTime(): boolean;
  56920. /**
  56921. * Enable or disable the particles render time capture
  56922. */
  56923. set captureParticlesRenderTime(value: boolean);
  56924. /**
  56925. * Gets the perf counter used for sprites render time
  56926. */
  56927. get spritesRenderTimeCounter(): PerfCounter;
  56928. /**
  56929. * Gets the sprites render time capture status
  56930. */
  56931. get captureSpritesRenderTime(): boolean;
  56932. /**
  56933. * Enable or disable the sprites render time capture
  56934. */
  56935. set captureSpritesRenderTime(value: boolean);
  56936. /**
  56937. * Gets the perf counter used for physics time
  56938. */
  56939. get physicsTimeCounter(): PerfCounter;
  56940. /**
  56941. * Gets the physics time capture status
  56942. */
  56943. get capturePhysicsTime(): boolean;
  56944. /**
  56945. * Enable or disable the physics time capture
  56946. */
  56947. set capturePhysicsTime(value: boolean);
  56948. /**
  56949. * Gets the perf counter used for animations time
  56950. */
  56951. get animationsTimeCounter(): PerfCounter;
  56952. /**
  56953. * Gets the animations time capture status
  56954. */
  56955. get captureAnimationsTime(): boolean;
  56956. /**
  56957. * Enable or disable the animations time capture
  56958. */
  56959. set captureAnimationsTime(value: boolean);
  56960. /**
  56961. * Gets the perf counter used for frame time capture
  56962. */
  56963. get frameTimeCounter(): PerfCounter;
  56964. /**
  56965. * Gets the frame time capture status
  56966. */
  56967. get captureFrameTime(): boolean;
  56968. /**
  56969. * Enable or disable the frame time capture
  56970. */
  56971. set captureFrameTime(value: boolean);
  56972. /**
  56973. * Gets the perf counter used for inter-frames time capture
  56974. */
  56975. get interFrameTimeCounter(): PerfCounter;
  56976. /**
  56977. * Gets the inter-frames time capture status
  56978. */
  56979. get captureInterFrameTime(): boolean;
  56980. /**
  56981. * Enable or disable the inter-frames time capture
  56982. */
  56983. set captureInterFrameTime(value: boolean);
  56984. /**
  56985. * Gets the perf counter used for render time capture
  56986. */
  56987. get renderTimeCounter(): PerfCounter;
  56988. /**
  56989. * Gets the render time capture status
  56990. */
  56991. get captureRenderTime(): boolean;
  56992. /**
  56993. * Enable or disable the render time capture
  56994. */
  56995. set captureRenderTime(value: boolean);
  56996. /**
  56997. * Gets the perf counter used for camera render time capture
  56998. */
  56999. get cameraRenderTimeCounter(): PerfCounter;
  57000. /**
  57001. * Gets the camera render time capture status
  57002. */
  57003. get captureCameraRenderTime(): boolean;
  57004. /**
  57005. * Enable or disable the camera render time capture
  57006. */
  57007. set captureCameraRenderTime(value: boolean);
  57008. /**
  57009. * Gets the perf counter used for draw calls
  57010. */
  57011. get drawCallsCounter(): PerfCounter;
  57012. /**
  57013. * Instantiates a new scene instrumentation.
  57014. * This class can be used to get instrumentation data from a Babylon engine
  57015. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57016. * @param scene Defines the scene to instrument
  57017. */
  57018. constructor(
  57019. /**
  57020. * Defines the scene to instrument
  57021. */
  57022. scene: Scene);
  57023. /**
  57024. * Dispose and release associated resources.
  57025. */
  57026. dispose(): void;
  57027. }
  57028. }
  57029. declare module BABYLON {
  57030. /** @hidden */
  57031. export var glowMapGenerationPixelShader: {
  57032. name: string;
  57033. shader: string;
  57034. };
  57035. }
  57036. declare module BABYLON {
  57037. /** @hidden */
  57038. export var glowMapGenerationVertexShader: {
  57039. name: string;
  57040. shader: string;
  57041. };
  57042. }
  57043. declare module BABYLON {
  57044. /**
  57045. * Effect layer options. This helps customizing the behaviour
  57046. * of the effect layer.
  57047. */
  57048. export interface IEffectLayerOptions {
  57049. /**
  57050. * Multiplication factor apply to the canvas size to compute the render target size
  57051. * used to generated the objects (the smaller the faster).
  57052. */
  57053. mainTextureRatio: number;
  57054. /**
  57055. * Enforces a fixed size texture to ensure effect stability across devices.
  57056. */
  57057. mainTextureFixedSize?: number;
  57058. /**
  57059. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57060. */
  57061. alphaBlendingMode: number;
  57062. /**
  57063. * The camera attached to the layer.
  57064. */
  57065. camera: Nullable<Camera>;
  57066. /**
  57067. * The rendering group to draw the layer in.
  57068. */
  57069. renderingGroupId: number;
  57070. }
  57071. /**
  57072. * The effect layer Helps adding post process effect blended with the main pass.
  57073. *
  57074. * This can be for instance use to generate glow or higlight effects on the scene.
  57075. *
  57076. * The effect layer class can not be used directly and is intented to inherited from to be
  57077. * customized per effects.
  57078. */
  57079. export abstract class EffectLayer {
  57080. private _vertexBuffers;
  57081. private _indexBuffer;
  57082. private _cachedDefines;
  57083. private _effectLayerMapGenerationEffect;
  57084. private _effectLayerOptions;
  57085. private _mergeEffect;
  57086. protected _scene: Scene;
  57087. protected _engine: Engine;
  57088. protected _maxSize: number;
  57089. protected _mainTextureDesiredSize: ISize;
  57090. protected _mainTexture: RenderTargetTexture;
  57091. protected _shouldRender: boolean;
  57092. protected _postProcesses: PostProcess[];
  57093. protected _textures: BaseTexture[];
  57094. protected _emissiveTextureAndColor: {
  57095. texture: Nullable<BaseTexture>;
  57096. color: Color4;
  57097. };
  57098. /**
  57099. * The name of the layer
  57100. */
  57101. name: string;
  57102. /**
  57103. * The clear color of the texture used to generate the glow map.
  57104. */
  57105. neutralColor: Color4;
  57106. /**
  57107. * Specifies whether the highlight layer is enabled or not.
  57108. */
  57109. isEnabled: boolean;
  57110. /**
  57111. * Gets the camera attached to the layer.
  57112. */
  57113. get camera(): Nullable<Camera>;
  57114. /**
  57115. * Gets the rendering group id the layer should render in.
  57116. */
  57117. get renderingGroupId(): number;
  57118. set renderingGroupId(renderingGroupId: number);
  57119. /**
  57120. * An event triggered when the effect layer has been disposed.
  57121. */
  57122. onDisposeObservable: Observable<EffectLayer>;
  57123. /**
  57124. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57125. */
  57126. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57127. /**
  57128. * An event triggered when the generated texture is being merged in the scene.
  57129. */
  57130. onBeforeComposeObservable: Observable<EffectLayer>;
  57131. /**
  57132. * An event triggered when the mesh is rendered into the effect render target.
  57133. */
  57134. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57135. /**
  57136. * An event triggered after the mesh has been rendered into the effect render target.
  57137. */
  57138. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57139. /**
  57140. * An event triggered when the generated texture has been merged in the scene.
  57141. */
  57142. onAfterComposeObservable: Observable<EffectLayer>;
  57143. /**
  57144. * An event triggered when the efffect layer changes its size.
  57145. */
  57146. onSizeChangedObservable: Observable<EffectLayer>;
  57147. /** @hidden */
  57148. static _SceneComponentInitialization: (scene: Scene) => void;
  57149. /**
  57150. * Instantiates a new effect Layer and references it in the scene.
  57151. * @param name The name of the layer
  57152. * @param scene The scene to use the layer in
  57153. */
  57154. constructor(
  57155. /** The Friendly of the effect in the scene */
  57156. name: string, scene: Scene);
  57157. /**
  57158. * Get the effect name of the layer.
  57159. * @return The effect name
  57160. */
  57161. abstract getEffectName(): string;
  57162. /**
  57163. * Checks for the readiness of the element composing the layer.
  57164. * @param subMesh the mesh to check for
  57165. * @param useInstances specify whether or not to use instances to render the mesh
  57166. * @return true if ready otherwise, false
  57167. */
  57168. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57169. /**
  57170. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57171. * @returns true if the effect requires stencil during the main canvas render pass.
  57172. */
  57173. abstract needStencil(): boolean;
  57174. /**
  57175. * Create the merge effect. This is the shader use to blit the information back
  57176. * to the main canvas at the end of the scene rendering.
  57177. * @returns The effect containing the shader used to merge the effect on the main canvas
  57178. */
  57179. protected abstract _createMergeEffect(): Effect;
  57180. /**
  57181. * Creates the render target textures and post processes used in the effect layer.
  57182. */
  57183. protected abstract _createTextureAndPostProcesses(): void;
  57184. /**
  57185. * Implementation specific of rendering the generating effect on the main canvas.
  57186. * @param effect The effect used to render through
  57187. */
  57188. protected abstract _internalRender(effect: Effect): void;
  57189. /**
  57190. * Sets the required values for both the emissive texture and and the main color.
  57191. */
  57192. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57193. /**
  57194. * Free any resources and references associated to a mesh.
  57195. * Internal use
  57196. * @param mesh The mesh to free.
  57197. */
  57198. abstract _disposeMesh(mesh: Mesh): void;
  57199. /**
  57200. * Serializes this layer (Glow or Highlight for example)
  57201. * @returns a serialized layer object
  57202. */
  57203. abstract serialize?(): any;
  57204. /**
  57205. * Initializes the effect layer with the required options.
  57206. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57207. */
  57208. protected _init(options: Partial<IEffectLayerOptions>): void;
  57209. /**
  57210. * Generates the index buffer of the full screen quad blending to the main canvas.
  57211. */
  57212. private _generateIndexBuffer;
  57213. /**
  57214. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57215. */
  57216. private _generateVertexBuffer;
  57217. /**
  57218. * Sets the main texture desired size which is the closest power of two
  57219. * of the engine canvas size.
  57220. */
  57221. private _setMainTextureSize;
  57222. /**
  57223. * Creates the main texture for the effect layer.
  57224. */
  57225. protected _createMainTexture(): void;
  57226. /**
  57227. * Adds specific effects defines.
  57228. * @param defines The defines to add specifics to.
  57229. */
  57230. protected _addCustomEffectDefines(defines: string[]): void;
  57231. /**
  57232. * Checks for the readiness of the element composing the layer.
  57233. * @param subMesh the mesh to check for
  57234. * @param useInstances specify whether or not to use instances to render the mesh
  57235. * @param emissiveTexture the associated emissive texture used to generate the glow
  57236. * @return true if ready otherwise, false
  57237. */
  57238. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57239. /**
  57240. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57241. */
  57242. render(): void;
  57243. /**
  57244. * Determine if a given mesh will be used in the current effect.
  57245. * @param mesh mesh to test
  57246. * @returns true if the mesh will be used
  57247. */
  57248. hasMesh(mesh: AbstractMesh): boolean;
  57249. /**
  57250. * Returns true if the layer contains information to display, otherwise false.
  57251. * @returns true if the glow layer should be rendered
  57252. */
  57253. shouldRender(): boolean;
  57254. /**
  57255. * Returns true if the mesh should render, otherwise false.
  57256. * @param mesh The mesh to render
  57257. * @returns true if it should render otherwise false
  57258. */
  57259. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57260. /**
  57261. * Returns true if the mesh can be rendered, otherwise false.
  57262. * @param mesh The mesh to render
  57263. * @param material The material used on the mesh
  57264. * @returns true if it can be rendered otherwise false
  57265. */
  57266. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57267. /**
  57268. * Returns true if the mesh should render, otherwise false.
  57269. * @param mesh The mesh to render
  57270. * @returns true if it should render otherwise false
  57271. */
  57272. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57273. /**
  57274. * Renders the submesh passed in parameter to the generation map.
  57275. */
  57276. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57277. /**
  57278. * Defines whether the current material of the mesh should be use to render the effect.
  57279. * @param mesh defines the current mesh to render
  57280. */
  57281. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57282. /**
  57283. * Rebuild the required buffers.
  57284. * @hidden Internal use only.
  57285. */
  57286. _rebuild(): void;
  57287. /**
  57288. * Dispose only the render target textures and post process.
  57289. */
  57290. private _disposeTextureAndPostProcesses;
  57291. /**
  57292. * Dispose the highlight layer and free resources.
  57293. */
  57294. dispose(): void;
  57295. /**
  57296. * Gets the class name of the effect layer
  57297. * @returns the string with the class name of the effect layer
  57298. */
  57299. getClassName(): string;
  57300. /**
  57301. * Creates an effect layer from parsed effect layer data
  57302. * @param parsedEffectLayer defines effect layer data
  57303. * @param scene defines the current scene
  57304. * @param rootUrl defines the root URL containing the effect layer information
  57305. * @returns a parsed effect Layer
  57306. */
  57307. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57308. }
  57309. }
  57310. declare module BABYLON {
  57311. interface AbstractScene {
  57312. /**
  57313. * The list of effect layers (highlights/glow) added to the scene
  57314. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57315. * @see https://doc.babylonjs.com/how_to/glow_layer
  57316. */
  57317. effectLayers: Array<EffectLayer>;
  57318. /**
  57319. * Removes the given effect layer from this scene.
  57320. * @param toRemove defines the effect layer to remove
  57321. * @returns the index of the removed effect layer
  57322. */
  57323. removeEffectLayer(toRemove: EffectLayer): number;
  57324. /**
  57325. * Adds the given effect layer to this scene
  57326. * @param newEffectLayer defines the effect layer to add
  57327. */
  57328. addEffectLayer(newEffectLayer: EffectLayer): void;
  57329. }
  57330. /**
  57331. * Defines the layer scene component responsible to manage any effect layers
  57332. * in a given scene.
  57333. */
  57334. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57335. /**
  57336. * The component name helpfull to identify the component in the list of scene components.
  57337. */
  57338. readonly name: string;
  57339. /**
  57340. * The scene the component belongs to.
  57341. */
  57342. scene: Scene;
  57343. private _engine;
  57344. private _renderEffects;
  57345. private _needStencil;
  57346. private _previousStencilState;
  57347. /**
  57348. * Creates a new instance of the component for the given scene
  57349. * @param scene Defines the scene to register the component in
  57350. */
  57351. constructor(scene: Scene);
  57352. /**
  57353. * Registers the component in a given scene
  57354. */
  57355. register(): void;
  57356. /**
  57357. * Rebuilds the elements related to this component in case of
  57358. * context lost for instance.
  57359. */
  57360. rebuild(): void;
  57361. /**
  57362. * Serializes the component data to the specified json object
  57363. * @param serializationObject The object to serialize to
  57364. */
  57365. serialize(serializationObject: any): void;
  57366. /**
  57367. * Adds all the elements from the container to the scene
  57368. * @param container the container holding the elements
  57369. */
  57370. addFromContainer(container: AbstractScene): void;
  57371. /**
  57372. * Removes all the elements in the container from the scene
  57373. * @param container contains the elements to remove
  57374. * @param dispose if the removed element should be disposed (default: false)
  57375. */
  57376. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57377. /**
  57378. * Disposes the component and the associated ressources.
  57379. */
  57380. dispose(): void;
  57381. private _isReadyForMesh;
  57382. private _renderMainTexture;
  57383. private _setStencil;
  57384. private _setStencilBack;
  57385. private _draw;
  57386. private _drawCamera;
  57387. private _drawRenderingGroup;
  57388. }
  57389. }
  57390. declare module BABYLON {
  57391. /** @hidden */
  57392. export var glowMapMergePixelShader: {
  57393. name: string;
  57394. shader: string;
  57395. };
  57396. }
  57397. declare module BABYLON {
  57398. /** @hidden */
  57399. export var glowMapMergeVertexShader: {
  57400. name: string;
  57401. shader: string;
  57402. };
  57403. }
  57404. declare module BABYLON {
  57405. interface AbstractScene {
  57406. /**
  57407. * Return a the first highlight layer of the scene with a given name.
  57408. * @param name The name of the highlight layer to look for.
  57409. * @return The highlight layer if found otherwise null.
  57410. */
  57411. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57412. }
  57413. /**
  57414. * Glow layer options. This helps customizing the behaviour
  57415. * of the glow layer.
  57416. */
  57417. export interface IGlowLayerOptions {
  57418. /**
  57419. * Multiplication factor apply to the canvas size to compute the render target size
  57420. * used to generated the glowing objects (the smaller the faster).
  57421. */
  57422. mainTextureRatio: number;
  57423. /**
  57424. * Enforces a fixed size texture to ensure resize independant blur.
  57425. */
  57426. mainTextureFixedSize?: number;
  57427. /**
  57428. * How big is the kernel of the blur texture.
  57429. */
  57430. blurKernelSize: number;
  57431. /**
  57432. * The camera attached to the layer.
  57433. */
  57434. camera: Nullable<Camera>;
  57435. /**
  57436. * Enable MSAA by chosing the number of samples.
  57437. */
  57438. mainTextureSamples?: number;
  57439. /**
  57440. * The rendering group to draw the layer in.
  57441. */
  57442. renderingGroupId: number;
  57443. }
  57444. /**
  57445. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57446. *
  57447. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57448. *
  57449. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57450. */
  57451. export class GlowLayer extends EffectLayer {
  57452. /**
  57453. * Effect Name of the layer.
  57454. */
  57455. static readonly EffectName: string;
  57456. /**
  57457. * The default blur kernel size used for the glow.
  57458. */
  57459. static DefaultBlurKernelSize: number;
  57460. /**
  57461. * The default texture size ratio used for the glow.
  57462. */
  57463. static DefaultTextureRatio: number;
  57464. /**
  57465. * Sets the kernel size of the blur.
  57466. */
  57467. set blurKernelSize(value: number);
  57468. /**
  57469. * Gets the kernel size of the blur.
  57470. */
  57471. get blurKernelSize(): number;
  57472. /**
  57473. * Sets the glow intensity.
  57474. */
  57475. set intensity(value: number);
  57476. /**
  57477. * Gets the glow intensity.
  57478. */
  57479. get intensity(): number;
  57480. private _options;
  57481. private _intensity;
  57482. private _horizontalBlurPostprocess1;
  57483. private _verticalBlurPostprocess1;
  57484. private _horizontalBlurPostprocess2;
  57485. private _verticalBlurPostprocess2;
  57486. private _blurTexture1;
  57487. private _blurTexture2;
  57488. private _postProcesses1;
  57489. private _postProcesses2;
  57490. private _includedOnlyMeshes;
  57491. private _excludedMeshes;
  57492. private _meshesUsingTheirOwnMaterials;
  57493. /**
  57494. * Callback used to let the user override the color selection on a per mesh basis
  57495. */
  57496. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57497. /**
  57498. * Callback used to let the user override the texture selection on a per mesh basis
  57499. */
  57500. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57501. /**
  57502. * Instantiates a new glow Layer and references it to the scene.
  57503. * @param name The name of the layer
  57504. * @param scene The scene to use the layer in
  57505. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57506. */
  57507. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57508. /**
  57509. * Get the effect name of the layer.
  57510. * @return The effect name
  57511. */
  57512. getEffectName(): string;
  57513. /**
  57514. * Create the merge effect. This is the shader use to blit the information back
  57515. * to the main canvas at the end of the scene rendering.
  57516. */
  57517. protected _createMergeEffect(): Effect;
  57518. /**
  57519. * Creates the render target textures and post processes used in the glow layer.
  57520. */
  57521. protected _createTextureAndPostProcesses(): void;
  57522. /**
  57523. * Checks for the readiness of the element composing the layer.
  57524. * @param subMesh the mesh to check for
  57525. * @param useInstances specify wether or not to use instances to render the mesh
  57526. * @param emissiveTexture the associated emissive texture used to generate the glow
  57527. * @return true if ready otherwise, false
  57528. */
  57529. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57530. /**
  57531. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57532. */
  57533. needStencil(): boolean;
  57534. /**
  57535. * Returns true if the mesh can be rendered, otherwise false.
  57536. * @param mesh The mesh to render
  57537. * @param material The material used on the mesh
  57538. * @returns true if it can be rendered otherwise false
  57539. */
  57540. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57541. /**
  57542. * Implementation specific of rendering the generating effect on the main canvas.
  57543. * @param effect The effect used to render through
  57544. */
  57545. protected _internalRender(effect: Effect): void;
  57546. /**
  57547. * Sets the required values for both the emissive texture and and the main color.
  57548. */
  57549. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57550. /**
  57551. * Returns true if the mesh should render, otherwise false.
  57552. * @param mesh The mesh to render
  57553. * @returns true if it should render otherwise false
  57554. */
  57555. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57556. /**
  57557. * Adds specific effects defines.
  57558. * @param defines The defines to add specifics to.
  57559. */
  57560. protected _addCustomEffectDefines(defines: string[]): void;
  57561. /**
  57562. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57563. * @param mesh The mesh to exclude from the glow layer
  57564. */
  57565. addExcludedMesh(mesh: Mesh): void;
  57566. /**
  57567. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57568. * @param mesh The mesh to remove
  57569. */
  57570. removeExcludedMesh(mesh: Mesh): void;
  57571. /**
  57572. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57573. * @param mesh The mesh to include in the glow layer
  57574. */
  57575. addIncludedOnlyMesh(mesh: Mesh): void;
  57576. /**
  57577. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57578. * @param mesh The mesh to remove
  57579. */
  57580. removeIncludedOnlyMesh(mesh: Mesh): void;
  57581. /**
  57582. * Determine if a given mesh will be used in the glow layer
  57583. * @param mesh The mesh to test
  57584. * @returns true if the mesh will be highlighted by the current glow layer
  57585. */
  57586. hasMesh(mesh: AbstractMesh): boolean;
  57587. /**
  57588. * Defines whether the current material of the mesh should be use to render the effect.
  57589. * @param mesh defines the current mesh to render
  57590. */
  57591. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57592. /**
  57593. * Add a mesh to be rendered through its own material and not with emissive only.
  57594. * @param mesh The mesh for which we need to use its material
  57595. */
  57596. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57597. /**
  57598. * Remove a mesh from being rendered through its own material and not with emissive only.
  57599. * @param mesh The mesh for which we need to not use its material
  57600. */
  57601. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57602. /**
  57603. * Free any resources and references associated to a mesh.
  57604. * Internal use
  57605. * @param mesh The mesh to free.
  57606. * @hidden
  57607. */
  57608. _disposeMesh(mesh: Mesh): void;
  57609. /**
  57610. * Gets the class name of the effect layer
  57611. * @returns the string with the class name of the effect layer
  57612. */
  57613. getClassName(): string;
  57614. /**
  57615. * Serializes this glow layer
  57616. * @returns a serialized glow layer object
  57617. */
  57618. serialize(): any;
  57619. /**
  57620. * Creates a Glow Layer from parsed glow layer data
  57621. * @param parsedGlowLayer defines glow layer data
  57622. * @param scene defines the current scene
  57623. * @param rootUrl defines the root URL containing the glow layer information
  57624. * @returns a parsed Glow Layer
  57625. */
  57626. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57627. }
  57628. }
  57629. declare module BABYLON {
  57630. /** @hidden */
  57631. export var glowBlurPostProcessPixelShader: {
  57632. name: string;
  57633. shader: string;
  57634. };
  57635. }
  57636. declare module BABYLON {
  57637. interface AbstractScene {
  57638. /**
  57639. * Return a the first highlight layer of the scene with a given name.
  57640. * @param name The name of the highlight layer to look for.
  57641. * @return The highlight layer if found otherwise null.
  57642. */
  57643. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57644. }
  57645. /**
  57646. * Highlight layer options. This helps customizing the behaviour
  57647. * of the highlight layer.
  57648. */
  57649. export interface IHighlightLayerOptions {
  57650. /**
  57651. * Multiplication factor apply to the canvas size to compute the render target size
  57652. * used to generated the glowing objects (the smaller the faster).
  57653. */
  57654. mainTextureRatio: number;
  57655. /**
  57656. * Enforces a fixed size texture to ensure resize independant blur.
  57657. */
  57658. mainTextureFixedSize?: number;
  57659. /**
  57660. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57661. * of the picture to blur (the smaller the faster).
  57662. */
  57663. blurTextureSizeRatio: number;
  57664. /**
  57665. * How big in texel of the blur texture is the vertical blur.
  57666. */
  57667. blurVerticalSize: number;
  57668. /**
  57669. * How big in texel of the blur texture is the horizontal blur.
  57670. */
  57671. blurHorizontalSize: number;
  57672. /**
  57673. * Alpha blending mode used to apply the blur. Default is combine.
  57674. */
  57675. alphaBlendingMode: number;
  57676. /**
  57677. * The camera attached to the layer.
  57678. */
  57679. camera: Nullable<Camera>;
  57680. /**
  57681. * Should we display highlight as a solid stroke?
  57682. */
  57683. isStroke?: boolean;
  57684. /**
  57685. * The rendering group to draw the layer in.
  57686. */
  57687. renderingGroupId: number;
  57688. }
  57689. /**
  57690. * The highlight layer Helps adding a glow effect around a mesh.
  57691. *
  57692. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57693. * glowy meshes to your scene.
  57694. *
  57695. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57696. */
  57697. export class HighlightLayer extends EffectLayer {
  57698. name: string;
  57699. /**
  57700. * Effect Name of the highlight layer.
  57701. */
  57702. static readonly EffectName: string;
  57703. /**
  57704. * The neutral color used during the preparation of the glow effect.
  57705. * This is black by default as the blend operation is a blend operation.
  57706. */
  57707. static NeutralColor: Color4;
  57708. /**
  57709. * Stencil value used for glowing meshes.
  57710. */
  57711. static GlowingMeshStencilReference: number;
  57712. /**
  57713. * Stencil value used for the other meshes in the scene.
  57714. */
  57715. static NormalMeshStencilReference: number;
  57716. /**
  57717. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57718. */
  57719. innerGlow: boolean;
  57720. /**
  57721. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57722. */
  57723. outerGlow: boolean;
  57724. /**
  57725. * Specifies the horizontal size of the blur.
  57726. */
  57727. set blurHorizontalSize(value: number);
  57728. /**
  57729. * Specifies the vertical size of the blur.
  57730. */
  57731. set blurVerticalSize(value: number);
  57732. /**
  57733. * Gets the horizontal size of the blur.
  57734. */
  57735. get blurHorizontalSize(): number;
  57736. /**
  57737. * Gets the vertical size of the blur.
  57738. */
  57739. get blurVerticalSize(): number;
  57740. /**
  57741. * An event triggered when the highlight layer is being blurred.
  57742. */
  57743. onBeforeBlurObservable: Observable<HighlightLayer>;
  57744. /**
  57745. * An event triggered when the highlight layer has been blurred.
  57746. */
  57747. onAfterBlurObservable: Observable<HighlightLayer>;
  57748. private _instanceGlowingMeshStencilReference;
  57749. private _options;
  57750. private _downSamplePostprocess;
  57751. private _horizontalBlurPostprocess;
  57752. private _verticalBlurPostprocess;
  57753. private _blurTexture;
  57754. private _meshes;
  57755. private _excludedMeshes;
  57756. /**
  57757. * Instantiates a new highlight Layer and references it to the scene..
  57758. * @param name The name of the layer
  57759. * @param scene The scene to use the layer in
  57760. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57761. */
  57762. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57763. /**
  57764. * Get the effect name of the layer.
  57765. * @return The effect name
  57766. */
  57767. getEffectName(): string;
  57768. /**
  57769. * Create the merge effect. This is the shader use to blit the information back
  57770. * to the main canvas at the end of the scene rendering.
  57771. */
  57772. protected _createMergeEffect(): Effect;
  57773. /**
  57774. * Creates the render target textures and post processes used in the highlight layer.
  57775. */
  57776. protected _createTextureAndPostProcesses(): void;
  57777. /**
  57778. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57779. */
  57780. needStencil(): boolean;
  57781. /**
  57782. * Checks for the readiness of the element composing the layer.
  57783. * @param subMesh the mesh to check for
  57784. * @param useInstances specify wether or not to use instances to render the mesh
  57785. * @param emissiveTexture the associated emissive texture used to generate the glow
  57786. * @return true if ready otherwise, false
  57787. */
  57788. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57789. /**
  57790. * Implementation specific of rendering the generating effect on the main canvas.
  57791. * @param effect The effect used to render through
  57792. */
  57793. protected _internalRender(effect: Effect): void;
  57794. /**
  57795. * Returns true if the layer contains information to display, otherwise false.
  57796. */
  57797. shouldRender(): boolean;
  57798. /**
  57799. * Returns true if the mesh should render, otherwise false.
  57800. * @param mesh The mesh to render
  57801. * @returns true if it should render otherwise false
  57802. */
  57803. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57804. /**
  57805. * Returns true if the mesh can be rendered, otherwise false.
  57806. * @param mesh The mesh to render
  57807. * @param material The material used on the mesh
  57808. * @returns true if it can be rendered otherwise false
  57809. */
  57810. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57811. /**
  57812. * Adds specific effects defines.
  57813. * @param defines The defines to add specifics to.
  57814. */
  57815. protected _addCustomEffectDefines(defines: string[]): void;
  57816. /**
  57817. * Sets the required values for both the emissive texture and and the main color.
  57818. */
  57819. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57820. /**
  57821. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57822. * @param mesh The mesh to exclude from the highlight layer
  57823. */
  57824. addExcludedMesh(mesh: Mesh): void;
  57825. /**
  57826. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57827. * @param mesh The mesh to highlight
  57828. */
  57829. removeExcludedMesh(mesh: Mesh): void;
  57830. /**
  57831. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57832. * @param mesh mesh to test
  57833. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57834. */
  57835. hasMesh(mesh: AbstractMesh): boolean;
  57836. /**
  57837. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57838. * @param mesh The mesh to highlight
  57839. * @param color The color of the highlight
  57840. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57841. */
  57842. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57843. /**
  57844. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57845. * @param mesh The mesh to highlight
  57846. */
  57847. removeMesh(mesh: Mesh): void;
  57848. /**
  57849. * Remove all the meshes currently referenced in the highlight layer
  57850. */
  57851. removeAllMeshes(): void;
  57852. /**
  57853. * Force the stencil to the normal expected value for none glowing parts
  57854. */
  57855. private _defaultStencilReference;
  57856. /**
  57857. * Free any resources and references associated to a mesh.
  57858. * Internal use
  57859. * @param mesh The mesh to free.
  57860. * @hidden
  57861. */
  57862. _disposeMesh(mesh: Mesh): void;
  57863. /**
  57864. * Dispose the highlight layer and free resources.
  57865. */
  57866. dispose(): void;
  57867. /**
  57868. * Gets the class name of the effect layer
  57869. * @returns the string with the class name of the effect layer
  57870. */
  57871. getClassName(): string;
  57872. /**
  57873. * Serializes this Highlight layer
  57874. * @returns a serialized Highlight layer object
  57875. */
  57876. serialize(): any;
  57877. /**
  57878. * Creates a Highlight layer from parsed Highlight layer data
  57879. * @param parsedHightlightLayer defines the Highlight layer data
  57880. * @param scene defines the current scene
  57881. * @param rootUrl defines the root URL containing the Highlight layer information
  57882. * @returns a parsed Highlight layer
  57883. */
  57884. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57885. }
  57886. }
  57887. declare module BABYLON {
  57888. interface AbstractScene {
  57889. /**
  57890. * The list of layers (background and foreground) of the scene
  57891. */
  57892. layers: Array<Layer>;
  57893. }
  57894. /**
  57895. * Defines the layer scene component responsible to manage any layers
  57896. * in a given scene.
  57897. */
  57898. export class LayerSceneComponent implements ISceneComponent {
  57899. /**
  57900. * The component name helpfull to identify the component in the list of scene components.
  57901. */
  57902. readonly name: string;
  57903. /**
  57904. * The scene the component belongs to.
  57905. */
  57906. scene: Scene;
  57907. private _engine;
  57908. /**
  57909. * Creates a new instance of the component for the given scene
  57910. * @param scene Defines the scene to register the component in
  57911. */
  57912. constructor(scene: Scene);
  57913. /**
  57914. * Registers the component in a given scene
  57915. */
  57916. register(): void;
  57917. /**
  57918. * Rebuilds the elements related to this component in case of
  57919. * context lost for instance.
  57920. */
  57921. rebuild(): void;
  57922. /**
  57923. * Disposes the component and the associated ressources.
  57924. */
  57925. dispose(): void;
  57926. private _draw;
  57927. private _drawCameraPredicate;
  57928. private _drawCameraBackground;
  57929. private _drawCameraForeground;
  57930. private _drawRenderTargetPredicate;
  57931. private _drawRenderTargetBackground;
  57932. private _drawRenderTargetForeground;
  57933. /**
  57934. * Adds all the elements from the container to the scene
  57935. * @param container the container holding the elements
  57936. */
  57937. addFromContainer(container: AbstractScene): void;
  57938. /**
  57939. * Removes all the elements in the container from the scene
  57940. * @param container contains the elements to remove
  57941. * @param dispose if the removed element should be disposed (default: false)
  57942. */
  57943. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57944. }
  57945. }
  57946. declare module BABYLON {
  57947. /** @hidden */
  57948. export var layerPixelShader: {
  57949. name: string;
  57950. shader: string;
  57951. };
  57952. }
  57953. declare module BABYLON {
  57954. /** @hidden */
  57955. export var layerVertexShader: {
  57956. name: string;
  57957. shader: string;
  57958. };
  57959. }
  57960. declare module BABYLON {
  57961. /**
  57962. * This represents a full screen 2d layer.
  57963. * This can be useful to display a picture in the background of your scene for instance.
  57964. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57965. */
  57966. export class Layer {
  57967. /**
  57968. * Define the name of the layer.
  57969. */
  57970. name: string;
  57971. /**
  57972. * Define the texture the layer should display.
  57973. */
  57974. texture: Nullable<Texture>;
  57975. /**
  57976. * Is the layer in background or foreground.
  57977. */
  57978. isBackground: boolean;
  57979. /**
  57980. * Define the color of the layer (instead of texture).
  57981. */
  57982. color: Color4;
  57983. /**
  57984. * Define the scale of the layer in order to zoom in out of the texture.
  57985. */
  57986. scale: Vector2;
  57987. /**
  57988. * Define an offset for the layer in order to shift the texture.
  57989. */
  57990. offset: Vector2;
  57991. /**
  57992. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57993. */
  57994. alphaBlendingMode: number;
  57995. /**
  57996. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57997. * Alpha test will not mix with the background color in case of transparency.
  57998. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57999. */
  58000. alphaTest: boolean;
  58001. /**
  58002. * Define a mask to restrict the layer to only some of the scene cameras.
  58003. */
  58004. layerMask: number;
  58005. /**
  58006. * Define the list of render target the layer is visible into.
  58007. */
  58008. renderTargetTextures: RenderTargetTexture[];
  58009. /**
  58010. * Define if the layer is only used in renderTarget or if it also
  58011. * renders in the main frame buffer of the canvas.
  58012. */
  58013. renderOnlyInRenderTargetTextures: boolean;
  58014. private _scene;
  58015. private _vertexBuffers;
  58016. private _indexBuffer;
  58017. private _effect;
  58018. private _previousDefines;
  58019. /**
  58020. * An event triggered when the layer is disposed.
  58021. */
  58022. onDisposeObservable: Observable<Layer>;
  58023. private _onDisposeObserver;
  58024. /**
  58025. * Back compatibility with callback before the onDisposeObservable existed.
  58026. * The set callback will be triggered when the layer has been disposed.
  58027. */
  58028. set onDispose(callback: () => void);
  58029. /**
  58030. * An event triggered before rendering the scene
  58031. */
  58032. onBeforeRenderObservable: Observable<Layer>;
  58033. private _onBeforeRenderObserver;
  58034. /**
  58035. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58036. * The set callback will be triggered just before rendering the layer.
  58037. */
  58038. set onBeforeRender(callback: () => void);
  58039. /**
  58040. * An event triggered after rendering the scene
  58041. */
  58042. onAfterRenderObservable: Observable<Layer>;
  58043. private _onAfterRenderObserver;
  58044. /**
  58045. * Back compatibility with callback before the onAfterRenderObservable existed.
  58046. * The set callback will be triggered just after rendering the layer.
  58047. */
  58048. set onAfterRender(callback: () => void);
  58049. /**
  58050. * Instantiates a new layer.
  58051. * This represents a full screen 2d layer.
  58052. * This can be useful to display a picture in the background of your scene for instance.
  58053. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58054. * @param name Define the name of the layer in the scene
  58055. * @param imgUrl Define the url of the texture to display in the layer
  58056. * @param scene Define the scene the layer belongs to
  58057. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58058. * @param color Defines a color for the layer
  58059. */
  58060. constructor(
  58061. /**
  58062. * Define the name of the layer.
  58063. */
  58064. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58065. private _createIndexBuffer;
  58066. /** @hidden */
  58067. _rebuild(): void;
  58068. /**
  58069. * Renders the layer in the scene.
  58070. */
  58071. render(): void;
  58072. /**
  58073. * Disposes and releases the associated ressources.
  58074. */
  58075. dispose(): void;
  58076. }
  58077. }
  58078. declare module BABYLON {
  58079. /** @hidden */
  58080. export var lensFlarePixelShader: {
  58081. name: string;
  58082. shader: string;
  58083. };
  58084. }
  58085. declare module BABYLON {
  58086. /** @hidden */
  58087. export var lensFlareVertexShader: {
  58088. name: string;
  58089. shader: string;
  58090. };
  58091. }
  58092. declare module BABYLON {
  58093. /**
  58094. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58095. * It is usually composed of several `lensFlare`.
  58096. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58097. */
  58098. export class LensFlareSystem {
  58099. /**
  58100. * Define the name of the lens flare system
  58101. */
  58102. name: string;
  58103. /**
  58104. * List of lens flares used in this system.
  58105. */
  58106. lensFlares: LensFlare[];
  58107. /**
  58108. * Define a limit from the border the lens flare can be visible.
  58109. */
  58110. borderLimit: number;
  58111. /**
  58112. * Define a viewport border we do not want to see the lens flare in.
  58113. */
  58114. viewportBorder: number;
  58115. /**
  58116. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58117. */
  58118. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58119. /**
  58120. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58121. */
  58122. layerMask: number;
  58123. /**
  58124. * Define the id of the lens flare system in the scene.
  58125. * (equal to name by default)
  58126. */
  58127. id: string;
  58128. private _scene;
  58129. private _emitter;
  58130. private _vertexBuffers;
  58131. private _indexBuffer;
  58132. private _effect;
  58133. private _positionX;
  58134. private _positionY;
  58135. private _isEnabled;
  58136. /** @hidden */
  58137. static _SceneComponentInitialization: (scene: Scene) => void;
  58138. /**
  58139. * Instantiates a lens flare system.
  58140. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58141. * It is usually composed of several `lensFlare`.
  58142. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58143. * @param name Define the name of the lens flare system in the scene
  58144. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58145. * @param scene Define the scene the lens flare system belongs to
  58146. */
  58147. constructor(
  58148. /**
  58149. * Define the name of the lens flare system
  58150. */
  58151. name: string, emitter: any, scene: Scene);
  58152. /**
  58153. * Define if the lens flare system is enabled.
  58154. */
  58155. get isEnabled(): boolean;
  58156. set isEnabled(value: boolean);
  58157. /**
  58158. * Get the scene the effects belongs to.
  58159. * @returns the scene holding the lens flare system
  58160. */
  58161. getScene(): Scene;
  58162. /**
  58163. * Get the emitter of the lens flare system.
  58164. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58165. * @returns the emitter of the lens flare system
  58166. */
  58167. getEmitter(): any;
  58168. /**
  58169. * Set the emitter of the lens flare system.
  58170. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58171. * @param newEmitter Define the new emitter of the system
  58172. */
  58173. setEmitter(newEmitter: any): void;
  58174. /**
  58175. * Get the lens flare system emitter position.
  58176. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58177. * @returns the position
  58178. */
  58179. getEmitterPosition(): Vector3;
  58180. /**
  58181. * @hidden
  58182. */
  58183. computeEffectivePosition(globalViewport: Viewport): boolean;
  58184. /** @hidden */
  58185. _isVisible(): boolean;
  58186. /**
  58187. * @hidden
  58188. */
  58189. render(): boolean;
  58190. /**
  58191. * Dispose and release the lens flare with its associated resources.
  58192. */
  58193. dispose(): void;
  58194. /**
  58195. * Parse a lens flare system from a JSON repressentation
  58196. * @param parsedLensFlareSystem Define the JSON to parse
  58197. * @param scene Define the scene the parsed system should be instantiated in
  58198. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58199. * @returns the parsed system
  58200. */
  58201. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58202. /**
  58203. * Serialize the current Lens Flare System into a JSON representation.
  58204. * @returns the serialized JSON
  58205. */
  58206. serialize(): any;
  58207. }
  58208. }
  58209. declare module BABYLON {
  58210. /**
  58211. * This represents one of the lens effect in a `lensFlareSystem`.
  58212. * It controls one of the indiviual texture used in the effect.
  58213. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58214. */
  58215. export class LensFlare {
  58216. /**
  58217. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58218. */
  58219. size: number;
  58220. /**
  58221. * 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.
  58222. */
  58223. position: number;
  58224. /**
  58225. * Define the lens color.
  58226. */
  58227. color: Color3;
  58228. /**
  58229. * Define the lens texture.
  58230. */
  58231. texture: Nullable<Texture>;
  58232. /**
  58233. * Define the alpha mode to render this particular lens.
  58234. */
  58235. alphaMode: number;
  58236. private _system;
  58237. /**
  58238. * Creates a new Lens Flare.
  58239. * This represents one of the lens effect in a `lensFlareSystem`.
  58240. * It controls one of the indiviual texture used in the effect.
  58241. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58242. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58243. * @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.
  58244. * @param color Define the lens color
  58245. * @param imgUrl Define the lens texture url
  58246. * @param system Define the `lensFlareSystem` this flare is part of
  58247. * @returns The newly created Lens Flare
  58248. */
  58249. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58250. /**
  58251. * Instantiates a new Lens Flare.
  58252. * This represents one of the lens effect in a `lensFlareSystem`.
  58253. * It controls one of the indiviual texture used in the effect.
  58254. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58255. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58256. * @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.
  58257. * @param color Define the lens color
  58258. * @param imgUrl Define the lens texture url
  58259. * @param system Define the `lensFlareSystem` this flare is part of
  58260. */
  58261. constructor(
  58262. /**
  58263. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58264. */
  58265. size: number,
  58266. /**
  58267. * 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.
  58268. */
  58269. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58270. /**
  58271. * Dispose and release the lens flare with its associated resources.
  58272. */
  58273. dispose(): void;
  58274. }
  58275. }
  58276. declare module BABYLON {
  58277. interface AbstractScene {
  58278. /**
  58279. * The list of lens flare system added to the scene
  58280. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58281. */
  58282. lensFlareSystems: Array<LensFlareSystem>;
  58283. /**
  58284. * Removes the given lens flare system from this scene.
  58285. * @param toRemove The lens flare system to remove
  58286. * @returns The index of the removed lens flare system
  58287. */
  58288. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58289. /**
  58290. * Adds the given lens flare system to this scene
  58291. * @param newLensFlareSystem The lens flare system to add
  58292. */
  58293. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58294. /**
  58295. * Gets a lens flare system using its name
  58296. * @param name defines the name to look for
  58297. * @returns the lens flare system or null if not found
  58298. */
  58299. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58300. /**
  58301. * Gets a lens flare system using its id
  58302. * @param id defines the id to look for
  58303. * @returns the lens flare system or null if not found
  58304. */
  58305. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58306. }
  58307. /**
  58308. * Defines the lens flare scene component responsible to manage any lens flares
  58309. * in a given scene.
  58310. */
  58311. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58312. /**
  58313. * The component name helpfull to identify the component in the list of scene components.
  58314. */
  58315. readonly name: string;
  58316. /**
  58317. * The scene the component belongs to.
  58318. */
  58319. scene: Scene;
  58320. /**
  58321. * Creates a new instance of the component for the given scene
  58322. * @param scene Defines the scene to register the component in
  58323. */
  58324. constructor(scene: Scene);
  58325. /**
  58326. * Registers the component in a given scene
  58327. */
  58328. register(): void;
  58329. /**
  58330. * Rebuilds the elements related to this component in case of
  58331. * context lost for instance.
  58332. */
  58333. rebuild(): void;
  58334. /**
  58335. * Adds all the elements from the container to the scene
  58336. * @param container the container holding the elements
  58337. */
  58338. addFromContainer(container: AbstractScene): void;
  58339. /**
  58340. * Removes all the elements in the container from the scene
  58341. * @param container contains the elements to remove
  58342. * @param dispose if the removed element should be disposed (default: false)
  58343. */
  58344. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58345. /**
  58346. * Serializes the component data to the specified json object
  58347. * @param serializationObject The object to serialize to
  58348. */
  58349. serialize(serializationObject: any): void;
  58350. /**
  58351. * Disposes the component and the associated ressources.
  58352. */
  58353. dispose(): void;
  58354. private _draw;
  58355. }
  58356. }
  58357. declare module BABYLON {
  58358. /** @hidden */
  58359. export var depthPixelShader: {
  58360. name: string;
  58361. shader: string;
  58362. };
  58363. }
  58364. declare module BABYLON {
  58365. /** @hidden */
  58366. export var depthVertexShader: {
  58367. name: string;
  58368. shader: string;
  58369. };
  58370. }
  58371. declare module BABYLON {
  58372. /**
  58373. * This represents a depth renderer in Babylon.
  58374. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58375. */
  58376. export class DepthRenderer {
  58377. private _scene;
  58378. private _depthMap;
  58379. private _effect;
  58380. private readonly _storeNonLinearDepth;
  58381. private readonly _clearColor;
  58382. /** Get if the depth renderer is using packed depth or not */
  58383. readonly isPacked: boolean;
  58384. private _cachedDefines;
  58385. private _camera;
  58386. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58387. enabled: boolean;
  58388. /**
  58389. * Specifiess that the depth renderer will only be used within
  58390. * the camera it is created for.
  58391. * This can help forcing its rendering during the camera processing.
  58392. */
  58393. useOnlyInActiveCamera: boolean;
  58394. /** @hidden */
  58395. static _SceneComponentInitialization: (scene: Scene) => void;
  58396. /**
  58397. * Instantiates a depth renderer
  58398. * @param scene The scene the renderer belongs to
  58399. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58400. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58401. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58402. */
  58403. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58404. /**
  58405. * Creates the depth rendering effect and checks if the effect is ready.
  58406. * @param subMesh The submesh to be used to render the depth map of
  58407. * @param useInstances If multiple world instances should be used
  58408. * @returns if the depth renderer is ready to render the depth map
  58409. */
  58410. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58411. /**
  58412. * Gets the texture which the depth map will be written to.
  58413. * @returns The depth map texture
  58414. */
  58415. getDepthMap(): RenderTargetTexture;
  58416. /**
  58417. * Disposes of the depth renderer.
  58418. */
  58419. dispose(): void;
  58420. }
  58421. }
  58422. declare module BABYLON {
  58423. /** @hidden */
  58424. export var minmaxReduxPixelShader: {
  58425. name: string;
  58426. shader: string;
  58427. };
  58428. }
  58429. declare module BABYLON {
  58430. /**
  58431. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58432. * and maximum values from all values of the texture.
  58433. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58434. * The source values are read from the red channel of the texture.
  58435. */
  58436. export class MinMaxReducer {
  58437. /**
  58438. * Observable triggered when the computation has been performed
  58439. */
  58440. onAfterReductionPerformed: Observable<{
  58441. min: number;
  58442. max: number;
  58443. }>;
  58444. protected _camera: Camera;
  58445. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58446. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58447. protected _postProcessManager: PostProcessManager;
  58448. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58449. protected _forceFullscreenViewport: boolean;
  58450. /**
  58451. * Creates a min/max reducer
  58452. * @param camera The camera to use for the post processes
  58453. */
  58454. constructor(camera: Camera);
  58455. /**
  58456. * Gets the texture used to read the values from.
  58457. */
  58458. get sourceTexture(): Nullable<RenderTargetTexture>;
  58459. /**
  58460. * Sets the source texture to read the values from.
  58461. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58462. * because in such textures '1' value must not be taken into account to compute the maximum
  58463. * as this value is used to clear the texture.
  58464. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58465. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58466. * @param depthRedux Indicates if the texture is a depth texture or not
  58467. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58468. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58469. */
  58470. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58471. /**
  58472. * Defines the refresh rate of the computation.
  58473. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58474. */
  58475. get refreshRate(): number;
  58476. set refreshRate(value: number);
  58477. protected _activated: boolean;
  58478. /**
  58479. * Gets the activation status of the reducer
  58480. */
  58481. get activated(): boolean;
  58482. /**
  58483. * Activates the reduction computation.
  58484. * When activated, the observers registered in onAfterReductionPerformed are
  58485. * called after the compuation is performed
  58486. */
  58487. activate(): void;
  58488. /**
  58489. * Deactivates the reduction computation.
  58490. */
  58491. deactivate(): void;
  58492. /**
  58493. * Disposes the min/max reducer
  58494. * @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.
  58495. */
  58496. dispose(disposeAll?: boolean): void;
  58497. }
  58498. }
  58499. declare module BABYLON {
  58500. /**
  58501. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58502. */
  58503. export class DepthReducer extends MinMaxReducer {
  58504. private _depthRenderer;
  58505. private _depthRendererId;
  58506. /**
  58507. * Gets the depth renderer used for the computation.
  58508. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58509. */
  58510. get depthRenderer(): Nullable<DepthRenderer>;
  58511. /**
  58512. * Creates a depth reducer
  58513. * @param camera The camera used to render the depth texture
  58514. */
  58515. constructor(camera: Camera);
  58516. /**
  58517. * Sets the depth renderer to use to generate the depth map
  58518. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58519. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58520. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58521. */
  58522. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58523. /** @hidden */
  58524. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58525. /**
  58526. * Activates the reduction computation.
  58527. * When activated, the observers registered in onAfterReductionPerformed are
  58528. * called after the compuation is performed
  58529. */
  58530. activate(): void;
  58531. /**
  58532. * Deactivates the reduction computation.
  58533. */
  58534. deactivate(): void;
  58535. /**
  58536. * Disposes the depth reducer
  58537. * @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.
  58538. */
  58539. dispose(disposeAll?: boolean): void;
  58540. }
  58541. }
  58542. declare module BABYLON {
  58543. /**
  58544. * A CSM implementation allowing casting shadows on large scenes.
  58545. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58546. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58547. */
  58548. export class CascadedShadowGenerator extends ShadowGenerator {
  58549. private static readonly frustumCornersNDCSpace;
  58550. /**
  58551. * Name of the CSM class
  58552. */
  58553. static CLASSNAME: string;
  58554. /**
  58555. * Defines the default number of cascades used by the CSM.
  58556. */
  58557. static readonly DEFAULT_CASCADES_COUNT: number;
  58558. /**
  58559. * Defines the minimum number of cascades used by the CSM.
  58560. */
  58561. static readonly MIN_CASCADES_COUNT: number;
  58562. /**
  58563. * Defines the maximum number of cascades used by the CSM.
  58564. */
  58565. static readonly MAX_CASCADES_COUNT: number;
  58566. protected _validateFilter(filter: number): number;
  58567. /**
  58568. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58569. */
  58570. penumbraDarkness: number;
  58571. private _numCascades;
  58572. /**
  58573. * Gets or set the number of cascades used by the CSM.
  58574. */
  58575. get numCascades(): number;
  58576. set numCascades(value: number);
  58577. /**
  58578. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58579. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58580. */
  58581. stabilizeCascades: boolean;
  58582. private _freezeShadowCastersBoundingInfo;
  58583. private _freezeShadowCastersBoundingInfoObservable;
  58584. /**
  58585. * Enables or disables the shadow casters bounding info computation.
  58586. * If your shadow casters don't move, you can disable this feature.
  58587. * If it is enabled, the bounding box computation is done every frame.
  58588. */
  58589. get freezeShadowCastersBoundingInfo(): boolean;
  58590. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58591. private _scbiMin;
  58592. private _scbiMax;
  58593. protected _computeShadowCastersBoundingInfo(): void;
  58594. protected _shadowCastersBoundingInfo: BoundingInfo;
  58595. /**
  58596. * Gets or sets the shadow casters bounding info.
  58597. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58598. * so that the system won't overwrite the bounds you provide
  58599. */
  58600. get shadowCastersBoundingInfo(): BoundingInfo;
  58601. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58602. protected _breaksAreDirty: boolean;
  58603. protected _minDistance: number;
  58604. protected _maxDistance: number;
  58605. /**
  58606. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58607. *
  58608. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58609. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58610. * @param min minimal distance for the breaks (default to 0.)
  58611. * @param max maximal distance for the breaks (default to 1.)
  58612. */
  58613. setMinMaxDistance(min: number, max: number): void;
  58614. /** Gets the minimal distance used in the cascade break computation */
  58615. get minDistance(): number;
  58616. /** Gets the maximal distance used in the cascade break computation */
  58617. get maxDistance(): number;
  58618. /**
  58619. * Gets the class name of that object
  58620. * @returns "CascadedShadowGenerator"
  58621. */
  58622. getClassName(): string;
  58623. private _cascadeMinExtents;
  58624. private _cascadeMaxExtents;
  58625. /**
  58626. * Gets a cascade minimum extents
  58627. * @param cascadeIndex index of the cascade
  58628. * @returns the minimum cascade extents
  58629. */
  58630. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58631. /**
  58632. * Gets a cascade maximum extents
  58633. * @param cascadeIndex index of the cascade
  58634. * @returns the maximum cascade extents
  58635. */
  58636. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58637. private _cascades;
  58638. private _currentLayer;
  58639. private _viewSpaceFrustumsZ;
  58640. private _viewMatrices;
  58641. private _projectionMatrices;
  58642. private _transformMatrices;
  58643. private _transformMatricesAsArray;
  58644. private _frustumLengths;
  58645. private _lightSizeUVCorrection;
  58646. private _depthCorrection;
  58647. private _frustumCornersWorldSpace;
  58648. private _frustumCenter;
  58649. private _shadowCameraPos;
  58650. private _shadowMaxZ;
  58651. /**
  58652. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58653. * It defaults to camera.maxZ
  58654. */
  58655. get shadowMaxZ(): number;
  58656. /**
  58657. * Sets the shadow max z distance.
  58658. */
  58659. set shadowMaxZ(value: number);
  58660. protected _debug: boolean;
  58661. /**
  58662. * Gets or sets the debug flag.
  58663. * When enabled, the cascades are materialized by different colors on the screen.
  58664. */
  58665. get debug(): boolean;
  58666. set debug(dbg: boolean);
  58667. private _depthClamp;
  58668. /**
  58669. * Gets or sets the depth clamping value.
  58670. *
  58671. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58672. * to account for the shadow casters far away.
  58673. *
  58674. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58675. */
  58676. get depthClamp(): boolean;
  58677. set depthClamp(value: boolean);
  58678. private _cascadeBlendPercentage;
  58679. /**
  58680. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58681. * It defaults to 0.1 (10% blending).
  58682. */
  58683. get cascadeBlendPercentage(): number;
  58684. set cascadeBlendPercentage(value: number);
  58685. private _lambda;
  58686. /**
  58687. * Gets or set the lambda parameter.
  58688. * This parameter is used to split the camera frustum and create the cascades.
  58689. * 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.
  58690. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58691. */
  58692. get lambda(): number;
  58693. set lambda(value: number);
  58694. /**
  58695. * Gets the view matrix corresponding to a given cascade
  58696. * @param cascadeNum cascade to retrieve the view matrix from
  58697. * @returns the cascade view matrix
  58698. */
  58699. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58700. /**
  58701. * Gets the projection matrix corresponding to a given cascade
  58702. * @param cascadeNum cascade to retrieve the projection matrix from
  58703. * @returns the cascade projection matrix
  58704. */
  58705. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58706. /**
  58707. * Gets the transformation matrix corresponding to a given cascade
  58708. * @param cascadeNum cascade to retrieve the transformation matrix from
  58709. * @returns the cascade transformation matrix
  58710. */
  58711. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58712. private _depthRenderer;
  58713. /**
  58714. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58715. *
  58716. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58717. *
  58718. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58719. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58720. * @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
  58721. */
  58722. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58723. private _depthReducer;
  58724. private _autoCalcDepthBounds;
  58725. /**
  58726. * Gets or sets the autoCalcDepthBounds property.
  58727. *
  58728. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58729. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58730. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58731. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58732. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58733. */
  58734. get autoCalcDepthBounds(): boolean;
  58735. set autoCalcDepthBounds(value: boolean);
  58736. /**
  58737. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58738. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58739. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58740. * for setting the refresh rate on the renderer yourself!
  58741. */
  58742. get autoCalcDepthBoundsRefreshRate(): number;
  58743. set autoCalcDepthBoundsRefreshRate(value: number);
  58744. /**
  58745. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58746. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58747. * you change the camera near/far planes!
  58748. */
  58749. splitFrustum(): void;
  58750. private _splitFrustum;
  58751. private _computeMatrices;
  58752. private _computeFrustumInWorldSpace;
  58753. private _computeCascadeFrustum;
  58754. /**
  58755. * Support test.
  58756. */
  58757. static get IsSupported(): boolean;
  58758. /** @hidden */
  58759. static _SceneComponentInitialization: (scene: Scene) => void;
  58760. /**
  58761. * Creates a Cascaded Shadow Generator object.
  58762. * A ShadowGenerator is the required tool to use the shadows.
  58763. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58764. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58765. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58766. * @param light The directional light object generating the shadows.
  58767. * @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.
  58768. */
  58769. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58770. protected _initializeGenerator(): void;
  58771. protected _createTargetRenderTexture(): void;
  58772. protected _initializeShadowMap(): void;
  58773. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58774. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58775. /**
  58776. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58777. * @param defines Defines of the material we want to update
  58778. * @param lightIndex Index of the light in the enabled light list of the material
  58779. */
  58780. prepareDefines(defines: any, lightIndex: number): void;
  58781. /**
  58782. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58783. * defined in the generator but impacting the effect).
  58784. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58785. * @param effect The effect we are binfing the information for
  58786. */
  58787. bindShadowLight(lightIndex: string, effect: Effect): void;
  58788. /**
  58789. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58790. * (eq to view projection * shadow projection matrices)
  58791. * @returns The transform matrix used to create the shadow map
  58792. */
  58793. getTransformMatrix(): Matrix;
  58794. /**
  58795. * Disposes the ShadowGenerator.
  58796. * Returns nothing.
  58797. */
  58798. dispose(): void;
  58799. /**
  58800. * Serializes the shadow generator setup to a json object.
  58801. * @returns The serialized JSON object
  58802. */
  58803. serialize(): any;
  58804. /**
  58805. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58806. * @param parsedShadowGenerator The JSON object to parse
  58807. * @param scene The scene to create the shadow map for
  58808. * @returns The parsed shadow generator
  58809. */
  58810. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58811. }
  58812. }
  58813. declare module BABYLON {
  58814. /**
  58815. * Defines the shadow generator component responsible to manage any shadow generators
  58816. * in a given scene.
  58817. */
  58818. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58819. /**
  58820. * The component name helpfull to identify the component in the list of scene components.
  58821. */
  58822. readonly name: string;
  58823. /**
  58824. * The scene the component belongs to.
  58825. */
  58826. scene: Scene;
  58827. /**
  58828. * Creates a new instance of the component for the given scene
  58829. * @param scene Defines the scene to register the component in
  58830. */
  58831. constructor(scene: Scene);
  58832. /**
  58833. * Registers the component in a given scene
  58834. */
  58835. register(): void;
  58836. /**
  58837. * Rebuilds the elements related to this component in case of
  58838. * context lost for instance.
  58839. */
  58840. rebuild(): void;
  58841. /**
  58842. * Serializes the component data to the specified json object
  58843. * @param serializationObject The object to serialize to
  58844. */
  58845. serialize(serializationObject: any): void;
  58846. /**
  58847. * Adds all the elements from the container to the scene
  58848. * @param container the container holding the elements
  58849. */
  58850. addFromContainer(container: AbstractScene): void;
  58851. /**
  58852. * Removes all the elements in the container from the scene
  58853. * @param container contains the elements to remove
  58854. * @param dispose if the removed element should be disposed (default: false)
  58855. */
  58856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58857. /**
  58858. * Rebuilds the elements related to this component in case of
  58859. * context lost for instance.
  58860. */
  58861. dispose(): void;
  58862. private _gatherRenderTargets;
  58863. }
  58864. }
  58865. declare module BABYLON {
  58866. /**
  58867. * A point light is a light defined by an unique point in world space.
  58868. * The light is emitted in every direction from this point.
  58869. * A good example of a point light is a standard light bulb.
  58870. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58871. */
  58872. export class PointLight extends ShadowLight {
  58873. private _shadowAngle;
  58874. /**
  58875. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58876. * This specifies what angle the shadow will use to be created.
  58877. *
  58878. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58879. */
  58880. get shadowAngle(): number;
  58881. /**
  58882. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58883. * This specifies what angle the shadow will use to be created.
  58884. *
  58885. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58886. */
  58887. set shadowAngle(value: number);
  58888. /**
  58889. * Gets the direction if it has been set.
  58890. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58891. */
  58892. get direction(): Vector3;
  58893. /**
  58894. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58895. */
  58896. set direction(value: Vector3);
  58897. /**
  58898. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58899. * A PointLight emits the light in every direction.
  58900. * It can cast shadows.
  58901. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58902. * ```javascript
  58903. * var pointLight = new PointLight("pl", camera.position, scene);
  58904. * ```
  58905. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58906. * @param name The light friendly name
  58907. * @param position The position of the point light in the scene
  58908. * @param scene The scene the lights belongs to
  58909. */
  58910. constructor(name: string, position: Vector3, scene: Scene);
  58911. /**
  58912. * Returns the string "PointLight"
  58913. * @returns the class name
  58914. */
  58915. getClassName(): string;
  58916. /**
  58917. * Returns the integer 0.
  58918. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58919. */
  58920. getTypeID(): number;
  58921. /**
  58922. * Specifies wether or not the shadowmap should be a cube texture.
  58923. * @returns true if the shadowmap needs to be a cube texture.
  58924. */
  58925. needCube(): boolean;
  58926. /**
  58927. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58928. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58929. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58930. */
  58931. getShadowDirection(faceIndex?: number): Vector3;
  58932. /**
  58933. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58934. * - fov = PI / 2
  58935. * - aspect ratio : 1.0
  58936. * - z-near and far equal to the active camera minZ and maxZ.
  58937. * Returns the PointLight.
  58938. */
  58939. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58940. protected _buildUniformLayout(): void;
  58941. /**
  58942. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58943. * @param effect The effect to update
  58944. * @param lightIndex The index of the light in the effect to update
  58945. * @returns The point light
  58946. */
  58947. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58948. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58949. /**
  58950. * Prepares the list of defines specific to the light type.
  58951. * @param defines the list of defines
  58952. * @param lightIndex defines the index of the light for the effect
  58953. */
  58954. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58955. }
  58956. }
  58957. declare module BABYLON {
  58958. /**
  58959. * Header information of HDR texture files.
  58960. */
  58961. export interface HDRInfo {
  58962. /**
  58963. * The height of the texture in pixels.
  58964. */
  58965. height: number;
  58966. /**
  58967. * The width of the texture in pixels.
  58968. */
  58969. width: number;
  58970. /**
  58971. * The index of the beginning of the data in the binary file.
  58972. */
  58973. dataPosition: number;
  58974. }
  58975. /**
  58976. * This groups tools to convert HDR texture to native colors array.
  58977. */
  58978. export class HDRTools {
  58979. private static Ldexp;
  58980. private static Rgbe2float;
  58981. private static readStringLine;
  58982. /**
  58983. * Reads header information from an RGBE texture stored in a native array.
  58984. * More information on this format are available here:
  58985. * https://en.wikipedia.org/wiki/RGBE_image_format
  58986. *
  58987. * @param uint8array The binary file stored in native array.
  58988. * @return The header information.
  58989. */
  58990. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58991. /**
  58992. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58993. * This RGBE texture needs to store the information as a panorama.
  58994. *
  58995. * More information on this format are available here:
  58996. * https://en.wikipedia.org/wiki/RGBE_image_format
  58997. *
  58998. * @param buffer The binary file stored in an array buffer.
  58999. * @param size The expected size of the extracted cubemap.
  59000. * @return The Cube Map information.
  59001. */
  59002. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59003. /**
  59004. * Returns the pixels data extracted from an RGBE texture.
  59005. * This pixels will be stored left to right up to down in the R G B order in one array.
  59006. *
  59007. * More information on this format are available here:
  59008. * https://en.wikipedia.org/wiki/RGBE_image_format
  59009. *
  59010. * @param uint8array The binary file stored in an array buffer.
  59011. * @param hdrInfo The header information of the file.
  59012. * @return The pixels data in RGB right to left up to down order.
  59013. */
  59014. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59015. private static RGBE_ReadPixels_RLE;
  59016. }
  59017. }
  59018. declare module BABYLON {
  59019. /**
  59020. * Effect Render Options
  59021. */
  59022. export interface IEffectRendererOptions {
  59023. /**
  59024. * Defines the vertices positions.
  59025. */
  59026. positions?: number[];
  59027. /**
  59028. * Defines the indices.
  59029. */
  59030. indices?: number[];
  59031. }
  59032. /**
  59033. * Helper class to render one or more effects.
  59034. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59035. */
  59036. export class EffectRenderer {
  59037. private engine;
  59038. private static _DefaultOptions;
  59039. private _vertexBuffers;
  59040. private _indexBuffer;
  59041. private _fullscreenViewport;
  59042. /**
  59043. * Creates an effect renderer
  59044. * @param engine the engine to use for rendering
  59045. * @param options defines the options of the effect renderer
  59046. */
  59047. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59048. /**
  59049. * Sets the current viewport in normalized coordinates 0-1
  59050. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59051. */
  59052. setViewport(viewport?: Viewport): void;
  59053. /**
  59054. * Binds the embedded attributes buffer to the effect.
  59055. * @param effect Defines the effect to bind the attributes for
  59056. */
  59057. bindBuffers(effect: Effect): void;
  59058. /**
  59059. * Sets the current effect wrapper to use during draw.
  59060. * The effect needs to be ready before calling this api.
  59061. * This also sets the default full screen position attribute.
  59062. * @param effectWrapper Defines the effect to draw with
  59063. */
  59064. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59065. /**
  59066. * Restores engine states
  59067. */
  59068. restoreStates(): void;
  59069. /**
  59070. * Draws a full screen quad.
  59071. */
  59072. draw(): void;
  59073. private isRenderTargetTexture;
  59074. /**
  59075. * renders one or more effects to a specified texture
  59076. * @param effectWrapper the effect to renderer
  59077. * @param outputTexture texture to draw to, if null it will render to the screen.
  59078. */
  59079. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59080. /**
  59081. * Disposes of the effect renderer
  59082. */
  59083. dispose(): void;
  59084. }
  59085. /**
  59086. * Options to create an EffectWrapper
  59087. */
  59088. interface EffectWrapperCreationOptions {
  59089. /**
  59090. * Engine to use to create the effect
  59091. */
  59092. engine: ThinEngine;
  59093. /**
  59094. * Fragment shader for the effect
  59095. */
  59096. fragmentShader: string;
  59097. /**
  59098. * Use the shader store instead of direct source code
  59099. */
  59100. useShaderStore?: boolean;
  59101. /**
  59102. * Vertex shader for the effect
  59103. */
  59104. vertexShader?: string;
  59105. /**
  59106. * Attributes to use in the shader
  59107. */
  59108. attributeNames?: Array<string>;
  59109. /**
  59110. * Uniforms to use in the shader
  59111. */
  59112. uniformNames?: Array<string>;
  59113. /**
  59114. * Texture sampler names to use in the shader
  59115. */
  59116. samplerNames?: Array<string>;
  59117. /**
  59118. * Defines to use in the shader
  59119. */
  59120. defines?: Array<string>;
  59121. /**
  59122. * Callback when effect is compiled
  59123. */
  59124. onCompiled?: Nullable<(effect: Effect) => void>;
  59125. /**
  59126. * The friendly name of the effect displayed in Spector.
  59127. */
  59128. name?: string;
  59129. }
  59130. /**
  59131. * Wraps an effect to be used for rendering
  59132. */
  59133. export class EffectWrapper {
  59134. /**
  59135. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59136. */
  59137. onApplyObservable: Observable<{}>;
  59138. /**
  59139. * The underlying effect
  59140. */
  59141. effect: Effect;
  59142. /**
  59143. * Creates an effect to be renderer
  59144. * @param creationOptions options to create the effect
  59145. */
  59146. constructor(creationOptions: EffectWrapperCreationOptions);
  59147. /**
  59148. * Disposes of the effect wrapper
  59149. */
  59150. dispose(): void;
  59151. }
  59152. }
  59153. declare module BABYLON {
  59154. /** @hidden */
  59155. export var hdrFilteringVertexShader: {
  59156. name: string;
  59157. shader: string;
  59158. };
  59159. }
  59160. declare module BABYLON {
  59161. /** @hidden */
  59162. export var hdrFilteringPixelShader: {
  59163. name: string;
  59164. shader: string;
  59165. };
  59166. }
  59167. declare module BABYLON {
  59168. /**
  59169. * Options for texture filtering
  59170. */
  59171. interface IHDRFilteringOptions {
  59172. /**
  59173. * Scales pixel intensity for the input HDR map.
  59174. */
  59175. hdrScale?: number;
  59176. /**
  59177. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59178. */
  59179. quality?: number;
  59180. }
  59181. /**
  59182. * Filters HDR maps to get correct renderings of PBR reflections
  59183. */
  59184. export class HDRFiltering {
  59185. private _engine;
  59186. private _effectRenderer;
  59187. private _effectWrapper;
  59188. private _lodGenerationOffset;
  59189. private _lodGenerationScale;
  59190. /**
  59191. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59192. * you care about baking speed.
  59193. */
  59194. quality: number;
  59195. /**
  59196. * Scales pixel intensity for the input HDR map.
  59197. */
  59198. hdrScale: number;
  59199. /**
  59200. * Instantiates HDR filter for reflection maps
  59201. *
  59202. * @param engine Thin engine
  59203. * @param options Options
  59204. */
  59205. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59206. private _createRenderTarget;
  59207. private _prefilterInternal;
  59208. private _createEffect;
  59209. /**
  59210. * Get a value indicating if the filter is ready to be used
  59211. * @param texture Texture to filter
  59212. * @returns true if the filter is ready
  59213. */
  59214. isReady(texture: BaseTexture): boolean;
  59215. /**
  59216. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59217. * Prefiltering will be invoked at the end of next rendering pass.
  59218. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59219. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59220. * @param texture Texture to filter
  59221. * @param onFinished Callback when filtering is done
  59222. * @return Promise called when prefiltering is done
  59223. */
  59224. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59225. }
  59226. }
  59227. declare module BABYLON {
  59228. /**
  59229. * This represents a texture coming from an HDR input.
  59230. *
  59231. * The only supported format is currently panorama picture stored in RGBE format.
  59232. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59233. */
  59234. export class HDRCubeTexture extends BaseTexture {
  59235. private static _facesMapping;
  59236. private _generateHarmonics;
  59237. private _noMipmap;
  59238. private _prefilterOnLoad;
  59239. private _textureMatrix;
  59240. private _size;
  59241. private _onLoad;
  59242. private _onError;
  59243. /**
  59244. * The texture URL.
  59245. */
  59246. url: string;
  59247. /**
  59248. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59249. */
  59250. coordinatesMode: number;
  59251. protected _isBlocking: boolean;
  59252. /**
  59253. * Sets wether or not the texture is blocking during loading.
  59254. */
  59255. set isBlocking(value: boolean);
  59256. /**
  59257. * Gets wether or not the texture is blocking during loading.
  59258. */
  59259. get isBlocking(): boolean;
  59260. protected _rotationY: number;
  59261. /**
  59262. * Sets texture matrix rotation angle around Y axis in radians.
  59263. */
  59264. set rotationY(value: number);
  59265. /**
  59266. * Gets texture matrix rotation angle around Y axis radians.
  59267. */
  59268. get rotationY(): number;
  59269. /**
  59270. * Gets or sets the center of the bounding box associated with the cube texture
  59271. * It must define where the camera used to render the texture was set
  59272. */
  59273. boundingBoxPosition: Vector3;
  59274. private _boundingBoxSize;
  59275. /**
  59276. * Gets or sets the size of the bounding box associated with the cube texture
  59277. * When defined, the cubemap will switch to local mode
  59278. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59279. * @example https://www.babylonjs-playground.com/#RNASML
  59280. */
  59281. set boundingBoxSize(value: Vector3);
  59282. get boundingBoxSize(): Vector3;
  59283. /**
  59284. * Instantiates an HDRTexture from the following parameters.
  59285. *
  59286. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59287. * @param sceneOrEngine The scene or engine the texture will be used in
  59288. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59289. * @param noMipmap Forces to not generate the mipmap if true
  59290. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59291. * @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)
  59292. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59293. */
  59294. 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>);
  59295. /**
  59296. * Get the current class name of the texture useful for serialization or dynamic coding.
  59297. * @returns "HDRCubeTexture"
  59298. */
  59299. getClassName(): string;
  59300. /**
  59301. * Occurs when the file is raw .hdr file.
  59302. */
  59303. private loadTexture;
  59304. clone(): HDRCubeTexture;
  59305. delayLoad(): void;
  59306. /**
  59307. * Get the texture reflection matrix used to rotate/transform the reflection.
  59308. * @returns the reflection matrix
  59309. */
  59310. getReflectionTextureMatrix(): Matrix;
  59311. /**
  59312. * Set the texture reflection matrix used to rotate/transform the reflection.
  59313. * @param value Define the reflection matrix to set
  59314. */
  59315. setReflectionTextureMatrix(value: Matrix): void;
  59316. /**
  59317. * Parses a JSON representation of an HDR Texture in order to create the texture
  59318. * @param parsedTexture Define the JSON representation
  59319. * @param scene Define the scene the texture should be created in
  59320. * @param rootUrl Define the root url in case we need to load relative dependencies
  59321. * @returns the newly created texture after parsing
  59322. */
  59323. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59324. serialize(): any;
  59325. }
  59326. }
  59327. declare module BABYLON {
  59328. /**
  59329. * Class used to control physics engine
  59330. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59331. */
  59332. export class PhysicsEngine implements IPhysicsEngine {
  59333. private _physicsPlugin;
  59334. /**
  59335. * Global value used to control the smallest number supported by the simulation
  59336. */
  59337. static Epsilon: number;
  59338. private _impostors;
  59339. private _joints;
  59340. private _subTimeStep;
  59341. /**
  59342. * Gets the gravity vector used by the simulation
  59343. */
  59344. gravity: Vector3;
  59345. /**
  59346. * Factory used to create the default physics plugin.
  59347. * @returns The default physics plugin
  59348. */
  59349. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59350. /**
  59351. * Creates a new Physics Engine
  59352. * @param gravity defines the gravity vector used by the simulation
  59353. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59354. */
  59355. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59356. /**
  59357. * Sets the gravity vector used by the simulation
  59358. * @param gravity defines the gravity vector to use
  59359. */
  59360. setGravity(gravity: Vector3): void;
  59361. /**
  59362. * Set the time step of the physics engine.
  59363. * Default is 1/60.
  59364. * To slow it down, enter 1/600 for example.
  59365. * To speed it up, 1/30
  59366. * @param newTimeStep defines the new timestep to apply to this world.
  59367. */
  59368. setTimeStep(newTimeStep?: number): void;
  59369. /**
  59370. * Get the time step of the physics engine.
  59371. * @returns the current time step
  59372. */
  59373. getTimeStep(): number;
  59374. /**
  59375. * Set the sub time step of the physics engine.
  59376. * Default is 0 meaning there is no sub steps
  59377. * To increase physics resolution precision, set a small value (like 1 ms)
  59378. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59379. */
  59380. setSubTimeStep(subTimeStep?: number): void;
  59381. /**
  59382. * Get the sub time step of the physics engine.
  59383. * @returns the current sub time step
  59384. */
  59385. getSubTimeStep(): number;
  59386. /**
  59387. * Release all resources
  59388. */
  59389. dispose(): void;
  59390. /**
  59391. * Gets the name of the current physics plugin
  59392. * @returns the name of the plugin
  59393. */
  59394. getPhysicsPluginName(): string;
  59395. /**
  59396. * Adding a new impostor for the impostor tracking.
  59397. * This will be done by the impostor itself.
  59398. * @param impostor the impostor to add
  59399. */
  59400. addImpostor(impostor: PhysicsImpostor): void;
  59401. /**
  59402. * Remove an impostor from the engine.
  59403. * This impostor and its mesh will not longer be updated by the physics engine.
  59404. * @param impostor the impostor to remove
  59405. */
  59406. removeImpostor(impostor: PhysicsImpostor): void;
  59407. /**
  59408. * Add a joint to the physics engine
  59409. * @param mainImpostor defines the main impostor to which the joint is added.
  59410. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59411. * @param joint defines the joint that will connect both impostors.
  59412. */
  59413. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59414. /**
  59415. * Removes a joint from the simulation
  59416. * @param mainImpostor defines the impostor used with the joint
  59417. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59418. * @param joint defines the joint to remove
  59419. */
  59420. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59421. /**
  59422. * Called by the scene. No need to call it.
  59423. * @param delta defines the timespam between frames
  59424. */
  59425. _step(delta: number): void;
  59426. /**
  59427. * Gets the current plugin used to run the simulation
  59428. * @returns current plugin
  59429. */
  59430. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59431. /**
  59432. * Gets the list of physic impostors
  59433. * @returns an array of PhysicsImpostor
  59434. */
  59435. getImpostors(): Array<PhysicsImpostor>;
  59436. /**
  59437. * Gets the impostor for a physics enabled object
  59438. * @param object defines the object impersonated by the impostor
  59439. * @returns the PhysicsImpostor or null if not found
  59440. */
  59441. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59442. /**
  59443. * Gets the impostor for a physics body object
  59444. * @param body defines physics body used by the impostor
  59445. * @returns the PhysicsImpostor or null if not found
  59446. */
  59447. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59448. /**
  59449. * Does a raycast in the physics world
  59450. * @param from when should the ray start?
  59451. * @param to when should the ray end?
  59452. * @returns PhysicsRaycastResult
  59453. */
  59454. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59455. }
  59456. }
  59457. declare module BABYLON {
  59458. /** @hidden */
  59459. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59460. private _useDeltaForWorldStep;
  59461. world: any;
  59462. name: string;
  59463. private _physicsMaterials;
  59464. private _fixedTimeStep;
  59465. private _cannonRaycastResult;
  59466. private _raycastResult;
  59467. private _physicsBodysToRemoveAfterStep;
  59468. private _firstFrame;
  59469. BJSCANNON: any;
  59470. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59471. setGravity(gravity: Vector3): void;
  59472. setTimeStep(timeStep: number): void;
  59473. getTimeStep(): number;
  59474. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59475. private _removeMarkedPhysicsBodiesFromWorld;
  59476. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59477. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59478. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59479. private _processChildMeshes;
  59480. removePhysicsBody(impostor: PhysicsImpostor): void;
  59481. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59482. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59483. private _addMaterial;
  59484. private _checkWithEpsilon;
  59485. private _createShape;
  59486. private _createHeightmap;
  59487. private _minus90X;
  59488. private _plus90X;
  59489. private _tmpPosition;
  59490. private _tmpDeltaPosition;
  59491. private _tmpUnityRotation;
  59492. private _updatePhysicsBodyTransformation;
  59493. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59494. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59495. isSupported(): boolean;
  59496. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59497. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59498. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59499. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59500. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59501. getBodyMass(impostor: PhysicsImpostor): number;
  59502. getBodyFriction(impostor: PhysicsImpostor): number;
  59503. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59504. getBodyRestitution(impostor: PhysicsImpostor): number;
  59505. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59506. sleepBody(impostor: PhysicsImpostor): void;
  59507. wakeUpBody(impostor: PhysicsImpostor): void;
  59508. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59509. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59510. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59511. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59512. getRadius(impostor: PhysicsImpostor): number;
  59513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59514. dispose(): void;
  59515. private _extendNamespace;
  59516. /**
  59517. * Does a raycast in the physics world
  59518. * @param from when should the ray start?
  59519. * @param to when should the ray end?
  59520. * @returns PhysicsRaycastResult
  59521. */
  59522. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59523. }
  59524. }
  59525. declare module BABYLON {
  59526. /** @hidden */
  59527. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59528. private _useDeltaForWorldStep;
  59529. world: any;
  59530. name: string;
  59531. BJSOIMO: any;
  59532. private _raycastResult;
  59533. private _fixedTimeStep;
  59534. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59535. setGravity(gravity: Vector3): void;
  59536. setTimeStep(timeStep: number): void;
  59537. getTimeStep(): number;
  59538. private _tmpImpostorsArray;
  59539. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59540. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59541. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59542. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59543. private _tmpPositionVector;
  59544. removePhysicsBody(impostor: PhysicsImpostor): void;
  59545. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59546. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59547. isSupported(): boolean;
  59548. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59549. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59550. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59551. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59552. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59553. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59554. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59555. getBodyMass(impostor: PhysicsImpostor): number;
  59556. getBodyFriction(impostor: PhysicsImpostor): number;
  59557. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59558. getBodyRestitution(impostor: PhysicsImpostor): number;
  59559. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59560. sleepBody(impostor: PhysicsImpostor): void;
  59561. wakeUpBody(impostor: PhysicsImpostor): void;
  59562. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59563. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59564. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59565. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59566. getRadius(impostor: PhysicsImpostor): number;
  59567. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59568. dispose(): void;
  59569. /**
  59570. * Does a raycast in the physics world
  59571. * @param from when should the ray start?
  59572. * @param to when should the ray end?
  59573. * @returns PhysicsRaycastResult
  59574. */
  59575. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59576. }
  59577. }
  59578. declare module BABYLON {
  59579. /**
  59580. * Class containing static functions to help procedurally build meshes
  59581. */
  59582. export class RibbonBuilder {
  59583. /**
  59584. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59585. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59586. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59587. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59588. * * 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
  59589. * * 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
  59590. * * 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
  59591. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59592. * * 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
  59593. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59594. * * 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
  59595. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59596. * * 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
  59597. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59599. * @param name defines the name of the mesh
  59600. * @param options defines the options used to create the mesh
  59601. * @param scene defines the hosting scene
  59602. * @returns the ribbon mesh
  59603. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59604. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59605. */
  59606. static CreateRibbon(name: string, options: {
  59607. pathArray: Vector3[][];
  59608. closeArray?: boolean;
  59609. closePath?: boolean;
  59610. offset?: number;
  59611. updatable?: boolean;
  59612. sideOrientation?: number;
  59613. frontUVs?: Vector4;
  59614. backUVs?: Vector4;
  59615. instance?: Mesh;
  59616. invertUV?: boolean;
  59617. uvs?: Vector2[];
  59618. colors?: Color4[];
  59619. }, scene?: Nullable<Scene>): Mesh;
  59620. }
  59621. }
  59622. declare module BABYLON {
  59623. /**
  59624. * Class containing static functions to help procedurally build meshes
  59625. */
  59626. export class ShapeBuilder {
  59627. /**
  59628. * 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.
  59629. * * 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.
  59630. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59631. * * 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.
  59632. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59633. * * 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
  59634. * * 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
  59635. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59636. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59637. * * 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
  59638. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59640. * @param name defines the name of the mesh
  59641. * @param options defines the options used to create the mesh
  59642. * @param scene defines the hosting scene
  59643. * @returns the extruded shape mesh
  59644. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59646. */
  59647. static ExtrudeShape(name: string, options: {
  59648. shape: Vector3[];
  59649. path: Vector3[];
  59650. scale?: number;
  59651. rotation?: number;
  59652. cap?: number;
  59653. updatable?: boolean;
  59654. sideOrientation?: number;
  59655. frontUVs?: Vector4;
  59656. backUVs?: Vector4;
  59657. instance?: Mesh;
  59658. invertUV?: boolean;
  59659. }, scene?: Nullable<Scene>): Mesh;
  59660. /**
  59661. * Creates an custom extruded shape mesh.
  59662. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59663. * * 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.
  59664. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59665. * * 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
  59666. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59667. * * 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
  59668. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59669. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59670. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59671. * * 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
  59672. * * 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
  59673. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59675. * * 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
  59676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59678. * @param name defines the name of the mesh
  59679. * @param options defines the options used to create the mesh
  59680. * @param scene defines the hosting scene
  59681. * @returns the custom extruded shape mesh
  59682. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59683. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59685. */
  59686. static ExtrudeShapeCustom(name: string, options: {
  59687. shape: Vector3[];
  59688. path: Vector3[];
  59689. scaleFunction?: any;
  59690. rotationFunction?: any;
  59691. ribbonCloseArray?: boolean;
  59692. ribbonClosePath?: boolean;
  59693. cap?: number;
  59694. updatable?: boolean;
  59695. sideOrientation?: number;
  59696. frontUVs?: Vector4;
  59697. backUVs?: Vector4;
  59698. instance?: Mesh;
  59699. invertUV?: boolean;
  59700. }, scene?: Nullable<Scene>): Mesh;
  59701. private static _ExtrudeShapeGeneric;
  59702. }
  59703. }
  59704. declare module BABYLON {
  59705. /**
  59706. * AmmoJS Physics plugin
  59707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59708. * @see https://github.com/kripken/ammo.js/
  59709. */
  59710. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59711. private _useDeltaForWorldStep;
  59712. /**
  59713. * Reference to the Ammo library
  59714. */
  59715. bjsAMMO: any;
  59716. /**
  59717. * Created ammoJS world which physics bodies are added to
  59718. */
  59719. world: any;
  59720. /**
  59721. * Name of the plugin
  59722. */
  59723. name: string;
  59724. private _timeStep;
  59725. private _fixedTimeStep;
  59726. private _maxSteps;
  59727. private _tmpQuaternion;
  59728. private _tmpAmmoTransform;
  59729. private _tmpAmmoQuaternion;
  59730. private _tmpAmmoConcreteContactResultCallback;
  59731. private _collisionConfiguration;
  59732. private _dispatcher;
  59733. private _overlappingPairCache;
  59734. private _solver;
  59735. private _softBodySolver;
  59736. private _tmpAmmoVectorA;
  59737. private _tmpAmmoVectorB;
  59738. private _tmpAmmoVectorC;
  59739. private _tmpAmmoVectorD;
  59740. private _tmpContactCallbackResult;
  59741. private _tmpAmmoVectorRCA;
  59742. private _tmpAmmoVectorRCB;
  59743. private _raycastResult;
  59744. private static readonly DISABLE_COLLISION_FLAG;
  59745. private static readonly KINEMATIC_FLAG;
  59746. private static readonly DISABLE_DEACTIVATION_FLAG;
  59747. /**
  59748. * Initializes the ammoJS plugin
  59749. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59750. * @param ammoInjection can be used to inject your own ammo reference
  59751. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59752. */
  59753. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59754. /**
  59755. * Sets the gravity of the physics world (m/(s^2))
  59756. * @param gravity Gravity to set
  59757. */
  59758. setGravity(gravity: Vector3): void;
  59759. /**
  59760. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59761. * @param timeStep timestep to use in seconds
  59762. */
  59763. setTimeStep(timeStep: number): void;
  59764. /**
  59765. * 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)
  59766. * @param fixedTimeStep fixedTimeStep to use in seconds
  59767. */
  59768. setFixedTimeStep(fixedTimeStep: number): void;
  59769. /**
  59770. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59771. * @param maxSteps the maximum number of steps by the physics engine per frame
  59772. */
  59773. setMaxSteps(maxSteps: number): void;
  59774. /**
  59775. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59776. * @returns the current timestep in seconds
  59777. */
  59778. getTimeStep(): number;
  59779. /**
  59780. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59781. */
  59782. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59783. private _isImpostorInContact;
  59784. private _isImpostorPairInContact;
  59785. private _stepSimulation;
  59786. /**
  59787. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59788. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59789. * After the step the babylon meshes are set to the position of the physics imposters
  59790. * @param delta amount of time to step forward
  59791. * @param impostors array of imposters to update before/after the step
  59792. */
  59793. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59794. /**
  59795. * Update babylon mesh to match physics world object
  59796. * @param impostor imposter to match
  59797. */
  59798. private _afterSoftStep;
  59799. /**
  59800. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59801. * @param impostor imposter to match
  59802. */
  59803. private _ropeStep;
  59804. /**
  59805. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59806. * @param impostor imposter to match
  59807. */
  59808. private _softbodyOrClothStep;
  59809. private _tmpMatrix;
  59810. /**
  59811. * Applies an impulse on the imposter
  59812. * @param impostor imposter to apply impulse to
  59813. * @param force amount of force to be applied to the imposter
  59814. * @param contactPoint the location to apply the impulse on the imposter
  59815. */
  59816. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59817. /**
  59818. * Applies a force on the imposter
  59819. * @param impostor imposter to apply force
  59820. * @param force amount of force to be applied to the imposter
  59821. * @param contactPoint the location to apply the force on the imposter
  59822. */
  59823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59824. /**
  59825. * Creates a physics body using the plugin
  59826. * @param impostor the imposter to create the physics body on
  59827. */
  59828. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59829. /**
  59830. * Removes the physics body from the imposter and disposes of the body's memory
  59831. * @param impostor imposter to remove the physics body from
  59832. */
  59833. removePhysicsBody(impostor: PhysicsImpostor): void;
  59834. /**
  59835. * Generates a joint
  59836. * @param impostorJoint the imposter joint to create the joint with
  59837. */
  59838. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59839. /**
  59840. * Removes a joint
  59841. * @param impostorJoint the imposter joint to remove the joint from
  59842. */
  59843. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59844. private _addMeshVerts;
  59845. /**
  59846. * Initialise the soft body vertices to match its object's (mesh) vertices
  59847. * Softbody vertices (nodes) are in world space and to match this
  59848. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59849. * @param impostor to create the softbody for
  59850. */
  59851. private _softVertexData;
  59852. /**
  59853. * Create an impostor's soft body
  59854. * @param impostor to create the softbody for
  59855. */
  59856. private _createSoftbody;
  59857. /**
  59858. * Create cloth for an impostor
  59859. * @param impostor to create the softbody for
  59860. */
  59861. private _createCloth;
  59862. /**
  59863. * Create rope for an impostor
  59864. * @param impostor to create the softbody for
  59865. */
  59866. private _createRope;
  59867. /**
  59868. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59869. * @param impostor to create the custom physics shape for
  59870. */
  59871. private _createCustom;
  59872. private _addHullVerts;
  59873. private _createShape;
  59874. /**
  59875. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59876. * @param impostor imposter containing the physics body and babylon object
  59877. */
  59878. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59879. /**
  59880. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59881. * @param impostor imposter containing the physics body and babylon object
  59882. * @param newPosition new position
  59883. * @param newRotation new rotation
  59884. */
  59885. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59886. /**
  59887. * If this plugin is supported
  59888. * @returns true if its supported
  59889. */
  59890. isSupported(): boolean;
  59891. /**
  59892. * Sets the linear velocity of the physics body
  59893. * @param impostor imposter to set the velocity on
  59894. * @param velocity velocity to set
  59895. */
  59896. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59897. /**
  59898. * Sets the angular velocity of the physics body
  59899. * @param impostor imposter to set the velocity on
  59900. * @param velocity velocity to set
  59901. */
  59902. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59903. /**
  59904. * gets the linear velocity
  59905. * @param impostor imposter to get linear velocity from
  59906. * @returns linear velocity
  59907. */
  59908. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59909. /**
  59910. * gets the angular velocity
  59911. * @param impostor imposter to get angular velocity from
  59912. * @returns angular velocity
  59913. */
  59914. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59915. /**
  59916. * Sets the mass of physics body
  59917. * @param impostor imposter to set the mass on
  59918. * @param mass mass to set
  59919. */
  59920. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59921. /**
  59922. * Gets the mass of the physics body
  59923. * @param impostor imposter to get the mass from
  59924. * @returns mass
  59925. */
  59926. getBodyMass(impostor: PhysicsImpostor): number;
  59927. /**
  59928. * Gets friction of the impostor
  59929. * @param impostor impostor to get friction from
  59930. * @returns friction value
  59931. */
  59932. getBodyFriction(impostor: PhysicsImpostor): number;
  59933. /**
  59934. * Sets friction of the impostor
  59935. * @param impostor impostor to set friction on
  59936. * @param friction friction value
  59937. */
  59938. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59939. /**
  59940. * Gets restitution of the impostor
  59941. * @param impostor impostor to get restitution from
  59942. * @returns restitution value
  59943. */
  59944. getBodyRestitution(impostor: PhysicsImpostor): number;
  59945. /**
  59946. * Sets resitution of the impostor
  59947. * @param impostor impostor to set resitution on
  59948. * @param restitution resitution value
  59949. */
  59950. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59951. /**
  59952. * Gets pressure inside the impostor
  59953. * @param impostor impostor to get pressure from
  59954. * @returns pressure value
  59955. */
  59956. getBodyPressure(impostor: PhysicsImpostor): number;
  59957. /**
  59958. * Sets pressure inside a soft body impostor
  59959. * Cloth and rope must remain 0 pressure
  59960. * @param impostor impostor to set pressure on
  59961. * @param pressure pressure value
  59962. */
  59963. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59964. /**
  59965. * Gets stiffness of the impostor
  59966. * @param impostor impostor to get stiffness from
  59967. * @returns pressure value
  59968. */
  59969. getBodyStiffness(impostor: PhysicsImpostor): number;
  59970. /**
  59971. * Sets stiffness of the impostor
  59972. * @param impostor impostor to set stiffness on
  59973. * @param stiffness stiffness value from 0 to 1
  59974. */
  59975. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59976. /**
  59977. * Gets velocityIterations of the impostor
  59978. * @param impostor impostor to get velocity iterations from
  59979. * @returns velocityIterations value
  59980. */
  59981. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59982. /**
  59983. * Sets velocityIterations of the impostor
  59984. * @param impostor impostor to set velocity iterations on
  59985. * @param velocityIterations velocityIterations value
  59986. */
  59987. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59988. /**
  59989. * Gets positionIterations of the impostor
  59990. * @param impostor impostor to get position iterations from
  59991. * @returns positionIterations value
  59992. */
  59993. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59994. /**
  59995. * Sets positionIterations of the impostor
  59996. * @param impostor impostor to set position on
  59997. * @param positionIterations positionIterations value
  59998. */
  59999. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60000. /**
  60001. * Append an anchor to a cloth object
  60002. * @param impostor is the cloth impostor to add anchor to
  60003. * @param otherImpostor is the rigid impostor to anchor to
  60004. * @param width ratio across width from 0 to 1
  60005. * @param height ratio up height from 0 to 1
  60006. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60007. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60008. */
  60009. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60010. /**
  60011. * Append an hook to a rope object
  60012. * @param impostor is the rope impostor to add hook to
  60013. * @param otherImpostor is the rigid impostor to hook to
  60014. * @param length ratio along the rope from 0 to 1
  60015. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60016. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60017. */
  60018. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60019. /**
  60020. * Sleeps the physics body and stops it from being active
  60021. * @param impostor impostor to sleep
  60022. */
  60023. sleepBody(impostor: PhysicsImpostor): void;
  60024. /**
  60025. * Activates the physics body
  60026. * @param impostor impostor to activate
  60027. */
  60028. wakeUpBody(impostor: PhysicsImpostor): void;
  60029. /**
  60030. * Updates the distance parameters of the joint
  60031. * @param joint joint to update
  60032. * @param maxDistance maximum distance of the joint
  60033. * @param minDistance minimum distance of the joint
  60034. */
  60035. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60036. /**
  60037. * Sets a motor on the joint
  60038. * @param joint joint to set motor on
  60039. * @param speed speed of the motor
  60040. * @param maxForce maximum force of the motor
  60041. * @param motorIndex index of the motor
  60042. */
  60043. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60044. /**
  60045. * Sets the motors limit
  60046. * @param joint joint to set limit on
  60047. * @param upperLimit upper limit
  60048. * @param lowerLimit lower limit
  60049. */
  60050. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60051. /**
  60052. * Syncs the position and rotation of a mesh with the impostor
  60053. * @param mesh mesh to sync
  60054. * @param impostor impostor to update the mesh with
  60055. */
  60056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60057. /**
  60058. * Gets the radius of the impostor
  60059. * @param impostor impostor to get radius from
  60060. * @returns the radius
  60061. */
  60062. getRadius(impostor: PhysicsImpostor): number;
  60063. /**
  60064. * Gets the box size of the impostor
  60065. * @param impostor impostor to get box size from
  60066. * @param result the resulting box size
  60067. */
  60068. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60069. /**
  60070. * Disposes of the impostor
  60071. */
  60072. dispose(): void;
  60073. /**
  60074. * Does a raycast in the physics world
  60075. * @param from when should the ray start?
  60076. * @param to when should the ray end?
  60077. * @returns PhysicsRaycastResult
  60078. */
  60079. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60080. }
  60081. }
  60082. declare module BABYLON {
  60083. interface AbstractScene {
  60084. /**
  60085. * The list of reflection probes added to the scene
  60086. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60087. */
  60088. reflectionProbes: Array<ReflectionProbe>;
  60089. /**
  60090. * Removes the given reflection probe from this scene.
  60091. * @param toRemove The reflection probe to remove
  60092. * @returns The index of the removed reflection probe
  60093. */
  60094. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60095. /**
  60096. * Adds the given reflection probe to this scene.
  60097. * @param newReflectionProbe The reflection probe to add
  60098. */
  60099. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60100. }
  60101. /**
  60102. * Class used to generate realtime reflection / refraction cube textures
  60103. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60104. */
  60105. export class ReflectionProbe {
  60106. /** defines the name of the probe */
  60107. name: string;
  60108. private _scene;
  60109. private _renderTargetTexture;
  60110. private _projectionMatrix;
  60111. private _viewMatrix;
  60112. private _target;
  60113. private _add;
  60114. private _attachedMesh;
  60115. private _invertYAxis;
  60116. /** Gets or sets probe position (center of the cube map) */
  60117. position: Vector3;
  60118. /**
  60119. * Creates a new reflection probe
  60120. * @param name defines the name of the probe
  60121. * @param size defines the texture resolution (for each face)
  60122. * @param scene defines the hosting scene
  60123. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60124. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60125. */
  60126. constructor(
  60127. /** defines the name of the probe */
  60128. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60129. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60130. get samples(): number;
  60131. set samples(value: number);
  60132. /** Gets or sets the refresh rate to use (on every frame by default) */
  60133. get refreshRate(): number;
  60134. set refreshRate(value: number);
  60135. /**
  60136. * Gets the hosting scene
  60137. * @returns a Scene
  60138. */
  60139. getScene(): Scene;
  60140. /** Gets the internal CubeTexture used to render to */
  60141. get cubeTexture(): RenderTargetTexture;
  60142. /** Gets the list of meshes to render */
  60143. get renderList(): Nullable<AbstractMesh[]>;
  60144. /**
  60145. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60146. * @param mesh defines the mesh to attach to
  60147. */
  60148. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60149. /**
  60150. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60151. * @param renderingGroupId The rendering group id corresponding to its index
  60152. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60153. */
  60154. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60155. /**
  60156. * Clean all associated resources
  60157. */
  60158. dispose(): void;
  60159. /**
  60160. * Converts the reflection probe information to a readable string for debug purpose.
  60161. * @param fullDetails Supports for multiple levels of logging within scene loading
  60162. * @returns the human readable reflection probe info
  60163. */
  60164. toString(fullDetails?: boolean): string;
  60165. /**
  60166. * Get the class name of the relfection probe.
  60167. * @returns "ReflectionProbe"
  60168. */
  60169. getClassName(): string;
  60170. /**
  60171. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60172. * @returns The JSON representation of the texture
  60173. */
  60174. serialize(): any;
  60175. /**
  60176. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60177. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60178. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60179. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60180. * @returns The parsed reflection probe if successful
  60181. */
  60182. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60183. }
  60184. }
  60185. declare module BABYLON {
  60186. /** @hidden */
  60187. export var _BabylonLoaderRegistered: boolean;
  60188. /**
  60189. * Helps setting up some configuration for the babylon file loader.
  60190. */
  60191. export class BabylonFileLoaderConfiguration {
  60192. /**
  60193. * The loader does not allow injecting custom physix engine into the plugins.
  60194. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60195. * So you could set this variable to your engine import to make it work.
  60196. */
  60197. static LoaderInjectedPhysicsEngine: any;
  60198. }
  60199. }
  60200. declare module BABYLON {
  60201. /**
  60202. * The Physically based simple base material of BJS.
  60203. *
  60204. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60205. * It is used as the base class for both the specGloss and metalRough conventions.
  60206. */
  60207. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60208. /**
  60209. * Number of Simultaneous lights allowed on the material.
  60210. */
  60211. maxSimultaneousLights: number;
  60212. /**
  60213. * If sets to true, disables all the lights affecting the material.
  60214. */
  60215. disableLighting: boolean;
  60216. /**
  60217. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60218. */
  60219. environmentTexture: BaseTexture;
  60220. /**
  60221. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60222. */
  60223. invertNormalMapX: boolean;
  60224. /**
  60225. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60226. */
  60227. invertNormalMapY: boolean;
  60228. /**
  60229. * Normal map used in the model.
  60230. */
  60231. normalTexture: BaseTexture;
  60232. /**
  60233. * Emissivie color used to self-illuminate the model.
  60234. */
  60235. emissiveColor: Color3;
  60236. /**
  60237. * Emissivie texture used to self-illuminate the model.
  60238. */
  60239. emissiveTexture: BaseTexture;
  60240. /**
  60241. * Occlusion Channel Strenght.
  60242. */
  60243. occlusionStrength: number;
  60244. /**
  60245. * Occlusion Texture of the material (adding extra occlusion effects).
  60246. */
  60247. occlusionTexture: BaseTexture;
  60248. /**
  60249. * Defines the alpha limits in alpha test mode.
  60250. */
  60251. alphaCutOff: number;
  60252. /**
  60253. * Gets the current double sided mode.
  60254. */
  60255. get doubleSided(): boolean;
  60256. /**
  60257. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60258. */
  60259. set doubleSided(value: boolean);
  60260. /**
  60261. * Stores the pre-calculated light information of a mesh in a texture.
  60262. */
  60263. lightmapTexture: BaseTexture;
  60264. /**
  60265. * If true, the light map contains occlusion information instead of lighting info.
  60266. */
  60267. useLightmapAsShadowmap: boolean;
  60268. /**
  60269. * Instantiates a new PBRMaterial instance.
  60270. *
  60271. * @param name The material name
  60272. * @param scene The scene the material will be use in.
  60273. */
  60274. constructor(name: string, scene: Scene);
  60275. getClassName(): string;
  60276. }
  60277. }
  60278. declare module BABYLON {
  60279. /**
  60280. * The PBR material of BJS following the metal roughness convention.
  60281. *
  60282. * This fits to the PBR convention in the GLTF definition:
  60283. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60284. */
  60285. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60286. /**
  60287. * The base color has two different interpretations depending on the value of metalness.
  60288. * When the material is a metal, the base color is the specific measured reflectance value
  60289. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60290. * of the material.
  60291. */
  60292. baseColor: Color3;
  60293. /**
  60294. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60295. * well as opacity information in the alpha channel.
  60296. */
  60297. baseTexture: BaseTexture;
  60298. /**
  60299. * Specifies the metallic scalar value of the material.
  60300. * Can also be used to scale the metalness values of the metallic texture.
  60301. */
  60302. metallic: number;
  60303. /**
  60304. * Specifies the roughness scalar value of the material.
  60305. * Can also be used to scale the roughness values of the metallic texture.
  60306. */
  60307. roughness: number;
  60308. /**
  60309. * Texture containing both the metallic value in the B channel and the
  60310. * roughness value in the G channel to keep better precision.
  60311. */
  60312. metallicRoughnessTexture: BaseTexture;
  60313. /**
  60314. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60315. *
  60316. * @param name The material name
  60317. * @param scene The scene the material will be use in.
  60318. */
  60319. constructor(name: string, scene: Scene);
  60320. /**
  60321. * Return the currrent class name of the material.
  60322. */
  60323. getClassName(): string;
  60324. /**
  60325. * Makes a duplicate of the current material.
  60326. * @param name - name to use for the new material.
  60327. */
  60328. clone(name: string): PBRMetallicRoughnessMaterial;
  60329. /**
  60330. * Serialize the material to a parsable JSON object.
  60331. */
  60332. serialize(): any;
  60333. /**
  60334. * Parses a JSON object correponding to the serialize function.
  60335. */
  60336. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60337. }
  60338. }
  60339. declare module BABYLON {
  60340. /**
  60341. * The PBR material of BJS following the specular glossiness convention.
  60342. *
  60343. * This fits to the PBR convention in the GLTF definition:
  60344. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60345. */
  60346. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60347. /**
  60348. * Specifies the diffuse color of the material.
  60349. */
  60350. diffuseColor: Color3;
  60351. /**
  60352. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60353. * channel.
  60354. */
  60355. diffuseTexture: BaseTexture;
  60356. /**
  60357. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60358. */
  60359. specularColor: Color3;
  60360. /**
  60361. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60362. */
  60363. glossiness: number;
  60364. /**
  60365. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60366. */
  60367. specularGlossinessTexture: BaseTexture;
  60368. /**
  60369. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60370. *
  60371. * @param name The material name
  60372. * @param scene The scene the material will be use in.
  60373. */
  60374. constructor(name: string, scene: Scene);
  60375. /**
  60376. * Return the currrent class name of the material.
  60377. */
  60378. getClassName(): string;
  60379. /**
  60380. * Makes a duplicate of the current material.
  60381. * @param name - name to use for the new material.
  60382. */
  60383. clone(name: string): PBRSpecularGlossinessMaterial;
  60384. /**
  60385. * Serialize the material to a parsable JSON object.
  60386. */
  60387. serialize(): any;
  60388. /**
  60389. * Parses a JSON object correponding to the serialize function.
  60390. */
  60391. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60392. }
  60393. }
  60394. declare module BABYLON {
  60395. /**
  60396. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60397. * It can help converting any input color in a desired output one. This can then be used to create effects
  60398. * from sepia, black and white to sixties or futuristic rendering...
  60399. *
  60400. * The only supported format is currently 3dl.
  60401. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60402. */
  60403. export class ColorGradingTexture extends BaseTexture {
  60404. /**
  60405. * The texture URL.
  60406. */
  60407. url: string;
  60408. /**
  60409. * Empty line regex stored for GC.
  60410. */
  60411. private static _noneEmptyLineRegex;
  60412. private _textureMatrix;
  60413. private _onLoad;
  60414. /**
  60415. * Instantiates a ColorGradingTexture from the following parameters.
  60416. *
  60417. * @param url The location of the color gradind data (currently only supporting 3dl)
  60418. * @param sceneOrEngine The scene or engine the texture will be used in
  60419. * @param onLoad defines a callback triggered when the texture has been loaded
  60420. */
  60421. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60422. /**
  60423. * Fires the onload event from the constructor if requested.
  60424. */
  60425. private _triggerOnLoad;
  60426. /**
  60427. * Returns the texture matrix used in most of the material.
  60428. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60429. */
  60430. getTextureMatrix(): Matrix;
  60431. /**
  60432. * Occurs when the file being loaded is a .3dl LUT file.
  60433. */
  60434. private load3dlTexture;
  60435. /**
  60436. * Starts the loading process of the texture.
  60437. */
  60438. private loadTexture;
  60439. /**
  60440. * Clones the color gradind texture.
  60441. */
  60442. clone(): ColorGradingTexture;
  60443. /**
  60444. * Called during delayed load for textures.
  60445. */
  60446. delayLoad(): void;
  60447. /**
  60448. * Parses a color grading texture serialized by Babylon.
  60449. * @param parsedTexture The texture information being parsedTexture
  60450. * @param scene The scene to load the texture in
  60451. * @param rootUrl The root url of the data assets to load
  60452. * @return A color gradind texture
  60453. */
  60454. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60455. /**
  60456. * Serializes the LUT texture to json format.
  60457. */
  60458. serialize(): any;
  60459. }
  60460. }
  60461. declare module BABYLON {
  60462. /**
  60463. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60464. */
  60465. export class EquiRectangularCubeTexture extends BaseTexture {
  60466. /** The six faces of the cube. */
  60467. private static _FacesMapping;
  60468. private _noMipmap;
  60469. private _onLoad;
  60470. private _onError;
  60471. /** The size of the cubemap. */
  60472. private _size;
  60473. /** The buffer of the image. */
  60474. private _buffer;
  60475. /** The width of the input image. */
  60476. private _width;
  60477. /** The height of the input image. */
  60478. private _height;
  60479. /** The URL to the image. */
  60480. url: string;
  60481. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60482. coordinatesMode: number;
  60483. /**
  60484. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60485. * @param url The location of the image
  60486. * @param scene The scene the texture will be used in
  60487. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60488. * @param noMipmap Forces to not generate the mipmap if true
  60489. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60490. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60491. * @param onLoad — defines a callback called when texture is loaded
  60492. * @param onError — defines a callback called if there is an error
  60493. */
  60494. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60495. /**
  60496. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60497. */
  60498. private loadImage;
  60499. /**
  60500. * Convert the image buffer into a cubemap and create a CubeTexture.
  60501. */
  60502. private loadTexture;
  60503. /**
  60504. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60505. * @param buffer The ArrayBuffer that should be converted.
  60506. * @returns The buffer as Float32Array.
  60507. */
  60508. private getFloat32ArrayFromArrayBuffer;
  60509. /**
  60510. * Get the current class name of the texture useful for serialization or dynamic coding.
  60511. * @returns "EquiRectangularCubeTexture"
  60512. */
  60513. getClassName(): string;
  60514. /**
  60515. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60516. * @returns A clone of the current EquiRectangularCubeTexture.
  60517. */
  60518. clone(): EquiRectangularCubeTexture;
  60519. }
  60520. }
  60521. declare module BABYLON {
  60522. /**
  60523. * Defines the options related to the creation of an HtmlElementTexture
  60524. */
  60525. export interface IHtmlElementTextureOptions {
  60526. /**
  60527. * Defines wether mip maps should be created or not.
  60528. */
  60529. generateMipMaps?: boolean;
  60530. /**
  60531. * Defines the sampling mode of the texture.
  60532. */
  60533. samplingMode?: number;
  60534. /**
  60535. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60536. */
  60537. engine: Nullable<ThinEngine>;
  60538. /**
  60539. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60540. */
  60541. scene: Nullable<Scene>;
  60542. }
  60543. /**
  60544. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60545. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60546. * is automatically managed.
  60547. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60548. * in your application.
  60549. *
  60550. * As the update is not automatic, you need to call them manually.
  60551. */
  60552. export class HtmlElementTexture extends BaseTexture {
  60553. /**
  60554. * The texture URL.
  60555. */
  60556. element: HTMLVideoElement | HTMLCanvasElement;
  60557. private static readonly DefaultOptions;
  60558. private _textureMatrix;
  60559. private _isVideo;
  60560. private _generateMipMaps;
  60561. private _samplingMode;
  60562. /**
  60563. * Instantiates a HtmlElementTexture from the following parameters.
  60564. *
  60565. * @param name Defines the name of the texture
  60566. * @param element Defines the video or canvas the texture is filled with
  60567. * @param options Defines the other none mandatory texture creation options
  60568. */
  60569. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60570. private _createInternalTexture;
  60571. /**
  60572. * Returns the texture matrix used in most of the material.
  60573. */
  60574. getTextureMatrix(): Matrix;
  60575. /**
  60576. * Updates the content of the texture.
  60577. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60578. */
  60579. update(invertY?: Nullable<boolean>): void;
  60580. }
  60581. }
  60582. declare module BABYLON {
  60583. /**
  60584. * Based on jsTGALoader - Javascript loader for TGA file
  60585. * By Vincent Thibault
  60586. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60587. */
  60588. export class TGATools {
  60589. private static _TYPE_INDEXED;
  60590. private static _TYPE_RGB;
  60591. private static _TYPE_GREY;
  60592. private static _TYPE_RLE_INDEXED;
  60593. private static _TYPE_RLE_RGB;
  60594. private static _TYPE_RLE_GREY;
  60595. private static _ORIGIN_MASK;
  60596. private static _ORIGIN_SHIFT;
  60597. private static _ORIGIN_BL;
  60598. private static _ORIGIN_BR;
  60599. private static _ORIGIN_UL;
  60600. private static _ORIGIN_UR;
  60601. /**
  60602. * Gets the header of a TGA file
  60603. * @param data defines the TGA data
  60604. * @returns the header
  60605. */
  60606. static GetTGAHeader(data: Uint8Array): any;
  60607. /**
  60608. * Uploads TGA content to a Babylon Texture
  60609. * @hidden
  60610. */
  60611. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60612. /** @hidden */
  60613. 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;
  60614. /** @hidden */
  60615. 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;
  60616. /** @hidden */
  60617. 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;
  60618. /** @hidden */
  60619. 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;
  60620. /** @hidden */
  60621. 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;
  60622. /** @hidden */
  60623. 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;
  60624. }
  60625. }
  60626. declare module BABYLON {
  60627. /**
  60628. * Implementation of the TGA Texture Loader.
  60629. * @hidden
  60630. */
  60631. export class _TGATextureLoader implements IInternalTextureLoader {
  60632. /**
  60633. * Defines wether the loader supports cascade loading the different faces.
  60634. */
  60635. readonly supportCascades: boolean;
  60636. /**
  60637. * This returns if the loader support the current file information.
  60638. * @param extension defines the file extension of the file being loaded
  60639. * @returns true if the loader can load the specified file
  60640. */
  60641. canLoad(extension: string): boolean;
  60642. /**
  60643. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60644. * @param data contains the texture data
  60645. * @param texture defines the BabylonJS internal texture
  60646. * @param createPolynomials will be true if polynomials have been requested
  60647. * @param onLoad defines the callback to trigger once the texture is ready
  60648. * @param onError defines the callback to trigger in case of error
  60649. */
  60650. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60651. /**
  60652. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60653. * @param data contains the texture data
  60654. * @param texture defines the BabylonJS internal texture
  60655. * @param callback defines the method to call once ready to upload
  60656. */
  60657. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60658. }
  60659. }
  60660. declare module BABYLON {
  60661. /**
  60662. * Info about the .basis files
  60663. */
  60664. class BasisFileInfo {
  60665. /**
  60666. * If the file has alpha
  60667. */
  60668. hasAlpha: boolean;
  60669. /**
  60670. * Info about each image of the basis file
  60671. */
  60672. images: Array<{
  60673. levels: Array<{
  60674. width: number;
  60675. height: number;
  60676. transcodedPixels: ArrayBufferView;
  60677. }>;
  60678. }>;
  60679. }
  60680. /**
  60681. * Result of transcoding a basis file
  60682. */
  60683. class TranscodeResult {
  60684. /**
  60685. * Info about the .basis file
  60686. */
  60687. fileInfo: BasisFileInfo;
  60688. /**
  60689. * Format to use when loading the file
  60690. */
  60691. format: number;
  60692. }
  60693. /**
  60694. * Configuration options for the Basis transcoder
  60695. */
  60696. export class BasisTranscodeConfiguration {
  60697. /**
  60698. * Supported compression formats used to determine the supported output format of the transcoder
  60699. */
  60700. supportedCompressionFormats?: {
  60701. /**
  60702. * etc1 compression format
  60703. */
  60704. etc1?: boolean;
  60705. /**
  60706. * s3tc compression format
  60707. */
  60708. s3tc?: boolean;
  60709. /**
  60710. * pvrtc compression format
  60711. */
  60712. pvrtc?: boolean;
  60713. /**
  60714. * etc2 compression format
  60715. */
  60716. etc2?: boolean;
  60717. };
  60718. /**
  60719. * If mipmap levels should be loaded for transcoded images (Default: true)
  60720. */
  60721. loadMipmapLevels?: boolean;
  60722. /**
  60723. * Index of a single image to load (Default: all images)
  60724. */
  60725. loadSingleImage?: number;
  60726. }
  60727. /**
  60728. * Used to load .Basis files
  60729. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60730. */
  60731. export class BasisTools {
  60732. private static _IgnoreSupportedFormats;
  60733. /**
  60734. * URL to use when loading the basis transcoder
  60735. */
  60736. static JSModuleURL: string;
  60737. /**
  60738. * URL to use when loading the wasm module for the transcoder
  60739. */
  60740. static WasmModuleURL: string;
  60741. /**
  60742. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60743. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60744. * @returns internal format corresponding to the Basis format
  60745. */
  60746. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60747. private static _WorkerPromise;
  60748. private static _Worker;
  60749. private static _actionId;
  60750. private static _CreateWorkerAsync;
  60751. /**
  60752. * Transcodes a loaded image file to compressed pixel data
  60753. * @param data image data to transcode
  60754. * @param config configuration options for the transcoding
  60755. * @returns a promise resulting in the transcoded image
  60756. */
  60757. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60758. /**
  60759. * Loads a texture from the transcode result
  60760. * @param texture texture load to
  60761. * @param transcodeResult the result of transcoding the basis file to load from
  60762. */
  60763. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60764. }
  60765. }
  60766. declare module BABYLON {
  60767. /**
  60768. * Loader for .basis file format
  60769. */
  60770. export class _BasisTextureLoader implements IInternalTextureLoader {
  60771. /**
  60772. * Defines whether the loader supports cascade loading the different faces.
  60773. */
  60774. readonly supportCascades: boolean;
  60775. /**
  60776. * This returns if the loader support the current file information.
  60777. * @param extension defines the file extension of the file being loaded
  60778. * @returns true if the loader can load the specified file
  60779. */
  60780. canLoad(extension: string): boolean;
  60781. /**
  60782. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60783. * @param data contains the texture data
  60784. * @param texture defines the BabylonJS internal texture
  60785. * @param createPolynomials will be true if polynomials have been requested
  60786. * @param onLoad defines the callback to trigger once the texture is ready
  60787. * @param onError defines the callback to trigger in case of error
  60788. */
  60789. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60790. /**
  60791. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60792. * @param data contains the texture data
  60793. * @param texture defines the BabylonJS internal texture
  60794. * @param callback defines the method to call once ready to upload
  60795. */
  60796. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60797. }
  60798. }
  60799. declare module BABYLON {
  60800. /**
  60801. * Defines the basic options interface of a TexturePacker Frame
  60802. */
  60803. export interface ITexturePackerFrame {
  60804. /**
  60805. * The frame ID
  60806. */
  60807. id: number;
  60808. /**
  60809. * The frames Scale
  60810. */
  60811. scale: Vector2;
  60812. /**
  60813. * The Frames offset
  60814. */
  60815. offset: Vector2;
  60816. }
  60817. /**
  60818. * This is a support class for frame Data on texture packer sets.
  60819. */
  60820. export class TexturePackerFrame implements ITexturePackerFrame {
  60821. /**
  60822. * The frame ID
  60823. */
  60824. id: number;
  60825. /**
  60826. * The frames Scale
  60827. */
  60828. scale: Vector2;
  60829. /**
  60830. * The Frames offset
  60831. */
  60832. offset: Vector2;
  60833. /**
  60834. * Initializes a texture package frame.
  60835. * @param id The numerical frame identifier
  60836. * @param scale Scalar Vector2 for UV frame
  60837. * @param offset Vector2 for the frame position in UV units.
  60838. * @returns TexturePackerFrame
  60839. */
  60840. constructor(id: number, scale: Vector2, offset: Vector2);
  60841. }
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * Defines the basic options interface of a TexturePacker
  60846. */
  60847. export interface ITexturePackerOptions {
  60848. /**
  60849. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60850. */
  60851. map?: string[];
  60852. /**
  60853. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60854. */
  60855. uvsIn?: string;
  60856. /**
  60857. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60858. */
  60859. uvsOut?: string;
  60860. /**
  60861. * number representing the layout style. Defaults to LAYOUT_STRIP
  60862. */
  60863. layout?: number;
  60864. /**
  60865. * number of columns if using custom column count layout(2). This defaults to 4.
  60866. */
  60867. colnum?: number;
  60868. /**
  60869. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60870. */
  60871. updateInputMeshes?: boolean;
  60872. /**
  60873. * boolean flag to dispose all the source textures. Defaults to true.
  60874. */
  60875. disposeSources?: boolean;
  60876. /**
  60877. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60878. */
  60879. fillBlanks?: boolean;
  60880. /**
  60881. * string value representing the context fill style color. Defaults to 'black'.
  60882. */
  60883. customFillColor?: string;
  60884. /**
  60885. * Width and Height Value of each Frame in the TexturePacker Sets
  60886. */
  60887. frameSize?: number;
  60888. /**
  60889. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60890. */
  60891. paddingRatio?: number;
  60892. /**
  60893. * Number that declares the fill method for the padding gutter.
  60894. */
  60895. paddingMode?: number;
  60896. /**
  60897. * If in SUBUV_COLOR padding mode what color to use.
  60898. */
  60899. paddingColor?: Color3 | Color4;
  60900. }
  60901. /**
  60902. * Defines the basic interface of a TexturePacker JSON File
  60903. */
  60904. export interface ITexturePackerJSON {
  60905. /**
  60906. * The frame ID
  60907. */
  60908. name: string;
  60909. /**
  60910. * The base64 channel data
  60911. */
  60912. sets: any;
  60913. /**
  60914. * The options of the Packer
  60915. */
  60916. options: ITexturePackerOptions;
  60917. /**
  60918. * The frame data of the Packer
  60919. */
  60920. frames: Array<number>;
  60921. }
  60922. /**
  60923. * This is a support class that generates a series of packed texture sets.
  60924. * @see https://doc.babylonjs.com/babylon101/materials
  60925. */
  60926. export class TexturePacker {
  60927. /** Packer Layout Constant 0 */
  60928. static readonly LAYOUT_STRIP: number;
  60929. /** Packer Layout Constant 1 */
  60930. static readonly LAYOUT_POWER2: number;
  60931. /** Packer Layout Constant 2 */
  60932. static readonly LAYOUT_COLNUM: number;
  60933. /** Packer Layout Constant 0 */
  60934. static readonly SUBUV_WRAP: number;
  60935. /** Packer Layout Constant 1 */
  60936. static readonly SUBUV_EXTEND: number;
  60937. /** Packer Layout Constant 2 */
  60938. static readonly SUBUV_COLOR: number;
  60939. /** The Name of the Texture Package */
  60940. name: string;
  60941. /** The scene scope of the TexturePacker */
  60942. scene: Scene;
  60943. /** The Meshes to target */
  60944. meshes: AbstractMesh[];
  60945. /** Arguments passed with the Constructor */
  60946. options: ITexturePackerOptions;
  60947. /** The promise that is started upon initialization */
  60948. promise: Nullable<Promise<TexturePacker | string>>;
  60949. /** The Container object for the channel sets that are generated */
  60950. sets: object;
  60951. /** The Container array for the frames that are generated */
  60952. frames: TexturePackerFrame[];
  60953. /** The expected number of textures the system is parsing. */
  60954. private _expecting;
  60955. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60956. private _paddingValue;
  60957. /**
  60958. * Initializes a texture package series from an array of meshes or a single mesh.
  60959. * @param name The name of the package
  60960. * @param meshes The target meshes to compose the package from
  60961. * @param options The arguments that texture packer should follow while building.
  60962. * @param scene The scene which the textures are scoped to.
  60963. * @returns TexturePacker
  60964. */
  60965. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60966. /**
  60967. * Starts the package process
  60968. * @param resolve The promises resolution function
  60969. * @returns TexturePacker
  60970. */
  60971. private _createFrames;
  60972. /**
  60973. * Calculates the Size of the Channel Sets
  60974. * @returns Vector2
  60975. */
  60976. private _calculateSize;
  60977. /**
  60978. * Calculates the UV data for the frames.
  60979. * @param baseSize the base frameSize
  60980. * @param padding the base frame padding
  60981. * @param dtSize size of the Dynamic Texture for that channel
  60982. * @param dtUnits is 1/dtSize
  60983. * @param update flag to update the input meshes
  60984. */
  60985. private _calculateMeshUVFrames;
  60986. /**
  60987. * Calculates the frames Offset.
  60988. * @param index of the frame
  60989. * @returns Vector2
  60990. */
  60991. private _getFrameOffset;
  60992. /**
  60993. * Updates a Mesh to the frame data
  60994. * @param mesh that is the target
  60995. * @param frameID or the frame index
  60996. */
  60997. private _updateMeshUV;
  60998. /**
  60999. * Updates a Meshes materials to use the texture packer channels
  61000. * @param m is the mesh to target
  61001. * @param force all channels on the packer to be set.
  61002. */
  61003. private _updateTextureReferences;
  61004. /**
  61005. * Public method to set a Mesh to a frame
  61006. * @param m that is the target
  61007. * @param frameID or the frame index
  61008. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61009. */
  61010. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61011. /**
  61012. * Starts the async promise to compile the texture packer.
  61013. * @returns Promise<void>
  61014. */
  61015. processAsync(): Promise<void>;
  61016. /**
  61017. * Disposes all textures associated with this packer
  61018. */
  61019. dispose(): void;
  61020. /**
  61021. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61022. * @param imageType is the image type to use.
  61023. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61024. */
  61025. download(imageType?: string, quality?: number): void;
  61026. /**
  61027. * Public method to load a texturePacker JSON file.
  61028. * @param data of the JSON file in string format.
  61029. */
  61030. updateFromJSON(data: string): void;
  61031. }
  61032. }
  61033. declare module BABYLON {
  61034. /**
  61035. * 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.
  61036. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61037. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61038. */
  61039. export class CustomProceduralTexture extends ProceduralTexture {
  61040. private _animate;
  61041. private _time;
  61042. private _config;
  61043. private _texturePath;
  61044. /**
  61045. * Instantiates a new Custom Procedural Texture.
  61046. * 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.
  61047. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61048. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61049. * @param name Define the name of the texture
  61050. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61051. * @param size Define the size of the texture to create
  61052. * @param scene Define the scene the texture belongs to
  61053. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61054. * @param generateMipMaps Define if the texture should creates mip maps or not
  61055. */
  61056. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61057. private _loadJson;
  61058. /**
  61059. * Is the texture ready to be used ? (rendered at least once)
  61060. * @returns true if ready, otherwise, false.
  61061. */
  61062. isReady(): boolean;
  61063. /**
  61064. * Render the texture to its associated render target.
  61065. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61066. */
  61067. render(useCameraPostProcess?: boolean): void;
  61068. /**
  61069. * Update the list of dependant textures samplers in the shader.
  61070. */
  61071. updateTextures(): void;
  61072. /**
  61073. * Update the uniform values of the procedural texture in the shader.
  61074. */
  61075. updateShaderUniforms(): void;
  61076. /**
  61077. * Define if the texture animates or not.
  61078. */
  61079. get animate(): boolean;
  61080. set animate(value: boolean);
  61081. }
  61082. }
  61083. declare module BABYLON {
  61084. /** @hidden */
  61085. export var noisePixelShader: {
  61086. name: string;
  61087. shader: string;
  61088. };
  61089. }
  61090. declare module BABYLON {
  61091. /**
  61092. * Class used to generate noise procedural textures
  61093. */
  61094. export class NoiseProceduralTexture extends ProceduralTexture {
  61095. private _time;
  61096. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61097. brightness: number;
  61098. /** Defines the number of octaves to process */
  61099. octaves: number;
  61100. /** Defines the level of persistence (0.8 by default) */
  61101. persistence: number;
  61102. /** Gets or sets animation speed factor (default is 1) */
  61103. animationSpeedFactor: number;
  61104. /**
  61105. * Creates a new NoiseProceduralTexture
  61106. * @param name defines the name fo the texture
  61107. * @param size defines the size of the texture (default is 256)
  61108. * @param scene defines the hosting scene
  61109. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61110. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61111. */
  61112. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61113. private _updateShaderUniforms;
  61114. protected _getDefines(): string;
  61115. /** Generate the current state of the procedural texture */
  61116. render(useCameraPostProcess?: boolean): void;
  61117. /**
  61118. * Serializes this noise procedural texture
  61119. * @returns a serialized noise procedural texture object
  61120. */
  61121. serialize(): any;
  61122. /**
  61123. * Clone the texture.
  61124. * @returns the cloned texture
  61125. */
  61126. clone(): NoiseProceduralTexture;
  61127. /**
  61128. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61129. * @param parsedTexture defines parsed texture data
  61130. * @param scene defines the current scene
  61131. * @param rootUrl defines the root URL containing noise procedural texture information
  61132. * @returns a parsed NoiseProceduralTexture
  61133. */
  61134. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61135. }
  61136. }
  61137. declare module BABYLON {
  61138. /**
  61139. * Raw cube texture where the raw buffers are passed in
  61140. */
  61141. export class RawCubeTexture extends CubeTexture {
  61142. /**
  61143. * Creates a cube texture where the raw buffers are passed in.
  61144. * @param scene defines the scene the texture is attached to
  61145. * @param data defines the array of data to use to create each face
  61146. * @param size defines the size of the textures
  61147. * @param format defines the format of the data
  61148. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61149. * @param generateMipMaps defines if the engine should generate the mip levels
  61150. * @param invertY defines if data must be stored with Y axis inverted
  61151. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61152. * @param compression defines the compression used (null by default)
  61153. */
  61154. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61155. /**
  61156. * Updates the raw cube texture.
  61157. * @param data defines the data to store
  61158. * @param format defines the data format
  61159. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61160. * @param invertY defines if data must be stored with Y axis inverted
  61161. * @param compression defines the compression used (null by default)
  61162. * @param level defines which level of the texture to update
  61163. */
  61164. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61165. /**
  61166. * Updates a raw cube texture with RGBD encoded data.
  61167. * @param data defines the array of data [mipmap][face] to use to create each face
  61168. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61169. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61170. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61171. * @returns a promsie that resolves when the operation is complete
  61172. */
  61173. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61174. /**
  61175. * Clones the raw cube texture.
  61176. * @return a new cube texture
  61177. */
  61178. clone(): CubeTexture;
  61179. /** @hidden */
  61180. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * Class used to store 2D array textures containing user data
  61186. */
  61187. export class RawTexture2DArray extends Texture {
  61188. /** Gets or sets the texture format to use */
  61189. format: number;
  61190. /**
  61191. * Create a new RawTexture2DArray
  61192. * @param data defines the data of the texture
  61193. * @param width defines the width of the texture
  61194. * @param height defines the height of the texture
  61195. * @param depth defines the number of layers of the texture
  61196. * @param format defines the texture format to use
  61197. * @param scene defines the hosting scene
  61198. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61199. * @param invertY defines if texture must be stored with Y axis inverted
  61200. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61201. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61202. */
  61203. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61204. /** Gets or sets the texture format to use */
  61205. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61206. /**
  61207. * Update the texture with new data
  61208. * @param data defines the data to store in the texture
  61209. */
  61210. update(data: ArrayBufferView): void;
  61211. }
  61212. }
  61213. declare module BABYLON {
  61214. /**
  61215. * Class used to store 3D textures containing user data
  61216. */
  61217. export class RawTexture3D extends Texture {
  61218. /** Gets or sets the texture format to use */
  61219. format: number;
  61220. /**
  61221. * Create a new RawTexture3D
  61222. * @param data defines the data of the texture
  61223. * @param width defines the width of the texture
  61224. * @param height defines the height of the texture
  61225. * @param depth defines the depth of the texture
  61226. * @param format defines the texture format to use
  61227. * @param scene defines the hosting scene
  61228. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61229. * @param invertY defines if texture must be stored with Y axis inverted
  61230. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61231. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61232. */
  61233. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61234. /** Gets or sets the texture format to use */
  61235. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61236. /**
  61237. * Update the texture with new data
  61238. * @param data defines the data to store in the texture
  61239. */
  61240. update(data: ArrayBufferView): void;
  61241. }
  61242. }
  61243. declare module BABYLON {
  61244. /**
  61245. * Creates a refraction texture used by refraction channel of the standard material.
  61246. * It is like a mirror but to see through a material.
  61247. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61248. */
  61249. export class RefractionTexture extends RenderTargetTexture {
  61250. /**
  61251. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61252. * 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.
  61253. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61254. */
  61255. refractionPlane: Plane;
  61256. /**
  61257. * Define how deep under the surface we should see.
  61258. */
  61259. depth: number;
  61260. /**
  61261. * Creates a refraction texture used by refraction channel of the standard material.
  61262. * It is like a mirror but to see through a material.
  61263. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61264. * @param name Define the texture name
  61265. * @param size Define the size of the underlying texture
  61266. * @param scene Define the scene the refraction belongs to
  61267. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61268. */
  61269. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61270. /**
  61271. * Clone the refraction texture.
  61272. * @returns the cloned texture
  61273. */
  61274. clone(): RefractionTexture;
  61275. /**
  61276. * Serialize the texture to a JSON representation you could use in Parse later on
  61277. * @returns the serialized JSON representation
  61278. */
  61279. serialize(): any;
  61280. }
  61281. }
  61282. declare module BABYLON {
  61283. /**
  61284. * Block used to add support for vertex skinning (bones)
  61285. */
  61286. export class BonesBlock extends NodeMaterialBlock {
  61287. /**
  61288. * Creates a new BonesBlock
  61289. * @param name defines the block name
  61290. */
  61291. constructor(name: string);
  61292. /**
  61293. * Initialize the block and prepare the context for build
  61294. * @param state defines the state that will be used for the build
  61295. */
  61296. initialize(state: NodeMaterialBuildState): void;
  61297. /**
  61298. * Gets the current class name
  61299. * @returns the class name
  61300. */
  61301. getClassName(): string;
  61302. /**
  61303. * Gets the matrix indices input component
  61304. */
  61305. get matricesIndices(): NodeMaterialConnectionPoint;
  61306. /**
  61307. * Gets the matrix weights input component
  61308. */
  61309. get matricesWeights(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the extra matrix indices input component
  61312. */
  61313. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the extra matrix weights input component
  61316. */
  61317. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the world input component
  61320. */
  61321. get world(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the output component
  61324. */
  61325. get output(): NodeMaterialConnectionPoint;
  61326. autoConfigure(material: NodeMaterial): void;
  61327. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61328. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61330. protected _buildBlock(state: NodeMaterialBuildState): this;
  61331. }
  61332. }
  61333. declare module BABYLON {
  61334. /**
  61335. * Block used to add support for instances
  61336. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61337. */
  61338. export class InstancesBlock extends NodeMaterialBlock {
  61339. /**
  61340. * Creates a new InstancesBlock
  61341. * @param name defines the block name
  61342. */
  61343. constructor(name: string);
  61344. /**
  61345. * Gets the current class name
  61346. * @returns the class name
  61347. */
  61348. getClassName(): string;
  61349. /**
  61350. * Gets the first world row input component
  61351. */
  61352. get world0(): NodeMaterialConnectionPoint;
  61353. /**
  61354. * Gets the second world row input component
  61355. */
  61356. get world1(): NodeMaterialConnectionPoint;
  61357. /**
  61358. * Gets the third world row input component
  61359. */
  61360. get world2(): NodeMaterialConnectionPoint;
  61361. /**
  61362. * Gets the forth world row input component
  61363. */
  61364. get world3(): NodeMaterialConnectionPoint;
  61365. /**
  61366. * Gets the world input component
  61367. */
  61368. get world(): NodeMaterialConnectionPoint;
  61369. /**
  61370. * Gets the output component
  61371. */
  61372. get output(): NodeMaterialConnectionPoint;
  61373. /**
  61374. * Gets the isntanceID component
  61375. */
  61376. get instanceID(): NodeMaterialConnectionPoint;
  61377. autoConfigure(material: NodeMaterial): void;
  61378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61379. protected _buildBlock(state: NodeMaterialBuildState): this;
  61380. }
  61381. }
  61382. declare module BABYLON {
  61383. /**
  61384. * Block used to add morph targets support to vertex shader
  61385. */
  61386. export class MorphTargetsBlock extends NodeMaterialBlock {
  61387. private _repeatableContentAnchor;
  61388. /**
  61389. * Create a new MorphTargetsBlock
  61390. * @param name defines the block name
  61391. */
  61392. constructor(name: string);
  61393. /**
  61394. * Gets the current class name
  61395. * @returns the class name
  61396. */
  61397. getClassName(): string;
  61398. /**
  61399. * Gets the position input component
  61400. */
  61401. get position(): NodeMaterialConnectionPoint;
  61402. /**
  61403. * Gets the normal input component
  61404. */
  61405. get normal(): NodeMaterialConnectionPoint;
  61406. /**
  61407. * Gets the tangent input component
  61408. */
  61409. get tangent(): NodeMaterialConnectionPoint;
  61410. /**
  61411. * Gets the tangent input component
  61412. */
  61413. get uv(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the position output component
  61416. */
  61417. get positionOutput(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the normal output component
  61420. */
  61421. get normalOutput(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the tangent output component
  61424. */
  61425. get tangentOutput(): NodeMaterialConnectionPoint;
  61426. /**
  61427. * Gets the tangent output component
  61428. */
  61429. get uvOutput(): NodeMaterialConnectionPoint;
  61430. initialize(state: NodeMaterialBuildState): void;
  61431. autoConfigure(material: NodeMaterial): void;
  61432. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61434. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61435. protected _buildBlock(state: NodeMaterialBuildState): this;
  61436. }
  61437. }
  61438. declare module BABYLON {
  61439. /**
  61440. * Block used to get data information from a light
  61441. */
  61442. export class LightInformationBlock extends NodeMaterialBlock {
  61443. private _lightDataUniformName;
  61444. private _lightColorUniformName;
  61445. private _lightTypeDefineName;
  61446. /**
  61447. * Gets or sets the light associated with this block
  61448. */
  61449. light: Nullable<Light>;
  61450. /**
  61451. * Creates a new LightInformationBlock
  61452. * @param name defines the block name
  61453. */
  61454. constructor(name: string);
  61455. /**
  61456. * Gets the current class name
  61457. * @returns the class name
  61458. */
  61459. getClassName(): string;
  61460. /**
  61461. * Gets the world position input component
  61462. */
  61463. get worldPosition(): NodeMaterialConnectionPoint;
  61464. /**
  61465. * Gets the direction output component
  61466. */
  61467. get direction(): NodeMaterialConnectionPoint;
  61468. /**
  61469. * Gets the direction output component
  61470. */
  61471. get color(): NodeMaterialConnectionPoint;
  61472. /**
  61473. * Gets the direction output component
  61474. */
  61475. get intensity(): NodeMaterialConnectionPoint;
  61476. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61477. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61478. protected _buildBlock(state: NodeMaterialBuildState): this;
  61479. serialize(): any;
  61480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. /**
  61485. * Block used to add image processing support to fragment shader
  61486. */
  61487. export class ImageProcessingBlock extends NodeMaterialBlock {
  61488. /**
  61489. * Create a new ImageProcessingBlock
  61490. * @param name defines the block name
  61491. */
  61492. constructor(name: string);
  61493. /**
  61494. * Gets the current class name
  61495. * @returns the class name
  61496. */
  61497. getClassName(): string;
  61498. /**
  61499. * Gets the color input component
  61500. */
  61501. get color(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the output component
  61504. */
  61505. get output(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Initialize the block and prepare the context for build
  61508. * @param state defines the state that will be used for the build
  61509. */
  61510. initialize(state: NodeMaterialBuildState): void;
  61511. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61513. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61514. protected _buildBlock(state: NodeMaterialBuildState): this;
  61515. }
  61516. }
  61517. declare module BABYLON {
  61518. /**
  61519. * Block used to pertub normals based on a normal map
  61520. */
  61521. export class PerturbNormalBlock extends NodeMaterialBlock {
  61522. private _tangentSpaceParameterName;
  61523. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61524. invertX: boolean;
  61525. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61526. invertY: boolean;
  61527. /**
  61528. * Create a new PerturbNormalBlock
  61529. * @param name defines the block name
  61530. */
  61531. constructor(name: string);
  61532. /**
  61533. * Gets the current class name
  61534. * @returns the class name
  61535. */
  61536. getClassName(): string;
  61537. /**
  61538. * Gets the world position input component
  61539. */
  61540. get worldPosition(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the world normal input component
  61543. */
  61544. get worldNormal(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the world tangent input component
  61547. */
  61548. get worldTangent(): NodeMaterialConnectionPoint;
  61549. /**
  61550. * Gets the uv input component
  61551. */
  61552. get uv(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the normal map color input component
  61555. */
  61556. get normalMapColor(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the strength input component
  61559. */
  61560. get strength(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the output component
  61563. */
  61564. get output(): NodeMaterialConnectionPoint;
  61565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61567. autoConfigure(material: NodeMaterial): void;
  61568. protected _buildBlock(state: NodeMaterialBuildState): this;
  61569. protected _dumpPropertiesCode(): string;
  61570. serialize(): any;
  61571. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61572. }
  61573. }
  61574. declare module BABYLON {
  61575. /**
  61576. * Block used to discard a pixel if a value is smaller than a cutoff
  61577. */
  61578. export class DiscardBlock extends NodeMaterialBlock {
  61579. /**
  61580. * Create a new DiscardBlock
  61581. * @param name defines the block name
  61582. */
  61583. constructor(name: string);
  61584. /**
  61585. * Gets the current class name
  61586. * @returns the class name
  61587. */
  61588. getClassName(): string;
  61589. /**
  61590. * Gets the color input component
  61591. */
  61592. get value(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the cutoff input component
  61595. */
  61596. get cutoff(): NodeMaterialConnectionPoint;
  61597. protected _buildBlock(state: NodeMaterialBuildState): this;
  61598. }
  61599. }
  61600. declare module BABYLON {
  61601. /**
  61602. * Block used to test if the fragment shader is front facing
  61603. */
  61604. export class FrontFacingBlock extends NodeMaterialBlock {
  61605. /**
  61606. * Creates a new FrontFacingBlock
  61607. * @param name defines the block name
  61608. */
  61609. constructor(name: string);
  61610. /**
  61611. * Gets the current class name
  61612. * @returns the class name
  61613. */
  61614. getClassName(): string;
  61615. /**
  61616. * Gets the output component
  61617. */
  61618. get output(): NodeMaterialConnectionPoint;
  61619. protected _buildBlock(state: NodeMaterialBuildState): this;
  61620. }
  61621. }
  61622. declare module BABYLON {
  61623. /**
  61624. * Block used to get the derivative value on x and y of a given input
  61625. */
  61626. export class DerivativeBlock extends NodeMaterialBlock {
  61627. /**
  61628. * Create a new DerivativeBlock
  61629. * @param name defines the block name
  61630. */
  61631. constructor(name: string);
  61632. /**
  61633. * Gets the current class name
  61634. * @returns the class name
  61635. */
  61636. getClassName(): string;
  61637. /**
  61638. * Gets the input component
  61639. */
  61640. get input(): NodeMaterialConnectionPoint;
  61641. /**
  61642. * Gets the derivative output on x
  61643. */
  61644. get dx(): NodeMaterialConnectionPoint;
  61645. /**
  61646. * Gets the derivative output on y
  61647. */
  61648. get dy(): NodeMaterialConnectionPoint;
  61649. protected _buildBlock(state: NodeMaterialBuildState): this;
  61650. }
  61651. }
  61652. declare module BABYLON {
  61653. /**
  61654. * Block used to make gl_FragCoord available
  61655. */
  61656. export class FragCoordBlock extends NodeMaterialBlock {
  61657. /**
  61658. * Creates a new FragCoordBlock
  61659. * @param name defines the block name
  61660. */
  61661. constructor(name: string);
  61662. /**
  61663. * Gets the current class name
  61664. * @returns the class name
  61665. */
  61666. getClassName(): string;
  61667. /**
  61668. * Gets the xy component
  61669. */
  61670. get xy(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the xyz component
  61673. */
  61674. get xyz(): NodeMaterialConnectionPoint;
  61675. /**
  61676. * Gets the xyzw component
  61677. */
  61678. get xyzw(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the x component
  61681. */
  61682. get x(): NodeMaterialConnectionPoint;
  61683. /**
  61684. * Gets the y component
  61685. */
  61686. get y(): NodeMaterialConnectionPoint;
  61687. /**
  61688. * Gets the z component
  61689. */
  61690. get z(): NodeMaterialConnectionPoint;
  61691. /**
  61692. * Gets the w component
  61693. */
  61694. get output(): NodeMaterialConnectionPoint;
  61695. protected writeOutputs(state: NodeMaterialBuildState): string;
  61696. protected _buildBlock(state: NodeMaterialBuildState): this;
  61697. }
  61698. }
  61699. declare module BABYLON {
  61700. /**
  61701. * Block used to get the screen sizes
  61702. */
  61703. export class ScreenSizeBlock extends NodeMaterialBlock {
  61704. private _varName;
  61705. private _scene;
  61706. /**
  61707. * Creates a new ScreenSizeBlock
  61708. * @param name defines the block name
  61709. */
  61710. constructor(name: string);
  61711. /**
  61712. * Gets the current class name
  61713. * @returns the class name
  61714. */
  61715. getClassName(): string;
  61716. /**
  61717. * Gets the xy component
  61718. */
  61719. get xy(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Gets the x component
  61722. */
  61723. get x(): NodeMaterialConnectionPoint;
  61724. /**
  61725. * Gets the y component
  61726. */
  61727. get y(): NodeMaterialConnectionPoint;
  61728. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61729. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61730. protected _buildBlock(state: NodeMaterialBuildState): this;
  61731. }
  61732. }
  61733. declare module BABYLON {
  61734. /**
  61735. * Block used to add support for scene fog
  61736. */
  61737. export class FogBlock extends NodeMaterialBlock {
  61738. private _fogDistanceName;
  61739. private _fogParameters;
  61740. /**
  61741. * Create a new FogBlock
  61742. * @param name defines the block name
  61743. */
  61744. constructor(name: string);
  61745. /**
  61746. * Gets the current class name
  61747. * @returns the class name
  61748. */
  61749. getClassName(): string;
  61750. /**
  61751. * Gets the world position input component
  61752. */
  61753. get worldPosition(): NodeMaterialConnectionPoint;
  61754. /**
  61755. * Gets the view input component
  61756. */
  61757. get view(): NodeMaterialConnectionPoint;
  61758. /**
  61759. * Gets the color input component
  61760. */
  61761. get input(): NodeMaterialConnectionPoint;
  61762. /**
  61763. * Gets the fog color input component
  61764. */
  61765. get fogColor(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the output component
  61768. */
  61769. get output(): NodeMaterialConnectionPoint;
  61770. autoConfigure(material: NodeMaterial): void;
  61771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61773. protected _buildBlock(state: NodeMaterialBuildState): this;
  61774. }
  61775. }
  61776. declare module BABYLON {
  61777. /**
  61778. * Block used to add light in the fragment shader
  61779. */
  61780. export class LightBlock extends NodeMaterialBlock {
  61781. private _lightId;
  61782. /**
  61783. * Gets or sets the light associated with this block
  61784. */
  61785. light: Nullable<Light>;
  61786. /**
  61787. * Create a new LightBlock
  61788. * @param name defines the block name
  61789. */
  61790. constructor(name: string);
  61791. /**
  61792. * Gets the current class name
  61793. * @returns the class name
  61794. */
  61795. getClassName(): string;
  61796. /**
  61797. * Gets the world position input component
  61798. */
  61799. get worldPosition(): NodeMaterialConnectionPoint;
  61800. /**
  61801. * Gets the world normal input component
  61802. */
  61803. get worldNormal(): NodeMaterialConnectionPoint;
  61804. /**
  61805. * Gets the camera (or eye) position component
  61806. */
  61807. get cameraPosition(): NodeMaterialConnectionPoint;
  61808. /**
  61809. * Gets the glossiness component
  61810. */
  61811. get glossiness(): NodeMaterialConnectionPoint;
  61812. /**
  61813. * Gets the glossinness power component
  61814. */
  61815. get glossPower(): NodeMaterialConnectionPoint;
  61816. /**
  61817. * Gets the diffuse color component
  61818. */
  61819. get diffuseColor(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the specular color component
  61822. */
  61823. get specularColor(): NodeMaterialConnectionPoint;
  61824. /**
  61825. * Gets the diffuse output component
  61826. */
  61827. get diffuseOutput(): NodeMaterialConnectionPoint;
  61828. /**
  61829. * Gets the specular output component
  61830. */
  61831. get specularOutput(): NodeMaterialConnectionPoint;
  61832. /**
  61833. * Gets the shadow output component
  61834. */
  61835. get shadow(): NodeMaterialConnectionPoint;
  61836. autoConfigure(material: NodeMaterial): void;
  61837. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61838. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61839. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61840. private _injectVertexCode;
  61841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61842. serialize(): any;
  61843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61844. }
  61845. }
  61846. declare module BABYLON {
  61847. /**
  61848. * Block used to read a reflection texture from a sampler
  61849. */
  61850. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61851. /**
  61852. * Create a new ReflectionTextureBlock
  61853. * @param name defines the block name
  61854. */
  61855. constructor(name: string);
  61856. /**
  61857. * Gets the current class name
  61858. * @returns the class name
  61859. */
  61860. getClassName(): string;
  61861. /**
  61862. * Gets the world position input component
  61863. */
  61864. get position(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the world position input component
  61867. */
  61868. get worldPosition(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the world normal input component
  61871. */
  61872. get worldNormal(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the world input component
  61875. */
  61876. get world(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the camera (or eye) position component
  61879. */
  61880. get cameraPosition(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the view input component
  61883. */
  61884. get view(): NodeMaterialConnectionPoint;
  61885. /**
  61886. * Gets the rgb output component
  61887. */
  61888. get rgb(): NodeMaterialConnectionPoint;
  61889. /**
  61890. * Gets the rgba output component
  61891. */
  61892. get rgba(): NodeMaterialConnectionPoint;
  61893. /**
  61894. * Gets the r output component
  61895. */
  61896. get r(): NodeMaterialConnectionPoint;
  61897. /**
  61898. * Gets the g output component
  61899. */
  61900. get g(): NodeMaterialConnectionPoint;
  61901. /**
  61902. * Gets the b output component
  61903. */
  61904. get b(): NodeMaterialConnectionPoint;
  61905. /**
  61906. * Gets the a output component
  61907. */
  61908. get a(): NodeMaterialConnectionPoint;
  61909. autoConfigure(material: NodeMaterial): void;
  61910. protected _buildBlock(state: NodeMaterialBuildState): this;
  61911. }
  61912. }
  61913. declare module BABYLON {
  61914. /**
  61915. * Block used to add 2 vectors
  61916. */
  61917. export class AddBlock extends NodeMaterialBlock {
  61918. /**
  61919. * Creates a new AddBlock
  61920. * @param name defines the block name
  61921. */
  61922. constructor(name: string);
  61923. /**
  61924. * Gets the current class name
  61925. * @returns the class name
  61926. */
  61927. getClassName(): string;
  61928. /**
  61929. * Gets the left operand input component
  61930. */
  61931. get left(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the right operand input component
  61934. */
  61935. get right(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the output component
  61938. */
  61939. get output(): NodeMaterialConnectionPoint;
  61940. protected _buildBlock(state: NodeMaterialBuildState): this;
  61941. }
  61942. }
  61943. declare module BABYLON {
  61944. /**
  61945. * Block used to scale a vector by a float
  61946. */
  61947. export class ScaleBlock extends NodeMaterialBlock {
  61948. /**
  61949. * Creates a new ScaleBlock
  61950. * @param name defines the block name
  61951. */
  61952. constructor(name: string);
  61953. /**
  61954. * Gets the current class name
  61955. * @returns the class name
  61956. */
  61957. getClassName(): string;
  61958. /**
  61959. * Gets the input component
  61960. */
  61961. get input(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the factor input component
  61964. */
  61965. get factor(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the output component
  61968. */
  61969. get output(): NodeMaterialConnectionPoint;
  61970. protected _buildBlock(state: NodeMaterialBuildState): this;
  61971. }
  61972. }
  61973. declare module BABYLON {
  61974. /**
  61975. * Block used to clamp a float
  61976. */
  61977. export class ClampBlock extends NodeMaterialBlock {
  61978. /** Gets or sets the minimum range */
  61979. minimum: number;
  61980. /** Gets or sets the maximum range */
  61981. maximum: number;
  61982. /**
  61983. * Creates a new ClampBlock
  61984. * @param name defines the block name
  61985. */
  61986. constructor(name: string);
  61987. /**
  61988. * Gets the current class name
  61989. * @returns the class name
  61990. */
  61991. getClassName(): string;
  61992. /**
  61993. * Gets the value input component
  61994. */
  61995. get value(): NodeMaterialConnectionPoint;
  61996. /**
  61997. * Gets the output component
  61998. */
  61999. get output(): NodeMaterialConnectionPoint;
  62000. protected _buildBlock(state: NodeMaterialBuildState): this;
  62001. protected _dumpPropertiesCode(): string;
  62002. serialize(): any;
  62003. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62004. }
  62005. }
  62006. declare module BABYLON {
  62007. /**
  62008. * Block used to apply a cross product between 2 vectors
  62009. */
  62010. export class CrossBlock extends NodeMaterialBlock {
  62011. /**
  62012. * Creates a new CrossBlock
  62013. * @param name defines the block name
  62014. */
  62015. constructor(name: string);
  62016. /**
  62017. * Gets the current class name
  62018. * @returns the class name
  62019. */
  62020. getClassName(): string;
  62021. /**
  62022. * Gets the left operand input component
  62023. */
  62024. get left(): NodeMaterialConnectionPoint;
  62025. /**
  62026. * Gets the right operand input component
  62027. */
  62028. get right(): NodeMaterialConnectionPoint;
  62029. /**
  62030. * Gets the output component
  62031. */
  62032. get output(): NodeMaterialConnectionPoint;
  62033. protected _buildBlock(state: NodeMaterialBuildState): this;
  62034. }
  62035. }
  62036. declare module BABYLON {
  62037. /**
  62038. * Block used to apply a dot product between 2 vectors
  62039. */
  62040. export class DotBlock extends NodeMaterialBlock {
  62041. /**
  62042. * Creates a new DotBlock
  62043. * @param name defines the block name
  62044. */
  62045. constructor(name: string);
  62046. /**
  62047. * Gets the current class name
  62048. * @returns the class name
  62049. */
  62050. getClassName(): string;
  62051. /**
  62052. * Gets the left operand input component
  62053. */
  62054. get left(): NodeMaterialConnectionPoint;
  62055. /**
  62056. * Gets the right operand input component
  62057. */
  62058. get right(): NodeMaterialConnectionPoint;
  62059. /**
  62060. * Gets the output component
  62061. */
  62062. get output(): NodeMaterialConnectionPoint;
  62063. protected _buildBlock(state: NodeMaterialBuildState): this;
  62064. }
  62065. }
  62066. declare module BABYLON {
  62067. /**
  62068. * Block used to normalize a vector
  62069. */
  62070. export class NormalizeBlock extends NodeMaterialBlock {
  62071. /**
  62072. * Creates a new NormalizeBlock
  62073. * @param name defines the block name
  62074. */
  62075. constructor(name: string);
  62076. /**
  62077. * Gets the current class name
  62078. * @returns the class name
  62079. */
  62080. getClassName(): string;
  62081. /**
  62082. * Gets the input component
  62083. */
  62084. get input(): NodeMaterialConnectionPoint;
  62085. /**
  62086. * Gets the output component
  62087. */
  62088. get output(): NodeMaterialConnectionPoint;
  62089. protected _buildBlock(state: NodeMaterialBuildState): this;
  62090. }
  62091. }
  62092. declare module BABYLON {
  62093. /**
  62094. * Operations supported by the Trigonometry block
  62095. */
  62096. export enum TrigonometryBlockOperations {
  62097. /** Cos */
  62098. Cos = 0,
  62099. /** Sin */
  62100. Sin = 1,
  62101. /** Abs */
  62102. Abs = 2,
  62103. /** Exp */
  62104. Exp = 3,
  62105. /** Exp2 */
  62106. Exp2 = 4,
  62107. /** Round */
  62108. Round = 5,
  62109. /** Floor */
  62110. Floor = 6,
  62111. /** Ceiling */
  62112. Ceiling = 7,
  62113. /** Square root */
  62114. Sqrt = 8,
  62115. /** Log */
  62116. Log = 9,
  62117. /** Tangent */
  62118. Tan = 10,
  62119. /** Arc tangent */
  62120. ArcTan = 11,
  62121. /** Arc cosinus */
  62122. ArcCos = 12,
  62123. /** Arc sinus */
  62124. ArcSin = 13,
  62125. /** Fraction */
  62126. Fract = 14,
  62127. /** Sign */
  62128. Sign = 15,
  62129. /** To radians (from degrees) */
  62130. Radians = 16,
  62131. /** To degrees (from radians) */
  62132. Degrees = 17
  62133. }
  62134. /**
  62135. * Block used to apply trigonometry operation to floats
  62136. */
  62137. export class TrigonometryBlock extends NodeMaterialBlock {
  62138. /**
  62139. * Gets or sets the operation applied by the block
  62140. */
  62141. operation: TrigonometryBlockOperations;
  62142. /**
  62143. * Creates a new TrigonometryBlock
  62144. * @param name defines the block name
  62145. */
  62146. constructor(name: string);
  62147. /**
  62148. * Gets the current class name
  62149. * @returns the class name
  62150. */
  62151. getClassName(): string;
  62152. /**
  62153. * Gets the input component
  62154. */
  62155. get input(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the output component
  62158. */
  62159. get output(): NodeMaterialConnectionPoint;
  62160. protected _buildBlock(state: NodeMaterialBuildState): this;
  62161. serialize(): any;
  62162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62163. protected _dumpPropertiesCode(): string;
  62164. }
  62165. }
  62166. declare module BABYLON {
  62167. /**
  62168. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62169. */
  62170. export class ColorMergerBlock extends NodeMaterialBlock {
  62171. /**
  62172. * Create a new ColorMergerBlock
  62173. * @param name defines the block name
  62174. */
  62175. constructor(name: string);
  62176. /**
  62177. * Gets the current class name
  62178. * @returns the class name
  62179. */
  62180. getClassName(): string;
  62181. /**
  62182. * Gets the rgb component (input)
  62183. */
  62184. get rgbIn(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the r component (input)
  62187. */
  62188. get r(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the g component (input)
  62191. */
  62192. get g(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the b component (input)
  62195. */
  62196. get b(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the a component (input)
  62199. */
  62200. get a(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the rgba component (output)
  62203. */
  62204. get rgba(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the rgb component (output)
  62207. */
  62208. get rgbOut(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the rgb component (output)
  62211. * @deprecated Please use rgbOut instead.
  62212. */
  62213. get rgb(): NodeMaterialConnectionPoint;
  62214. protected _buildBlock(state: NodeMaterialBuildState): this;
  62215. }
  62216. }
  62217. declare module BABYLON {
  62218. /**
  62219. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62220. */
  62221. export class VectorSplitterBlock extends NodeMaterialBlock {
  62222. /**
  62223. * Create a new VectorSplitterBlock
  62224. * @param name defines the block name
  62225. */
  62226. constructor(name: string);
  62227. /**
  62228. * Gets the current class name
  62229. * @returns the class name
  62230. */
  62231. getClassName(): string;
  62232. /**
  62233. * Gets the xyzw component (input)
  62234. */
  62235. get xyzw(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the xyz component (input)
  62238. */
  62239. get xyzIn(): NodeMaterialConnectionPoint;
  62240. /**
  62241. * Gets the xy component (input)
  62242. */
  62243. get xyIn(): NodeMaterialConnectionPoint;
  62244. /**
  62245. * Gets the xyz component (output)
  62246. */
  62247. get xyzOut(): NodeMaterialConnectionPoint;
  62248. /**
  62249. * Gets the xy component (output)
  62250. */
  62251. get xyOut(): NodeMaterialConnectionPoint;
  62252. /**
  62253. * Gets the x component (output)
  62254. */
  62255. get x(): NodeMaterialConnectionPoint;
  62256. /**
  62257. * Gets the y component (output)
  62258. */
  62259. get y(): NodeMaterialConnectionPoint;
  62260. /**
  62261. * Gets the z component (output)
  62262. */
  62263. get z(): NodeMaterialConnectionPoint;
  62264. /**
  62265. * Gets the w component (output)
  62266. */
  62267. get w(): NodeMaterialConnectionPoint;
  62268. protected _inputRename(name: string): string;
  62269. protected _outputRename(name: string): string;
  62270. protected _buildBlock(state: NodeMaterialBuildState): this;
  62271. }
  62272. }
  62273. declare module BABYLON {
  62274. /**
  62275. * Block used to lerp between 2 values
  62276. */
  62277. export class LerpBlock extends NodeMaterialBlock {
  62278. /**
  62279. * Creates a new LerpBlock
  62280. * @param name defines the block name
  62281. */
  62282. constructor(name: string);
  62283. /**
  62284. * Gets the current class name
  62285. * @returns the class name
  62286. */
  62287. getClassName(): string;
  62288. /**
  62289. * Gets the left operand input component
  62290. */
  62291. get left(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the right operand input component
  62294. */
  62295. get right(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the gradient operand input component
  62298. */
  62299. get gradient(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the output component
  62302. */
  62303. get output(): NodeMaterialConnectionPoint;
  62304. protected _buildBlock(state: NodeMaterialBuildState): this;
  62305. }
  62306. }
  62307. declare module BABYLON {
  62308. /**
  62309. * Block used to divide 2 vectors
  62310. */
  62311. export class DivideBlock extends NodeMaterialBlock {
  62312. /**
  62313. * Creates a new DivideBlock
  62314. * @param name defines the block name
  62315. */
  62316. constructor(name: string);
  62317. /**
  62318. * Gets the current class name
  62319. * @returns the class name
  62320. */
  62321. getClassName(): string;
  62322. /**
  62323. * Gets the left operand input component
  62324. */
  62325. get left(): NodeMaterialConnectionPoint;
  62326. /**
  62327. * Gets the right operand input component
  62328. */
  62329. get right(): NodeMaterialConnectionPoint;
  62330. /**
  62331. * Gets the output component
  62332. */
  62333. get output(): NodeMaterialConnectionPoint;
  62334. protected _buildBlock(state: NodeMaterialBuildState): this;
  62335. }
  62336. }
  62337. declare module BABYLON {
  62338. /**
  62339. * Block used to subtract 2 vectors
  62340. */
  62341. export class SubtractBlock extends NodeMaterialBlock {
  62342. /**
  62343. * Creates a new SubtractBlock
  62344. * @param name defines the block name
  62345. */
  62346. constructor(name: string);
  62347. /**
  62348. * Gets the current class name
  62349. * @returns the class name
  62350. */
  62351. getClassName(): string;
  62352. /**
  62353. * Gets the left operand input component
  62354. */
  62355. get left(): NodeMaterialConnectionPoint;
  62356. /**
  62357. * Gets the right operand input component
  62358. */
  62359. get right(): NodeMaterialConnectionPoint;
  62360. /**
  62361. * Gets the output component
  62362. */
  62363. get output(): NodeMaterialConnectionPoint;
  62364. protected _buildBlock(state: NodeMaterialBuildState): this;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /**
  62369. * Block used to step a value
  62370. */
  62371. export class StepBlock extends NodeMaterialBlock {
  62372. /**
  62373. * Creates a new StepBlock
  62374. * @param name defines the block name
  62375. */
  62376. constructor(name: string);
  62377. /**
  62378. * Gets the current class name
  62379. * @returns the class name
  62380. */
  62381. getClassName(): string;
  62382. /**
  62383. * Gets the value operand input component
  62384. */
  62385. get value(): NodeMaterialConnectionPoint;
  62386. /**
  62387. * Gets the edge operand input component
  62388. */
  62389. get edge(): NodeMaterialConnectionPoint;
  62390. /**
  62391. * Gets the output component
  62392. */
  62393. get output(): NodeMaterialConnectionPoint;
  62394. protected _buildBlock(state: NodeMaterialBuildState): this;
  62395. }
  62396. }
  62397. declare module BABYLON {
  62398. /**
  62399. * Block used to get the opposite (1 - x) of a value
  62400. */
  62401. export class OneMinusBlock extends NodeMaterialBlock {
  62402. /**
  62403. * Creates a new OneMinusBlock
  62404. * @param name defines the block name
  62405. */
  62406. constructor(name: string);
  62407. /**
  62408. * Gets the current class name
  62409. * @returns the class name
  62410. */
  62411. getClassName(): string;
  62412. /**
  62413. * Gets the input component
  62414. */
  62415. get input(): NodeMaterialConnectionPoint;
  62416. /**
  62417. * Gets the output component
  62418. */
  62419. get output(): NodeMaterialConnectionPoint;
  62420. protected _buildBlock(state: NodeMaterialBuildState): this;
  62421. }
  62422. }
  62423. declare module BABYLON {
  62424. /**
  62425. * Block used to get the view direction
  62426. */
  62427. export class ViewDirectionBlock extends NodeMaterialBlock {
  62428. /**
  62429. * Creates a new ViewDirectionBlock
  62430. * @param name defines the block name
  62431. */
  62432. constructor(name: string);
  62433. /**
  62434. * Gets the current class name
  62435. * @returns the class name
  62436. */
  62437. getClassName(): string;
  62438. /**
  62439. * Gets the world position component
  62440. */
  62441. get worldPosition(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the camera position component
  62444. */
  62445. get cameraPosition(): NodeMaterialConnectionPoint;
  62446. /**
  62447. * Gets the output component
  62448. */
  62449. get output(): NodeMaterialConnectionPoint;
  62450. autoConfigure(material: NodeMaterial): void;
  62451. protected _buildBlock(state: NodeMaterialBuildState): this;
  62452. }
  62453. }
  62454. declare module BABYLON {
  62455. /**
  62456. * Block used to compute fresnel value
  62457. */
  62458. export class FresnelBlock extends NodeMaterialBlock {
  62459. /**
  62460. * Create a new FresnelBlock
  62461. * @param name defines the block name
  62462. */
  62463. constructor(name: string);
  62464. /**
  62465. * Gets the current class name
  62466. * @returns the class name
  62467. */
  62468. getClassName(): string;
  62469. /**
  62470. * Gets the world normal input component
  62471. */
  62472. get worldNormal(): NodeMaterialConnectionPoint;
  62473. /**
  62474. * Gets the view direction input component
  62475. */
  62476. get viewDirection(): NodeMaterialConnectionPoint;
  62477. /**
  62478. * Gets the bias input component
  62479. */
  62480. get bias(): NodeMaterialConnectionPoint;
  62481. /**
  62482. * Gets the camera (or eye) position component
  62483. */
  62484. get power(): NodeMaterialConnectionPoint;
  62485. /**
  62486. * Gets the fresnel output component
  62487. */
  62488. get fresnel(): NodeMaterialConnectionPoint;
  62489. autoConfigure(material: NodeMaterial): void;
  62490. protected _buildBlock(state: NodeMaterialBuildState): this;
  62491. }
  62492. }
  62493. declare module BABYLON {
  62494. /**
  62495. * Block used to get the max of 2 values
  62496. */
  62497. export class MaxBlock extends NodeMaterialBlock {
  62498. /**
  62499. * Creates a new MaxBlock
  62500. * @param name defines the block name
  62501. */
  62502. constructor(name: string);
  62503. /**
  62504. * Gets the current class name
  62505. * @returns the class name
  62506. */
  62507. getClassName(): string;
  62508. /**
  62509. * Gets the left operand input component
  62510. */
  62511. get left(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the right operand input component
  62514. */
  62515. get right(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the output component
  62518. */
  62519. get output(): NodeMaterialConnectionPoint;
  62520. protected _buildBlock(state: NodeMaterialBuildState): this;
  62521. }
  62522. }
  62523. declare module BABYLON {
  62524. /**
  62525. * Block used to get the min of 2 values
  62526. */
  62527. export class MinBlock extends NodeMaterialBlock {
  62528. /**
  62529. * Creates a new MinBlock
  62530. * @param name defines the block name
  62531. */
  62532. constructor(name: string);
  62533. /**
  62534. * Gets the current class name
  62535. * @returns the class name
  62536. */
  62537. getClassName(): string;
  62538. /**
  62539. * Gets the left operand input component
  62540. */
  62541. get left(): NodeMaterialConnectionPoint;
  62542. /**
  62543. * Gets the right operand input component
  62544. */
  62545. get right(): NodeMaterialConnectionPoint;
  62546. /**
  62547. * Gets the output component
  62548. */
  62549. get output(): NodeMaterialConnectionPoint;
  62550. protected _buildBlock(state: NodeMaterialBuildState): this;
  62551. }
  62552. }
  62553. declare module BABYLON {
  62554. /**
  62555. * Block used to get the distance between 2 values
  62556. */
  62557. export class DistanceBlock extends NodeMaterialBlock {
  62558. /**
  62559. * Creates a new DistanceBlock
  62560. * @param name defines the block name
  62561. */
  62562. constructor(name: string);
  62563. /**
  62564. * Gets the current class name
  62565. * @returns the class name
  62566. */
  62567. getClassName(): string;
  62568. /**
  62569. * Gets the left operand input component
  62570. */
  62571. get left(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the right operand input component
  62574. */
  62575. get right(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the output component
  62578. */
  62579. get output(): NodeMaterialConnectionPoint;
  62580. protected _buildBlock(state: NodeMaterialBuildState): this;
  62581. }
  62582. }
  62583. declare module BABYLON {
  62584. /**
  62585. * Block used to get the length of a vector
  62586. */
  62587. export class LengthBlock extends NodeMaterialBlock {
  62588. /**
  62589. * Creates a new LengthBlock
  62590. * @param name defines the block name
  62591. */
  62592. constructor(name: string);
  62593. /**
  62594. * Gets the current class name
  62595. * @returns the class name
  62596. */
  62597. getClassName(): string;
  62598. /**
  62599. * Gets the value input component
  62600. */
  62601. get value(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the output component
  62604. */
  62605. get output(): NodeMaterialConnectionPoint;
  62606. protected _buildBlock(state: NodeMaterialBuildState): this;
  62607. }
  62608. }
  62609. declare module BABYLON {
  62610. /**
  62611. * Block used to get negative version of a value (i.e. x * -1)
  62612. */
  62613. export class NegateBlock extends NodeMaterialBlock {
  62614. /**
  62615. * Creates a new NegateBlock
  62616. * @param name defines the block name
  62617. */
  62618. constructor(name: string);
  62619. /**
  62620. * Gets the current class name
  62621. * @returns the class name
  62622. */
  62623. getClassName(): string;
  62624. /**
  62625. * Gets the value input component
  62626. */
  62627. get value(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the output component
  62630. */
  62631. get output(): NodeMaterialConnectionPoint;
  62632. protected _buildBlock(state: NodeMaterialBuildState): this;
  62633. }
  62634. }
  62635. declare module BABYLON {
  62636. /**
  62637. * Block used to get the value of the first parameter raised to the power of the second
  62638. */
  62639. export class PowBlock extends NodeMaterialBlock {
  62640. /**
  62641. * Creates a new PowBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the value operand input component
  62652. */
  62653. get value(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the power operand input component
  62656. */
  62657. get power(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the output component
  62660. */
  62661. get output(): NodeMaterialConnectionPoint;
  62662. protected _buildBlock(state: NodeMaterialBuildState): this;
  62663. }
  62664. }
  62665. declare module BABYLON {
  62666. /**
  62667. * Block used to get a random number
  62668. */
  62669. export class RandomNumberBlock extends NodeMaterialBlock {
  62670. /**
  62671. * Creates a new RandomNumberBlock
  62672. * @param name defines the block name
  62673. */
  62674. constructor(name: string);
  62675. /**
  62676. * Gets the current class name
  62677. * @returns the class name
  62678. */
  62679. getClassName(): string;
  62680. /**
  62681. * Gets the seed input component
  62682. */
  62683. get seed(): NodeMaterialConnectionPoint;
  62684. /**
  62685. * Gets the output component
  62686. */
  62687. get output(): NodeMaterialConnectionPoint;
  62688. protected _buildBlock(state: NodeMaterialBuildState): this;
  62689. }
  62690. }
  62691. declare module BABYLON {
  62692. /**
  62693. * Block used to compute arc tangent of 2 values
  62694. */
  62695. export class ArcTan2Block extends NodeMaterialBlock {
  62696. /**
  62697. * Creates a new ArcTan2Block
  62698. * @param name defines the block name
  62699. */
  62700. constructor(name: string);
  62701. /**
  62702. * Gets the current class name
  62703. * @returns the class name
  62704. */
  62705. getClassName(): string;
  62706. /**
  62707. * Gets the x operand input component
  62708. */
  62709. get x(): NodeMaterialConnectionPoint;
  62710. /**
  62711. * Gets the y operand input component
  62712. */
  62713. get y(): NodeMaterialConnectionPoint;
  62714. /**
  62715. * Gets the output component
  62716. */
  62717. get output(): NodeMaterialConnectionPoint;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * Block used to smooth step a value
  62724. */
  62725. export class SmoothStepBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Creates a new SmoothStepBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the value operand input component
  62738. */
  62739. get value(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the first edge operand input component
  62742. */
  62743. get edge0(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the second edge operand input component
  62746. */
  62747. get edge1(): NodeMaterialConnectionPoint;
  62748. /**
  62749. * Gets the output component
  62750. */
  62751. get output(): NodeMaterialConnectionPoint;
  62752. protected _buildBlock(state: NodeMaterialBuildState): this;
  62753. }
  62754. }
  62755. declare module BABYLON {
  62756. /**
  62757. * Block used to get the reciprocal (1 / x) of a value
  62758. */
  62759. export class ReciprocalBlock extends NodeMaterialBlock {
  62760. /**
  62761. * Creates a new ReciprocalBlock
  62762. * @param name defines the block name
  62763. */
  62764. constructor(name: string);
  62765. /**
  62766. * Gets the current class name
  62767. * @returns the class name
  62768. */
  62769. getClassName(): string;
  62770. /**
  62771. * Gets the input component
  62772. */
  62773. get input(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the output component
  62776. */
  62777. get output(): NodeMaterialConnectionPoint;
  62778. protected _buildBlock(state: NodeMaterialBuildState): this;
  62779. }
  62780. }
  62781. declare module BABYLON {
  62782. /**
  62783. * Block used to replace a color by another one
  62784. */
  62785. export class ReplaceColorBlock extends NodeMaterialBlock {
  62786. /**
  62787. * Creates a new ReplaceColorBlock
  62788. * @param name defines the block name
  62789. */
  62790. constructor(name: string);
  62791. /**
  62792. * Gets the current class name
  62793. * @returns the class name
  62794. */
  62795. getClassName(): string;
  62796. /**
  62797. * Gets the value input component
  62798. */
  62799. get value(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the reference input component
  62802. */
  62803. get reference(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the distance input component
  62806. */
  62807. get distance(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the replacement input component
  62810. */
  62811. get replacement(): NodeMaterialConnectionPoint;
  62812. /**
  62813. * Gets the output component
  62814. */
  62815. get output(): NodeMaterialConnectionPoint;
  62816. protected _buildBlock(state: NodeMaterialBuildState): this;
  62817. }
  62818. }
  62819. declare module BABYLON {
  62820. /**
  62821. * Block used to posterize a value
  62822. * @see https://en.wikipedia.org/wiki/Posterization
  62823. */
  62824. export class PosterizeBlock extends NodeMaterialBlock {
  62825. /**
  62826. * Creates a new PosterizeBlock
  62827. * @param name defines the block name
  62828. */
  62829. constructor(name: string);
  62830. /**
  62831. * Gets the current class name
  62832. * @returns the class name
  62833. */
  62834. getClassName(): string;
  62835. /**
  62836. * Gets the value input component
  62837. */
  62838. get value(): NodeMaterialConnectionPoint;
  62839. /**
  62840. * Gets the steps input component
  62841. */
  62842. get steps(): NodeMaterialConnectionPoint;
  62843. /**
  62844. * Gets the output component
  62845. */
  62846. get output(): NodeMaterialConnectionPoint;
  62847. protected _buildBlock(state: NodeMaterialBuildState): this;
  62848. }
  62849. }
  62850. declare module BABYLON {
  62851. /**
  62852. * Operations supported by the Wave block
  62853. */
  62854. export enum WaveBlockKind {
  62855. /** SawTooth */
  62856. SawTooth = 0,
  62857. /** Square */
  62858. Square = 1,
  62859. /** Triangle */
  62860. Triangle = 2
  62861. }
  62862. /**
  62863. * Block used to apply wave operation to floats
  62864. */
  62865. export class WaveBlock extends NodeMaterialBlock {
  62866. /**
  62867. * Gets or sets the kibnd of wave to be applied by the block
  62868. */
  62869. kind: WaveBlockKind;
  62870. /**
  62871. * Creates a new WaveBlock
  62872. * @param name defines the block name
  62873. */
  62874. constructor(name: string);
  62875. /**
  62876. * Gets the current class name
  62877. * @returns the class name
  62878. */
  62879. getClassName(): string;
  62880. /**
  62881. * Gets the input component
  62882. */
  62883. get input(): NodeMaterialConnectionPoint;
  62884. /**
  62885. * Gets the output component
  62886. */
  62887. get output(): NodeMaterialConnectionPoint;
  62888. protected _buildBlock(state: NodeMaterialBuildState): this;
  62889. serialize(): any;
  62890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62891. }
  62892. }
  62893. declare module BABYLON {
  62894. /**
  62895. * Class used to store a color step for the GradientBlock
  62896. */
  62897. export class GradientBlockColorStep {
  62898. /**
  62899. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62900. */
  62901. step: number;
  62902. /**
  62903. * Gets or sets the color associated with this step
  62904. */
  62905. color: Color3;
  62906. /**
  62907. * Creates a new GradientBlockColorStep
  62908. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62909. * @param color defines the color associated with this step
  62910. */
  62911. constructor(
  62912. /**
  62913. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62914. */
  62915. step: number,
  62916. /**
  62917. * Gets or sets the color associated with this step
  62918. */
  62919. color: Color3);
  62920. }
  62921. /**
  62922. * Block used to return a color from a gradient based on an input value between 0 and 1
  62923. */
  62924. export class GradientBlock extends NodeMaterialBlock {
  62925. /**
  62926. * Gets or sets the list of color steps
  62927. */
  62928. colorSteps: GradientBlockColorStep[];
  62929. /**
  62930. * Creates a new GradientBlock
  62931. * @param name defines the block name
  62932. */
  62933. constructor(name: string);
  62934. /**
  62935. * Gets the current class name
  62936. * @returns the class name
  62937. */
  62938. getClassName(): string;
  62939. /**
  62940. * Gets the gradient input component
  62941. */
  62942. get gradient(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the output component
  62945. */
  62946. get output(): NodeMaterialConnectionPoint;
  62947. private _writeColorConstant;
  62948. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62949. serialize(): any;
  62950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62951. protected _dumpPropertiesCode(): string;
  62952. }
  62953. }
  62954. declare module BABYLON {
  62955. /**
  62956. * Block used to normalize lerp between 2 values
  62957. */
  62958. export class NLerpBlock extends NodeMaterialBlock {
  62959. /**
  62960. * Creates a new NLerpBlock
  62961. * @param name defines the block name
  62962. */
  62963. constructor(name: string);
  62964. /**
  62965. * Gets the current class name
  62966. * @returns the class name
  62967. */
  62968. getClassName(): string;
  62969. /**
  62970. * Gets the left operand input component
  62971. */
  62972. get left(): NodeMaterialConnectionPoint;
  62973. /**
  62974. * Gets the right operand input component
  62975. */
  62976. get right(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the gradient operand input component
  62979. */
  62980. get gradient(): NodeMaterialConnectionPoint;
  62981. /**
  62982. * Gets the output component
  62983. */
  62984. get output(): NodeMaterialConnectionPoint;
  62985. protected _buildBlock(state: NodeMaterialBuildState): this;
  62986. }
  62987. }
  62988. declare module BABYLON {
  62989. /**
  62990. * block used to Generate a Worley Noise 3D Noise Pattern
  62991. */
  62992. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62993. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62994. manhattanDistance: boolean;
  62995. /**
  62996. * Creates a new WorleyNoise3DBlock
  62997. * @param name defines the block name
  62998. */
  62999. constructor(name: string);
  63000. /**
  63001. * Gets the current class name
  63002. * @returns the class name
  63003. */
  63004. getClassName(): string;
  63005. /**
  63006. * Gets the seed input component
  63007. */
  63008. get seed(): NodeMaterialConnectionPoint;
  63009. /**
  63010. * Gets the jitter input component
  63011. */
  63012. get jitter(): NodeMaterialConnectionPoint;
  63013. /**
  63014. * Gets the output component
  63015. */
  63016. get output(): NodeMaterialConnectionPoint;
  63017. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63018. /**
  63019. * Exposes the properties to the UI?
  63020. */
  63021. protected _dumpPropertiesCode(): string;
  63022. /**
  63023. * Exposes the properties to the Seralize?
  63024. */
  63025. serialize(): any;
  63026. /**
  63027. * Exposes the properties to the deseralize?
  63028. */
  63029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63030. }
  63031. }
  63032. declare module BABYLON {
  63033. /**
  63034. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63035. */
  63036. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63037. /**
  63038. * Creates a new SimplexPerlin3DBlock
  63039. * @param name defines the block name
  63040. */
  63041. constructor(name: string);
  63042. /**
  63043. * Gets the current class name
  63044. * @returns the class name
  63045. */
  63046. getClassName(): string;
  63047. /**
  63048. * Gets the seed operand input component
  63049. */
  63050. get seed(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the output component
  63053. */
  63054. get output(): NodeMaterialConnectionPoint;
  63055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63056. }
  63057. }
  63058. declare module BABYLON {
  63059. /**
  63060. * Block used to blend normals
  63061. */
  63062. export class NormalBlendBlock extends NodeMaterialBlock {
  63063. /**
  63064. * Creates a new NormalBlendBlock
  63065. * @param name defines the block name
  63066. */
  63067. constructor(name: string);
  63068. /**
  63069. * Gets the current class name
  63070. * @returns the class name
  63071. */
  63072. getClassName(): string;
  63073. /**
  63074. * Gets the first input component
  63075. */
  63076. get normalMap0(): NodeMaterialConnectionPoint;
  63077. /**
  63078. * Gets the second input component
  63079. */
  63080. get normalMap1(): NodeMaterialConnectionPoint;
  63081. /**
  63082. * Gets the output component
  63083. */
  63084. get output(): NodeMaterialConnectionPoint;
  63085. protected _buildBlock(state: NodeMaterialBuildState): this;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. /**
  63090. * Block used to rotate a 2d vector by a given angle
  63091. */
  63092. export class Rotate2dBlock extends NodeMaterialBlock {
  63093. /**
  63094. * Creates a new Rotate2dBlock
  63095. * @param name defines the block name
  63096. */
  63097. constructor(name: string);
  63098. /**
  63099. * Gets the current class name
  63100. * @returns the class name
  63101. */
  63102. getClassName(): string;
  63103. /**
  63104. * Gets the input vector
  63105. */
  63106. get input(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the input angle
  63109. */
  63110. get angle(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the output component
  63113. */
  63114. get output(): NodeMaterialConnectionPoint;
  63115. autoConfigure(material: NodeMaterial): void;
  63116. protected _buildBlock(state: NodeMaterialBuildState): this;
  63117. }
  63118. }
  63119. declare module BABYLON {
  63120. /**
  63121. * Block used to get the reflected vector from a direction and a normal
  63122. */
  63123. export class ReflectBlock extends NodeMaterialBlock {
  63124. /**
  63125. * Creates a new ReflectBlock
  63126. * @param name defines the block name
  63127. */
  63128. constructor(name: string);
  63129. /**
  63130. * Gets the current class name
  63131. * @returns the class name
  63132. */
  63133. getClassName(): string;
  63134. /**
  63135. * Gets the incident component
  63136. */
  63137. get incident(): NodeMaterialConnectionPoint;
  63138. /**
  63139. * Gets the normal component
  63140. */
  63141. get normal(): NodeMaterialConnectionPoint;
  63142. /**
  63143. * Gets the output component
  63144. */
  63145. get output(): NodeMaterialConnectionPoint;
  63146. protected _buildBlock(state: NodeMaterialBuildState): this;
  63147. }
  63148. }
  63149. declare module BABYLON {
  63150. /**
  63151. * Block used to get the refracted vector from a direction and a normal
  63152. */
  63153. export class RefractBlock extends NodeMaterialBlock {
  63154. /**
  63155. * Creates a new RefractBlock
  63156. * @param name defines the block name
  63157. */
  63158. constructor(name: string);
  63159. /**
  63160. * Gets the current class name
  63161. * @returns the class name
  63162. */
  63163. getClassName(): string;
  63164. /**
  63165. * Gets the incident component
  63166. */
  63167. get incident(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the normal component
  63170. */
  63171. get normal(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the index of refraction component
  63174. */
  63175. get ior(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the output component
  63178. */
  63179. get output(): NodeMaterialConnectionPoint;
  63180. protected _buildBlock(state: NodeMaterialBuildState): this;
  63181. }
  63182. }
  63183. declare module BABYLON {
  63184. /**
  63185. * Block used to desaturate a color
  63186. */
  63187. export class DesaturateBlock extends NodeMaterialBlock {
  63188. /**
  63189. * Creates a new DesaturateBlock
  63190. * @param name defines the block name
  63191. */
  63192. constructor(name: string);
  63193. /**
  63194. * Gets the current class name
  63195. * @returns the class name
  63196. */
  63197. getClassName(): string;
  63198. /**
  63199. * Gets the color operand input component
  63200. */
  63201. get color(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the level operand input component
  63204. */
  63205. get level(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the output component
  63208. */
  63209. get output(): NodeMaterialConnectionPoint;
  63210. protected _buildBlock(state: NodeMaterialBuildState): this;
  63211. }
  63212. }
  63213. declare module BABYLON {
  63214. /**
  63215. * Block used to implement the ambient occlusion module of the PBR material
  63216. */
  63217. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63218. /**
  63219. * Create a new AmbientOcclusionBlock
  63220. * @param name defines the block name
  63221. */
  63222. constructor(name: string);
  63223. /**
  63224. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63225. */
  63226. useAmbientInGrayScale: boolean;
  63227. /**
  63228. * Initialize the block and prepare the context for build
  63229. * @param state defines the state that will be used for the build
  63230. */
  63231. initialize(state: NodeMaterialBuildState): void;
  63232. /**
  63233. * Gets the current class name
  63234. * @returns the class name
  63235. */
  63236. getClassName(): string;
  63237. /**
  63238. * Gets the texture input component
  63239. */
  63240. get texture(): NodeMaterialConnectionPoint;
  63241. /**
  63242. * Gets the texture intensity component
  63243. */
  63244. get intensity(): NodeMaterialConnectionPoint;
  63245. /**
  63246. * Gets the direct light intensity input component
  63247. */
  63248. get directLightIntensity(): NodeMaterialConnectionPoint;
  63249. /**
  63250. * Gets the ambient occlusion object output component
  63251. */
  63252. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the main code of the block (fragment side)
  63255. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63256. * @returns the shader code
  63257. */
  63258. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63259. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63260. protected _buildBlock(state: NodeMaterialBuildState): this;
  63261. protected _dumpPropertiesCode(): string;
  63262. serialize(): any;
  63263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63264. }
  63265. }
  63266. declare module BABYLON {
  63267. /**
  63268. * Block used to implement the reflection module of the PBR material
  63269. */
  63270. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63271. /** @hidden */
  63272. _defineLODReflectionAlpha: string;
  63273. /** @hidden */
  63274. _defineLinearSpecularReflection: string;
  63275. private _vEnvironmentIrradianceName;
  63276. /** @hidden */
  63277. _vReflectionMicrosurfaceInfosName: string;
  63278. /** @hidden */
  63279. _vReflectionInfosName: string;
  63280. /** @hidden */
  63281. _vReflectionFilteringInfoName: string;
  63282. private _scene;
  63283. /**
  63284. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63285. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63286. * It's less burden on the user side in the editor part.
  63287. */
  63288. /** @hidden */
  63289. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63290. /** @hidden */
  63291. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63292. /** @hidden */
  63293. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63294. /**
  63295. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63296. * diffuse part of the IBL.
  63297. */
  63298. useSphericalHarmonics: boolean;
  63299. /**
  63300. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63301. */
  63302. forceIrradianceInFragment: boolean;
  63303. /**
  63304. * Create a new ReflectionBlock
  63305. * @param name defines the block name
  63306. */
  63307. constructor(name: string);
  63308. /**
  63309. * Gets the current class name
  63310. * @returns the class name
  63311. */
  63312. getClassName(): string;
  63313. /**
  63314. * Gets the position input component
  63315. */
  63316. get position(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the world position input component
  63319. */
  63320. get worldPosition(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the world normal input component
  63323. */
  63324. get worldNormal(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the world input component
  63327. */
  63328. get world(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the camera (or eye) position component
  63331. */
  63332. get cameraPosition(): NodeMaterialConnectionPoint;
  63333. /**
  63334. * Gets the view input component
  63335. */
  63336. get view(): NodeMaterialConnectionPoint;
  63337. /**
  63338. * Gets the color input component
  63339. */
  63340. get color(): NodeMaterialConnectionPoint;
  63341. /**
  63342. * Gets the reflection object output component
  63343. */
  63344. get reflection(): NodeMaterialConnectionPoint;
  63345. /**
  63346. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63347. */
  63348. get hasTexture(): boolean;
  63349. /**
  63350. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63351. */
  63352. get reflectionColor(): string;
  63353. protected _getTexture(): Nullable<BaseTexture>;
  63354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63356. /**
  63357. * Gets the code to inject in the vertex shader
  63358. * @param state current state of the node material building
  63359. * @returns the shader code
  63360. */
  63361. handleVertexSide(state: NodeMaterialBuildState): string;
  63362. /**
  63363. * Gets the main code of the block (fragment side)
  63364. * @param state current state of the node material building
  63365. * @param normalVarName name of the existing variable corresponding to the normal
  63366. * @returns the shader code
  63367. */
  63368. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63369. protected _buildBlock(state: NodeMaterialBuildState): this;
  63370. protected _dumpPropertiesCode(): string;
  63371. serialize(): any;
  63372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63373. }
  63374. }
  63375. declare module BABYLON {
  63376. /**
  63377. * Block used to implement the sheen module of the PBR material
  63378. */
  63379. export class SheenBlock extends NodeMaterialBlock {
  63380. /**
  63381. * Create a new SheenBlock
  63382. * @param name defines the block name
  63383. */
  63384. constructor(name: string);
  63385. /**
  63386. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63387. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63388. * making it easier to setup and tweak the effect
  63389. */
  63390. albedoScaling: boolean;
  63391. /**
  63392. * Defines if the sheen is linked to the sheen color.
  63393. */
  63394. linkSheenWithAlbedo: boolean;
  63395. /**
  63396. * Initialize the block and prepare the context for build
  63397. * @param state defines the state that will be used for the build
  63398. */
  63399. initialize(state: NodeMaterialBuildState): void;
  63400. /**
  63401. * Gets the current class name
  63402. * @returns the class name
  63403. */
  63404. getClassName(): string;
  63405. /**
  63406. * Gets the intensity input component
  63407. */
  63408. get intensity(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the color input component
  63411. */
  63412. get color(): NodeMaterialConnectionPoint;
  63413. /**
  63414. * Gets the roughness input component
  63415. */
  63416. get roughness(): NodeMaterialConnectionPoint;
  63417. /**
  63418. * Gets the sheen object output component
  63419. */
  63420. get sheen(): NodeMaterialConnectionPoint;
  63421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63422. /**
  63423. * Gets the main code of the block (fragment side)
  63424. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63425. * @returns the shader code
  63426. */
  63427. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63428. protected _buildBlock(state: NodeMaterialBuildState): this;
  63429. protected _dumpPropertiesCode(): string;
  63430. serialize(): any;
  63431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63432. }
  63433. }
  63434. declare module BABYLON {
  63435. /**
  63436. * Block used to implement the reflectivity module of the PBR material
  63437. */
  63438. export class ReflectivityBlock extends NodeMaterialBlock {
  63439. private _metallicReflectanceColor;
  63440. private _metallicF0Factor;
  63441. /** @hidden */
  63442. _vMetallicReflectanceFactorsName: string;
  63443. /**
  63444. * The property below is set by the main PBR block prior to calling methods of this class.
  63445. */
  63446. /** @hidden */
  63447. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63448. /**
  63449. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63450. */
  63451. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63452. /**
  63453. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63454. */
  63455. useMetallnessFromMetallicTextureBlue: boolean;
  63456. /**
  63457. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63458. */
  63459. useRoughnessFromMetallicTextureAlpha: boolean;
  63460. /**
  63461. * Specifies if the metallic texture contains the roughness information in its green channel.
  63462. */
  63463. useRoughnessFromMetallicTextureGreen: boolean;
  63464. /**
  63465. * Create a new ReflectivityBlock
  63466. * @param name defines the block name
  63467. */
  63468. constructor(name: string);
  63469. /**
  63470. * Initialize the block and prepare the context for build
  63471. * @param state defines the state that will be used for the build
  63472. */
  63473. initialize(state: NodeMaterialBuildState): void;
  63474. /**
  63475. * Gets the current class name
  63476. * @returns the class name
  63477. */
  63478. getClassName(): string;
  63479. /**
  63480. * Gets the metallic input component
  63481. */
  63482. get metallic(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the roughness input component
  63485. */
  63486. get roughness(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the texture input component
  63489. */
  63490. get texture(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the reflectivity object output component
  63493. */
  63494. get reflectivity(): NodeMaterialConnectionPoint;
  63495. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63496. /**
  63497. * Gets the main code of the block (fragment side)
  63498. * @param state current state of the node material building
  63499. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63500. * @returns the shader code
  63501. */
  63502. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63503. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63504. protected _buildBlock(state: NodeMaterialBuildState): this;
  63505. protected _dumpPropertiesCode(): string;
  63506. serialize(): any;
  63507. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63508. }
  63509. }
  63510. declare module BABYLON {
  63511. /**
  63512. * Block used to implement the anisotropy module of the PBR material
  63513. */
  63514. export class AnisotropyBlock extends NodeMaterialBlock {
  63515. /**
  63516. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63517. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63518. * It's less burden on the user side in the editor part.
  63519. */
  63520. /** @hidden */
  63521. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63522. /** @hidden */
  63523. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63524. /**
  63525. * Create a new AnisotropyBlock
  63526. * @param name defines the block name
  63527. */
  63528. constructor(name: string);
  63529. /**
  63530. * Initialize the block and prepare the context for build
  63531. * @param state defines the state that will be used for the build
  63532. */
  63533. initialize(state: NodeMaterialBuildState): void;
  63534. /**
  63535. * Gets the current class name
  63536. * @returns the class name
  63537. */
  63538. getClassName(): string;
  63539. /**
  63540. * Gets the intensity input component
  63541. */
  63542. get intensity(): NodeMaterialConnectionPoint;
  63543. /**
  63544. * Gets the direction input component
  63545. */
  63546. get direction(): NodeMaterialConnectionPoint;
  63547. /**
  63548. * Gets the texture input component
  63549. */
  63550. get texture(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the uv input component
  63553. */
  63554. get uv(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the worldTangent input component
  63557. */
  63558. get worldTangent(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the anisotropy object output component
  63561. */
  63562. get anisotropy(): NodeMaterialConnectionPoint;
  63563. private _generateTBNSpace;
  63564. /**
  63565. * Gets the main code of the block (fragment side)
  63566. * @param state current state of the node material building
  63567. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63568. * @returns the shader code
  63569. */
  63570. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63571. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63572. protected _buildBlock(state: NodeMaterialBuildState): this;
  63573. }
  63574. }
  63575. declare module BABYLON {
  63576. /**
  63577. * Block used to implement the clear coat module of the PBR material
  63578. */
  63579. export class ClearCoatBlock extends NodeMaterialBlock {
  63580. private _scene;
  63581. /**
  63582. * Create a new ClearCoatBlock
  63583. * @param name defines the block name
  63584. */
  63585. constructor(name: string);
  63586. /**
  63587. * Initialize the block and prepare the context for build
  63588. * @param state defines the state that will be used for the build
  63589. */
  63590. initialize(state: NodeMaterialBuildState): void;
  63591. /**
  63592. * Gets the current class name
  63593. * @returns the class name
  63594. */
  63595. getClassName(): string;
  63596. /**
  63597. * Gets the intensity input component
  63598. */
  63599. get intensity(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the roughness input component
  63602. */
  63603. get roughness(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the ior input component
  63606. */
  63607. get ior(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the texture input component
  63610. */
  63611. get texture(): NodeMaterialConnectionPoint;
  63612. /**
  63613. * Gets the bump texture input component
  63614. */
  63615. get bumpTexture(): NodeMaterialConnectionPoint;
  63616. /**
  63617. * Gets the uv input component
  63618. */
  63619. get uv(): NodeMaterialConnectionPoint;
  63620. /**
  63621. * Gets the tint color input component
  63622. */
  63623. get tintColor(): NodeMaterialConnectionPoint;
  63624. /**
  63625. * Gets the tint "at distance" input component
  63626. */
  63627. get tintAtDistance(): NodeMaterialConnectionPoint;
  63628. /**
  63629. * Gets the tint thickness input component
  63630. */
  63631. get tintThickness(): NodeMaterialConnectionPoint;
  63632. /**
  63633. * Gets the world tangent input component
  63634. */
  63635. get worldTangent(): NodeMaterialConnectionPoint;
  63636. /**
  63637. * Gets the clear coat object output component
  63638. */
  63639. get clearcoat(): NodeMaterialConnectionPoint;
  63640. autoConfigure(material: NodeMaterial): void;
  63641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63642. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63643. private _generateTBNSpace;
  63644. /**
  63645. * Gets the main code of the block (fragment side)
  63646. * @param state current state of the node material building
  63647. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63648. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63649. * @param worldPosVarName name of the variable holding the world position
  63650. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63651. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63652. * @param worldNormalVarName name of the variable holding the world normal
  63653. * @returns the shader code
  63654. */
  63655. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63656. protected _buildBlock(state: NodeMaterialBuildState): this;
  63657. }
  63658. }
  63659. declare module BABYLON {
  63660. /**
  63661. * Block used to implement the sub surface module of the PBR material
  63662. */
  63663. export class SubSurfaceBlock extends NodeMaterialBlock {
  63664. /**
  63665. * Create a new SubSurfaceBlock
  63666. * @param name defines the block name
  63667. */
  63668. constructor(name: string);
  63669. /**
  63670. * Stores the intensity of the different subsurface effects in the thickness texture.
  63671. * * the green channel is the translucency intensity.
  63672. * * the blue channel is the scattering intensity.
  63673. * * the alpha channel is the refraction intensity.
  63674. */
  63675. useMaskFromThicknessTexture: boolean;
  63676. /**
  63677. * Initialize the block and prepare the context for build
  63678. * @param state defines the state that will be used for the build
  63679. */
  63680. initialize(state: NodeMaterialBuildState): void;
  63681. /**
  63682. * Gets the current class name
  63683. * @returns the class name
  63684. */
  63685. getClassName(): string;
  63686. /**
  63687. * Gets the min thickness input component
  63688. */
  63689. get minThickness(): NodeMaterialConnectionPoint;
  63690. /**
  63691. * Gets the max thickness input component
  63692. */
  63693. get maxThickness(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the thickness texture component
  63696. */
  63697. get thicknessTexture(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the tint color input component
  63700. */
  63701. get tintColor(): NodeMaterialConnectionPoint;
  63702. /**
  63703. * Gets the translucency intensity input component
  63704. */
  63705. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the translucency diffusion distance input component
  63708. */
  63709. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the refraction object parameters
  63712. */
  63713. get refraction(): NodeMaterialConnectionPoint;
  63714. /**
  63715. * Gets the sub surface object output component
  63716. */
  63717. get subsurface(): NodeMaterialConnectionPoint;
  63718. autoConfigure(material: NodeMaterial): void;
  63719. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63720. /**
  63721. * Gets the main code of the block (fragment side)
  63722. * @param state current state of the node material building
  63723. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63724. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63725. * @param worldPosVarName name of the variable holding the world position
  63726. * @returns the shader code
  63727. */
  63728. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63729. protected _buildBlock(state: NodeMaterialBuildState): this;
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /**
  63734. * Block used to implement the PBR metallic/roughness model
  63735. */
  63736. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63737. /**
  63738. * Gets or sets the light associated with this block
  63739. */
  63740. light: Nullable<Light>;
  63741. private _lightId;
  63742. private _scene;
  63743. private _environmentBRDFTexture;
  63744. private _environmentBrdfSamplerName;
  63745. private _vNormalWName;
  63746. private _invertNormalName;
  63747. /**
  63748. * Create a new ReflectionBlock
  63749. * @param name defines the block name
  63750. */
  63751. constructor(name: string);
  63752. /**
  63753. * Intensity of the direct lights e.g. the four lights available in your scene.
  63754. * This impacts both the direct diffuse and specular highlights.
  63755. */
  63756. directIntensity: number;
  63757. /**
  63758. * Intensity of the environment e.g. how much the environment will light the object
  63759. * either through harmonics for rough material or through the refelction for shiny ones.
  63760. */
  63761. environmentIntensity: number;
  63762. /**
  63763. * This is a special control allowing the reduction of the specular highlights coming from the
  63764. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63765. */
  63766. specularIntensity: number;
  63767. /**
  63768. * Defines the falloff type used in this material.
  63769. * It by default is Physical.
  63770. */
  63771. lightFalloff: number;
  63772. /**
  63773. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63774. */
  63775. useAlphaFromAlbedoTexture: boolean;
  63776. /**
  63777. * Specifies that alpha test should be used
  63778. */
  63779. useAlphaTest: boolean;
  63780. /**
  63781. * Defines the alpha limits in alpha test mode.
  63782. */
  63783. alphaTestCutoff: number;
  63784. /**
  63785. * Specifies that alpha blending should be used
  63786. */
  63787. useAlphaBlending: boolean;
  63788. /**
  63789. * Defines if the alpha value should be determined via the rgb values.
  63790. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63791. */
  63792. opacityRGB: boolean;
  63793. /**
  63794. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63795. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63796. */
  63797. useRadianceOverAlpha: boolean;
  63798. /**
  63799. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63800. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63801. */
  63802. useSpecularOverAlpha: boolean;
  63803. /**
  63804. * Enables specular anti aliasing in the PBR shader.
  63805. * It will both interacts on the Geometry for analytical and IBL lighting.
  63806. * It also prefilter the roughness map based on the bump values.
  63807. */
  63808. enableSpecularAntiAliasing: boolean;
  63809. /**
  63810. * Enables realtime filtering on the texture.
  63811. */
  63812. realTimeFiltering: boolean;
  63813. /**
  63814. * Quality switch for realtime filtering
  63815. */
  63816. realTimeFilteringQuality: number;
  63817. /**
  63818. * Defines if the material uses energy conservation.
  63819. */
  63820. useEnergyConservation: boolean;
  63821. /**
  63822. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63823. * too much the area relying on ambient texture to define their ambient occlusion.
  63824. */
  63825. useRadianceOcclusion: boolean;
  63826. /**
  63827. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63828. * makes the reflect vector face the model (under horizon).
  63829. */
  63830. useHorizonOcclusion: boolean;
  63831. /**
  63832. * If set to true, no lighting calculations will be applied.
  63833. */
  63834. unlit: boolean;
  63835. /**
  63836. * Force normal to face away from face.
  63837. */
  63838. forceNormalForward: boolean;
  63839. /**
  63840. * Defines the material debug mode.
  63841. * It helps seeing only some components of the material while troubleshooting.
  63842. */
  63843. debugMode: number;
  63844. /**
  63845. * Specify from where on screen the debug mode should start.
  63846. * The value goes from -1 (full screen) to 1 (not visible)
  63847. * It helps with side by side comparison against the final render
  63848. * This defaults to 0
  63849. */
  63850. debugLimit: number;
  63851. /**
  63852. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63853. * You can use the factor to better multiply the final value.
  63854. */
  63855. debugFactor: number;
  63856. /**
  63857. * Initialize the block and prepare the context for build
  63858. * @param state defines the state that will be used for the build
  63859. */
  63860. initialize(state: NodeMaterialBuildState): void;
  63861. /**
  63862. * Gets the current class name
  63863. * @returns the class name
  63864. */
  63865. getClassName(): string;
  63866. /**
  63867. * Gets the world position input component
  63868. */
  63869. get worldPosition(): NodeMaterialConnectionPoint;
  63870. /**
  63871. * Gets the world normal input component
  63872. */
  63873. get worldNormal(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the perturbed normal input component
  63876. */
  63877. get perturbedNormal(): NodeMaterialConnectionPoint;
  63878. /**
  63879. * Gets the camera position input component
  63880. */
  63881. get cameraPosition(): NodeMaterialConnectionPoint;
  63882. /**
  63883. * Gets the base color input component
  63884. */
  63885. get baseColor(): NodeMaterialConnectionPoint;
  63886. /**
  63887. * Gets the opacity texture input component
  63888. */
  63889. get opacityTexture(): NodeMaterialConnectionPoint;
  63890. /**
  63891. * Gets the ambient color input component
  63892. */
  63893. get ambientColor(): NodeMaterialConnectionPoint;
  63894. /**
  63895. * Gets the reflectivity object parameters
  63896. */
  63897. get reflectivity(): NodeMaterialConnectionPoint;
  63898. /**
  63899. * Gets the ambient occlusion object parameters
  63900. */
  63901. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the reflection object parameters
  63904. */
  63905. get reflection(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the sheen object parameters
  63908. */
  63909. get sheen(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the clear coat object parameters
  63912. */
  63913. get clearcoat(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the sub surface object parameters
  63916. */
  63917. get subsurface(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the anisotropy object parameters
  63920. */
  63921. get anisotropy(): NodeMaterialConnectionPoint;
  63922. /**
  63923. * Gets the ambient output component
  63924. */
  63925. get ambient(): NodeMaterialConnectionPoint;
  63926. /**
  63927. * Gets the diffuse output component
  63928. */
  63929. get diffuse(): NodeMaterialConnectionPoint;
  63930. /**
  63931. * Gets the specular output component
  63932. */
  63933. get specular(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the sheen output component
  63936. */
  63937. get sheenDir(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the clear coat output component
  63940. */
  63941. get clearcoatDir(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the indirect diffuse output component
  63944. */
  63945. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the indirect specular output component
  63948. */
  63949. get specularIndirect(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the indirect sheen output component
  63952. */
  63953. get sheenIndirect(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the indirect clear coat output component
  63956. */
  63957. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the refraction output component
  63960. */
  63961. get refraction(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the global lighting output component
  63964. */
  63965. get lighting(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the shadow output component
  63968. */
  63969. get shadow(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the alpha output component
  63972. */
  63973. get alpha(): NodeMaterialConnectionPoint;
  63974. autoConfigure(material: NodeMaterial): void;
  63975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63976. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63978. private _injectVertexCode;
  63979. /**
  63980. * Gets the code corresponding to the albedo/opacity module
  63981. * @returns the shader code
  63982. */
  63983. getAlbedoOpacityCode(): string;
  63984. protected _buildBlock(state: NodeMaterialBuildState): this;
  63985. protected _dumpPropertiesCode(): string;
  63986. serialize(): any;
  63987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63988. }
  63989. }
  63990. declare module BABYLON {
  63991. /**
  63992. * Block used to compute value of one parameter modulo another
  63993. */
  63994. export class ModBlock extends NodeMaterialBlock {
  63995. /**
  63996. * Creates a new ModBlock
  63997. * @param name defines the block name
  63998. */
  63999. constructor(name: string);
  64000. /**
  64001. * Gets the current class name
  64002. * @returns the class name
  64003. */
  64004. getClassName(): string;
  64005. /**
  64006. * Gets the left operand input component
  64007. */
  64008. get left(): NodeMaterialConnectionPoint;
  64009. /**
  64010. * Gets the right operand input component
  64011. */
  64012. get right(): NodeMaterialConnectionPoint;
  64013. /**
  64014. * Gets the output component
  64015. */
  64016. get output(): NodeMaterialConnectionPoint;
  64017. protected _buildBlock(state: NodeMaterialBuildState): this;
  64018. }
  64019. }
  64020. declare module BABYLON {
  64021. /**
  64022. * Helper class to push actions to a pool of workers.
  64023. */
  64024. export class WorkerPool implements IDisposable {
  64025. private _workerInfos;
  64026. private _pendingActions;
  64027. /**
  64028. * Constructor
  64029. * @param workers Array of workers to use for actions
  64030. */
  64031. constructor(workers: Array<Worker>);
  64032. /**
  64033. * Terminates all workers and clears any pending actions.
  64034. */
  64035. dispose(): void;
  64036. /**
  64037. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64038. * pended until a worker has completed its action.
  64039. * @param action The action to perform. Call onComplete when the action is complete.
  64040. */
  64041. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64042. private _execute;
  64043. }
  64044. }
  64045. declare module BABYLON {
  64046. /**
  64047. * Configuration for Draco compression
  64048. */
  64049. export interface IDracoCompressionConfiguration {
  64050. /**
  64051. * Configuration for the decoder.
  64052. */
  64053. decoder: {
  64054. /**
  64055. * The url to the WebAssembly module.
  64056. */
  64057. wasmUrl?: string;
  64058. /**
  64059. * The url to the WebAssembly binary.
  64060. */
  64061. wasmBinaryUrl?: string;
  64062. /**
  64063. * The url to the fallback JavaScript module.
  64064. */
  64065. fallbackUrl?: string;
  64066. };
  64067. }
  64068. /**
  64069. * Draco compression (https://google.github.io/draco/)
  64070. *
  64071. * This class wraps the Draco module.
  64072. *
  64073. * **Encoder**
  64074. *
  64075. * The encoder is not currently implemented.
  64076. *
  64077. * **Decoder**
  64078. *
  64079. * 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.
  64080. *
  64081. * To update the configuration, use the following code:
  64082. * ```javascript
  64083. * DracoCompression.Configuration = {
  64084. * decoder: {
  64085. * wasmUrl: "<url to the WebAssembly library>",
  64086. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64087. * fallbackUrl: "<url to the fallback JavaScript library>",
  64088. * }
  64089. * };
  64090. * ```
  64091. *
  64092. * 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.
  64093. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64094. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64095. *
  64096. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64097. * ```javascript
  64098. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64099. * ```
  64100. *
  64101. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64102. */
  64103. export class DracoCompression implements IDisposable {
  64104. private _workerPoolPromise?;
  64105. private _decoderModulePromise?;
  64106. /**
  64107. * The configuration. Defaults to the following urls:
  64108. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64109. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64110. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64111. */
  64112. static Configuration: IDracoCompressionConfiguration;
  64113. /**
  64114. * Returns true if the decoder configuration is available.
  64115. */
  64116. static get DecoderAvailable(): boolean;
  64117. /**
  64118. * Default number of workers to create when creating the draco compression object.
  64119. */
  64120. static DefaultNumWorkers: number;
  64121. private static GetDefaultNumWorkers;
  64122. private static _Default;
  64123. /**
  64124. * Default instance for the draco compression object.
  64125. */
  64126. static get Default(): DracoCompression;
  64127. /**
  64128. * Constructor
  64129. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64130. */
  64131. constructor(numWorkers?: number);
  64132. /**
  64133. * Stop all async operations and release resources.
  64134. */
  64135. dispose(): void;
  64136. /**
  64137. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64138. * @returns a promise that resolves when ready
  64139. */
  64140. whenReadyAsync(): Promise<void>;
  64141. /**
  64142. * Decode Draco compressed mesh data to vertex data.
  64143. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64144. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64145. * @returns A promise that resolves with the decoded vertex data
  64146. */
  64147. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64148. [kind: string]: number;
  64149. }): Promise<VertexData>;
  64150. }
  64151. }
  64152. declare module BABYLON {
  64153. /**
  64154. * Class for building Constructive Solid Geometry
  64155. */
  64156. export class CSG {
  64157. private polygons;
  64158. /**
  64159. * The world matrix
  64160. */
  64161. matrix: Matrix;
  64162. /**
  64163. * Stores the position
  64164. */
  64165. position: Vector3;
  64166. /**
  64167. * Stores the rotation
  64168. */
  64169. rotation: Vector3;
  64170. /**
  64171. * Stores the rotation quaternion
  64172. */
  64173. rotationQuaternion: Nullable<Quaternion>;
  64174. /**
  64175. * Stores the scaling vector
  64176. */
  64177. scaling: Vector3;
  64178. /**
  64179. * Convert the Mesh to CSG
  64180. * @param mesh The Mesh to convert to CSG
  64181. * @returns A new CSG from the Mesh
  64182. */
  64183. static FromMesh(mesh: Mesh): CSG;
  64184. /**
  64185. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64186. * @param polygons Polygons used to construct a CSG solid
  64187. */
  64188. private static FromPolygons;
  64189. /**
  64190. * Clones, or makes a deep copy, of the CSG
  64191. * @returns A new CSG
  64192. */
  64193. clone(): CSG;
  64194. /**
  64195. * Unions this CSG with another CSG
  64196. * @param csg The CSG to union against this CSG
  64197. * @returns The unioned CSG
  64198. */
  64199. union(csg: CSG): CSG;
  64200. /**
  64201. * Unions this CSG with another CSG in place
  64202. * @param csg The CSG to union against this CSG
  64203. */
  64204. unionInPlace(csg: CSG): void;
  64205. /**
  64206. * Subtracts this CSG with another CSG
  64207. * @param csg The CSG to subtract against this CSG
  64208. * @returns A new CSG
  64209. */
  64210. subtract(csg: CSG): CSG;
  64211. /**
  64212. * Subtracts this CSG with another CSG in place
  64213. * @param csg The CSG to subtact against this CSG
  64214. */
  64215. subtractInPlace(csg: CSG): void;
  64216. /**
  64217. * Intersect this CSG with another CSG
  64218. * @param csg The CSG to intersect against this CSG
  64219. * @returns A new CSG
  64220. */
  64221. intersect(csg: CSG): CSG;
  64222. /**
  64223. * Intersects this CSG with another CSG in place
  64224. * @param csg The CSG to intersect against this CSG
  64225. */
  64226. intersectInPlace(csg: CSG): void;
  64227. /**
  64228. * Return a new CSG solid with solid and empty space switched. This solid is
  64229. * not modified.
  64230. * @returns A new CSG solid with solid and empty space switched
  64231. */
  64232. inverse(): CSG;
  64233. /**
  64234. * Inverses the CSG in place
  64235. */
  64236. inverseInPlace(): void;
  64237. /**
  64238. * This is used to keep meshes transformations so they can be restored
  64239. * when we build back a Babylon Mesh
  64240. * NB : All CSG operations are performed in world coordinates
  64241. * @param csg The CSG to copy the transform attributes from
  64242. * @returns This CSG
  64243. */
  64244. copyTransformAttributes(csg: CSG): CSG;
  64245. /**
  64246. * Build Raw mesh from CSG
  64247. * Coordinates here are in world space
  64248. * @param name The name of the mesh geometry
  64249. * @param scene The Scene
  64250. * @param keepSubMeshes Specifies if the submeshes should be kept
  64251. * @returns A new Mesh
  64252. */
  64253. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64254. /**
  64255. * Build Mesh from CSG taking material and transforms into account
  64256. * @param name The name of the Mesh
  64257. * @param material The material of the Mesh
  64258. * @param scene The Scene
  64259. * @param keepSubMeshes Specifies if submeshes should be kept
  64260. * @returns The new Mesh
  64261. */
  64262. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64263. }
  64264. }
  64265. declare module BABYLON {
  64266. /**
  64267. * Class used to create a trail following a mesh
  64268. */
  64269. export class TrailMesh extends Mesh {
  64270. private _generator;
  64271. private _autoStart;
  64272. private _running;
  64273. private _diameter;
  64274. private _length;
  64275. private _sectionPolygonPointsCount;
  64276. private _sectionVectors;
  64277. private _sectionNormalVectors;
  64278. private _beforeRenderObserver;
  64279. /**
  64280. * @constructor
  64281. * @param name The value used by scene.getMeshByName() to do a lookup.
  64282. * @param generator The mesh or transform node to generate a trail.
  64283. * @param scene The scene to add this mesh to.
  64284. * @param diameter Diameter of trailing mesh. Default is 1.
  64285. * @param length Length of trailing mesh. Default is 60.
  64286. * @param autoStart Automatically start trailing mesh. Default true.
  64287. */
  64288. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64289. /**
  64290. * "TrailMesh"
  64291. * @returns "TrailMesh"
  64292. */
  64293. getClassName(): string;
  64294. private _createMesh;
  64295. /**
  64296. * Start trailing mesh.
  64297. */
  64298. start(): void;
  64299. /**
  64300. * Stop trailing mesh.
  64301. */
  64302. stop(): void;
  64303. /**
  64304. * Update trailing mesh geometry.
  64305. */
  64306. update(): void;
  64307. /**
  64308. * Returns a new TrailMesh object.
  64309. * @param name is a string, the name given to the new mesh
  64310. * @param newGenerator use new generator object for cloned trail mesh
  64311. * @returns a new mesh
  64312. */
  64313. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64314. /**
  64315. * Serializes this trail mesh
  64316. * @param serializationObject object to write serialization to
  64317. */
  64318. serialize(serializationObject: any): void;
  64319. /**
  64320. * Parses a serialized trail mesh
  64321. * @param parsedMesh the serialized mesh
  64322. * @param scene the scene to create the trail mesh in
  64323. * @returns the created trail mesh
  64324. */
  64325. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64326. }
  64327. }
  64328. declare module BABYLON {
  64329. /**
  64330. * Class containing static functions to help procedurally build meshes
  64331. */
  64332. export class TiledBoxBuilder {
  64333. /**
  64334. * Creates a box mesh
  64335. * 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)
  64336. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64338. * * 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
  64339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64340. * @param name defines the name of the mesh
  64341. * @param options defines the options used to create the mesh
  64342. * @param scene defines the hosting scene
  64343. * @returns the box mesh
  64344. */
  64345. static CreateTiledBox(name: string, options: {
  64346. pattern?: number;
  64347. width?: number;
  64348. height?: number;
  64349. depth?: number;
  64350. tileSize?: number;
  64351. tileWidth?: number;
  64352. tileHeight?: number;
  64353. alignHorizontal?: number;
  64354. alignVertical?: number;
  64355. faceUV?: Vector4[];
  64356. faceColors?: Color4[];
  64357. sideOrientation?: number;
  64358. updatable?: boolean;
  64359. }, scene?: Nullable<Scene>): Mesh;
  64360. }
  64361. }
  64362. declare module BABYLON {
  64363. /**
  64364. * Class containing static functions to help procedurally build meshes
  64365. */
  64366. export class TorusKnotBuilder {
  64367. /**
  64368. * Creates a torus knot mesh
  64369. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64370. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64371. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64372. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64374. * * 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
  64375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64376. * @param name defines the name of the mesh
  64377. * @param options defines the options used to create the mesh
  64378. * @param scene defines the hosting scene
  64379. * @returns the torus knot mesh
  64380. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64381. */
  64382. static CreateTorusKnot(name: string, options: {
  64383. radius?: number;
  64384. tube?: number;
  64385. radialSegments?: number;
  64386. tubularSegments?: number;
  64387. p?: number;
  64388. q?: number;
  64389. updatable?: boolean;
  64390. sideOrientation?: number;
  64391. frontUVs?: Vector4;
  64392. backUVs?: Vector4;
  64393. }, scene: any): Mesh;
  64394. }
  64395. }
  64396. declare module BABYLON {
  64397. /**
  64398. * Polygon
  64399. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64400. */
  64401. export class Polygon {
  64402. /**
  64403. * Creates a rectangle
  64404. * @param xmin bottom X coord
  64405. * @param ymin bottom Y coord
  64406. * @param xmax top X coord
  64407. * @param ymax top Y coord
  64408. * @returns points that make the resulting rectation
  64409. */
  64410. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64411. /**
  64412. * Creates a circle
  64413. * @param radius radius of circle
  64414. * @param cx scale in x
  64415. * @param cy scale in y
  64416. * @param numberOfSides number of sides that make up the circle
  64417. * @returns points that make the resulting circle
  64418. */
  64419. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64420. /**
  64421. * Creates a polygon from input string
  64422. * @param input Input polygon data
  64423. * @returns the parsed points
  64424. */
  64425. static Parse(input: string): Vector2[];
  64426. /**
  64427. * Starts building a polygon from x and y coordinates
  64428. * @param x x coordinate
  64429. * @param y y coordinate
  64430. * @returns the started path2
  64431. */
  64432. static StartingAt(x: number, y: number): Path2;
  64433. }
  64434. /**
  64435. * Builds a polygon
  64436. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64437. */
  64438. export class PolygonMeshBuilder {
  64439. private _points;
  64440. private _outlinepoints;
  64441. private _holes;
  64442. private _name;
  64443. private _scene;
  64444. private _epoints;
  64445. private _eholes;
  64446. private _addToepoint;
  64447. /**
  64448. * Babylon reference to the earcut plugin.
  64449. */
  64450. bjsEarcut: any;
  64451. /**
  64452. * Creates a PolygonMeshBuilder
  64453. * @param name name of the builder
  64454. * @param contours Path of the polygon
  64455. * @param scene scene to add to when creating the mesh
  64456. * @param earcutInjection can be used to inject your own earcut reference
  64457. */
  64458. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64459. /**
  64460. * Adds a whole within the polygon
  64461. * @param hole Array of points defining the hole
  64462. * @returns this
  64463. */
  64464. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64465. /**
  64466. * Creates the polygon
  64467. * @param updatable If the mesh should be updatable
  64468. * @param depth The depth of the mesh created
  64469. * @returns the created mesh
  64470. */
  64471. build(updatable?: boolean, depth?: number): Mesh;
  64472. /**
  64473. * Creates the polygon
  64474. * @param depth The depth of the mesh created
  64475. * @returns the created VertexData
  64476. */
  64477. buildVertexData(depth?: number): VertexData;
  64478. /**
  64479. * Adds a side to the polygon
  64480. * @param positions points that make the polygon
  64481. * @param normals normals of the polygon
  64482. * @param uvs uvs of the polygon
  64483. * @param indices indices of the polygon
  64484. * @param bounds bounds of the polygon
  64485. * @param points points of the polygon
  64486. * @param depth depth of the polygon
  64487. * @param flip flip of the polygon
  64488. */
  64489. private addSide;
  64490. }
  64491. }
  64492. declare module BABYLON {
  64493. /**
  64494. * Class containing static functions to help procedurally build meshes
  64495. */
  64496. export class PolygonBuilder {
  64497. /**
  64498. * Creates a polygon mesh
  64499. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64500. * * 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
  64501. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64503. * * 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)
  64504. * * Remember you can only change the shape positions, not their number when updating a polygon
  64505. * @param name defines the name of the mesh
  64506. * @param options defines the options used to create the mesh
  64507. * @param scene defines the hosting scene
  64508. * @param earcutInjection can be used to inject your own earcut reference
  64509. * @returns the polygon mesh
  64510. */
  64511. static CreatePolygon(name: string, options: {
  64512. shape: Vector3[];
  64513. holes?: Vector3[][];
  64514. depth?: number;
  64515. faceUV?: Vector4[];
  64516. faceColors?: Color4[];
  64517. updatable?: boolean;
  64518. sideOrientation?: number;
  64519. frontUVs?: Vector4;
  64520. backUVs?: Vector4;
  64521. wrap?: boolean;
  64522. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64523. /**
  64524. * Creates an extruded polygon mesh, with depth in the Y direction.
  64525. * * 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)
  64526. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64527. * @param name defines the name of the mesh
  64528. * @param options defines the options used to create the mesh
  64529. * @param scene defines the hosting scene
  64530. * @param earcutInjection can be used to inject your own earcut reference
  64531. * @returns the polygon mesh
  64532. */
  64533. static ExtrudePolygon(name: string, options: {
  64534. shape: Vector3[];
  64535. holes?: Vector3[][];
  64536. depth?: number;
  64537. faceUV?: Vector4[];
  64538. faceColors?: Color4[];
  64539. updatable?: boolean;
  64540. sideOrientation?: number;
  64541. frontUVs?: Vector4;
  64542. backUVs?: Vector4;
  64543. wrap?: boolean;
  64544. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64545. }
  64546. }
  64547. declare module BABYLON {
  64548. /**
  64549. * Class containing static functions to help procedurally build meshes
  64550. */
  64551. export class LatheBuilder {
  64552. /**
  64553. * Creates lathe mesh.
  64554. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64555. * * 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
  64556. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64557. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64558. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64559. * * 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
  64560. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64561. * * 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
  64562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64563. * * 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
  64564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64566. * @param name defines the name of the mesh
  64567. * @param options defines the options used to create the mesh
  64568. * @param scene defines the hosting scene
  64569. * @returns the lathe mesh
  64570. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64571. */
  64572. static CreateLathe(name: string, options: {
  64573. shape: Vector3[];
  64574. radius?: number;
  64575. tessellation?: number;
  64576. clip?: number;
  64577. arc?: number;
  64578. closed?: boolean;
  64579. updatable?: boolean;
  64580. sideOrientation?: number;
  64581. frontUVs?: Vector4;
  64582. backUVs?: Vector4;
  64583. cap?: number;
  64584. invertUV?: boolean;
  64585. }, scene?: Nullable<Scene>): Mesh;
  64586. }
  64587. }
  64588. declare module BABYLON {
  64589. /**
  64590. * Class containing static functions to help procedurally build meshes
  64591. */
  64592. export class TiledPlaneBuilder {
  64593. /**
  64594. * Creates a tiled plane mesh
  64595. * * The parameter `pattern` will, depending on value, do nothing or
  64596. * * * flip (reflect about central vertical) alternate tiles across and up
  64597. * * * flip every tile on alternate rows
  64598. * * * rotate (180 degs) alternate tiles across and up
  64599. * * * rotate every tile on alternate rows
  64600. * * * flip and rotate alternate tiles across and up
  64601. * * * flip and rotate every tile on alternate rows
  64602. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64603. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64604. * * 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
  64605. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64606. * * 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)
  64607. * * 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)
  64608. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64609. * @param name defines the name of the mesh
  64610. * @param options defines the options used to create the mesh
  64611. * @param scene defines the hosting scene
  64612. * @returns the box mesh
  64613. */
  64614. static CreateTiledPlane(name: string, options: {
  64615. pattern?: number;
  64616. tileSize?: number;
  64617. tileWidth?: number;
  64618. tileHeight?: number;
  64619. size?: number;
  64620. width?: number;
  64621. height?: number;
  64622. alignHorizontal?: number;
  64623. alignVertical?: number;
  64624. sideOrientation?: number;
  64625. frontUVs?: Vector4;
  64626. backUVs?: Vector4;
  64627. updatable?: boolean;
  64628. }, scene?: Nullable<Scene>): Mesh;
  64629. }
  64630. }
  64631. declare module BABYLON {
  64632. /**
  64633. * Class containing static functions to help procedurally build meshes
  64634. */
  64635. export class TubeBuilder {
  64636. /**
  64637. * Creates a tube mesh.
  64638. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64639. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64640. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64641. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64642. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64643. * * 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)
  64644. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64645. * * 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
  64646. * * 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
  64647. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64648. * * 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
  64649. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64651. * @param name defines the name of the mesh
  64652. * @param options defines the options used to create the mesh
  64653. * @param scene defines the hosting scene
  64654. * @returns the tube mesh
  64655. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64656. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64657. */
  64658. static CreateTube(name: string, options: {
  64659. path: Vector3[];
  64660. radius?: number;
  64661. tessellation?: number;
  64662. radiusFunction?: {
  64663. (i: number, distance: number): number;
  64664. };
  64665. cap?: number;
  64666. arc?: number;
  64667. updatable?: boolean;
  64668. sideOrientation?: number;
  64669. frontUVs?: Vector4;
  64670. backUVs?: Vector4;
  64671. instance?: Mesh;
  64672. invertUV?: boolean;
  64673. }, scene?: Nullable<Scene>): Mesh;
  64674. }
  64675. }
  64676. declare module BABYLON {
  64677. /**
  64678. * Class containing static functions to help procedurally build meshes
  64679. */
  64680. export class IcoSphereBuilder {
  64681. /**
  64682. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64683. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64684. * * 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`)
  64685. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64686. * * 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
  64687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64688. * * 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
  64689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64690. * @param name defines the name of the mesh
  64691. * @param options defines the options used to create the mesh
  64692. * @param scene defines the hosting scene
  64693. * @returns the icosahedron mesh
  64694. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64695. */
  64696. static CreateIcoSphere(name: string, options: {
  64697. radius?: number;
  64698. radiusX?: number;
  64699. radiusY?: number;
  64700. radiusZ?: number;
  64701. flat?: boolean;
  64702. subdivisions?: number;
  64703. sideOrientation?: number;
  64704. frontUVs?: Vector4;
  64705. backUVs?: Vector4;
  64706. updatable?: boolean;
  64707. }, scene?: Nullable<Scene>): Mesh;
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /**
  64712. * Class containing static functions to help procedurally build meshes
  64713. */
  64714. export class DecalBuilder {
  64715. /**
  64716. * Creates a decal mesh.
  64717. * 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
  64718. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64719. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64720. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64721. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64722. * @param name defines the name of the mesh
  64723. * @param sourceMesh defines the mesh where the decal must be applied
  64724. * @param options defines the options used to create the mesh
  64725. * @param scene defines the hosting scene
  64726. * @returns the decal mesh
  64727. * @see https://doc.babylonjs.com/how_to/decals
  64728. */
  64729. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64730. position?: Vector3;
  64731. normal?: Vector3;
  64732. size?: Vector3;
  64733. angle?: number;
  64734. }): Mesh;
  64735. }
  64736. }
  64737. declare module BABYLON {
  64738. /**
  64739. * Class containing static functions to help procedurally build meshes
  64740. */
  64741. export class MeshBuilder {
  64742. /**
  64743. * Creates a box mesh
  64744. * * The parameter `size` sets the size (float) of each box side (default 1)
  64745. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64746. * * 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)
  64747. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64749. * * 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
  64750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64751. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64752. * @param name defines the name of the mesh
  64753. * @param options defines the options used to create the mesh
  64754. * @param scene defines the hosting scene
  64755. * @returns the box mesh
  64756. */
  64757. static CreateBox(name: string, options: {
  64758. size?: number;
  64759. width?: number;
  64760. height?: number;
  64761. depth?: number;
  64762. faceUV?: Vector4[];
  64763. faceColors?: Color4[];
  64764. sideOrientation?: number;
  64765. frontUVs?: Vector4;
  64766. backUVs?: Vector4;
  64767. wrap?: boolean;
  64768. topBaseAt?: number;
  64769. bottomBaseAt?: number;
  64770. updatable?: boolean;
  64771. }, scene?: Nullable<Scene>): Mesh;
  64772. /**
  64773. * Creates a tiled box mesh
  64774. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64776. * @param name defines the name of the mesh
  64777. * @param options defines the options used to create the mesh
  64778. * @param scene defines the hosting scene
  64779. * @returns the tiled box mesh
  64780. */
  64781. static CreateTiledBox(name: string, options: {
  64782. pattern?: number;
  64783. size?: number;
  64784. width?: number;
  64785. height?: number;
  64786. depth: number;
  64787. tileSize?: number;
  64788. tileWidth?: number;
  64789. tileHeight?: number;
  64790. faceUV?: Vector4[];
  64791. faceColors?: Color4[];
  64792. alignHorizontal?: number;
  64793. alignVertical?: number;
  64794. sideOrientation?: number;
  64795. updatable?: boolean;
  64796. }, scene?: Nullable<Scene>): Mesh;
  64797. /**
  64798. * Creates a sphere mesh
  64799. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64800. * * 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`)
  64801. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64802. * * 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
  64803. * * 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)
  64804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64805. * * 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
  64806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64807. * @param name defines the name of the mesh
  64808. * @param options defines the options used to create the mesh
  64809. * @param scene defines the hosting scene
  64810. * @returns the sphere mesh
  64811. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64812. */
  64813. static CreateSphere(name: string, options: {
  64814. segments?: number;
  64815. diameter?: number;
  64816. diameterX?: number;
  64817. diameterY?: number;
  64818. diameterZ?: number;
  64819. arc?: number;
  64820. slice?: number;
  64821. sideOrientation?: number;
  64822. frontUVs?: Vector4;
  64823. backUVs?: Vector4;
  64824. updatable?: boolean;
  64825. }, scene?: Nullable<Scene>): Mesh;
  64826. /**
  64827. * Creates a plane polygonal mesh. By default, this is a disc
  64828. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64829. * * 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
  64830. * * 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
  64831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64832. * * 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
  64833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64834. * @param name defines the name of the mesh
  64835. * @param options defines the options used to create the mesh
  64836. * @param scene defines the hosting scene
  64837. * @returns the plane polygonal mesh
  64838. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64839. */
  64840. static CreateDisc(name: string, options: {
  64841. radius?: number;
  64842. tessellation?: number;
  64843. arc?: number;
  64844. updatable?: boolean;
  64845. sideOrientation?: number;
  64846. frontUVs?: Vector4;
  64847. backUVs?: Vector4;
  64848. }, scene?: Nullable<Scene>): Mesh;
  64849. /**
  64850. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64851. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64852. * * 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`)
  64853. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64854. * * 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
  64855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64856. * * 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
  64857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64858. * @param name defines the name of the mesh
  64859. * @param options defines the options used to create the mesh
  64860. * @param scene defines the hosting scene
  64861. * @returns the icosahedron mesh
  64862. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64863. */
  64864. static CreateIcoSphere(name: string, options: {
  64865. radius?: number;
  64866. radiusX?: number;
  64867. radiusY?: number;
  64868. radiusZ?: number;
  64869. flat?: boolean;
  64870. subdivisions?: number;
  64871. sideOrientation?: number;
  64872. frontUVs?: Vector4;
  64873. backUVs?: Vector4;
  64874. updatable?: boolean;
  64875. }, scene?: Nullable<Scene>): Mesh;
  64876. /**
  64877. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64878. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64879. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64880. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64881. * * 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
  64882. * * 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
  64883. * * 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
  64884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64885. * * 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
  64886. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64887. * * 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
  64888. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64889. * * 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
  64890. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64892. * @param name defines the name of the mesh
  64893. * @param options defines the options used to create the mesh
  64894. * @param scene defines the hosting scene
  64895. * @returns the ribbon mesh
  64896. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64897. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64898. */
  64899. static CreateRibbon(name: string, options: {
  64900. pathArray: Vector3[][];
  64901. closeArray?: boolean;
  64902. closePath?: boolean;
  64903. offset?: number;
  64904. updatable?: boolean;
  64905. sideOrientation?: number;
  64906. frontUVs?: Vector4;
  64907. backUVs?: Vector4;
  64908. instance?: Mesh;
  64909. invertUV?: boolean;
  64910. uvs?: Vector2[];
  64911. colors?: Color4[];
  64912. }, scene?: Nullable<Scene>): Mesh;
  64913. /**
  64914. * Creates a cylinder or a cone mesh
  64915. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64916. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64917. * * 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.
  64918. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64919. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64920. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64921. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64922. * * 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).
  64923. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64924. * * 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).
  64925. * * 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
  64926. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64927. * * 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
  64928. * * 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.
  64929. * * If `enclose` is false, a ring surface is one element.
  64930. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64931. * * 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
  64932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64933. * * 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
  64934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64935. * @param name defines the name of the mesh
  64936. * @param options defines the options used to create the mesh
  64937. * @param scene defines the hosting scene
  64938. * @returns the cylinder mesh
  64939. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64940. */
  64941. static CreateCylinder(name: string, options: {
  64942. height?: number;
  64943. diameterTop?: number;
  64944. diameterBottom?: number;
  64945. diameter?: number;
  64946. tessellation?: number;
  64947. subdivisions?: number;
  64948. arc?: number;
  64949. faceColors?: Color4[];
  64950. faceUV?: Vector4[];
  64951. updatable?: boolean;
  64952. hasRings?: boolean;
  64953. enclose?: boolean;
  64954. cap?: number;
  64955. sideOrientation?: number;
  64956. frontUVs?: Vector4;
  64957. backUVs?: Vector4;
  64958. }, scene?: Nullable<Scene>): Mesh;
  64959. /**
  64960. * Creates a torus mesh
  64961. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64962. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64963. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64965. * * 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
  64966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64967. * @param name defines the name of the mesh
  64968. * @param options defines the options used to create the mesh
  64969. * @param scene defines the hosting scene
  64970. * @returns the torus mesh
  64971. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64972. */
  64973. static CreateTorus(name: string, options: {
  64974. diameter?: number;
  64975. thickness?: number;
  64976. tessellation?: number;
  64977. updatable?: boolean;
  64978. sideOrientation?: number;
  64979. frontUVs?: Vector4;
  64980. backUVs?: Vector4;
  64981. }, scene?: Nullable<Scene>): Mesh;
  64982. /**
  64983. * Creates a torus knot mesh
  64984. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64985. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64986. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64987. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64989. * * 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
  64990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64991. * @param name defines the name of the mesh
  64992. * @param options defines the options used to create the mesh
  64993. * @param scene defines the hosting scene
  64994. * @returns the torus knot mesh
  64995. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64996. */
  64997. static CreateTorusKnot(name: string, options: {
  64998. radius?: number;
  64999. tube?: number;
  65000. radialSegments?: number;
  65001. tubularSegments?: number;
  65002. p?: number;
  65003. q?: number;
  65004. updatable?: boolean;
  65005. sideOrientation?: number;
  65006. frontUVs?: Vector4;
  65007. backUVs?: Vector4;
  65008. }, scene?: Nullable<Scene>): Mesh;
  65009. /**
  65010. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65011. * * 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
  65012. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65013. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65014. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65015. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65016. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65017. * * 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
  65018. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65020. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65021. * @param name defines the name of the new line system
  65022. * @param options defines the options used to create the line system
  65023. * @param scene defines the hosting scene
  65024. * @returns a new line system mesh
  65025. */
  65026. static CreateLineSystem(name: string, options: {
  65027. lines: Vector3[][];
  65028. updatable?: boolean;
  65029. instance?: Nullable<LinesMesh>;
  65030. colors?: Nullable<Color4[][]>;
  65031. useVertexAlpha?: boolean;
  65032. }, scene: Nullable<Scene>): LinesMesh;
  65033. /**
  65034. * Creates a line mesh
  65035. * 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
  65036. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65037. * * The parameter `points` is an array successive Vector3
  65038. * * 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
  65039. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65040. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65041. * * When updating an instance, remember that only point positions can change, not the number of points
  65042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65044. * @param name defines the name of the new line system
  65045. * @param options defines the options used to create the line system
  65046. * @param scene defines the hosting scene
  65047. * @returns a new line mesh
  65048. */
  65049. static CreateLines(name: string, options: {
  65050. points: Vector3[];
  65051. updatable?: boolean;
  65052. instance?: Nullable<LinesMesh>;
  65053. colors?: Color4[];
  65054. useVertexAlpha?: boolean;
  65055. }, scene?: Nullable<Scene>): LinesMesh;
  65056. /**
  65057. * Creates a dashed line mesh
  65058. * * 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
  65059. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65060. * * The parameter `points` is an array successive Vector3
  65061. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65062. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65063. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65064. * * 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
  65065. * * When updating an instance, remember that only point positions can change, not the number of points
  65066. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65067. * @param name defines the name of the mesh
  65068. * @param options defines the options used to create the mesh
  65069. * @param scene defines the hosting scene
  65070. * @returns the dashed line mesh
  65071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65072. */
  65073. static CreateDashedLines(name: string, options: {
  65074. points: Vector3[];
  65075. dashSize?: number;
  65076. gapSize?: number;
  65077. dashNb?: number;
  65078. updatable?: boolean;
  65079. instance?: LinesMesh;
  65080. }, scene?: Nullable<Scene>): LinesMesh;
  65081. /**
  65082. * 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.
  65083. * * 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.
  65084. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65085. * * 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.
  65086. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65087. * * 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
  65088. * * 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
  65089. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65091. * * 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
  65092. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65094. * @param name defines the name of the mesh
  65095. * @param options defines the options used to create the mesh
  65096. * @param scene defines the hosting scene
  65097. * @returns the extruded shape mesh
  65098. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65100. */
  65101. static ExtrudeShape(name: string, options: {
  65102. shape: Vector3[];
  65103. path: Vector3[];
  65104. scale?: number;
  65105. rotation?: number;
  65106. cap?: number;
  65107. updatable?: boolean;
  65108. sideOrientation?: number;
  65109. frontUVs?: Vector4;
  65110. backUVs?: Vector4;
  65111. instance?: Mesh;
  65112. invertUV?: boolean;
  65113. }, scene?: Nullable<Scene>): Mesh;
  65114. /**
  65115. * Creates an custom extruded shape mesh.
  65116. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65117. * * 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.
  65118. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65119. * * 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
  65120. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65121. * * 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
  65122. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65123. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65124. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65125. * * 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
  65126. * * 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
  65127. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65129. * * 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
  65130. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65132. * @param name defines the name of the mesh
  65133. * @param options defines the options used to create the mesh
  65134. * @param scene defines the hosting scene
  65135. * @returns the custom extruded shape mesh
  65136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65139. */
  65140. static ExtrudeShapeCustom(name: string, options: {
  65141. shape: Vector3[];
  65142. path: Vector3[];
  65143. scaleFunction?: any;
  65144. rotationFunction?: any;
  65145. ribbonCloseArray?: boolean;
  65146. ribbonClosePath?: boolean;
  65147. cap?: number;
  65148. updatable?: boolean;
  65149. sideOrientation?: number;
  65150. frontUVs?: Vector4;
  65151. backUVs?: Vector4;
  65152. instance?: Mesh;
  65153. invertUV?: boolean;
  65154. }, scene?: Nullable<Scene>): Mesh;
  65155. /**
  65156. * Creates lathe mesh.
  65157. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65158. * * 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
  65159. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65160. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65161. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65162. * * 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
  65163. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65164. * * 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
  65165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65166. * * 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
  65167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65169. * @param name defines the name of the mesh
  65170. * @param options defines the options used to create the mesh
  65171. * @param scene defines the hosting scene
  65172. * @returns the lathe mesh
  65173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65174. */
  65175. static CreateLathe(name: string, options: {
  65176. shape: Vector3[];
  65177. radius?: number;
  65178. tessellation?: number;
  65179. clip?: number;
  65180. arc?: number;
  65181. closed?: boolean;
  65182. updatable?: boolean;
  65183. sideOrientation?: number;
  65184. frontUVs?: Vector4;
  65185. backUVs?: Vector4;
  65186. cap?: number;
  65187. invertUV?: boolean;
  65188. }, scene?: Nullable<Scene>): Mesh;
  65189. /**
  65190. * Creates a tiled plane mesh
  65191. * * You can set a limited pattern arrangement with the tiles
  65192. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65193. * * 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
  65194. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65195. * @param name defines the name of the mesh
  65196. * @param options defines the options used to create the mesh
  65197. * @param scene defines the hosting scene
  65198. * @returns the plane mesh
  65199. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65200. */
  65201. static CreateTiledPlane(name: string, options: {
  65202. pattern?: number;
  65203. tileSize?: number;
  65204. tileWidth?: number;
  65205. tileHeight?: number;
  65206. size?: number;
  65207. width?: number;
  65208. height?: number;
  65209. alignHorizontal?: number;
  65210. alignVertical?: number;
  65211. sideOrientation?: number;
  65212. frontUVs?: Vector4;
  65213. backUVs?: Vector4;
  65214. updatable?: boolean;
  65215. }, scene?: Nullable<Scene>): Mesh;
  65216. /**
  65217. * Creates a plane mesh
  65218. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65219. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65220. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65222. * * 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
  65223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65224. * @param name defines the name of the mesh
  65225. * @param options defines the options used to create the mesh
  65226. * @param scene defines the hosting scene
  65227. * @returns the plane mesh
  65228. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65229. */
  65230. static CreatePlane(name: string, options: {
  65231. size?: number;
  65232. width?: number;
  65233. height?: number;
  65234. sideOrientation?: number;
  65235. frontUVs?: Vector4;
  65236. backUVs?: Vector4;
  65237. updatable?: boolean;
  65238. sourcePlane?: Plane;
  65239. }, scene?: Nullable<Scene>): Mesh;
  65240. /**
  65241. * Creates a ground mesh
  65242. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65243. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65245. * @param name defines the name of the mesh
  65246. * @param options defines the options used to create the mesh
  65247. * @param scene defines the hosting scene
  65248. * @returns the ground mesh
  65249. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65250. */
  65251. static CreateGround(name: string, options: {
  65252. width?: number;
  65253. height?: number;
  65254. subdivisions?: number;
  65255. subdivisionsX?: number;
  65256. subdivisionsY?: number;
  65257. updatable?: boolean;
  65258. }, scene?: Nullable<Scene>): Mesh;
  65259. /**
  65260. * Creates a tiled ground mesh
  65261. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65262. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65263. * * 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
  65264. * * 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
  65265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65266. * @param name defines the name of the mesh
  65267. * @param options defines the options used to create the mesh
  65268. * @param scene defines the hosting scene
  65269. * @returns the tiled ground mesh
  65270. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65271. */
  65272. static CreateTiledGround(name: string, options: {
  65273. xmin: number;
  65274. zmin: number;
  65275. xmax: number;
  65276. zmax: number;
  65277. subdivisions?: {
  65278. w: number;
  65279. h: number;
  65280. };
  65281. precision?: {
  65282. w: number;
  65283. h: number;
  65284. };
  65285. updatable?: boolean;
  65286. }, scene?: Nullable<Scene>): Mesh;
  65287. /**
  65288. * Creates a ground mesh from a height map
  65289. * * The parameter `url` sets the URL of the height map image resource.
  65290. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65291. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65292. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65293. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65294. * * 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.
  65295. * * 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).
  65296. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65298. * @param name defines the name of the mesh
  65299. * @param url defines the url to the height map
  65300. * @param options defines the options used to create the mesh
  65301. * @param scene defines the hosting scene
  65302. * @returns the ground mesh
  65303. * @see https://doc.babylonjs.com/babylon101/height_map
  65304. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65305. */
  65306. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65307. width?: number;
  65308. height?: number;
  65309. subdivisions?: number;
  65310. minHeight?: number;
  65311. maxHeight?: number;
  65312. colorFilter?: Color3;
  65313. alphaFilter?: number;
  65314. updatable?: boolean;
  65315. onReady?: (mesh: GroundMesh) => void;
  65316. }, scene?: Nullable<Scene>): GroundMesh;
  65317. /**
  65318. * Creates a polygon mesh
  65319. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65320. * * 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
  65321. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65323. * * 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)
  65324. * * Remember you can only change the shape positions, not their number when updating a polygon
  65325. * @param name defines the name of the mesh
  65326. * @param options defines the options used to create the mesh
  65327. * @param scene defines the hosting scene
  65328. * @param earcutInjection can be used to inject your own earcut reference
  65329. * @returns the polygon mesh
  65330. */
  65331. static CreatePolygon(name: string, options: {
  65332. shape: Vector3[];
  65333. holes?: Vector3[][];
  65334. depth?: number;
  65335. faceUV?: Vector4[];
  65336. faceColors?: Color4[];
  65337. updatable?: boolean;
  65338. sideOrientation?: number;
  65339. frontUVs?: Vector4;
  65340. backUVs?: Vector4;
  65341. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65342. /**
  65343. * Creates an extruded polygon mesh, with depth in the Y direction.
  65344. * * 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)
  65345. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65346. * @param name defines the name of the mesh
  65347. * @param options defines the options used to create the mesh
  65348. * @param scene defines the hosting scene
  65349. * @param earcutInjection can be used to inject your own earcut reference
  65350. * @returns the polygon mesh
  65351. */
  65352. static ExtrudePolygon(name: string, options: {
  65353. shape: Vector3[];
  65354. holes?: Vector3[][];
  65355. depth?: number;
  65356. faceUV?: Vector4[];
  65357. faceColors?: Color4[];
  65358. updatable?: boolean;
  65359. sideOrientation?: number;
  65360. frontUVs?: Vector4;
  65361. backUVs?: Vector4;
  65362. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65363. /**
  65364. * Creates a tube mesh.
  65365. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65366. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65367. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65368. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65369. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65370. * * 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)
  65371. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65372. * * 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
  65373. * * 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
  65374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65375. * * 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
  65376. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65378. * @param name defines the name of the mesh
  65379. * @param options defines the options used to create the mesh
  65380. * @param scene defines the hosting scene
  65381. * @returns the tube mesh
  65382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65383. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65384. */
  65385. static CreateTube(name: string, options: {
  65386. path: Vector3[];
  65387. radius?: number;
  65388. tessellation?: number;
  65389. radiusFunction?: {
  65390. (i: number, distance: number): number;
  65391. };
  65392. cap?: number;
  65393. arc?: number;
  65394. updatable?: boolean;
  65395. sideOrientation?: number;
  65396. frontUVs?: Vector4;
  65397. backUVs?: Vector4;
  65398. instance?: Mesh;
  65399. invertUV?: boolean;
  65400. }, scene?: Nullable<Scene>): Mesh;
  65401. /**
  65402. * Creates a polyhedron mesh
  65403. * * 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
  65404. * * The parameter `size` (positive float, default 1) sets the polygon size
  65405. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65406. * * 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`
  65407. * * 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
  65408. * * 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)`)
  65409. * * 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
  65410. * * 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
  65411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65412. * * 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
  65413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65414. * @param name defines the name of the mesh
  65415. * @param options defines the options used to create the mesh
  65416. * @param scene defines the hosting scene
  65417. * @returns the polyhedron mesh
  65418. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65419. */
  65420. static CreatePolyhedron(name: string, options: {
  65421. type?: number;
  65422. size?: number;
  65423. sizeX?: number;
  65424. sizeY?: number;
  65425. sizeZ?: number;
  65426. custom?: any;
  65427. faceUV?: Vector4[];
  65428. faceColors?: Color4[];
  65429. flat?: boolean;
  65430. updatable?: boolean;
  65431. sideOrientation?: number;
  65432. frontUVs?: Vector4;
  65433. backUVs?: Vector4;
  65434. }, scene?: Nullable<Scene>): Mesh;
  65435. /**
  65436. * Creates a decal mesh.
  65437. * 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
  65438. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65439. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65440. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65441. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65442. * @param name defines the name of the mesh
  65443. * @param sourceMesh defines the mesh where the decal must be applied
  65444. * @param options defines the options used to create the mesh
  65445. * @param scene defines the hosting scene
  65446. * @returns the decal mesh
  65447. * @see https://doc.babylonjs.com/how_to/decals
  65448. */
  65449. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65450. position?: Vector3;
  65451. normal?: Vector3;
  65452. size?: Vector3;
  65453. angle?: number;
  65454. }): Mesh;
  65455. }
  65456. }
  65457. declare module BABYLON {
  65458. /**
  65459. * A simplifier interface for future simplification implementations
  65460. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65461. */
  65462. export interface ISimplifier {
  65463. /**
  65464. * Simplification of a given mesh according to the given settings.
  65465. * Since this requires computation, it is assumed that the function runs async.
  65466. * @param settings The settings of the simplification, including quality and distance
  65467. * @param successCallback A callback that will be called after the mesh was simplified.
  65468. * @param errorCallback in case of an error, this callback will be called. optional.
  65469. */
  65470. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65471. }
  65472. /**
  65473. * Expected simplification settings.
  65474. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65475. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65476. */
  65477. export interface ISimplificationSettings {
  65478. /**
  65479. * Gets or sets the expected quality
  65480. */
  65481. quality: number;
  65482. /**
  65483. * Gets or sets the distance when this optimized version should be used
  65484. */
  65485. distance: number;
  65486. /**
  65487. * Gets an already optimized mesh
  65488. */
  65489. optimizeMesh?: boolean;
  65490. }
  65491. /**
  65492. * Class used to specify simplification options
  65493. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65494. */
  65495. export class SimplificationSettings implements ISimplificationSettings {
  65496. /** expected quality */
  65497. quality: number;
  65498. /** distance when this optimized version should be used */
  65499. distance: number;
  65500. /** already optimized mesh */
  65501. optimizeMesh?: boolean | undefined;
  65502. /**
  65503. * Creates a SimplificationSettings
  65504. * @param quality expected quality
  65505. * @param distance distance when this optimized version should be used
  65506. * @param optimizeMesh already optimized mesh
  65507. */
  65508. constructor(
  65509. /** expected quality */
  65510. quality: number,
  65511. /** distance when this optimized version should be used */
  65512. distance: number,
  65513. /** already optimized mesh */
  65514. optimizeMesh?: boolean | undefined);
  65515. }
  65516. /**
  65517. * Interface used to define a simplification task
  65518. */
  65519. export interface ISimplificationTask {
  65520. /**
  65521. * Array of settings
  65522. */
  65523. settings: Array<ISimplificationSettings>;
  65524. /**
  65525. * Simplification type
  65526. */
  65527. simplificationType: SimplificationType;
  65528. /**
  65529. * Mesh to simplify
  65530. */
  65531. mesh: Mesh;
  65532. /**
  65533. * Callback called on success
  65534. */
  65535. successCallback?: () => void;
  65536. /**
  65537. * Defines if parallel processing can be used
  65538. */
  65539. parallelProcessing: boolean;
  65540. }
  65541. /**
  65542. * Queue used to order the simplification tasks
  65543. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65544. */
  65545. export class SimplificationQueue {
  65546. private _simplificationArray;
  65547. /**
  65548. * Gets a boolean indicating that the process is still running
  65549. */
  65550. running: boolean;
  65551. /**
  65552. * Creates a new queue
  65553. */
  65554. constructor();
  65555. /**
  65556. * Adds a new simplification task
  65557. * @param task defines a task to add
  65558. */
  65559. addTask(task: ISimplificationTask): void;
  65560. /**
  65561. * Execute next task
  65562. */
  65563. executeNext(): void;
  65564. /**
  65565. * Execute a simplification task
  65566. * @param task defines the task to run
  65567. */
  65568. runSimplification(task: ISimplificationTask): void;
  65569. private getSimplifier;
  65570. }
  65571. /**
  65572. * The implemented types of simplification
  65573. * At the moment only Quadratic Error Decimation is implemented
  65574. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65575. */
  65576. export enum SimplificationType {
  65577. /** Quadratic error decimation */
  65578. QUADRATIC = 0
  65579. }
  65580. /**
  65581. * An implementation of the Quadratic Error simplification algorithm.
  65582. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65583. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65584. * @author RaananW
  65585. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65586. */
  65587. export class QuadraticErrorSimplification implements ISimplifier {
  65588. private _mesh;
  65589. private triangles;
  65590. private vertices;
  65591. private references;
  65592. private _reconstructedMesh;
  65593. /** Gets or sets the number pf sync interations */
  65594. syncIterations: number;
  65595. /** Gets or sets the aggressiveness of the simplifier */
  65596. aggressiveness: number;
  65597. /** Gets or sets the number of allowed iterations for decimation */
  65598. decimationIterations: number;
  65599. /** Gets or sets the espilon to use for bounding box computation */
  65600. boundingBoxEpsilon: number;
  65601. /**
  65602. * Creates a new QuadraticErrorSimplification
  65603. * @param _mesh defines the target mesh
  65604. */
  65605. constructor(_mesh: Mesh);
  65606. /**
  65607. * Simplification of a given mesh according to the given settings.
  65608. * Since this requires computation, it is assumed that the function runs async.
  65609. * @param settings The settings of the simplification, including quality and distance
  65610. * @param successCallback A callback that will be called after the mesh was simplified.
  65611. */
  65612. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65613. private runDecimation;
  65614. private initWithMesh;
  65615. private init;
  65616. private reconstructMesh;
  65617. private initDecimatedMesh;
  65618. private isFlipped;
  65619. private updateTriangles;
  65620. private identifyBorder;
  65621. private updateMesh;
  65622. private vertexError;
  65623. private calculateError;
  65624. }
  65625. }
  65626. declare module BABYLON {
  65627. interface Scene {
  65628. /** @hidden (Backing field) */
  65629. _simplificationQueue: SimplificationQueue;
  65630. /**
  65631. * Gets or sets the simplification queue attached to the scene
  65632. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65633. */
  65634. simplificationQueue: SimplificationQueue;
  65635. }
  65636. interface Mesh {
  65637. /**
  65638. * Simplify the mesh according to the given array of settings.
  65639. * Function will return immediately and will simplify async
  65640. * @param settings a collection of simplification settings
  65641. * @param parallelProcessing should all levels calculate parallel or one after the other
  65642. * @param simplificationType the type of simplification to run
  65643. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65644. * @returns the current mesh
  65645. */
  65646. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65647. }
  65648. /**
  65649. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65650. * created in a scene
  65651. */
  65652. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65653. /**
  65654. * The component name helpfull to identify the component in the list of scene components.
  65655. */
  65656. readonly name: string;
  65657. /**
  65658. * The scene the component belongs to.
  65659. */
  65660. scene: Scene;
  65661. /**
  65662. * Creates a new instance of the component for the given scene
  65663. * @param scene Defines the scene to register the component in
  65664. */
  65665. constructor(scene: Scene);
  65666. /**
  65667. * Registers the component in a given scene
  65668. */
  65669. register(): void;
  65670. /**
  65671. * Rebuilds the elements related to this component in case of
  65672. * context lost for instance.
  65673. */
  65674. rebuild(): void;
  65675. /**
  65676. * Disposes the component and the associated ressources
  65677. */
  65678. dispose(): void;
  65679. private _beforeCameraUpdate;
  65680. }
  65681. }
  65682. declare module BABYLON {
  65683. interface Mesh {
  65684. /**
  65685. * Creates a new thin instance
  65686. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65687. * @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
  65688. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65689. */
  65690. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65691. /**
  65692. * Adds the transformation (matrix) of the current mesh as a thin instance
  65693. * @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
  65694. * @returns the thin instance index number
  65695. */
  65696. thinInstanceAddSelf(refresh: boolean): number;
  65697. /**
  65698. * Registers a custom attribute to be used with thin instances
  65699. * @param kind name of the attribute
  65700. * @param stride size in floats of the attribute
  65701. */
  65702. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65703. /**
  65704. * Sets the matrix of a thin instance
  65705. * @param index index of the thin instance
  65706. * @param matrix matrix to set
  65707. * @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
  65708. */
  65709. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65710. /**
  65711. * Sets the value of a custom attribute for a thin instance
  65712. * @param kind name of the attribute
  65713. * @param index index of the thin instance
  65714. * @param value value to set
  65715. * @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
  65716. */
  65717. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65718. /**
  65719. * 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.
  65720. */
  65721. thinInstanceCount: number;
  65722. /**
  65723. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65724. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65725. * @param buffer buffer to set
  65726. * @param stride size in floats of each value of the buffer
  65727. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65728. */
  65729. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65730. /**
  65731. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65732. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65733. */
  65734. thinInstanceBufferUpdated(kind: string): void;
  65735. /**
  65736. * Refreshes the bounding info, taking into account all the thin instances defined
  65737. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65738. */
  65739. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65740. /** @hidden */
  65741. _thinInstanceInitializeUserStorage(): void;
  65742. /** @hidden */
  65743. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65744. /** @hidden */
  65745. _userThinInstanceBuffersStorage: {
  65746. data: {
  65747. [key: string]: Float32Array;
  65748. };
  65749. sizes: {
  65750. [key: string]: number;
  65751. };
  65752. vertexBuffers: {
  65753. [key: string]: Nullable<VertexBuffer>;
  65754. };
  65755. strides: {
  65756. [key: string]: number;
  65757. };
  65758. };
  65759. }
  65760. }
  65761. declare module BABYLON {
  65762. /**
  65763. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65764. */
  65765. export interface INavigationEnginePlugin {
  65766. /**
  65767. * plugin name
  65768. */
  65769. name: string;
  65770. /**
  65771. * Creates a navigation mesh
  65772. * @param meshes array of all the geometry used to compute the navigatio mesh
  65773. * @param parameters bunch of parameters used to filter geometry
  65774. */
  65775. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65776. /**
  65777. * Create a navigation mesh debug mesh
  65778. * @param scene is where the mesh will be added
  65779. * @returns debug display mesh
  65780. */
  65781. createDebugNavMesh(scene: Scene): Mesh;
  65782. /**
  65783. * Get a navigation mesh constrained position, closest to the parameter position
  65784. * @param position world position
  65785. * @returns the closest point to position constrained by the navigation mesh
  65786. */
  65787. getClosestPoint(position: Vector3): Vector3;
  65788. /**
  65789. * Get a navigation mesh constrained position, closest to the parameter position
  65790. * @param position world position
  65791. * @param result output the closest point to position constrained by the navigation mesh
  65792. */
  65793. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65794. /**
  65795. * Get a navigation mesh constrained position, within a particular radius
  65796. * @param position world position
  65797. * @param maxRadius the maximum distance to the constrained world position
  65798. * @returns the closest point to position constrained by the navigation mesh
  65799. */
  65800. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65801. /**
  65802. * Get a navigation mesh constrained position, within a particular radius
  65803. * @param position world position
  65804. * @param maxRadius the maximum distance to the constrained world position
  65805. * @param result output the closest point to position constrained by the navigation mesh
  65806. */
  65807. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65808. /**
  65809. * Compute the final position from a segment made of destination-position
  65810. * @param position world position
  65811. * @param destination world position
  65812. * @returns the resulting point along the navmesh
  65813. */
  65814. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65815. /**
  65816. * Compute the final position from a segment made of destination-position
  65817. * @param position world position
  65818. * @param destination world position
  65819. * @param result output the resulting point along the navmesh
  65820. */
  65821. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65822. /**
  65823. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65824. * @param start world position
  65825. * @param end world position
  65826. * @returns array containing world position composing the path
  65827. */
  65828. computePath(start: Vector3, end: Vector3): Vector3[];
  65829. /**
  65830. * If this plugin is supported
  65831. * @returns true if plugin is supported
  65832. */
  65833. isSupported(): boolean;
  65834. /**
  65835. * Create a new Crowd so you can add agents
  65836. * @param maxAgents the maximum agent count in the crowd
  65837. * @param maxAgentRadius the maximum radius an agent can have
  65838. * @param scene to attach the crowd to
  65839. * @returns the crowd you can add agents to
  65840. */
  65841. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65842. /**
  65843. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65844. * The queries will try to find a solution within those bounds
  65845. * default is (1,1,1)
  65846. * @param extent x,y,z value that define the extent around the queries point of reference
  65847. */
  65848. setDefaultQueryExtent(extent: Vector3): void;
  65849. /**
  65850. * Get the Bounding box extent specified by setDefaultQueryExtent
  65851. * @returns the box extent values
  65852. */
  65853. getDefaultQueryExtent(): Vector3;
  65854. /**
  65855. * build the navmesh from a previously saved state using getNavmeshData
  65856. * @param data the Uint8Array returned by getNavmeshData
  65857. */
  65858. buildFromNavmeshData(data: Uint8Array): void;
  65859. /**
  65860. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65861. * @returns data the Uint8Array that can be saved and reused
  65862. */
  65863. getNavmeshData(): Uint8Array;
  65864. /**
  65865. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65866. * @param result output the box extent values
  65867. */
  65868. getDefaultQueryExtentToRef(result: Vector3): void;
  65869. /**
  65870. * Release all resources
  65871. */
  65872. dispose(): void;
  65873. }
  65874. /**
  65875. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65876. */
  65877. export interface ICrowd {
  65878. /**
  65879. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65880. * You can attach anything to that node. The node position is updated in the scene update tick.
  65881. * @param pos world position that will be constrained by the navigation mesh
  65882. * @param parameters agent parameters
  65883. * @param transform hooked to the agent that will be update by the scene
  65884. * @returns agent index
  65885. */
  65886. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65887. /**
  65888. * Returns the agent position in world space
  65889. * @param index agent index returned by addAgent
  65890. * @returns world space position
  65891. */
  65892. getAgentPosition(index: number): Vector3;
  65893. /**
  65894. * Gets the agent position result in world space
  65895. * @param index agent index returned by addAgent
  65896. * @param result output world space position
  65897. */
  65898. getAgentPositionToRef(index: number, result: Vector3): void;
  65899. /**
  65900. * Gets the agent velocity in world space
  65901. * @param index agent index returned by addAgent
  65902. * @returns world space velocity
  65903. */
  65904. getAgentVelocity(index: number): Vector3;
  65905. /**
  65906. * Gets the agent velocity result in world space
  65907. * @param index agent index returned by addAgent
  65908. * @param result output world space velocity
  65909. */
  65910. getAgentVelocityToRef(index: number, result: Vector3): void;
  65911. /**
  65912. * remove a particular agent previously created
  65913. * @param index agent index returned by addAgent
  65914. */
  65915. removeAgent(index: number): void;
  65916. /**
  65917. * get the list of all agents attached to this crowd
  65918. * @returns list of agent indices
  65919. */
  65920. getAgents(): number[];
  65921. /**
  65922. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65923. * @param deltaTime in seconds
  65924. */
  65925. update(deltaTime: number): void;
  65926. /**
  65927. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65928. * @param index agent index returned by addAgent
  65929. * @param destination targeted world position
  65930. */
  65931. agentGoto(index: number, destination: Vector3): void;
  65932. /**
  65933. * Teleport the agent to a new position
  65934. * @param index agent index returned by addAgent
  65935. * @param destination targeted world position
  65936. */
  65937. agentTeleport(index: number, destination: Vector3): void;
  65938. /**
  65939. * Update agent parameters
  65940. * @param index agent index returned by addAgent
  65941. * @param parameters agent parameters
  65942. */
  65943. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65944. /**
  65945. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65946. * The queries will try to find a solution within those bounds
  65947. * default is (1,1,1)
  65948. * @param extent x,y,z value that define the extent around the queries point of reference
  65949. */
  65950. setDefaultQueryExtent(extent: Vector3): void;
  65951. /**
  65952. * Get the Bounding box extent specified by setDefaultQueryExtent
  65953. * @returns the box extent values
  65954. */
  65955. getDefaultQueryExtent(): Vector3;
  65956. /**
  65957. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65958. * @param result output the box extent values
  65959. */
  65960. getDefaultQueryExtentToRef(result: Vector3): void;
  65961. /**
  65962. * Release all resources
  65963. */
  65964. dispose(): void;
  65965. }
  65966. /**
  65967. * Configures an agent
  65968. */
  65969. export interface IAgentParameters {
  65970. /**
  65971. * Agent radius. [Limit: >= 0]
  65972. */
  65973. radius: number;
  65974. /**
  65975. * Agent height. [Limit: > 0]
  65976. */
  65977. height: number;
  65978. /**
  65979. * Maximum allowed acceleration. [Limit: >= 0]
  65980. */
  65981. maxAcceleration: number;
  65982. /**
  65983. * Maximum allowed speed. [Limit: >= 0]
  65984. */
  65985. maxSpeed: number;
  65986. /**
  65987. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65988. */
  65989. collisionQueryRange: number;
  65990. /**
  65991. * The path visibility optimization range. [Limit: > 0]
  65992. */
  65993. pathOptimizationRange: number;
  65994. /**
  65995. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65996. */
  65997. separationWeight: number;
  65998. }
  65999. /**
  66000. * Configures the navigation mesh creation
  66001. */
  66002. export interface INavMeshParameters {
  66003. /**
  66004. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66005. */
  66006. cs: number;
  66007. /**
  66008. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66009. */
  66010. ch: number;
  66011. /**
  66012. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66013. */
  66014. walkableSlopeAngle: number;
  66015. /**
  66016. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66017. * be considered walkable. [Limit: >= 3] [Units: vx]
  66018. */
  66019. walkableHeight: number;
  66020. /**
  66021. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66022. */
  66023. walkableClimb: number;
  66024. /**
  66025. * The distance to erode/shrink the walkable area of the heightfield away from
  66026. * obstructions. [Limit: >=0] [Units: vx]
  66027. */
  66028. walkableRadius: number;
  66029. /**
  66030. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66031. */
  66032. maxEdgeLen: number;
  66033. /**
  66034. * The maximum distance a simplfied contour's border edges should deviate
  66035. * the original raw contour. [Limit: >=0] [Units: vx]
  66036. */
  66037. maxSimplificationError: number;
  66038. /**
  66039. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66040. */
  66041. minRegionArea: number;
  66042. /**
  66043. * Any regions with a span count smaller than this value will, if possible,
  66044. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66045. */
  66046. mergeRegionArea: number;
  66047. /**
  66048. * The maximum number of vertices allowed for polygons generated during the
  66049. * contour to polygon conversion process. [Limit: >= 3]
  66050. */
  66051. maxVertsPerPoly: number;
  66052. /**
  66053. * Sets the sampling distance to use when generating the detail mesh.
  66054. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66055. */
  66056. detailSampleDist: number;
  66057. /**
  66058. * The maximum distance the detail mesh surface should deviate from heightfield
  66059. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66060. */
  66061. detailSampleMaxError: number;
  66062. }
  66063. }
  66064. declare module BABYLON {
  66065. /**
  66066. * RecastJS navigation plugin
  66067. */
  66068. export class RecastJSPlugin implements INavigationEnginePlugin {
  66069. /**
  66070. * Reference to the Recast library
  66071. */
  66072. bjsRECAST: any;
  66073. /**
  66074. * plugin name
  66075. */
  66076. name: string;
  66077. /**
  66078. * the first navmesh created. We might extend this to support multiple navmeshes
  66079. */
  66080. navMesh: any;
  66081. /**
  66082. * Initializes the recastJS plugin
  66083. * @param recastInjection can be used to inject your own recast reference
  66084. */
  66085. constructor(recastInjection?: any);
  66086. /**
  66087. * Creates a navigation mesh
  66088. * @param meshes array of all the geometry used to compute the navigatio mesh
  66089. * @param parameters bunch of parameters used to filter geometry
  66090. */
  66091. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66092. /**
  66093. * Create a navigation mesh debug mesh
  66094. * @param scene is where the mesh will be added
  66095. * @returns debug display mesh
  66096. */
  66097. createDebugNavMesh(scene: Scene): Mesh;
  66098. /**
  66099. * Get a navigation mesh constrained position, closest to the parameter position
  66100. * @param position world position
  66101. * @returns the closest point to position constrained by the navigation mesh
  66102. */
  66103. getClosestPoint(position: Vector3): Vector3;
  66104. /**
  66105. * Get a navigation mesh constrained position, closest to the parameter position
  66106. * @param position world position
  66107. * @param result output the closest point to position constrained by the navigation mesh
  66108. */
  66109. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66110. /**
  66111. * Get a navigation mesh constrained position, within a particular radius
  66112. * @param position world position
  66113. * @param maxRadius the maximum distance to the constrained world position
  66114. * @returns the closest point to position constrained by the navigation mesh
  66115. */
  66116. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66117. /**
  66118. * Get a navigation mesh constrained position, within a particular radius
  66119. * @param position world position
  66120. * @param maxRadius the maximum distance to the constrained world position
  66121. * @param result output the closest point to position constrained by the navigation mesh
  66122. */
  66123. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66124. /**
  66125. * Compute the final position from a segment made of destination-position
  66126. * @param position world position
  66127. * @param destination world position
  66128. * @returns the resulting point along the navmesh
  66129. */
  66130. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66131. /**
  66132. * Compute the final position from a segment made of destination-position
  66133. * @param position world position
  66134. * @param destination world position
  66135. * @param result output the resulting point along the navmesh
  66136. */
  66137. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66138. /**
  66139. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66140. * @param start world position
  66141. * @param end world position
  66142. * @returns array containing world position composing the path
  66143. */
  66144. computePath(start: Vector3, end: Vector3): Vector3[];
  66145. /**
  66146. * Create a new Crowd so you can add agents
  66147. * @param maxAgents the maximum agent count in the crowd
  66148. * @param maxAgentRadius the maximum radius an agent can have
  66149. * @param scene to attach the crowd to
  66150. * @returns the crowd you can add agents to
  66151. */
  66152. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66153. /**
  66154. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66155. * The queries will try to find a solution within those bounds
  66156. * default is (1,1,1)
  66157. * @param extent x,y,z value that define the extent around the queries point of reference
  66158. */
  66159. setDefaultQueryExtent(extent: Vector3): void;
  66160. /**
  66161. * Get the Bounding box extent specified by setDefaultQueryExtent
  66162. * @returns the box extent values
  66163. */
  66164. getDefaultQueryExtent(): Vector3;
  66165. /**
  66166. * build the navmesh from a previously saved state using getNavmeshData
  66167. * @param data the Uint8Array returned by getNavmeshData
  66168. */
  66169. buildFromNavmeshData(data: Uint8Array): void;
  66170. /**
  66171. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66172. * @returns data the Uint8Array that can be saved and reused
  66173. */
  66174. getNavmeshData(): Uint8Array;
  66175. /**
  66176. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66177. * @param result output the box extent values
  66178. */
  66179. getDefaultQueryExtentToRef(result: Vector3): void;
  66180. /**
  66181. * Disposes
  66182. */
  66183. dispose(): void;
  66184. /**
  66185. * If this plugin is supported
  66186. * @returns true if plugin is supported
  66187. */
  66188. isSupported(): boolean;
  66189. }
  66190. /**
  66191. * Recast detour crowd implementation
  66192. */
  66193. export class RecastJSCrowd implements ICrowd {
  66194. /**
  66195. * Recast/detour plugin
  66196. */
  66197. bjsRECASTPlugin: RecastJSPlugin;
  66198. /**
  66199. * Link to the detour crowd
  66200. */
  66201. recastCrowd: any;
  66202. /**
  66203. * One transform per agent
  66204. */
  66205. transforms: TransformNode[];
  66206. /**
  66207. * All agents created
  66208. */
  66209. agents: number[];
  66210. /**
  66211. * Link to the scene is kept to unregister the crowd from the scene
  66212. */
  66213. private _scene;
  66214. /**
  66215. * Observer for crowd updates
  66216. */
  66217. private _onBeforeAnimationsObserver;
  66218. /**
  66219. * Constructor
  66220. * @param plugin recastJS plugin
  66221. * @param maxAgents the maximum agent count in the crowd
  66222. * @param maxAgentRadius the maximum radius an agent can have
  66223. * @param scene to attach the crowd to
  66224. * @returns the crowd you can add agents to
  66225. */
  66226. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66227. /**
  66228. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66229. * You can attach anything to that node. The node position is updated in the scene update tick.
  66230. * @param pos world position that will be constrained by the navigation mesh
  66231. * @param parameters agent parameters
  66232. * @param transform hooked to the agent that will be update by the scene
  66233. * @returns agent index
  66234. */
  66235. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66236. /**
  66237. * Returns the agent position in world space
  66238. * @param index agent index returned by addAgent
  66239. * @returns world space position
  66240. */
  66241. getAgentPosition(index: number): Vector3;
  66242. /**
  66243. * Returns the agent position result in world space
  66244. * @param index agent index returned by addAgent
  66245. * @param result output world space position
  66246. */
  66247. getAgentPositionToRef(index: number, result: Vector3): void;
  66248. /**
  66249. * Returns the agent velocity in world space
  66250. * @param index agent index returned by addAgent
  66251. * @returns world space velocity
  66252. */
  66253. getAgentVelocity(index: number): Vector3;
  66254. /**
  66255. * Returns the agent velocity result in world space
  66256. * @param index agent index returned by addAgent
  66257. * @param result output world space velocity
  66258. */
  66259. getAgentVelocityToRef(index: number, result: Vector3): void;
  66260. /**
  66261. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66262. * @param index agent index returned by addAgent
  66263. * @param destination targeted world position
  66264. */
  66265. agentGoto(index: number, destination: Vector3): void;
  66266. /**
  66267. * Teleport the agent to a new position
  66268. * @param index agent index returned by addAgent
  66269. * @param destination targeted world position
  66270. */
  66271. agentTeleport(index: number, destination: Vector3): void;
  66272. /**
  66273. * Update agent parameters
  66274. * @param index agent index returned by addAgent
  66275. * @param parameters agent parameters
  66276. */
  66277. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66278. /**
  66279. * remove a particular agent previously created
  66280. * @param index agent index returned by addAgent
  66281. */
  66282. removeAgent(index: number): void;
  66283. /**
  66284. * get the list of all agents attached to this crowd
  66285. * @returns list of agent indices
  66286. */
  66287. getAgents(): number[];
  66288. /**
  66289. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66290. * @param deltaTime in seconds
  66291. */
  66292. update(deltaTime: number): void;
  66293. /**
  66294. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66295. * The queries will try to find a solution within those bounds
  66296. * default is (1,1,1)
  66297. * @param extent x,y,z value that define the extent around the queries point of reference
  66298. */
  66299. setDefaultQueryExtent(extent: Vector3): void;
  66300. /**
  66301. * Get the Bounding box extent specified by setDefaultQueryExtent
  66302. * @returns the box extent values
  66303. */
  66304. getDefaultQueryExtent(): Vector3;
  66305. /**
  66306. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66307. * @param result output the box extent values
  66308. */
  66309. getDefaultQueryExtentToRef(result: Vector3): void;
  66310. /**
  66311. * Release all resources
  66312. */
  66313. dispose(): void;
  66314. }
  66315. }
  66316. declare module BABYLON {
  66317. /**
  66318. * Class used to enable access to IndexedDB
  66319. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66320. */
  66321. export class Database implements IOfflineProvider {
  66322. private _callbackManifestChecked;
  66323. private _currentSceneUrl;
  66324. private _db;
  66325. private _enableSceneOffline;
  66326. private _enableTexturesOffline;
  66327. private _manifestVersionFound;
  66328. private _mustUpdateRessources;
  66329. private _hasReachedQuota;
  66330. private _isSupported;
  66331. private _idbFactory;
  66332. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66333. private static IsUASupportingBlobStorage;
  66334. /**
  66335. * Gets a boolean indicating if Database storate is enabled (off by default)
  66336. */
  66337. static IDBStorageEnabled: boolean;
  66338. /**
  66339. * Gets a boolean indicating if scene must be saved in the database
  66340. */
  66341. get enableSceneOffline(): boolean;
  66342. /**
  66343. * Gets a boolean indicating if textures must be saved in the database
  66344. */
  66345. get enableTexturesOffline(): boolean;
  66346. /**
  66347. * Creates a new Database
  66348. * @param urlToScene defines the url to load the scene
  66349. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66350. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66351. */
  66352. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66353. private static _ParseURL;
  66354. private static _ReturnFullUrlLocation;
  66355. private _checkManifestFile;
  66356. /**
  66357. * Open the database and make it available
  66358. * @param successCallback defines the callback to call on success
  66359. * @param errorCallback defines the callback to call on error
  66360. */
  66361. open(successCallback: () => void, errorCallback: () => void): void;
  66362. /**
  66363. * Loads an image from the database
  66364. * @param url defines the url to load from
  66365. * @param image defines the target DOM image
  66366. */
  66367. loadImage(url: string, image: HTMLImageElement): void;
  66368. private _loadImageFromDBAsync;
  66369. private _saveImageIntoDBAsync;
  66370. private _checkVersionFromDB;
  66371. private _loadVersionFromDBAsync;
  66372. private _saveVersionIntoDBAsync;
  66373. /**
  66374. * Loads a file from database
  66375. * @param url defines the URL to load from
  66376. * @param sceneLoaded defines a callback to call on success
  66377. * @param progressCallBack defines a callback to call when progress changed
  66378. * @param errorCallback defines a callback to call on error
  66379. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66380. */
  66381. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66382. private _loadFileAsync;
  66383. private _saveFileAsync;
  66384. /**
  66385. * Validates if xhr data is correct
  66386. * @param xhr defines the request to validate
  66387. * @param dataType defines the expected data type
  66388. * @returns true if data is correct
  66389. */
  66390. private static _ValidateXHRData;
  66391. }
  66392. }
  66393. declare module BABYLON {
  66394. /** @hidden */
  66395. export var gpuUpdateParticlesPixelShader: {
  66396. name: string;
  66397. shader: string;
  66398. };
  66399. }
  66400. declare module BABYLON {
  66401. /** @hidden */
  66402. export var gpuUpdateParticlesVertexShader: {
  66403. name: string;
  66404. shader: string;
  66405. };
  66406. }
  66407. declare module BABYLON {
  66408. /** @hidden */
  66409. export var clipPlaneFragmentDeclaration2: {
  66410. name: string;
  66411. shader: string;
  66412. };
  66413. }
  66414. declare module BABYLON {
  66415. /** @hidden */
  66416. export var gpuRenderParticlesPixelShader: {
  66417. name: string;
  66418. shader: string;
  66419. };
  66420. }
  66421. declare module BABYLON {
  66422. /** @hidden */
  66423. export var clipPlaneVertexDeclaration2: {
  66424. name: string;
  66425. shader: string;
  66426. };
  66427. }
  66428. declare module BABYLON {
  66429. /** @hidden */
  66430. export var gpuRenderParticlesVertexShader: {
  66431. name: string;
  66432. shader: string;
  66433. };
  66434. }
  66435. declare module BABYLON {
  66436. /**
  66437. * This represents a GPU particle system in Babylon
  66438. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66439. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66440. */
  66441. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66442. /**
  66443. * The layer mask we are rendering the particles through.
  66444. */
  66445. layerMask: number;
  66446. private _capacity;
  66447. private _activeCount;
  66448. private _currentActiveCount;
  66449. private _accumulatedCount;
  66450. private _renderEffect;
  66451. private _updateEffect;
  66452. private _buffer0;
  66453. private _buffer1;
  66454. private _spriteBuffer;
  66455. private _updateVAO;
  66456. private _renderVAO;
  66457. private _targetIndex;
  66458. private _sourceBuffer;
  66459. private _targetBuffer;
  66460. private _engine;
  66461. private _currentRenderId;
  66462. private _started;
  66463. private _stopped;
  66464. private _timeDelta;
  66465. private _randomTexture;
  66466. private _randomTexture2;
  66467. private _attributesStrideSize;
  66468. private _updateEffectOptions;
  66469. private _randomTextureSize;
  66470. private _actualFrame;
  66471. private _customEffect;
  66472. private readonly _rawTextureWidth;
  66473. /**
  66474. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66475. */
  66476. static get IsSupported(): boolean;
  66477. /**
  66478. * An event triggered when the system is disposed.
  66479. */
  66480. onDisposeObservable: Observable<IParticleSystem>;
  66481. /**
  66482. * Gets the maximum number of particles active at the same time.
  66483. * @returns The max number of active particles.
  66484. */
  66485. getCapacity(): number;
  66486. /**
  66487. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66488. * to override the particles.
  66489. */
  66490. forceDepthWrite: boolean;
  66491. /**
  66492. * Gets or set the number of active particles
  66493. */
  66494. get activeParticleCount(): number;
  66495. set activeParticleCount(value: number);
  66496. private _preWarmDone;
  66497. /**
  66498. * Specifies if the particles are updated in emitter local space or world space.
  66499. */
  66500. isLocal: boolean;
  66501. /**
  66502. * Is this system ready to be used/rendered
  66503. * @return true if the system is ready
  66504. */
  66505. isReady(): boolean;
  66506. /**
  66507. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66508. * @returns True if it has been started, otherwise false.
  66509. */
  66510. isStarted(): boolean;
  66511. /**
  66512. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66513. * @returns True if it has been stopped, otherwise false.
  66514. */
  66515. isStopped(): boolean;
  66516. /**
  66517. * Gets a boolean indicating that the system is stopping
  66518. * @returns true if the system is currently stopping
  66519. */
  66520. isStopping(): boolean;
  66521. /**
  66522. * Gets the number of particles active at the same time.
  66523. * @returns The number of active particles.
  66524. */
  66525. getActiveCount(): number;
  66526. /**
  66527. * Starts the particle system and begins to emit
  66528. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66529. */
  66530. start(delay?: number): void;
  66531. /**
  66532. * Stops the particle system.
  66533. */
  66534. stop(): void;
  66535. /**
  66536. * Remove all active particles
  66537. */
  66538. reset(): void;
  66539. /**
  66540. * Returns the string "GPUParticleSystem"
  66541. * @returns a string containing the class name
  66542. */
  66543. getClassName(): string;
  66544. /**
  66545. * Gets the custom effect used to render the particles
  66546. * @param blendMode Blend mode for which the effect should be retrieved
  66547. * @returns The effect
  66548. */
  66549. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66550. /**
  66551. * Sets the custom effect used to render the particles
  66552. * @param effect The effect to set
  66553. * @param blendMode Blend mode for which the effect should be set
  66554. */
  66555. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66556. /** @hidden */
  66557. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66558. /**
  66559. * Observable that will be called just before the particles are drawn
  66560. */
  66561. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66562. /**
  66563. * Gets the name of the particle vertex shader
  66564. */
  66565. get vertexShaderName(): string;
  66566. private _colorGradientsTexture;
  66567. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66568. /**
  66569. * Adds a new color gradient
  66570. * @param gradient defines the gradient to use (between 0 and 1)
  66571. * @param color1 defines the color to affect to the specified gradient
  66572. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66573. * @returns the current particle system
  66574. */
  66575. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66576. private _refreshColorGradient;
  66577. /** Force the system to rebuild all gradients that need to be resync */
  66578. forceRefreshGradients(): void;
  66579. /**
  66580. * Remove a specific color gradient
  66581. * @param gradient defines the gradient to remove
  66582. * @returns the current particle system
  66583. */
  66584. removeColorGradient(gradient: number): GPUParticleSystem;
  66585. private _angularSpeedGradientsTexture;
  66586. private _sizeGradientsTexture;
  66587. private _velocityGradientsTexture;
  66588. private _limitVelocityGradientsTexture;
  66589. private _dragGradientsTexture;
  66590. private _addFactorGradient;
  66591. /**
  66592. * Adds a new size gradient
  66593. * @param gradient defines the gradient to use (between 0 and 1)
  66594. * @param factor defines the size factor to affect to the specified gradient
  66595. * @returns the current particle system
  66596. */
  66597. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66598. /**
  66599. * Remove a specific size gradient
  66600. * @param gradient defines the gradient to remove
  66601. * @returns the current particle system
  66602. */
  66603. removeSizeGradient(gradient: number): GPUParticleSystem;
  66604. private _refreshFactorGradient;
  66605. /**
  66606. * Adds a new angular speed gradient
  66607. * @param gradient defines the gradient to use (between 0 and 1)
  66608. * @param factor defines the angular speed to affect to the specified gradient
  66609. * @returns the current particle system
  66610. */
  66611. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66612. /**
  66613. * Remove a specific angular speed gradient
  66614. * @param gradient defines the gradient to remove
  66615. * @returns the current particle system
  66616. */
  66617. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66618. /**
  66619. * Adds a new velocity gradient
  66620. * @param gradient defines the gradient to use (between 0 and 1)
  66621. * @param factor defines the velocity to affect to the specified gradient
  66622. * @returns the current particle system
  66623. */
  66624. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66625. /**
  66626. * Remove a specific velocity gradient
  66627. * @param gradient defines the gradient to remove
  66628. * @returns the current particle system
  66629. */
  66630. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66631. /**
  66632. * Adds a new limit velocity gradient
  66633. * @param gradient defines the gradient to use (between 0 and 1)
  66634. * @param factor defines the limit velocity value to affect to the specified gradient
  66635. * @returns the current particle system
  66636. */
  66637. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66638. /**
  66639. * Remove a specific limit velocity gradient
  66640. * @param gradient defines the gradient to remove
  66641. * @returns the current particle system
  66642. */
  66643. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66644. /**
  66645. * Adds a new drag gradient
  66646. * @param gradient defines the gradient to use (between 0 and 1)
  66647. * @param factor defines the drag value to affect to the specified gradient
  66648. * @returns the current particle system
  66649. */
  66650. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66651. /**
  66652. * Remove a specific drag gradient
  66653. * @param gradient defines the gradient to remove
  66654. * @returns the current particle system
  66655. */
  66656. removeDragGradient(gradient: number): GPUParticleSystem;
  66657. /**
  66658. * Not supported by GPUParticleSystem
  66659. * @param gradient defines the gradient to use (between 0 and 1)
  66660. * @param factor defines the emit rate value to affect to the specified gradient
  66661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66662. * @returns the current particle system
  66663. */
  66664. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66665. /**
  66666. * Not supported by GPUParticleSystem
  66667. * @param gradient defines the gradient to remove
  66668. * @returns the current particle system
  66669. */
  66670. removeEmitRateGradient(gradient: number): IParticleSystem;
  66671. /**
  66672. * Not supported by GPUParticleSystem
  66673. * @param gradient defines the gradient to use (between 0 and 1)
  66674. * @param factor defines the start size value to affect to the specified gradient
  66675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66676. * @returns the current particle system
  66677. */
  66678. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66679. /**
  66680. * Not supported by GPUParticleSystem
  66681. * @param gradient defines the gradient to remove
  66682. * @returns the current particle system
  66683. */
  66684. removeStartSizeGradient(gradient: number): IParticleSystem;
  66685. /**
  66686. * Not supported by GPUParticleSystem
  66687. * @param gradient defines the gradient to use (between 0 and 1)
  66688. * @param min defines the color remap minimal range
  66689. * @param max defines the color remap maximal range
  66690. * @returns the current particle system
  66691. */
  66692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66693. /**
  66694. * Not supported by GPUParticleSystem
  66695. * @param gradient defines the gradient to remove
  66696. * @returns the current particle system
  66697. */
  66698. removeColorRemapGradient(): IParticleSystem;
  66699. /**
  66700. * Not supported by GPUParticleSystem
  66701. * @param gradient defines the gradient to use (between 0 and 1)
  66702. * @param min defines the alpha remap minimal range
  66703. * @param max defines the alpha remap maximal range
  66704. * @returns the current particle system
  66705. */
  66706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66707. /**
  66708. * Not supported by GPUParticleSystem
  66709. * @param gradient defines the gradient to remove
  66710. * @returns the current particle system
  66711. */
  66712. removeAlphaRemapGradient(): IParticleSystem;
  66713. /**
  66714. * Not supported by GPUParticleSystem
  66715. * @param gradient defines the gradient to use (between 0 and 1)
  66716. * @param color defines the color to affect to the specified gradient
  66717. * @returns the current particle system
  66718. */
  66719. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66720. /**
  66721. * Not supported by GPUParticleSystem
  66722. * @param gradient defines the gradient to remove
  66723. * @returns the current particle system
  66724. */
  66725. removeRampGradient(): IParticleSystem;
  66726. /**
  66727. * Not supported by GPUParticleSystem
  66728. * @returns the list of ramp gradients
  66729. */
  66730. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66731. /**
  66732. * Not supported by GPUParticleSystem
  66733. * Gets or sets a boolean indicating that ramp gradients must be used
  66734. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66735. */
  66736. get useRampGradients(): boolean;
  66737. set useRampGradients(value: boolean);
  66738. /**
  66739. * Not supported by GPUParticleSystem
  66740. * @param gradient defines the gradient to use (between 0 and 1)
  66741. * @param factor defines the life time factor to affect to the specified gradient
  66742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66743. * @returns the current particle system
  66744. */
  66745. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66746. /**
  66747. * Not supported by GPUParticleSystem
  66748. * @param gradient defines the gradient to remove
  66749. * @returns the current particle system
  66750. */
  66751. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66752. /**
  66753. * Instantiates a GPU particle system.
  66754. * 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.
  66755. * @param name The name of the particle system
  66756. * @param options The options used to create the system
  66757. * @param scene The scene the particle system belongs to
  66758. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66759. * @param customEffect a custom effect used to change the way particles are rendered by default
  66760. */
  66761. constructor(name: string, options: Partial<{
  66762. capacity: number;
  66763. randomTextureSize: number;
  66764. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66765. protected _reset(): void;
  66766. private _createUpdateVAO;
  66767. private _createRenderVAO;
  66768. private _initialize;
  66769. /** @hidden */
  66770. _recreateUpdateEffect(): void;
  66771. private _getEffect;
  66772. /**
  66773. * Fill the defines array according to the current settings of the particle system
  66774. * @param defines Array to be updated
  66775. * @param blendMode blend mode to take into account when updating the array
  66776. */
  66777. fillDefines(defines: Array<string>, blendMode?: number): void;
  66778. /**
  66779. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66780. * @param uniforms Uniforms array to fill
  66781. * @param attributes Attributes array to fill
  66782. * @param samplers Samplers array to fill
  66783. */
  66784. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66785. /** @hidden */
  66786. _recreateRenderEffect(): Effect;
  66787. /**
  66788. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66789. * @param preWarm defines if we are in the pre-warmimg phase
  66790. */
  66791. animate(preWarm?: boolean): void;
  66792. private _createFactorGradientTexture;
  66793. private _createSizeGradientTexture;
  66794. private _createAngularSpeedGradientTexture;
  66795. private _createVelocityGradientTexture;
  66796. private _createLimitVelocityGradientTexture;
  66797. private _createDragGradientTexture;
  66798. private _createColorGradientTexture;
  66799. /**
  66800. * Renders the particle system in its current state
  66801. * @param preWarm defines if the system should only update the particles but not render them
  66802. * @returns the current number of particles
  66803. */
  66804. render(preWarm?: boolean): number;
  66805. /**
  66806. * Rebuilds the particle system
  66807. */
  66808. rebuild(): void;
  66809. private _releaseBuffers;
  66810. private _releaseVAOs;
  66811. /**
  66812. * Disposes the particle system and free the associated resources
  66813. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66814. */
  66815. dispose(disposeTexture?: boolean): void;
  66816. /**
  66817. * Clones the particle system.
  66818. * @param name The name of the cloned object
  66819. * @param newEmitter The new emitter to use
  66820. * @returns the cloned particle system
  66821. */
  66822. clone(name: string, newEmitter: any): GPUParticleSystem;
  66823. /**
  66824. * Serializes the particle system to a JSON object
  66825. * @param serializeTexture defines if the texture must be serialized as well
  66826. * @returns the JSON object
  66827. */
  66828. serialize(serializeTexture?: boolean): any;
  66829. /**
  66830. * Parses a JSON object to create a GPU particle system.
  66831. * @param parsedParticleSystem The JSON object to parse
  66832. * @param scene The scene to create the particle system in
  66833. * @param rootUrl The root url to use to load external dependencies like texture
  66834. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66835. * @returns the parsed GPU particle system
  66836. */
  66837. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66838. }
  66839. }
  66840. declare module BABYLON {
  66841. /**
  66842. * Represents a set of particle systems working together to create a specific effect
  66843. */
  66844. export class ParticleSystemSet implements IDisposable {
  66845. /**
  66846. * Gets or sets base Assets URL
  66847. */
  66848. static BaseAssetsUrl: string;
  66849. private _emitterCreationOptions;
  66850. private _emitterNode;
  66851. /**
  66852. * Gets the particle system list
  66853. */
  66854. systems: IParticleSystem[];
  66855. /**
  66856. * Gets the emitter node used with this set
  66857. */
  66858. get emitterNode(): Nullable<TransformNode>;
  66859. /**
  66860. * Creates a new emitter mesh as a sphere
  66861. * @param options defines the options used to create the sphere
  66862. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66863. * @param scene defines the hosting scene
  66864. */
  66865. setEmitterAsSphere(options: {
  66866. diameter: number;
  66867. segments: number;
  66868. color: Color3;
  66869. }, renderingGroupId: number, scene: Scene): void;
  66870. /**
  66871. * Starts all particle systems of the set
  66872. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66873. */
  66874. start(emitter?: AbstractMesh): void;
  66875. /**
  66876. * Release all associated resources
  66877. */
  66878. dispose(): void;
  66879. /**
  66880. * Serialize the set into a JSON compatible object
  66881. * @param serializeTexture defines if the texture must be serialized as well
  66882. * @returns a JSON compatible representation of the set
  66883. */
  66884. serialize(serializeTexture?: boolean): any;
  66885. /**
  66886. * Parse a new ParticleSystemSet from a serialized source
  66887. * @param data defines a JSON compatible representation of the set
  66888. * @param scene defines the hosting scene
  66889. * @param gpu defines if we want GPU particles or CPU particles
  66890. * @returns a new ParticleSystemSet
  66891. */
  66892. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66893. }
  66894. }
  66895. declare module BABYLON {
  66896. /**
  66897. * This class is made for on one-liner static method to help creating particle system set.
  66898. */
  66899. export class ParticleHelper {
  66900. /**
  66901. * Gets or sets base Assets URL
  66902. */
  66903. static BaseAssetsUrl: string;
  66904. /** Define the Url to load snippets */
  66905. static SnippetUrl: string;
  66906. /**
  66907. * Create a default particle system that you can tweak
  66908. * @param emitter defines the emitter to use
  66909. * @param capacity defines the system capacity (default is 500 particles)
  66910. * @param scene defines the hosting scene
  66911. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66912. * @returns the new Particle system
  66913. */
  66914. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66915. /**
  66916. * This is the main static method (one-liner) of this helper to create different particle systems
  66917. * @param type This string represents the type to the particle system to create
  66918. * @param scene The scene where the particle system should live
  66919. * @param gpu If the system will use gpu
  66920. * @returns the ParticleSystemSet created
  66921. */
  66922. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66923. /**
  66924. * Static function used to export a particle system to a ParticleSystemSet variable.
  66925. * Please note that the emitter shape is not exported
  66926. * @param systems defines the particle systems to export
  66927. * @returns the created particle system set
  66928. */
  66929. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66930. /**
  66931. * Creates a particle system from a snippet saved in a remote file
  66932. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66933. * @param url defines the url to load from
  66934. * @param scene defines the hosting scene
  66935. * @param gpu If the system will use gpu
  66936. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66937. * @returns a promise that will resolve to the new particle system
  66938. */
  66939. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66940. /**
  66941. * Creates a particle system from a snippet saved by the particle system editor
  66942. * @param snippetId defines the snippet to load
  66943. * @param scene defines the hosting scene
  66944. * @param gpu If the system will use gpu
  66945. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66946. * @returns a promise that will resolve to the new particle system
  66947. */
  66948. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66949. }
  66950. }
  66951. declare module BABYLON {
  66952. interface Engine {
  66953. /**
  66954. * Create an effect to use with particle systems.
  66955. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66956. * the particle system for which you want to create a custom effect in the last parameter
  66957. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66958. * @param uniformsNames defines a list of attribute names
  66959. * @param samplers defines an array of string used to represent textures
  66960. * @param defines defines the string containing the defines to use to compile the shaders
  66961. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66962. * @param onCompiled defines a function to call when the effect creation is successful
  66963. * @param onError defines a function to call when the effect creation has failed
  66964. * @param particleSystem the particle system you want to create the effect for
  66965. * @returns the new Effect
  66966. */
  66967. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66968. }
  66969. interface Mesh {
  66970. /**
  66971. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66972. * @returns an array of IParticleSystem
  66973. */
  66974. getEmittedParticleSystems(): IParticleSystem[];
  66975. /**
  66976. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66977. * @returns an array of IParticleSystem
  66978. */
  66979. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66980. }
  66981. }
  66982. declare module BABYLON {
  66983. /** Defines the 4 color options */
  66984. export enum PointColor {
  66985. /** color value */
  66986. Color = 2,
  66987. /** uv value */
  66988. UV = 1,
  66989. /** random value */
  66990. Random = 0,
  66991. /** stated value */
  66992. Stated = 3
  66993. }
  66994. /**
  66995. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66996. * 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.
  66997. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66998. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66999. *
  67000. * Full documentation here : TO BE ENTERED
  67001. */
  67002. export class PointsCloudSystem implements IDisposable {
  67003. /**
  67004. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67005. * Example : var p = SPS.particles[i];
  67006. */
  67007. particles: CloudPoint[];
  67008. /**
  67009. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67010. */
  67011. nbParticles: number;
  67012. /**
  67013. * This a counter for your own usage. It's not set by any SPS functions.
  67014. */
  67015. counter: number;
  67016. /**
  67017. * The PCS name. This name is also given to the underlying mesh.
  67018. */
  67019. name: string;
  67020. /**
  67021. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67022. */
  67023. mesh: Mesh;
  67024. /**
  67025. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67026. * Please read :
  67027. */
  67028. vars: any;
  67029. /**
  67030. * @hidden
  67031. */
  67032. _size: number;
  67033. private _scene;
  67034. private _promises;
  67035. private _positions;
  67036. private _indices;
  67037. private _normals;
  67038. private _colors;
  67039. private _uvs;
  67040. private _indices32;
  67041. private _positions32;
  67042. private _colors32;
  67043. private _uvs32;
  67044. private _updatable;
  67045. private _isVisibilityBoxLocked;
  67046. private _alwaysVisible;
  67047. private _groups;
  67048. private _groupCounter;
  67049. private _computeParticleColor;
  67050. private _computeParticleTexture;
  67051. private _computeParticleRotation;
  67052. private _computeBoundingBox;
  67053. private _isReady;
  67054. /**
  67055. * Creates a PCS (Points Cloud System) object
  67056. * @param name (String) is the PCS name, this will be the underlying mesh name
  67057. * @param pointSize (number) is the size for each point
  67058. * @param scene (Scene) is the scene in which the PCS is added
  67059. * @param options defines the options of the PCS e.g.
  67060. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67061. */
  67062. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67063. updatable?: boolean;
  67064. });
  67065. /**
  67066. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67067. * If no points were added to the PCS, the returned mesh is just a single point.
  67068. * @returns a promise for the created mesh
  67069. */
  67070. buildMeshAsync(): Promise<Mesh>;
  67071. /**
  67072. * @hidden
  67073. */
  67074. private _buildMesh;
  67075. private _addParticle;
  67076. private _randomUnitVector;
  67077. private _getColorIndicesForCoord;
  67078. private _setPointsColorOrUV;
  67079. private _colorFromTexture;
  67080. private _calculateDensity;
  67081. /**
  67082. * Adds points to the PCS in random positions within a unit sphere
  67083. * @param nb (positive integer) the number of particles to be created from this model
  67084. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67085. * @returns the number of groups in the system
  67086. */
  67087. addPoints(nb: number, pointFunction?: any): number;
  67088. /**
  67089. * Adds points to the PCS from the surface of the model shape
  67090. * @param mesh is any Mesh object that will be used as a surface model for the points
  67091. * @param nb (positive integer) the number of particles to be created from this model
  67092. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67093. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67094. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67095. * @returns the number of groups in the system
  67096. */
  67097. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67098. /**
  67099. * Adds points to the PCS inside the model shape
  67100. * @param mesh is any Mesh object that will be used as a surface model for the points
  67101. * @param nb (positive integer) the number of particles to be created from this model
  67102. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67103. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67104. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67105. * @returns the number of groups in the system
  67106. */
  67107. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67108. /**
  67109. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67110. * This method calls `updateParticle()` for each particle of the SPS.
  67111. * For an animated SPS, it is usually called within the render loop.
  67112. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67113. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67114. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67115. * @returns the PCS.
  67116. */
  67117. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67118. /**
  67119. * Disposes the PCS.
  67120. */
  67121. dispose(): void;
  67122. /**
  67123. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67124. * doc :
  67125. * @returns the PCS.
  67126. */
  67127. refreshVisibleSize(): PointsCloudSystem;
  67128. /**
  67129. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67130. * @param size the size (float) of the visibility box
  67131. * note : this doesn't lock the PCS mesh bounding box.
  67132. * doc :
  67133. */
  67134. setVisibilityBox(size: number): void;
  67135. /**
  67136. * Gets whether the PCS is always visible or not
  67137. * doc :
  67138. */
  67139. get isAlwaysVisible(): boolean;
  67140. /**
  67141. * Sets the PCS as always visible or not
  67142. * doc :
  67143. */
  67144. set isAlwaysVisible(val: boolean);
  67145. /**
  67146. * Tells to `setParticles()` to compute the particle rotations or not
  67147. * Default value : false. The PCS is faster when it's set to false
  67148. * Note : particle rotations are only applied to parent particles
  67149. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67150. */
  67151. set computeParticleRotation(val: boolean);
  67152. /**
  67153. * Tells to `setParticles()` to compute the particle colors or not.
  67154. * Default value : true. The PCS is faster when it's set to false.
  67155. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67156. */
  67157. set computeParticleColor(val: boolean);
  67158. set computeParticleTexture(val: boolean);
  67159. /**
  67160. * Gets if `setParticles()` computes the particle colors or not.
  67161. * Default value : false. The PCS is faster when it's set to false.
  67162. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67163. */
  67164. get computeParticleColor(): boolean;
  67165. /**
  67166. * Gets if `setParticles()` computes the particle textures or not.
  67167. * Default value : false. The PCS is faster when it's set to false.
  67168. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67169. */
  67170. get computeParticleTexture(): boolean;
  67171. /**
  67172. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67173. */
  67174. set computeBoundingBox(val: boolean);
  67175. /**
  67176. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67177. */
  67178. get computeBoundingBox(): boolean;
  67179. /**
  67180. * This function does nothing. It may be overwritten to set all the particle first values.
  67181. * The PCS doesn't call this function, you may have to call it by your own.
  67182. * doc :
  67183. */
  67184. initParticles(): void;
  67185. /**
  67186. * This function does nothing. It may be overwritten to recycle a particle
  67187. * The PCS doesn't call this function, you can to call it
  67188. * doc :
  67189. * @param particle The particle to recycle
  67190. * @returns the recycled particle
  67191. */
  67192. recycleParticle(particle: CloudPoint): CloudPoint;
  67193. /**
  67194. * Updates a particle : this function should be overwritten by the user.
  67195. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67196. * doc :
  67197. * @example : just set a particle position or velocity and recycle conditions
  67198. * @param particle The particle to update
  67199. * @returns the updated particle
  67200. */
  67201. updateParticle(particle: CloudPoint): CloudPoint;
  67202. /**
  67203. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67204. * This does nothing and may be overwritten by the user.
  67205. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67206. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67207. * @param update the boolean update value actually passed to setParticles()
  67208. */
  67209. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67210. /**
  67211. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67212. * This will be passed three parameters.
  67213. * This does nothing and may be overwritten by the user.
  67214. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67215. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67216. * @param update the boolean update value actually passed to setParticles()
  67217. */
  67218. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67219. }
  67220. }
  67221. declare module BABYLON {
  67222. /**
  67223. * Represents one particle of a points cloud system.
  67224. */
  67225. export class CloudPoint {
  67226. /**
  67227. * particle global index
  67228. */
  67229. idx: number;
  67230. /**
  67231. * The color of the particle
  67232. */
  67233. color: Nullable<Color4>;
  67234. /**
  67235. * The world space position of the particle.
  67236. */
  67237. position: Vector3;
  67238. /**
  67239. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67240. */
  67241. rotation: Vector3;
  67242. /**
  67243. * The world space rotation quaternion of the particle.
  67244. */
  67245. rotationQuaternion: Nullable<Quaternion>;
  67246. /**
  67247. * The uv of the particle.
  67248. */
  67249. uv: Nullable<Vector2>;
  67250. /**
  67251. * The current speed of the particle.
  67252. */
  67253. velocity: Vector3;
  67254. /**
  67255. * The pivot point in the particle local space.
  67256. */
  67257. pivot: Vector3;
  67258. /**
  67259. * Must the particle be translated from its pivot point in its local space ?
  67260. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67261. * Default : false
  67262. */
  67263. translateFromPivot: boolean;
  67264. /**
  67265. * Index of this particle in the global "positions" array (Internal use)
  67266. * @hidden
  67267. */
  67268. _pos: number;
  67269. /**
  67270. * @hidden Index of this particle in the global "indices" array (Internal use)
  67271. */
  67272. _ind: number;
  67273. /**
  67274. * Group this particle belongs to
  67275. */
  67276. _group: PointsGroup;
  67277. /**
  67278. * Group id of this particle
  67279. */
  67280. groupId: number;
  67281. /**
  67282. * Index of the particle in its group id (Internal use)
  67283. */
  67284. idxInGroup: number;
  67285. /**
  67286. * @hidden Particle BoundingInfo object (Internal use)
  67287. */
  67288. _boundingInfo: BoundingInfo;
  67289. /**
  67290. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67291. */
  67292. _pcs: PointsCloudSystem;
  67293. /**
  67294. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67295. */
  67296. _stillInvisible: boolean;
  67297. /**
  67298. * @hidden Last computed particle rotation matrix
  67299. */
  67300. _rotationMatrix: number[];
  67301. /**
  67302. * Parent particle Id, if any.
  67303. * Default null.
  67304. */
  67305. parentId: Nullable<number>;
  67306. /**
  67307. * @hidden Internal global position in the PCS.
  67308. */
  67309. _globalPosition: Vector3;
  67310. /**
  67311. * Creates a Point Cloud object.
  67312. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67313. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67314. * @param group (PointsGroup) is the group the particle belongs to
  67315. * @param groupId (integer) is the group identifier in the PCS.
  67316. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67317. * @param pcs defines the PCS it is associated to
  67318. */
  67319. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67320. /**
  67321. * get point size
  67322. */
  67323. get size(): Vector3;
  67324. /**
  67325. * Set point size
  67326. */
  67327. set size(scale: Vector3);
  67328. /**
  67329. * Legacy support, changed quaternion to rotationQuaternion
  67330. */
  67331. get quaternion(): Nullable<Quaternion>;
  67332. /**
  67333. * Legacy support, changed quaternion to rotationQuaternion
  67334. */
  67335. set quaternion(q: Nullable<Quaternion>);
  67336. /**
  67337. * Returns a boolean. True if the particle intersects a mesh, else false
  67338. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67339. * @param target is the object (point or mesh) what the intersection is computed against
  67340. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67341. * @returns true if it intersects
  67342. */
  67343. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67344. /**
  67345. * get the rotation matrix of the particle
  67346. * @hidden
  67347. */
  67348. getRotationMatrix(m: Matrix): void;
  67349. }
  67350. /**
  67351. * Represents a group of points in a points cloud system
  67352. * * PCS internal tool, don't use it manually.
  67353. */
  67354. export class PointsGroup {
  67355. /**
  67356. * The group id
  67357. * @hidden
  67358. */
  67359. groupID: number;
  67360. /**
  67361. * image data for group (internal use)
  67362. * @hidden
  67363. */
  67364. _groupImageData: Nullable<ArrayBufferView>;
  67365. /**
  67366. * Image Width (internal use)
  67367. * @hidden
  67368. */
  67369. _groupImgWidth: number;
  67370. /**
  67371. * Image Height (internal use)
  67372. * @hidden
  67373. */
  67374. _groupImgHeight: number;
  67375. /**
  67376. * Custom position function (internal use)
  67377. * @hidden
  67378. */
  67379. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67380. /**
  67381. * density per facet for surface points
  67382. * @hidden
  67383. */
  67384. _groupDensity: number[];
  67385. /**
  67386. * Only when points are colored by texture carries pointer to texture list array
  67387. * @hidden
  67388. */
  67389. _textureNb: number;
  67390. /**
  67391. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67392. * PCS internal tool, don't use it manually.
  67393. * @hidden
  67394. */
  67395. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67396. }
  67397. }
  67398. declare module BABYLON {
  67399. interface Scene {
  67400. /** @hidden (Backing field) */
  67401. _physicsEngine: Nullable<IPhysicsEngine>;
  67402. /** @hidden */
  67403. _physicsTimeAccumulator: number;
  67404. /**
  67405. * Gets the current physics engine
  67406. * @returns a IPhysicsEngine or null if none attached
  67407. */
  67408. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67409. /**
  67410. * Enables physics to the current scene
  67411. * @param gravity defines the scene's gravity for the physics engine
  67412. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67413. * @return a boolean indicating if the physics engine was initialized
  67414. */
  67415. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67416. /**
  67417. * Disables and disposes the physics engine associated with the scene
  67418. */
  67419. disablePhysicsEngine(): void;
  67420. /**
  67421. * Gets a boolean indicating if there is an active physics engine
  67422. * @returns a boolean indicating if there is an active physics engine
  67423. */
  67424. isPhysicsEnabled(): boolean;
  67425. /**
  67426. * Deletes a physics compound impostor
  67427. * @param compound defines the compound to delete
  67428. */
  67429. deleteCompoundImpostor(compound: any): void;
  67430. /**
  67431. * An event triggered when physic simulation is about to be run
  67432. */
  67433. onBeforePhysicsObservable: Observable<Scene>;
  67434. /**
  67435. * An event triggered when physic simulation has been done
  67436. */
  67437. onAfterPhysicsObservable: Observable<Scene>;
  67438. }
  67439. interface AbstractMesh {
  67440. /** @hidden */
  67441. _physicsImpostor: Nullable<PhysicsImpostor>;
  67442. /**
  67443. * Gets or sets impostor used for physic simulation
  67444. * @see https://doc.babylonjs.com/features/physics_engine
  67445. */
  67446. physicsImpostor: Nullable<PhysicsImpostor>;
  67447. /**
  67448. * Gets the current physics impostor
  67449. * @see https://doc.babylonjs.com/features/physics_engine
  67450. * @returns a physics impostor or null
  67451. */
  67452. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67453. /** Apply a physic impulse to the mesh
  67454. * @param force defines the force to apply
  67455. * @param contactPoint defines where to apply the force
  67456. * @returns the current mesh
  67457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67458. */
  67459. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67460. /**
  67461. * Creates a physic joint between two meshes
  67462. * @param otherMesh defines the other mesh to use
  67463. * @param pivot1 defines the pivot to use on this mesh
  67464. * @param pivot2 defines the pivot to use on the other mesh
  67465. * @param options defines additional options (can be plugin dependent)
  67466. * @returns the current mesh
  67467. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67468. */
  67469. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67470. /** @hidden */
  67471. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67472. }
  67473. /**
  67474. * Defines the physics engine scene component responsible to manage a physics engine
  67475. */
  67476. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67477. /**
  67478. * The component name helpful to identify the component in the list of scene components.
  67479. */
  67480. readonly name: string;
  67481. /**
  67482. * The scene the component belongs to.
  67483. */
  67484. scene: Scene;
  67485. /**
  67486. * Creates a new instance of the component for the given scene
  67487. * @param scene Defines the scene to register the component in
  67488. */
  67489. constructor(scene: Scene);
  67490. /**
  67491. * Registers the component in a given scene
  67492. */
  67493. register(): void;
  67494. /**
  67495. * Rebuilds the elements related to this component in case of
  67496. * context lost for instance.
  67497. */
  67498. rebuild(): void;
  67499. /**
  67500. * Disposes the component and the associated ressources
  67501. */
  67502. dispose(): void;
  67503. }
  67504. }
  67505. declare module BABYLON {
  67506. /**
  67507. * A helper for physics simulations
  67508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67509. */
  67510. export class PhysicsHelper {
  67511. private _scene;
  67512. private _physicsEngine;
  67513. /**
  67514. * Initializes the Physics helper
  67515. * @param scene Babylon.js scene
  67516. */
  67517. constructor(scene: Scene);
  67518. /**
  67519. * Applies a radial explosion impulse
  67520. * @param origin the origin of the explosion
  67521. * @param radiusOrEventOptions the radius or the options of radial explosion
  67522. * @param strength the explosion strength
  67523. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67524. * @returns A physics radial explosion event, or null
  67525. */
  67526. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67527. /**
  67528. * Applies a radial explosion force
  67529. * @param origin the origin of the explosion
  67530. * @param radiusOrEventOptions the radius or the options of radial explosion
  67531. * @param strength the explosion strength
  67532. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67533. * @returns A physics radial explosion event, or null
  67534. */
  67535. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67536. /**
  67537. * Creates a gravitational field
  67538. * @param origin the origin of the explosion
  67539. * @param radiusOrEventOptions the radius or the options of radial explosion
  67540. * @param strength the explosion strength
  67541. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67542. * @returns A physics gravitational field event, or null
  67543. */
  67544. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67545. /**
  67546. * Creates a physics updraft event
  67547. * @param origin the origin of the updraft
  67548. * @param radiusOrEventOptions the radius or the options of the updraft
  67549. * @param strength the strength of the updraft
  67550. * @param height the height of the updraft
  67551. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67552. * @returns A physics updraft event, or null
  67553. */
  67554. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67555. /**
  67556. * Creates a physics vortex event
  67557. * @param origin the of the vortex
  67558. * @param radiusOrEventOptions the radius or the options of the vortex
  67559. * @param strength the strength of the vortex
  67560. * @param height the height of the vortex
  67561. * @returns a Physics vortex event, or null
  67562. * A physics vortex event or null
  67563. */
  67564. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67565. }
  67566. /**
  67567. * Represents a physics radial explosion event
  67568. */
  67569. class PhysicsRadialExplosionEvent {
  67570. private _scene;
  67571. private _options;
  67572. private _sphere;
  67573. private _dataFetched;
  67574. /**
  67575. * Initializes a radial explosioin event
  67576. * @param _scene BabylonJS scene
  67577. * @param _options The options for the vortex event
  67578. */
  67579. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67580. /**
  67581. * Returns the data related to the radial explosion event (sphere).
  67582. * @returns The radial explosion event data
  67583. */
  67584. getData(): PhysicsRadialExplosionEventData;
  67585. /**
  67586. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67587. * @param impostor A physics imposter
  67588. * @param origin the origin of the explosion
  67589. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67590. */
  67591. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67592. /**
  67593. * Triggers affecterd impostors callbacks
  67594. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67595. */
  67596. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67597. /**
  67598. * Disposes the sphere.
  67599. * @param force Specifies if the sphere should be disposed by force
  67600. */
  67601. dispose(force?: boolean): void;
  67602. /*** Helpers ***/
  67603. private _prepareSphere;
  67604. private _intersectsWithSphere;
  67605. }
  67606. /**
  67607. * Represents a gravitational field event
  67608. */
  67609. class PhysicsGravitationalFieldEvent {
  67610. private _physicsHelper;
  67611. private _scene;
  67612. private _origin;
  67613. private _options;
  67614. private _tickCallback;
  67615. private _sphere;
  67616. private _dataFetched;
  67617. /**
  67618. * Initializes the physics gravitational field event
  67619. * @param _physicsHelper A physics helper
  67620. * @param _scene BabylonJS scene
  67621. * @param _origin The origin position of the gravitational field event
  67622. * @param _options The options for the vortex event
  67623. */
  67624. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67625. /**
  67626. * Returns the data related to the gravitational field event (sphere).
  67627. * @returns A gravitational field event
  67628. */
  67629. getData(): PhysicsGravitationalFieldEventData;
  67630. /**
  67631. * Enables the gravitational field.
  67632. */
  67633. enable(): void;
  67634. /**
  67635. * Disables the gravitational field.
  67636. */
  67637. disable(): void;
  67638. /**
  67639. * Disposes the sphere.
  67640. * @param force The force to dispose from the gravitational field event
  67641. */
  67642. dispose(force?: boolean): void;
  67643. private _tick;
  67644. }
  67645. /**
  67646. * Represents a physics updraft event
  67647. */
  67648. class PhysicsUpdraftEvent {
  67649. private _scene;
  67650. private _origin;
  67651. private _options;
  67652. private _physicsEngine;
  67653. private _originTop;
  67654. private _originDirection;
  67655. private _tickCallback;
  67656. private _cylinder;
  67657. private _cylinderPosition;
  67658. private _dataFetched;
  67659. /**
  67660. * Initializes the physics updraft event
  67661. * @param _scene BabylonJS scene
  67662. * @param _origin The origin position of the updraft
  67663. * @param _options The options for the updraft event
  67664. */
  67665. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67666. /**
  67667. * Returns the data related to the updraft event (cylinder).
  67668. * @returns A physics updraft event
  67669. */
  67670. getData(): PhysicsUpdraftEventData;
  67671. /**
  67672. * Enables the updraft.
  67673. */
  67674. enable(): void;
  67675. /**
  67676. * Disables the updraft.
  67677. */
  67678. disable(): void;
  67679. /**
  67680. * Disposes the cylinder.
  67681. * @param force Specifies if the updraft should be disposed by force
  67682. */
  67683. dispose(force?: boolean): void;
  67684. private getImpostorHitData;
  67685. private _tick;
  67686. /*** Helpers ***/
  67687. private _prepareCylinder;
  67688. private _intersectsWithCylinder;
  67689. }
  67690. /**
  67691. * Represents a physics vortex event
  67692. */
  67693. class PhysicsVortexEvent {
  67694. private _scene;
  67695. private _origin;
  67696. private _options;
  67697. private _physicsEngine;
  67698. private _originTop;
  67699. private _tickCallback;
  67700. private _cylinder;
  67701. private _cylinderPosition;
  67702. private _dataFetched;
  67703. /**
  67704. * Initializes the physics vortex event
  67705. * @param _scene The BabylonJS scene
  67706. * @param _origin The origin position of the vortex
  67707. * @param _options The options for the vortex event
  67708. */
  67709. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67710. /**
  67711. * Returns the data related to the vortex event (cylinder).
  67712. * @returns The physics vortex event data
  67713. */
  67714. getData(): PhysicsVortexEventData;
  67715. /**
  67716. * Enables the vortex.
  67717. */
  67718. enable(): void;
  67719. /**
  67720. * Disables the cortex.
  67721. */
  67722. disable(): void;
  67723. /**
  67724. * Disposes the sphere.
  67725. * @param force
  67726. */
  67727. dispose(force?: boolean): void;
  67728. private getImpostorHitData;
  67729. private _tick;
  67730. /*** Helpers ***/
  67731. private _prepareCylinder;
  67732. private _intersectsWithCylinder;
  67733. }
  67734. /**
  67735. * Options fot the radial explosion event
  67736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67737. */
  67738. export class PhysicsRadialExplosionEventOptions {
  67739. /**
  67740. * The radius of the sphere for the radial explosion.
  67741. */
  67742. radius: number;
  67743. /**
  67744. * The strenth of the explosion.
  67745. */
  67746. strength: number;
  67747. /**
  67748. * The strenght of the force in correspondence to the distance of the affected object
  67749. */
  67750. falloff: PhysicsRadialImpulseFalloff;
  67751. /**
  67752. * Sphere options for the radial explosion.
  67753. */
  67754. sphere: {
  67755. segments: number;
  67756. diameter: number;
  67757. };
  67758. /**
  67759. * Sphere options for the radial explosion.
  67760. */
  67761. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67762. }
  67763. /**
  67764. * Options fot the updraft event
  67765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67766. */
  67767. export class PhysicsUpdraftEventOptions {
  67768. /**
  67769. * The radius of the cylinder for the vortex
  67770. */
  67771. radius: number;
  67772. /**
  67773. * The strenth of the updraft.
  67774. */
  67775. strength: number;
  67776. /**
  67777. * The height of the cylinder for the updraft.
  67778. */
  67779. height: number;
  67780. /**
  67781. * The mode for the the updraft.
  67782. */
  67783. updraftMode: PhysicsUpdraftMode;
  67784. }
  67785. /**
  67786. * Options fot the vortex event
  67787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67788. */
  67789. export class PhysicsVortexEventOptions {
  67790. /**
  67791. * The radius of the cylinder for the vortex
  67792. */
  67793. radius: number;
  67794. /**
  67795. * The strenth of the vortex.
  67796. */
  67797. strength: number;
  67798. /**
  67799. * The height of the cylinder for the vortex.
  67800. */
  67801. height: number;
  67802. /**
  67803. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67804. */
  67805. centripetalForceThreshold: number;
  67806. /**
  67807. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67808. */
  67809. centripetalForceMultiplier: number;
  67810. /**
  67811. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67812. */
  67813. centrifugalForceMultiplier: number;
  67814. /**
  67815. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67816. */
  67817. updraftForceMultiplier: number;
  67818. }
  67819. /**
  67820. * The strenght of the force in correspondence to the distance of the affected object
  67821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67822. */
  67823. export enum PhysicsRadialImpulseFalloff {
  67824. /** Defines that impulse is constant in strength across it's whole radius */
  67825. Constant = 0,
  67826. /** Defines that impulse gets weaker if it's further from the origin */
  67827. Linear = 1
  67828. }
  67829. /**
  67830. * The strength of the force in correspondence to the distance of the affected object
  67831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67832. */
  67833. export enum PhysicsUpdraftMode {
  67834. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67835. Center = 0,
  67836. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67837. Perpendicular = 1
  67838. }
  67839. /**
  67840. * Interface for a physics hit data
  67841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67842. */
  67843. export interface PhysicsHitData {
  67844. /**
  67845. * The force applied at the contact point
  67846. */
  67847. force: Vector3;
  67848. /**
  67849. * The contact point
  67850. */
  67851. contactPoint: Vector3;
  67852. /**
  67853. * The distance from the origin to the contact point
  67854. */
  67855. distanceFromOrigin: number;
  67856. }
  67857. /**
  67858. * Interface for radial explosion event data
  67859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67860. */
  67861. export interface PhysicsRadialExplosionEventData {
  67862. /**
  67863. * A sphere used for the radial explosion event
  67864. */
  67865. sphere: Mesh;
  67866. }
  67867. /**
  67868. * Interface for gravitational field event data
  67869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67870. */
  67871. export interface PhysicsGravitationalFieldEventData {
  67872. /**
  67873. * A sphere mesh used for the gravitational field event
  67874. */
  67875. sphere: Mesh;
  67876. }
  67877. /**
  67878. * Interface for updraft event data
  67879. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67880. */
  67881. export interface PhysicsUpdraftEventData {
  67882. /**
  67883. * A cylinder used for the updraft event
  67884. */
  67885. cylinder: Mesh;
  67886. }
  67887. /**
  67888. * Interface for vortex event data
  67889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67890. */
  67891. export interface PhysicsVortexEventData {
  67892. /**
  67893. * A cylinder used for the vortex event
  67894. */
  67895. cylinder: Mesh;
  67896. }
  67897. /**
  67898. * Interface for an affected physics impostor
  67899. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67900. */
  67901. export interface PhysicsAffectedImpostorWithData {
  67902. /**
  67903. * The impostor affected by the effect
  67904. */
  67905. impostor: PhysicsImpostor;
  67906. /**
  67907. * The data about the hit/horce from the explosion
  67908. */
  67909. hitData: PhysicsHitData;
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /** @hidden */
  67914. export var blackAndWhitePixelShader: {
  67915. name: string;
  67916. shader: string;
  67917. };
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Post process used to render in black and white
  67922. */
  67923. export class BlackAndWhitePostProcess extends PostProcess {
  67924. /**
  67925. * Linear about to convert he result to black and white (default: 1)
  67926. */
  67927. degree: number;
  67928. /**
  67929. * Creates a black and white post process
  67930. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67931. * @param name The name of the effect.
  67932. * @param options The required width/height ratio to downsize to before computing the render pass.
  67933. * @param camera The camera to apply the render pass to.
  67934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67935. * @param engine The engine which the post process will be applied. (default: current engine)
  67936. * @param reusable If the post process can be reused on the same frame. (default: false)
  67937. */
  67938. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67939. }
  67940. }
  67941. declare module BABYLON {
  67942. /**
  67943. * This represents a set of one or more post processes in Babylon.
  67944. * A post process can be used to apply a shader to a texture after it is rendered.
  67945. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67946. */
  67947. export class PostProcessRenderEffect {
  67948. private _postProcesses;
  67949. private _getPostProcesses;
  67950. private _singleInstance;
  67951. private _cameras;
  67952. private _indicesForCamera;
  67953. /**
  67954. * Name of the effect
  67955. * @hidden
  67956. */
  67957. _name: string;
  67958. /**
  67959. * Instantiates a post process render effect.
  67960. * A post process can be used to apply a shader to a texture after it is rendered.
  67961. * @param engine The engine the effect is tied to
  67962. * @param name The name of the effect
  67963. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67964. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67965. */
  67966. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67967. /**
  67968. * Checks if all the post processes in the effect are supported.
  67969. */
  67970. get isSupported(): boolean;
  67971. /**
  67972. * Updates the current state of the effect
  67973. * @hidden
  67974. */
  67975. _update(): void;
  67976. /**
  67977. * Attaches the effect on cameras
  67978. * @param cameras The camera to attach to.
  67979. * @hidden
  67980. */
  67981. _attachCameras(cameras: Camera): void;
  67982. /**
  67983. * Attaches the effect on cameras
  67984. * @param cameras The camera to attach to.
  67985. * @hidden
  67986. */
  67987. _attachCameras(cameras: Camera[]): void;
  67988. /**
  67989. * Detaches the effect on cameras
  67990. * @param cameras The camera to detatch from.
  67991. * @hidden
  67992. */
  67993. _detachCameras(cameras: Camera): void;
  67994. /**
  67995. * Detatches the effect on cameras
  67996. * @param cameras The camera to detatch from.
  67997. * @hidden
  67998. */
  67999. _detachCameras(cameras: Camera[]): void;
  68000. /**
  68001. * Enables the effect on given cameras
  68002. * @param cameras The camera to enable.
  68003. * @hidden
  68004. */
  68005. _enable(cameras: Camera): void;
  68006. /**
  68007. * Enables the effect on given cameras
  68008. * @param cameras The camera to enable.
  68009. * @hidden
  68010. */
  68011. _enable(cameras: Nullable<Camera[]>): void;
  68012. /**
  68013. * Disables the effect on the given cameras
  68014. * @param cameras The camera to disable.
  68015. * @hidden
  68016. */
  68017. _disable(cameras: Camera): void;
  68018. /**
  68019. * Disables the effect on the given cameras
  68020. * @param cameras The camera to disable.
  68021. * @hidden
  68022. */
  68023. _disable(cameras: Nullable<Camera[]>): void;
  68024. /**
  68025. * Gets a list of the post processes contained in the effect.
  68026. * @param camera The camera to get the post processes on.
  68027. * @returns The list of the post processes in the effect.
  68028. */
  68029. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /** @hidden */
  68034. export var extractHighlightsPixelShader: {
  68035. name: string;
  68036. shader: string;
  68037. };
  68038. }
  68039. declare module BABYLON {
  68040. /**
  68041. * 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.
  68042. */
  68043. export class ExtractHighlightsPostProcess extends PostProcess {
  68044. /**
  68045. * The luminance threshold, pixels below this value will be set to black.
  68046. */
  68047. threshold: number;
  68048. /** @hidden */
  68049. _exposure: number;
  68050. /**
  68051. * Post process which has the input texture to be used when performing highlight extraction
  68052. * @hidden
  68053. */
  68054. _inputPostProcess: Nullable<PostProcess>;
  68055. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68056. }
  68057. }
  68058. declare module BABYLON {
  68059. /** @hidden */
  68060. export var bloomMergePixelShader: {
  68061. name: string;
  68062. shader: string;
  68063. };
  68064. }
  68065. declare module BABYLON {
  68066. /**
  68067. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68068. */
  68069. export class BloomMergePostProcess extends PostProcess {
  68070. /** Weight of the bloom to be added to the original input. */
  68071. weight: number;
  68072. /**
  68073. * Creates a new instance of @see BloomMergePostProcess
  68074. * @param name The name of the effect.
  68075. * @param originalFromInput Post process which's input will be used for the merge.
  68076. * @param blurred Blurred highlights post process which's output will be used.
  68077. * @param weight Weight of the bloom to be added to the original input.
  68078. * @param options The required width/height ratio to downsize to before computing the render pass.
  68079. * @param camera The camera to apply the render pass to.
  68080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68081. * @param engine The engine which the post process will be applied. (default: current engine)
  68082. * @param reusable If the post process can be reused on the same frame. (default: false)
  68083. * @param textureType Type of textures used when performing the post process. (default: 0)
  68084. * @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)
  68085. */
  68086. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68087. /** Weight of the bloom to be added to the original input. */
  68088. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68089. }
  68090. }
  68091. declare module BABYLON {
  68092. /**
  68093. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68094. */
  68095. export class BloomEffect extends PostProcessRenderEffect {
  68096. private bloomScale;
  68097. /**
  68098. * @hidden Internal
  68099. */
  68100. _effects: Array<PostProcess>;
  68101. /**
  68102. * @hidden Internal
  68103. */
  68104. _downscale: ExtractHighlightsPostProcess;
  68105. private _blurX;
  68106. private _blurY;
  68107. private _merge;
  68108. /**
  68109. * The luminance threshold to find bright areas of the image to bloom.
  68110. */
  68111. get threshold(): number;
  68112. set threshold(value: number);
  68113. /**
  68114. * The strength of the bloom.
  68115. */
  68116. get weight(): number;
  68117. set weight(value: number);
  68118. /**
  68119. * Specifies the size of the bloom blur kernel, relative to the final output size
  68120. */
  68121. get kernel(): number;
  68122. set kernel(value: number);
  68123. /**
  68124. * Creates a new instance of @see BloomEffect
  68125. * @param scene The scene the effect belongs to.
  68126. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68127. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68128. * @param bloomWeight The the strength of bloom.
  68129. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68130. * @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)
  68131. */
  68132. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68133. /**
  68134. * Disposes each of the internal effects for a given camera.
  68135. * @param camera The camera to dispose the effect on.
  68136. */
  68137. disposeEffects(camera: Camera): void;
  68138. /**
  68139. * @hidden Internal
  68140. */
  68141. _updateEffects(): void;
  68142. /**
  68143. * Internal
  68144. * @returns if all the contained post processes are ready.
  68145. * @hidden
  68146. */
  68147. _isReady(): boolean;
  68148. }
  68149. }
  68150. declare module BABYLON {
  68151. /** @hidden */
  68152. export var chromaticAberrationPixelShader: {
  68153. name: string;
  68154. shader: string;
  68155. };
  68156. }
  68157. declare module BABYLON {
  68158. /**
  68159. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68160. */
  68161. export class ChromaticAberrationPostProcess extends PostProcess {
  68162. /**
  68163. * The amount of seperation of rgb channels (default: 30)
  68164. */
  68165. aberrationAmount: number;
  68166. /**
  68167. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68168. */
  68169. radialIntensity: number;
  68170. /**
  68171. * 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))
  68172. */
  68173. direction: Vector2;
  68174. /**
  68175. * 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))
  68176. */
  68177. centerPosition: Vector2;
  68178. /**
  68179. * Creates a new instance ChromaticAberrationPostProcess
  68180. * @param name The name of the effect.
  68181. * @param screenWidth The width of the screen to apply the effect on.
  68182. * @param screenHeight The height of the screen to apply the effect on.
  68183. * @param options The required width/height ratio to downsize to before computing the render pass.
  68184. * @param camera The camera to apply the render pass to.
  68185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68186. * @param engine The engine which the post process will be applied. (default: current engine)
  68187. * @param reusable If the post process can be reused on the same frame. (default: false)
  68188. * @param textureType Type of textures used when performing the post process. (default: 0)
  68189. * @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)
  68190. */
  68191. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68192. }
  68193. }
  68194. declare module BABYLON {
  68195. /** @hidden */
  68196. export var circleOfConfusionPixelShader: {
  68197. name: string;
  68198. shader: string;
  68199. };
  68200. }
  68201. declare module BABYLON {
  68202. /**
  68203. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68204. */
  68205. export class CircleOfConfusionPostProcess extends PostProcess {
  68206. /**
  68207. * 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.
  68208. */
  68209. lensSize: number;
  68210. /**
  68211. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68212. */
  68213. fStop: number;
  68214. /**
  68215. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68216. */
  68217. focusDistance: number;
  68218. /**
  68219. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68220. */
  68221. focalLength: number;
  68222. private _depthTexture;
  68223. /**
  68224. * Creates a new instance CircleOfConfusionPostProcess
  68225. * @param name The name of the effect.
  68226. * @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.
  68227. * @param options The required width/height ratio to downsize to before computing the render pass.
  68228. * @param camera The camera to apply the render pass to.
  68229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68230. * @param engine The engine which the post process will be applied. (default: current engine)
  68231. * @param reusable If the post process can be reused on the same frame. (default: false)
  68232. * @param textureType Type of textures used when performing the post process. (default: 0)
  68233. * @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)
  68234. */
  68235. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68236. /**
  68237. * 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.
  68238. */
  68239. set depthTexture(value: RenderTargetTexture);
  68240. }
  68241. }
  68242. declare module BABYLON {
  68243. /** @hidden */
  68244. export var colorCorrectionPixelShader: {
  68245. name: string;
  68246. shader: string;
  68247. };
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. *
  68252. * This post-process allows the modification of rendered colors by using
  68253. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68254. *
  68255. * The object needs to be provided an url to a texture containing the color
  68256. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68257. * Use an image editing software to tweak the LUT to match your needs.
  68258. *
  68259. * For an example of a color LUT, see here:
  68260. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68261. * For explanations on color grading, see here:
  68262. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68263. *
  68264. */
  68265. export class ColorCorrectionPostProcess extends PostProcess {
  68266. private _colorTableTexture;
  68267. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68268. }
  68269. }
  68270. declare module BABYLON {
  68271. /** @hidden */
  68272. export var convolutionPixelShader: {
  68273. name: string;
  68274. shader: string;
  68275. };
  68276. }
  68277. declare module BABYLON {
  68278. /**
  68279. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68280. * input texture to perform effects such as edge detection or sharpening
  68281. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68282. */
  68283. export class ConvolutionPostProcess extends PostProcess {
  68284. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68285. kernel: number[];
  68286. /**
  68287. * Creates a new instance ConvolutionPostProcess
  68288. * @param name The name of the effect.
  68289. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68290. * @param options The required width/height ratio to downsize to before computing the render pass.
  68291. * @param camera The camera to apply the render pass to.
  68292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68293. * @param engine The engine which the post process will be applied. (default: current engine)
  68294. * @param reusable If the post process can be reused on the same frame. (default: false)
  68295. * @param textureType Type of textures used when performing the post process. (default: 0)
  68296. */
  68297. constructor(name: string,
  68298. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68299. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68300. /**
  68301. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68302. */
  68303. static EdgeDetect0Kernel: number[];
  68304. /**
  68305. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68306. */
  68307. static EdgeDetect1Kernel: number[];
  68308. /**
  68309. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68310. */
  68311. static EdgeDetect2Kernel: number[];
  68312. /**
  68313. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68314. */
  68315. static SharpenKernel: number[];
  68316. /**
  68317. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68318. */
  68319. static EmbossKernel: number[];
  68320. /**
  68321. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68322. */
  68323. static GaussianKernel: number[];
  68324. }
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68329. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68330. * based on samples that have a large difference in distance than the center pixel.
  68331. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68332. */
  68333. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68334. direction: Vector2;
  68335. /**
  68336. * Creates a new instance CircleOfConfusionPostProcess
  68337. * @param name The name of the effect.
  68338. * @param scene The scene the effect belongs to.
  68339. * @param direction The direction the blur should be applied.
  68340. * @param kernel The size of the kernel used to blur.
  68341. * @param options The required width/height ratio to downsize to before computing the render pass.
  68342. * @param camera The camera to apply the render pass to.
  68343. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68344. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68346. * @param engine The engine which the post process will be applied. (default: current engine)
  68347. * @param reusable If the post process can be reused on the same frame. (default: false)
  68348. * @param textureType Type of textures used when performing the post process. (default: 0)
  68349. * @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)
  68350. */
  68351. 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);
  68352. }
  68353. }
  68354. declare module BABYLON {
  68355. /** @hidden */
  68356. export var depthOfFieldMergePixelShader: {
  68357. name: string;
  68358. shader: string;
  68359. };
  68360. }
  68361. declare module BABYLON {
  68362. /**
  68363. * Options to be set when merging outputs from the default pipeline.
  68364. */
  68365. export class DepthOfFieldMergePostProcessOptions {
  68366. /**
  68367. * The original image to merge on top of
  68368. */
  68369. originalFromInput: PostProcess;
  68370. /**
  68371. * Parameters to perform the merge of the depth of field effect
  68372. */
  68373. depthOfField?: {
  68374. circleOfConfusion: PostProcess;
  68375. blurSteps: Array<PostProcess>;
  68376. };
  68377. /**
  68378. * Parameters to perform the merge of bloom effect
  68379. */
  68380. bloom?: {
  68381. blurred: PostProcess;
  68382. weight: number;
  68383. };
  68384. }
  68385. /**
  68386. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68387. */
  68388. export class DepthOfFieldMergePostProcess extends PostProcess {
  68389. private blurSteps;
  68390. /**
  68391. * Creates a new instance of DepthOfFieldMergePostProcess
  68392. * @param name The name of the effect.
  68393. * @param originalFromInput Post process which's input will be used for the merge.
  68394. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68395. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68396. * @param options The required width/height ratio to downsize to before computing the render pass.
  68397. * @param camera The camera to apply the render pass to.
  68398. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68399. * @param engine The engine which the post process will be applied. (default: current engine)
  68400. * @param reusable If the post process can be reused on the same frame. (default: false)
  68401. * @param textureType Type of textures used when performing the post process. (default: 0)
  68402. * @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)
  68403. */
  68404. 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);
  68405. /**
  68406. * Updates the effect with the current post process compile time values and recompiles the shader.
  68407. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68408. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68409. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68410. * @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
  68411. * @param onCompiled Called when the shader has been compiled.
  68412. * @param onError Called if there is an error when compiling a shader.
  68413. */
  68414. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68415. }
  68416. }
  68417. declare module BABYLON {
  68418. /**
  68419. * Specifies the level of max blur that should be applied when using the depth of field effect
  68420. */
  68421. export enum DepthOfFieldEffectBlurLevel {
  68422. /**
  68423. * Subtle blur
  68424. */
  68425. Low = 0,
  68426. /**
  68427. * Medium blur
  68428. */
  68429. Medium = 1,
  68430. /**
  68431. * Large blur
  68432. */
  68433. High = 2
  68434. }
  68435. /**
  68436. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68437. */
  68438. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68439. private _circleOfConfusion;
  68440. /**
  68441. * @hidden Internal, blurs from high to low
  68442. */
  68443. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68444. private _depthOfFieldBlurY;
  68445. private _dofMerge;
  68446. /**
  68447. * @hidden Internal post processes in depth of field effect
  68448. */
  68449. _effects: Array<PostProcess>;
  68450. /**
  68451. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68452. */
  68453. set focalLength(value: number);
  68454. get focalLength(): number;
  68455. /**
  68456. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68457. */
  68458. set fStop(value: number);
  68459. get fStop(): number;
  68460. /**
  68461. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68462. */
  68463. set focusDistance(value: number);
  68464. get focusDistance(): number;
  68465. /**
  68466. * 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.
  68467. */
  68468. set lensSize(value: number);
  68469. get lensSize(): number;
  68470. /**
  68471. * Creates a new instance DepthOfFieldEffect
  68472. * @param scene The scene the effect belongs to.
  68473. * @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.
  68474. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68475. * @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)
  68476. */
  68477. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68478. /**
  68479. * Get the current class name of the current effet
  68480. * @returns "DepthOfFieldEffect"
  68481. */
  68482. getClassName(): string;
  68483. /**
  68484. * 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.
  68485. */
  68486. set depthTexture(value: RenderTargetTexture);
  68487. /**
  68488. * Disposes each of the internal effects for a given camera.
  68489. * @param camera The camera to dispose the effect on.
  68490. */
  68491. disposeEffects(camera: Camera): void;
  68492. /**
  68493. * @hidden Internal
  68494. */
  68495. _updateEffects(): void;
  68496. /**
  68497. * Internal
  68498. * @returns if all the contained post processes are ready.
  68499. * @hidden
  68500. */
  68501. _isReady(): boolean;
  68502. }
  68503. }
  68504. declare module BABYLON {
  68505. /** @hidden */
  68506. export var displayPassPixelShader: {
  68507. name: string;
  68508. shader: string;
  68509. };
  68510. }
  68511. declare module BABYLON {
  68512. /**
  68513. * DisplayPassPostProcess which produces an output the same as it's input
  68514. */
  68515. export class DisplayPassPostProcess extends PostProcess {
  68516. /**
  68517. * Creates the DisplayPassPostProcess
  68518. * @param name The name of the effect.
  68519. * @param options The required width/height ratio to downsize to before computing the render pass.
  68520. * @param camera The camera to apply the render pass to.
  68521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68522. * @param engine The engine which the post process will be applied. (default: current engine)
  68523. * @param reusable If the post process can be reused on the same frame. (default: false)
  68524. */
  68525. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68526. }
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export var filterPixelShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module BABYLON {
  68536. /**
  68537. * Applies a kernel filter to the image
  68538. */
  68539. export class FilterPostProcess extends PostProcess {
  68540. /** The matrix to be applied to the image */
  68541. kernelMatrix: Matrix;
  68542. /**
  68543. *
  68544. * @param name The name of the effect.
  68545. * @param kernelMatrix The matrix to be applied to the image
  68546. * @param options The required width/height ratio to downsize to before computing the render pass.
  68547. * @param camera The camera to apply the render pass to.
  68548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68549. * @param engine The engine which the post process will be applied. (default: current engine)
  68550. * @param reusable If the post process can be reused on the same frame. (default: false)
  68551. */
  68552. constructor(name: string,
  68553. /** The matrix to be applied to the image */
  68554. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68555. }
  68556. }
  68557. declare module BABYLON {
  68558. /** @hidden */
  68559. export var fxaaPixelShader: {
  68560. name: string;
  68561. shader: string;
  68562. };
  68563. }
  68564. declare module BABYLON {
  68565. /** @hidden */
  68566. export var fxaaVertexShader: {
  68567. name: string;
  68568. shader: string;
  68569. };
  68570. }
  68571. declare module BABYLON {
  68572. /**
  68573. * Fxaa post process
  68574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68575. */
  68576. export class FxaaPostProcess extends PostProcess {
  68577. /** @hidden */
  68578. texelWidth: number;
  68579. /** @hidden */
  68580. texelHeight: number;
  68581. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68582. private _getDefines;
  68583. }
  68584. }
  68585. declare module BABYLON {
  68586. /** @hidden */
  68587. export var grainPixelShader: {
  68588. name: string;
  68589. shader: string;
  68590. };
  68591. }
  68592. declare module BABYLON {
  68593. /**
  68594. * The GrainPostProcess adds noise to the image at mid luminance levels
  68595. */
  68596. export class GrainPostProcess extends PostProcess {
  68597. /**
  68598. * The intensity of the grain added (default: 30)
  68599. */
  68600. intensity: number;
  68601. /**
  68602. * If the grain should be randomized on every frame
  68603. */
  68604. animated: boolean;
  68605. /**
  68606. * Creates a new instance of @see GrainPostProcess
  68607. * @param name The name of the effect.
  68608. * @param options The required width/height ratio to downsize to before computing the render pass.
  68609. * @param camera The camera to apply the render pass to.
  68610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68611. * @param engine The engine which the post process will be applied. (default: current engine)
  68612. * @param reusable If the post process can be reused on the same frame. (default: false)
  68613. * @param textureType Type of textures used when performing the post process. (default: 0)
  68614. * @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)
  68615. */
  68616. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /** @hidden */
  68621. export var highlightsPixelShader: {
  68622. name: string;
  68623. shader: string;
  68624. };
  68625. }
  68626. declare module BABYLON {
  68627. /**
  68628. * Extracts highlights from the image
  68629. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68630. */
  68631. export class HighlightsPostProcess extends PostProcess {
  68632. /**
  68633. * Extracts highlights from the image
  68634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68635. * @param name The name of the effect.
  68636. * @param options The required width/height ratio to downsize to before computing the render pass.
  68637. * @param camera The camera to apply the render pass to.
  68638. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68639. * @param engine The engine which the post process will be applied. (default: current engine)
  68640. * @param reusable If the post process can be reused on the same frame. (default: false)
  68641. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68642. */
  68643. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68644. }
  68645. }
  68646. declare module BABYLON {
  68647. /** @hidden */
  68648. export var mrtFragmentDeclaration: {
  68649. name: string;
  68650. shader: string;
  68651. };
  68652. }
  68653. declare module BABYLON {
  68654. /** @hidden */
  68655. export var geometryPixelShader: {
  68656. name: string;
  68657. shader: string;
  68658. };
  68659. }
  68660. declare module BABYLON {
  68661. /** @hidden */
  68662. export var geometryVertexShader: {
  68663. name: string;
  68664. shader: string;
  68665. };
  68666. }
  68667. declare module BABYLON {
  68668. /** @hidden */
  68669. interface ISavedTransformationMatrix {
  68670. world: Matrix;
  68671. viewProjection: Matrix;
  68672. }
  68673. /**
  68674. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68675. */
  68676. export class GeometryBufferRenderer {
  68677. /**
  68678. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68679. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68680. */
  68681. static readonly POSITION_TEXTURE_TYPE: number;
  68682. /**
  68683. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68684. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68685. */
  68686. static readonly VELOCITY_TEXTURE_TYPE: number;
  68687. /**
  68688. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68689. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68690. */
  68691. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68692. /**
  68693. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68694. * in order to compute objects velocities when enableVelocity is set to "true"
  68695. * @hidden
  68696. */
  68697. _previousTransformationMatrices: {
  68698. [index: number]: ISavedTransformationMatrix;
  68699. };
  68700. /**
  68701. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68702. * in order to compute objects velocities when enableVelocity is set to "true"
  68703. * @hidden
  68704. */
  68705. _previousBonesTransformationMatrices: {
  68706. [index: number]: Float32Array;
  68707. };
  68708. /**
  68709. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68710. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68711. */
  68712. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68713. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68714. renderTransparentMeshes: boolean;
  68715. private _scene;
  68716. private _multiRenderTarget;
  68717. private _ratio;
  68718. private _enablePosition;
  68719. private _enableVelocity;
  68720. private _enableReflectivity;
  68721. private _positionIndex;
  68722. private _velocityIndex;
  68723. private _reflectivityIndex;
  68724. protected _effect: Effect;
  68725. protected _cachedDefines: string;
  68726. /**
  68727. * Set the render list (meshes to be rendered) used in the G buffer.
  68728. */
  68729. set renderList(meshes: Mesh[]);
  68730. /**
  68731. * Gets wether or not G buffer are supported by the running hardware.
  68732. * This requires draw buffer supports
  68733. */
  68734. get isSupported(): boolean;
  68735. /**
  68736. * Returns the index of the given texture type in the G-Buffer textures array
  68737. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68738. * @returns the index of the given texture type in the G-Buffer textures array
  68739. */
  68740. getTextureIndex(textureType: number): number;
  68741. /**
  68742. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68743. */
  68744. get enablePosition(): boolean;
  68745. /**
  68746. * Sets whether or not objects positions are enabled for the G buffer.
  68747. */
  68748. set enablePosition(enable: boolean);
  68749. /**
  68750. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68751. */
  68752. get enableVelocity(): boolean;
  68753. /**
  68754. * Sets wether or not objects velocities are enabled for the G buffer.
  68755. */
  68756. set enableVelocity(enable: boolean);
  68757. /**
  68758. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68759. */
  68760. get enableReflectivity(): boolean;
  68761. /**
  68762. * Sets wether or not objects roughness are enabled for the G buffer.
  68763. */
  68764. set enableReflectivity(enable: boolean);
  68765. /**
  68766. * Gets the scene associated with the buffer.
  68767. */
  68768. get scene(): Scene;
  68769. /**
  68770. * Gets the ratio used by the buffer during its creation.
  68771. * How big is the buffer related to the main canvas.
  68772. */
  68773. get ratio(): number;
  68774. /** @hidden */
  68775. static _SceneComponentInitialization: (scene: Scene) => void;
  68776. /**
  68777. * Creates a new G Buffer for the scene
  68778. * @param scene The scene the buffer belongs to
  68779. * @param ratio How big is the buffer related to the main canvas.
  68780. */
  68781. constructor(scene: Scene, ratio?: number);
  68782. /**
  68783. * Checks wether everything is ready to render a submesh to the G buffer.
  68784. * @param subMesh the submesh to check readiness for
  68785. * @param useInstances is the mesh drawn using instance or not
  68786. * @returns true if ready otherwise false
  68787. */
  68788. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68789. /**
  68790. * Gets the current underlying G Buffer.
  68791. * @returns the buffer
  68792. */
  68793. getGBuffer(): MultiRenderTarget;
  68794. /**
  68795. * Gets the number of samples used to render the buffer (anti aliasing).
  68796. */
  68797. get samples(): number;
  68798. /**
  68799. * Sets the number of samples used to render the buffer (anti aliasing).
  68800. */
  68801. set samples(value: number);
  68802. /**
  68803. * Disposes the renderer and frees up associated resources.
  68804. */
  68805. dispose(): void;
  68806. protected _createRenderTargets(): void;
  68807. private _copyBonesTransformationMatrices;
  68808. }
  68809. }
  68810. declare module BABYLON {
  68811. interface Scene {
  68812. /** @hidden (Backing field) */
  68813. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68814. /**
  68815. * Gets or Sets the current geometry buffer associated to the scene.
  68816. */
  68817. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68818. /**
  68819. * Enables a GeometryBufferRender and associates it with the scene
  68820. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68821. * @returns the GeometryBufferRenderer
  68822. */
  68823. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68824. /**
  68825. * Disables the GeometryBufferRender associated with the scene
  68826. */
  68827. disableGeometryBufferRenderer(): void;
  68828. }
  68829. /**
  68830. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68831. * in several rendering techniques.
  68832. */
  68833. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68834. /**
  68835. * The component name helpful to identify the component in the list of scene components.
  68836. */
  68837. readonly name: string;
  68838. /**
  68839. * The scene the component belongs to.
  68840. */
  68841. scene: Scene;
  68842. /**
  68843. * Creates a new instance of the component for the given scene
  68844. * @param scene Defines the scene to register the component in
  68845. */
  68846. constructor(scene: Scene);
  68847. /**
  68848. * Registers the component in a given scene
  68849. */
  68850. register(): void;
  68851. /**
  68852. * Rebuilds the elements related to this component in case of
  68853. * context lost for instance.
  68854. */
  68855. rebuild(): void;
  68856. /**
  68857. * Disposes the component and the associated ressources
  68858. */
  68859. dispose(): void;
  68860. private _gatherRenderTargets;
  68861. }
  68862. }
  68863. declare module BABYLON {
  68864. /** @hidden */
  68865. export var motionBlurPixelShader: {
  68866. name: string;
  68867. shader: string;
  68868. };
  68869. }
  68870. declare module BABYLON {
  68871. /**
  68872. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68873. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68874. * As an example, all you have to do is to create the post-process:
  68875. * var mb = new BABYLON.MotionBlurPostProcess(
  68876. * 'mb', // The name of the effect.
  68877. * scene, // The scene containing the objects to blur according to their velocity.
  68878. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68879. * camera // The camera to apply the render pass to.
  68880. * );
  68881. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68882. */
  68883. export class MotionBlurPostProcess extends PostProcess {
  68884. /**
  68885. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68886. */
  68887. motionStrength: number;
  68888. /**
  68889. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68890. */
  68891. get motionBlurSamples(): number;
  68892. /**
  68893. * Sets the number of iterations to be used for motion blur quality
  68894. */
  68895. set motionBlurSamples(samples: number);
  68896. private _motionBlurSamples;
  68897. private _geometryBufferRenderer;
  68898. /**
  68899. * Creates a new instance MotionBlurPostProcess
  68900. * @param name The name of the effect.
  68901. * @param scene The scene containing the objects to blur according to their velocity.
  68902. * @param options The required width/height ratio to downsize to before computing the render pass.
  68903. * @param camera The camera to apply the render pass to.
  68904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68905. * @param engine The engine which the post process will be applied. (default: current engine)
  68906. * @param reusable If the post process can be reused on the same frame. (default: false)
  68907. * @param textureType Type of textures used when performing the post process. (default: 0)
  68908. * @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)
  68909. */
  68910. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68911. /**
  68912. * Excludes the given skinned mesh from computing bones velocities.
  68913. * 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.
  68914. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68915. */
  68916. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68917. /**
  68918. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68919. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68920. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68921. */
  68922. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68923. /**
  68924. * Disposes the post process.
  68925. * @param camera The camera to dispose the post process on.
  68926. */
  68927. dispose(camera?: Camera): void;
  68928. }
  68929. }
  68930. declare module BABYLON {
  68931. /** @hidden */
  68932. export var refractionPixelShader: {
  68933. name: string;
  68934. shader: string;
  68935. };
  68936. }
  68937. declare module BABYLON {
  68938. /**
  68939. * Post process which applies a refractin texture
  68940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68941. */
  68942. export class RefractionPostProcess extends PostProcess {
  68943. /** the base color of the refraction (used to taint the rendering) */
  68944. color: Color3;
  68945. /** simulated refraction depth */
  68946. depth: number;
  68947. /** the coefficient of the base color (0 to remove base color tainting) */
  68948. colorLevel: number;
  68949. private _refTexture;
  68950. private _ownRefractionTexture;
  68951. /**
  68952. * Gets or sets the refraction texture
  68953. * Please note that you are responsible for disposing the texture if you set it manually
  68954. */
  68955. get refractionTexture(): Texture;
  68956. set refractionTexture(value: Texture);
  68957. /**
  68958. * Initializes the RefractionPostProcess
  68959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68960. * @param name The name of the effect.
  68961. * @param refractionTextureUrl Url of the refraction texture to use
  68962. * @param color the base color of the refraction (used to taint the rendering)
  68963. * @param depth simulated refraction depth
  68964. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68965. * @param camera The camera to apply the render pass to.
  68966. * @param options The required width/height ratio to downsize to before computing the render pass.
  68967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68968. * @param engine The engine which the post process will be applied. (default: current engine)
  68969. * @param reusable If the post process can be reused on the same frame. (default: false)
  68970. */
  68971. constructor(name: string, refractionTextureUrl: string,
  68972. /** the base color of the refraction (used to taint the rendering) */
  68973. color: Color3,
  68974. /** simulated refraction depth */
  68975. depth: number,
  68976. /** the coefficient of the base color (0 to remove base color tainting) */
  68977. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68978. /**
  68979. * Disposes of the post process
  68980. * @param camera Camera to dispose post process on
  68981. */
  68982. dispose(camera: Camera): void;
  68983. }
  68984. }
  68985. declare module BABYLON {
  68986. /** @hidden */
  68987. export var sharpenPixelShader: {
  68988. name: string;
  68989. shader: string;
  68990. };
  68991. }
  68992. declare module BABYLON {
  68993. /**
  68994. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68995. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68996. */
  68997. export class SharpenPostProcess extends PostProcess {
  68998. /**
  68999. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69000. */
  69001. colorAmount: number;
  69002. /**
  69003. * How much sharpness should be applied (default: 0.3)
  69004. */
  69005. edgeAmount: number;
  69006. /**
  69007. * Creates a new instance ConvolutionPostProcess
  69008. * @param name The name of the effect.
  69009. * @param options The required width/height ratio to downsize to before computing the render pass.
  69010. * @param camera The camera to apply the render pass to.
  69011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69012. * @param engine The engine which the post process will be applied. (default: current engine)
  69013. * @param reusable If the post process can be reused on the same frame. (default: false)
  69014. * @param textureType Type of textures used when performing the post process. (default: 0)
  69015. * @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)
  69016. */
  69017. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69018. }
  69019. }
  69020. declare module BABYLON {
  69021. /**
  69022. * PostProcessRenderPipeline
  69023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69024. */
  69025. export class PostProcessRenderPipeline {
  69026. private engine;
  69027. private _renderEffects;
  69028. private _renderEffectsForIsolatedPass;
  69029. /**
  69030. * List of inspectable custom properties (used by the Inspector)
  69031. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69032. */
  69033. inspectableCustomProperties: IInspectable[];
  69034. /**
  69035. * @hidden
  69036. */
  69037. protected _cameras: Camera[];
  69038. /** @hidden */
  69039. _name: string;
  69040. /**
  69041. * Gets pipeline name
  69042. */
  69043. get name(): string;
  69044. /** Gets the list of attached cameras */
  69045. get cameras(): Camera[];
  69046. /**
  69047. * Initializes a PostProcessRenderPipeline
  69048. * @param engine engine to add the pipeline to
  69049. * @param name name of the pipeline
  69050. */
  69051. constructor(engine: Engine, name: string);
  69052. /**
  69053. * Gets the class name
  69054. * @returns "PostProcessRenderPipeline"
  69055. */
  69056. getClassName(): string;
  69057. /**
  69058. * If all the render effects in the pipeline are supported
  69059. */
  69060. get isSupported(): boolean;
  69061. /**
  69062. * Adds an effect to the pipeline
  69063. * @param renderEffect the effect to add
  69064. */
  69065. addEffect(renderEffect: PostProcessRenderEffect): void;
  69066. /** @hidden */
  69067. _rebuild(): void;
  69068. /** @hidden */
  69069. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69070. /** @hidden */
  69071. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69072. /** @hidden */
  69073. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69074. /** @hidden */
  69075. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69076. /** @hidden */
  69077. _attachCameras(cameras: Camera, unique: boolean): void;
  69078. /** @hidden */
  69079. _attachCameras(cameras: Camera[], unique: boolean): void;
  69080. /** @hidden */
  69081. _detachCameras(cameras: Camera): void;
  69082. /** @hidden */
  69083. _detachCameras(cameras: Nullable<Camera[]>): void;
  69084. /** @hidden */
  69085. _update(): void;
  69086. /** @hidden */
  69087. _reset(): void;
  69088. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69089. /**
  69090. * Disposes of the pipeline
  69091. */
  69092. dispose(): void;
  69093. }
  69094. }
  69095. declare module BABYLON {
  69096. /**
  69097. * PostProcessRenderPipelineManager class
  69098. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69099. */
  69100. export class PostProcessRenderPipelineManager {
  69101. private _renderPipelines;
  69102. /**
  69103. * Initializes a PostProcessRenderPipelineManager
  69104. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69105. */
  69106. constructor();
  69107. /**
  69108. * Gets the list of supported render pipelines
  69109. */
  69110. get supportedPipelines(): PostProcessRenderPipeline[];
  69111. /**
  69112. * Adds a pipeline to the manager
  69113. * @param renderPipeline The pipeline to add
  69114. */
  69115. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69116. /**
  69117. * Attaches a camera to the pipeline
  69118. * @param renderPipelineName The name of the pipeline to attach to
  69119. * @param cameras the camera to attach
  69120. * @param unique if the camera can be attached multiple times to the pipeline
  69121. */
  69122. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69123. /**
  69124. * Detaches a camera from the pipeline
  69125. * @param renderPipelineName The name of the pipeline to detach from
  69126. * @param cameras the camera to detach
  69127. */
  69128. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69129. /**
  69130. * Enables an effect by name on a pipeline
  69131. * @param renderPipelineName the name of the pipeline to enable the effect in
  69132. * @param renderEffectName the name of the effect to enable
  69133. * @param cameras the cameras that the effect should be enabled on
  69134. */
  69135. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69136. /**
  69137. * Disables an effect by name on a pipeline
  69138. * @param renderPipelineName the name of the pipeline to disable the effect in
  69139. * @param renderEffectName the name of the effect to disable
  69140. * @param cameras the cameras that the effect should be disabled on
  69141. */
  69142. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69143. /**
  69144. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69145. */
  69146. update(): void;
  69147. /** @hidden */
  69148. _rebuild(): void;
  69149. /**
  69150. * Disposes of the manager and pipelines
  69151. */
  69152. dispose(): void;
  69153. }
  69154. }
  69155. declare module BABYLON {
  69156. interface Scene {
  69157. /** @hidden (Backing field) */
  69158. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69159. /**
  69160. * Gets the postprocess render pipeline manager
  69161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69162. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69163. */
  69164. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69165. }
  69166. /**
  69167. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69168. */
  69169. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69170. /**
  69171. * The component name helpfull to identify the component in the list of scene components.
  69172. */
  69173. readonly name: string;
  69174. /**
  69175. * The scene the component belongs to.
  69176. */
  69177. scene: Scene;
  69178. /**
  69179. * Creates a new instance of the component for the given scene
  69180. * @param scene Defines the scene to register the component in
  69181. */
  69182. constructor(scene: Scene);
  69183. /**
  69184. * Registers the component in a given scene
  69185. */
  69186. register(): void;
  69187. /**
  69188. * Rebuilds the elements related to this component in case of
  69189. * context lost for instance.
  69190. */
  69191. rebuild(): void;
  69192. /**
  69193. * Disposes the component and the associated ressources
  69194. */
  69195. dispose(): void;
  69196. private _gatherRenderTargets;
  69197. }
  69198. }
  69199. declare module BABYLON {
  69200. /**
  69201. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69202. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69203. */
  69204. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69205. private _scene;
  69206. private _camerasToBeAttached;
  69207. /**
  69208. * ID of the sharpen post process,
  69209. */
  69210. private readonly SharpenPostProcessId;
  69211. /**
  69212. * @ignore
  69213. * ID of the image processing post process;
  69214. */
  69215. readonly ImageProcessingPostProcessId: string;
  69216. /**
  69217. * @ignore
  69218. * ID of the Fast Approximate Anti-Aliasing post process;
  69219. */
  69220. readonly FxaaPostProcessId: string;
  69221. /**
  69222. * ID of the chromatic aberration post process,
  69223. */
  69224. private readonly ChromaticAberrationPostProcessId;
  69225. /**
  69226. * ID of the grain post process
  69227. */
  69228. private readonly GrainPostProcessId;
  69229. /**
  69230. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69231. */
  69232. sharpen: SharpenPostProcess;
  69233. private _sharpenEffect;
  69234. private bloom;
  69235. /**
  69236. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69237. */
  69238. depthOfField: DepthOfFieldEffect;
  69239. /**
  69240. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69241. */
  69242. fxaa: FxaaPostProcess;
  69243. /**
  69244. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69245. */
  69246. imageProcessing: ImageProcessingPostProcess;
  69247. /**
  69248. * Chromatic aberration post process which will shift rgb colors in the image
  69249. */
  69250. chromaticAberration: ChromaticAberrationPostProcess;
  69251. private _chromaticAberrationEffect;
  69252. /**
  69253. * Grain post process which add noise to the image
  69254. */
  69255. grain: GrainPostProcess;
  69256. private _grainEffect;
  69257. /**
  69258. * Glow post process which adds a glow to emissive areas of the image
  69259. */
  69260. private _glowLayer;
  69261. /**
  69262. * Animations which can be used to tweak settings over a period of time
  69263. */
  69264. animations: Animation[];
  69265. private _imageProcessingConfigurationObserver;
  69266. private _sharpenEnabled;
  69267. private _bloomEnabled;
  69268. private _depthOfFieldEnabled;
  69269. private _depthOfFieldBlurLevel;
  69270. private _fxaaEnabled;
  69271. private _imageProcessingEnabled;
  69272. private _defaultPipelineTextureType;
  69273. private _bloomScale;
  69274. private _chromaticAberrationEnabled;
  69275. private _grainEnabled;
  69276. private _buildAllowed;
  69277. /**
  69278. * Gets active scene
  69279. */
  69280. get scene(): Scene;
  69281. /**
  69282. * Enable or disable the sharpen process from the pipeline
  69283. */
  69284. set sharpenEnabled(enabled: boolean);
  69285. get sharpenEnabled(): boolean;
  69286. private _resizeObserver;
  69287. private _hardwareScaleLevel;
  69288. private _bloomKernel;
  69289. /**
  69290. * Specifies the size of the bloom blur kernel, relative to the final output size
  69291. */
  69292. get bloomKernel(): number;
  69293. set bloomKernel(value: number);
  69294. /**
  69295. * Specifies the weight of the bloom in the final rendering
  69296. */
  69297. private _bloomWeight;
  69298. /**
  69299. * Specifies the luma threshold for the area that will be blurred by the bloom
  69300. */
  69301. private _bloomThreshold;
  69302. private _hdr;
  69303. /**
  69304. * The strength of the bloom.
  69305. */
  69306. set bloomWeight(value: number);
  69307. get bloomWeight(): number;
  69308. /**
  69309. * The strength of the bloom.
  69310. */
  69311. set bloomThreshold(value: number);
  69312. get bloomThreshold(): number;
  69313. /**
  69314. * The scale of the bloom, lower value will provide better performance.
  69315. */
  69316. set bloomScale(value: number);
  69317. get bloomScale(): number;
  69318. /**
  69319. * Enable or disable the bloom from the pipeline
  69320. */
  69321. set bloomEnabled(enabled: boolean);
  69322. get bloomEnabled(): boolean;
  69323. private _rebuildBloom;
  69324. /**
  69325. * If the depth of field is enabled.
  69326. */
  69327. get depthOfFieldEnabled(): boolean;
  69328. set depthOfFieldEnabled(enabled: boolean);
  69329. /**
  69330. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69331. */
  69332. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69333. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69334. /**
  69335. * If the anti aliasing is enabled.
  69336. */
  69337. set fxaaEnabled(enabled: boolean);
  69338. get fxaaEnabled(): boolean;
  69339. private _samples;
  69340. /**
  69341. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69342. */
  69343. set samples(sampleCount: number);
  69344. get samples(): number;
  69345. /**
  69346. * If image processing is enabled.
  69347. */
  69348. set imageProcessingEnabled(enabled: boolean);
  69349. get imageProcessingEnabled(): boolean;
  69350. /**
  69351. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69352. */
  69353. set glowLayerEnabled(enabled: boolean);
  69354. get glowLayerEnabled(): boolean;
  69355. /**
  69356. * Gets the glow layer (or null if not defined)
  69357. */
  69358. get glowLayer(): Nullable<GlowLayer>;
  69359. /**
  69360. * Enable or disable the chromaticAberration process from the pipeline
  69361. */
  69362. set chromaticAberrationEnabled(enabled: boolean);
  69363. get chromaticAberrationEnabled(): boolean;
  69364. /**
  69365. * Enable or disable the grain process from the pipeline
  69366. */
  69367. set grainEnabled(enabled: boolean);
  69368. get grainEnabled(): boolean;
  69369. /**
  69370. * @constructor
  69371. * @param name - The rendering pipeline name (default: "")
  69372. * @param hdr - If high dynamic range textures should be used (default: true)
  69373. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69374. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69375. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69376. */
  69377. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69378. /**
  69379. * Get the class name
  69380. * @returns "DefaultRenderingPipeline"
  69381. */
  69382. getClassName(): string;
  69383. /**
  69384. * Force the compilation of the entire pipeline.
  69385. */
  69386. prepare(): void;
  69387. private _hasCleared;
  69388. private _prevPostProcess;
  69389. private _prevPrevPostProcess;
  69390. private _setAutoClearAndTextureSharing;
  69391. private _depthOfFieldSceneObserver;
  69392. private _buildPipeline;
  69393. private _disposePostProcesses;
  69394. /**
  69395. * Adds a camera to the pipeline
  69396. * @param camera the camera to be added
  69397. */
  69398. addCamera(camera: Camera): void;
  69399. /**
  69400. * Removes a camera from the pipeline
  69401. * @param camera the camera to remove
  69402. */
  69403. removeCamera(camera: Camera): void;
  69404. /**
  69405. * Dispose of the pipeline and stop all post processes
  69406. */
  69407. dispose(): void;
  69408. /**
  69409. * Serialize the rendering pipeline (Used when exporting)
  69410. * @returns the serialized object
  69411. */
  69412. serialize(): any;
  69413. /**
  69414. * Parse the serialized pipeline
  69415. * @param source Source pipeline.
  69416. * @param scene The scene to load the pipeline to.
  69417. * @param rootUrl The URL of the serialized pipeline.
  69418. * @returns An instantiated pipeline from the serialized object.
  69419. */
  69420. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /** @hidden */
  69425. export var lensHighlightsPixelShader: {
  69426. name: string;
  69427. shader: string;
  69428. };
  69429. }
  69430. declare module BABYLON {
  69431. /** @hidden */
  69432. export var depthOfFieldPixelShader: {
  69433. name: string;
  69434. shader: string;
  69435. };
  69436. }
  69437. declare module BABYLON {
  69438. /**
  69439. * BABYLON.JS Chromatic Aberration GLSL Shader
  69440. * Author: Olivier Guyot
  69441. * Separates very slightly R, G and B colors on the edges of the screen
  69442. * Inspired by Francois Tarlier & Martins Upitis
  69443. */
  69444. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69445. /**
  69446. * @ignore
  69447. * The chromatic aberration PostProcess id in the pipeline
  69448. */
  69449. LensChromaticAberrationEffect: string;
  69450. /**
  69451. * @ignore
  69452. * The highlights enhancing PostProcess id in the pipeline
  69453. */
  69454. HighlightsEnhancingEffect: string;
  69455. /**
  69456. * @ignore
  69457. * The depth-of-field PostProcess id in the pipeline
  69458. */
  69459. LensDepthOfFieldEffect: string;
  69460. private _scene;
  69461. private _depthTexture;
  69462. private _grainTexture;
  69463. private _chromaticAberrationPostProcess;
  69464. private _highlightsPostProcess;
  69465. private _depthOfFieldPostProcess;
  69466. private _edgeBlur;
  69467. private _grainAmount;
  69468. private _chromaticAberration;
  69469. private _distortion;
  69470. private _highlightsGain;
  69471. private _highlightsThreshold;
  69472. private _dofDistance;
  69473. private _dofAperture;
  69474. private _dofDarken;
  69475. private _dofPentagon;
  69476. private _blurNoise;
  69477. /**
  69478. * @constructor
  69479. *
  69480. * Effect parameters are as follow:
  69481. * {
  69482. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69483. * edge_blur: number; // from 0 to x (1 for realism)
  69484. * distortion: number; // from 0 to x (1 for realism)
  69485. * grain_amount: number; // from 0 to 1
  69486. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69487. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69488. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69489. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69490. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69491. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69492. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69493. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69494. * }
  69495. * Note: if an effect parameter is unset, effect is disabled
  69496. *
  69497. * @param name The rendering pipeline name
  69498. * @param parameters - An object containing all parameters (see above)
  69499. * @param scene The scene linked to this pipeline
  69500. * @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)
  69501. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69502. */
  69503. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69504. /**
  69505. * Get the class name
  69506. * @returns "LensRenderingPipeline"
  69507. */
  69508. getClassName(): string;
  69509. /**
  69510. * Gets associated scene
  69511. */
  69512. get scene(): Scene;
  69513. /**
  69514. * Gets or sets the edge blur
  69515. */
  69516. get edgeBlur(): number;
  69517. set edgeBlur(value: number);
  69518. /**
  69519. * Gets or sets the grain amount
  69520. */
  69521. get grainAmount(): number;
  69522. set grainAmount(value: number);
  69523. /**
  69524. * Gets or sets the chromatic aberration amount
  69525. */
  69526. get chromaticAberration(): number;
  69527. set chromaticAberration(value: number);
  69528. /**
  69529. * Gets or sets the depth of field aperture
  69530. */
  69531. get dofAperture(): number;
  69532. set dofAperture(value: number);
  69533. /**
  69534. * Gets or sets the edge distortion
  69535. */
  69536. get edgeDistortion(): number;
  69537. set edgeDistortion(value: number);
  69538. /**
  69539. * Gets or sets the depth of field distortion
  69540. */
  69541. get dofDistortion(): number;
  69542. set dofDistortion(value: number);
  69543. /**
  69544. * Gets or sets the darken out of focus amount
  69545. */
  69546. get darkenOutOfFocus(): number;
  69547. set darkenOutOfFocus(value: number);
  69548. /**
  69549. * Gets or sets a boolean indicating if blur noise is enabled
  69550. */
  69551. get blurNoise(): boolean;
  69552. set blurNoise(value: boolean);
  69553. /**
  69554. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69555. */
  69556. get pentagonBokeh(): boolean;
  69557. set pentagonBokeh(value: boolean);
  69558. /**
  69559. * Gets or sets the highlight grain amount
  69560. */
  69561. get highlightsGain(): number;
  69562. set highlightsGain(value: number);
  69563. /**
  69564. * Gets or sets the highlight threshold
  69565. */
  69566. get highlightsThreshold(): number;
  69567. set highlightsThreshold(value: number);
  69568. /**
  69569. * Sets the amount of blur at the edges
  69570. * @param amount blur amount
  69571. */
  69572. setEdgeBlur(amount: number): void;
  69573. /**
  69574. * Sets edge blur to 0
  69575. */
  69576. disableEdgeBlur(): void;
  69577. /**
  69578. * Sets the amout of grain
  69579. * @param amount Amount of grain
  69580. */
  69581. setGrainAmount(amount: number): void;
  69582. /**
  69583. * Set grain amount to 0
  69584. */
  69585. disableGrain(): void;
  69586. /**
  69587. * Sets the chromatic aberration amount
  69588. * @param amount amount of chromatic aberration
  69589. */
  69590. setChromaticAberration(amount: number): void;
  69591. /**
  69592. * Sets chromatic aberration amount to 0
  69593. */
  69594. disableChromaticAberration(): void;
  69595. /**
  69596. * Sets the EdgeDistortion amount
  69597. * @param amount amount of EdgeDistortion
  69598. */
  69599. setEdgeDistortion(amount: number): void;
  69600. /**
  69601. * Sets edge distortion to 0
  69602. */
  69603. disableEdgeDistortion(): void;
  69604. /**
  69605. * Sets the FocusDistance amount
  69606. * @param amount amount of FocusDistance
  69607. */
  69608. setFocusDistance(amount: number): void;
  69609. /**
  69610. * Disables depth of field
  69611. */
  69612. disableDepthOfField(): void;
  69613. /**
  69614. * Sets the Aperture amount
  69615. * @param amount amount of Aperture
  69616. */
  69617. setAperture(amount: number): void;
  69618. /**
  69619. * Sets the DarkenOutOfFocus amount
  69620. * @param amount amount of DarkenOutOfFocus
  69621. */
  69622. setDarkenOutOfFocus(amount: number): void;
  69623. private _pentagonBokehIsEnabled;
  69624. /**
  69625. * Creates a pentagon bokeh effect
  69626. */
  69627. enablePentagonBokeh(): void;
  69628. /**
  69629. * Disables the pentagon bokeh effect
  69630. */
  69631. disablePentagonBokeh(): void;
  69632. /**
  69633. * Enables noise blur
  69634. */
  69635. enableNoiseBlur(): void;
  69636. /**
  69637. * Disables noise blur
  69638. */
  69639. disableNoiseBlur(): void;
  69640. /**
  69641. * Sets the HighlightsGain amount
  69642. * @param amount amount of HighlightsGain
  69643. */
  69644. setHighlightsGain(amount: number): void;
  69645. /**
  69646. * Sets the HighlightsThreshold amount
  69647. * @param amount amount of HighlightsThreshold
  69648. */
  69649. setHighlightsThreshold(amount: number): void;
  69650. /**
  69651. * Disables highlights
  69652. */
  69653. disableHighlights(): void;
  69654. /**
  69655. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69656. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69657. */
  69658. dispose(disableDepthRender?: boolean): void;
  69659. private _createChromaticAberrationPostProcess;
  69660. private _createHighlightsPostProcess;
  69661. private _createDepthOfFieldPostProcess;
  69662. private _createGrainTexture;
  69663. }
  69664. }
  69665. declare module BABYLON {
  69666. /** @hidden */
  69667. export var fibonacci: {
  69668. name: string;
  69669. shader: string;
  69670. };
  69671. }
  69672. declare module BABYLON {
  69673. /** @hidden */
  69674. export var diffusionProfile: {
  69675. name: string;
  69676. shader: string;
  69677. };
  69678. }
  69679. declare module BABYLON {
  69680. /** @hidden */
  69681. export var subSurfaceScatteringPixelShader: {
  69682. name: string;
  69683. shader: string;
  69684. };
  69685. }
  69686. declare module BABYLON {
  69687. /**
  69688. * Sub surface scattering post process
  69689. */
  69690. export class SubSurfaceScatteringPostProcess extends PostProcess {
  69691. /** @hidden */
  69692. texelWidth: number;
  69693. /** @hidden */
  69694. texelHeight: number;
  69695. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Interface for defining prepass effects in the prepass post-process pipeline
  69701. */
  69702. export interface PrePassEffectConfiguration {
  69703. /**
  69704. * Post process to attach for this effect
  69705. */
  69706. postProcess: PostProcess;
  69707. /**
  69708. * Is the effect enabled
  69709. */
  69710. enabled: boolean;
  69711. /**
  69712. * Disposes the effect configuration
  69713. */
  69714. dispose(): void;
  69715. /**
  69716. * Disposes the effect configuration
  69717. */
  69718. createPostProcess: () => PostProcess;
  69719. }
  69720. }
  69721. declare module BABYLON {
  69722. /**
  69723. * Contains all parameters needed for the prepass to perform
  69724. * screen space subsurface scattering
  69725. */
  69726. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  69727. private _ssDiffusionS;
  69728. private _ssFilterRadii;
  69729. private _ssDiffusionD;
  69730. /**
  69731. * Post process to attach for screen space subsurface scattering
  69732. */
  69733. postProcess: SubSurfaceScatteringPostProcess;
  69734. /**
  69735. * Diffusion profile color for subsurface scattering
  69736. */
  69737. get ssDiffusionS(): number[];
  69738. /**
  69739. * Diffusion profile max color channel value for subsurface scattering
  69740. */
  69741. get ssDiffusionD(): number[];
  69742. /**
  69743. * Diffusion profile filter radius for subsurface scattering
  69744. */
  69745. get ssFilterRadii(): number[];
  69746. /**
  69747. * Is subsurface enabled
  69748. */
  69749. enabled: boolean;
  69750. /**
  69751. * Diffusion profile colors for subsurface scattering
  69752. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  69753. * See ...
  69754. * Note that you can only store up to 5 of them
  69755. */
  69756. ssDiffusionProfileColors: Color3[];
  69757. /**
  69758. * Defines the ratio real world => scene units.
  69759. * Used for subsurface scattering
  69760. */
  69761. metersPerUnit: number;
  69762. private _scene;
  69763. /**
  69764. * Builds a subsurface configuration object
  69765. * @param scene The scene
  69766. */
  69767. constructor(scene: Scene);
  69768. /**
  69769. * Adds a new diffusion profile.
  69770. * Useful for more realistic subsurface scattering on diverse materials.
  69771. * @param color The color of the diffusion profile. Should be the average color of the material.
  69772. * @return The index of the diffusion profile for the material subsurface configuration
  69773. */
  69774. addDiffusionProfile(color: Color3): number;
  69775. /**
  69776. * Creates the sss post process
  69777. * @return The created post process
  69778. */
  69779. createPostProcess(): SubSurfaceScatteringPostProcess;
  69780. /**
  69781. * Deletes all diffusion profiles.
  69782. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  69783. */
  69784. clearAllDiffusionProfiles(): void;
  69785. /**
  69786. * Disposes this object
  69787. */
  69788. dispose(): void;
  69789. /**
  69790. * @hidden
  69791. * https://zero-radiance.github.io/post/sampling-diffusion/
  69792. *
  69793. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  69794. * ------------------------------------------------------------------------------------
  69795. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  69796. * PDF[r, phi, s] = r * R[r, phi, s]
  69797. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  69798. * ------------------------------------------------------------------------------------
  69799. * We importance sample the color channel with the widest scattering distance.
  69800. */
  69801. getDiffusionProfileParameters(color: Color3): number;
  69802. /**
  69803. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  69804. * 'u' is the random number (the value of the CDF): [0, 1).
  69805. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  69806. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  69807. */
  69808. private _sampleBurleyDiffusionProfile;
  69809. }
  69810. }
  69811. declare module BABYLON {
  69812. /**
  69813. * Renders a pre pass of the scene
  69814. * This means every mesh in the scene will be rendered to a render target texture
  69815. * And then this texture will be composited to the rendering canvas with post processes
  69816. * It is necessary for effects like subsurface scattering or deferred shading
  69817. */
  69818. export class PrePassRenderer {
  69819. /** @hidden */
  69820. static _SceneComponentInitialization: (scene: Scene) => void;
  69821. private _scene;
  69822. private _engine;
  69823. private _isDirty;
  69824. /**
  69825. * Number of textures in the multi render target texture where the scene is directly rendered
  69826. */
  69827. readonly mrtCount: number;
  69828. /**
  69829. * The render target where the scene is directly rendered
  69830. */
  69831. prePassRT: MultiRenderTarget;
  69832. private _mrtTypes;
  69833. private _multiRenderAttachments;
  69834. private _defaultAttachments;
  69835. private _clearAttachments;
  69836. private _postProcesses;
  69837. private readonly _clearColor;
  69838. /**
  69839. * Image processing post process for composition
  69840. */
  69841. imageProcessingPostProcess: ImageProcessingPostProcess;
  69842. /**
  69843. * Configuration for sub surface scattering post process
  69844. */
  69845. subSurfaceConfiguration: SubSurfaceConfiguration;
  69846. /**
  69847. * Should materials render their geometry on the MRT
  69848. */
  69849. materialsShouldRenderGeometry: boolean;
  69850. /**
  69851. * Should materials render the irradiance information on the MRT
  69852. */
  69853. materialsShouldRenderIrradiance: boolean;
  69854. private _enabled;
  69855. /**
  69856. * Indicates if the prepass is enabled
  69857. */
  69858. get enabled(): boolean;
  69859. /**
  69860. * How many samples are used for MSAA of the scene render target
  69861. */
  69862. get samples(): number;
  69863. set samples(n: number);
  69864. /**
  69865. * Instanciates a prepass renderer
  69866. * @param scene The scene
  69867. */
  69868. constructor(scene: Scene);
  69869. private _initializeAttachments;
  69870. private _createCompositionEffect;
  69871. /**
  69872. * Indicates if rendering a prepass is supported
  69873. */
  69874. get isSupported(): boolean;
  69875. /**
  69876. * Sets the proper output textures to draw in the engine.
  69877. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  69878. */
  69879. bindAttachmentsForEffect(effect: Effect): void;
  69880. /**
  69881. * @hidden
  69882. */
  69883. _beforeCameraDraw(): void;
  69884. /**
  69885. * @hidden
  69886. */
  69887. _afterCameraDraw(): void;
  69888. private _checkRTSize;
  69889. private _bindFrameBuffer;
  69890. /**
  69891. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  69892. */
  69893. clear(): void;
  69894. private _setState;
  69895. private _enable;
  69896. private _disable;
  69897. private _resetPostProcessChain;
  69898. private _bindPostProcessChain;
  69899. /**
  69900. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  69901. */
  69902. markAsDirty(): void;
  69903. private _update;
  69904. /**
  69905. * Disposes the prepass renderer.
  69906. */
  69907. dispose(): void;
  69908. }
  69909. }
  69910. declare module BABYLON {
  69911. /** @hidden */
  69912. export var ssao2PixelShader: {
  69913. name: string;
  69914. shader: string;
  69915. };
  69916. }
  69917. declare module BABYLON {
  69918. /** @hidden */
  69919. export var ssaoCombinePixelShader: {
  69920. name: string;
  69921. shader: string;
  69922. };
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Render pipeline to produce ssao effect
  69927. */
  69928. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69929. /**
  69930. * @ignore
  69931. * The PassPostProcess id in the pipeline that contains the original scene color
  69932. */
  69933. SSAOOriginalSceneColorEffect: string;
  69934. /**
  69935. * @ignore
  69936. * The SSAO PostProcess id in the pipeline
  69937. */
  69938. SSAORenderEffect: string;
  69939. /**
  69940. * @ignore
  69941. * The horizontal blur PostProcess id in the pipeline
  69942. */
  69943. SSAOBlurHRenderEffect: string;
  69944. /**
  69945. * @ignore
  69946. * The vertical blur PostProcess id in the pipeline
  69947. */
  69948. SSAOBlurVRenderEffect: string;
  69949. /**
  69950. * @ignore
  69951. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69952. */
  69953. SSAOCombineRenderEffect: string;
  69954. /**
  69955. * The output strength of the SSAO post-process. Default value is 1.0.
  69956. */
  69957. totalStrength: number;
  69958. /**
  69959. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69960. */
  69961. maxZ: number;
  69962. /**
  69963. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69964. */
  69965. minZAspect: number;
  69966. private _samples;
  69967. /**
  69968. * Number of samples used for the SSAO calculations. Default value is 8
  69969. */
  69970. set samples(n: number);
  69971. get samples(): number;
  69972. private _textureSamples;
  69973. /**
  69974. * Number of samples to use for antialiasing
  69975. */
  69976. set textureSamples(n: number);
  69977. get textureSamples(): number;
  69978. /**
  69979. * Force rendering the geometry through geometry buffer
  69980. */
  69981. private _forceGeometryBuffer;
  69982. /**
  69983. * Ratio object used for SSAO ratio and blur ratio
  69984. */
  69985. private _ratio;
  69986. /**
  69987. * Dynamically generated sphere sampler.
  69988. */
  69989. private _sampleSphere;
  69990. /**
  69991. * Blur filter offsets
  69992. */
  69993. private _samplerOffsets;
  69994. private _expensiveBlur;
  69995. /**
  69996. * If bilateral blur should be used
  69997. */
  69998. set expensiveBlur(b: boolean);
  69999. get expensiveBlur(): boolean;
  70000. /**
  70001. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70002. */
  70003. radius: number;
  70004. /**
  70005. * The base color of the SSAO post-process
  70006. * The final result is "base + ssao" between [0, 1]
  70007. */
  70008. base: number;
  70009. /**
  70010. * Support test.
  70011. */
  70012. static get IsSupported(): boolean;
  70013. private _scene;
  70014. private _randomTexture;
  70015. private _originalColorPostProcess;
  70016. private _ssaoPostProcess;
  70017. private _blurHPostProcess;
  70018. private _blurVPostProcess;
  70019. private _ssaoCombinePostProcess;
  70020. private _prePassRenderer;
  70021. /**
  70022. * Gets active scene
  70023. */
  70024. get scene(): Scene;
  70025. /**
  70026. * @constructor
  70027. * @param name The rendering pipeline name
  70028. * @param scene The scene linked to this pipeline
  70029. * @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 }
  70030. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70031. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70032. */
  70033. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70034. /**
  70035. * Get the class name
  70036. * @returns "SSAO2RenderingPipeline"
  70037. */
  70038. getClassName(): string;
  70039. /**
  70040. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70041. */
  70042. dispose(disableGeometryBufferRenderer?: boolean): void;
  70043. private _createBlurPostProcess;
  70044. /** @hidden */
  70045. _rebuild(): void;
  70046. private _bits;
  70047. private _radicalInverse_VdC;
  70048. private _hammersley;
  70049. private _hemisphereSample_uniform;
  70050. private _generateHemisphere;
  70051. private _getDefinesForSSAO;
  70052. private _createSSAOPostProcess;
  70053. private _createSSAOCombinePostProcess;
  70054. private _createRandomTexture;
  70055. /**
  70056. * Serialize the rendering pipeline (Used when exporting)
  70057. * @returns the serialized object
  70058. */
  70059. serialize(): any;
  70060. /**
  70061. * Parse the serialized pipeline
  70062. * @param source Source pipeline.
  70063. * @param scene The scene to load the pipeline to.
  70064. * @param rootUrl The URL of the serialized pipeline.
  70065. * @returns An instantiated pipeline from the serialized object.
  70066. */
  70067. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70068. }
  70069. }
  70070. declare module BABYLON {
  70071. /** @hidden */
  70072. export var ssaoPixelShader: {
  70073. name: string;
  70074. shader: string;
  70075. };
  70076. }
  70077. declare module BABYLON {
  70078. /**
  70079. * Render pipeline to produce ssao effect
  70080. */
  70081. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70082. /**
  70083. * @ignore
  70084. * The PassPostProcess id in the pipeline that contains the original scene color
  70085. */
  70086. SSAOOriginalSceneColorEffect: string;
  70087. /**
  70088. * @ignore
  70089. * The SSAO PostProcess id in the pipeline
  70090. */
  70091. SSAORenderEffect: string;
  70092. /**
  70093. * @ignore
  70094. * The horizontal blur PostProcess id in the pipeline
  70095. */
  70096. SSAOBlurHRenderEffect: string;
  70097. /**
  70098. * @ignore
  70099. * The vertical blur PostProcess id in the pipeline
  70100. */
  70101. SSAOBlurVRenderEffect: string;
  70102. /**
  70103. * @ignore
  70104. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70105. */
  70106. SSAOCombineRenderEffect: string;
  70107. /**
  70108. * The output strength of the SSAO post-process. Default value is 1.0.
  70109. */
  70110. totalStrength: number;
  70111. /**
  70112. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70113. */
  70114. radius: number;
  70115. /**
  70116. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70117. * Must not be equal to fallOff and superior to fallOff.
  70118. * Default value is 0.0075
  70119. */
  70120. area: number;
  70121. /**
  70122. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70123. * Must not be equal to area and inferior to area.
  70124. * Default value is 0.000001
  70125. */
  70126. fallOff: number;
  70127. /**
  70128. * The base color of the SSAO post-process
  70129. * The final result is "base + ssao" between [0, 1]
  70130. */
  70131. base: number;
  70132. private _scene;
  70133. private _depthTexture;
  70134. private _randomTexture;
  70135. private _originalColorPostProcess;
  70136. private _ssaoPostProcess;
  70137. private _blurHPostProcess;
  70138. private _blurVPostProcess;
  70139. private _ssaoCombinePostProcess;
  70140. private _firstUpdate;
  70141. /**
  70142. * Gets active scene
  70143. */
  70144. get scene(): Scene;
  70145. /**
  70146. * @constructor
  70147. * @param name - The rendering pipeline name
  70148. * @param scene - The scene linked to this pipeline
  70149. * @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 }
  70150. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70151. */
  70152. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70153. /**
  70154. * Get the class name
  70155. * @returns "SSAORenderingPipeline"
  70156. */
  70157. getClassName(): string;
  70158. /**
  70159. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70160. */
  70161. dispose(disableDepthRender?: boolean): void;
  70162. private _createBlurPostProcess;
  70163. /** @hidden */
  70164. _rebuild(): void;
  70165. private _createSSAOPostProcess;
  70166. private _createSSAOCombinePostProcess;
  70167. private _createRandomTexture;
  70168. }
  70169. }
  70170. declare module BABYLON {
  70171. /** @hidden */
  70172. export var screenSpaceReflectionPixelShader: {
  70173. name: string;
  70174. shader: string;
  70175. };
  70176. }
  70177. declare module BABYLON {
  70178. /**
  70179. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70180. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70181. */
  70182. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70183. /**
  70184. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70185. */
  70186. threshold: number;
  70187. /**
  70188. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70189. */
  70190. strength: number;
  70191. /**
  70192. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70193. */
  70194. reflectionSpecularFalloffExponent: number;
  70195. /**
  70196. * 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]
  70197. */
  70198. step: number;
  70199. /**
  70200. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70201. */
  70202. roughnessFactor: number;
  70203. private _geometryBufferRenderer;
  70204. private _enableSmoothReflections;
  70205. private _reflectionSamples;
  70206. private _smoothSteps;
  70207. /**
  70208. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70209. * @param name The name of the effect.
  70210. * @param scene The scene containing the objects to calculate reflections.
  70211. * @param options The required width/height ratio to downsize to before computing the render pass.
  70212. * @param camera The camera to apply the render pass to.
  70213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70214. * @param engine The engine which the post process will be applied. (default: current engine)
  70215. * @param reusable If the post process can be reused on the same frame. (default: false)
  70216. * @param textureType Type of textures used when performing the post process. (default: 0)
  70217. * @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)
  70218. */
  70219. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70220. /**
  70221. * Gets wether or not smoothing reflections is enabled.
  70222. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70223. */
  70224. get enableSmoothReflections(): boolean;
  70225. /**
  70226. * Sets wether or not smoothing reflections is enabled.
  70227. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70228. */
  70229. set enableSmoothReflections(enabled: boolean);
  70230. /**
  70231. * Gets the number of samples taken while computing reflections. More samples count is high,
  70232. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70233. */
  70234. get reflectionSamples(): number;
  70235. /**
  70236. * Sets the number of samples taken while computing reflections. More samples count is high,
  70237. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70238. */
  70239. set reflectionSamples(samples: number);
  70240. /**
  70241. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70242. * more the post-process will require GPU power and can generate a drop in FPS.
  70243. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70244. */
  70245. get smoothSteps(): number;
  70246. set smoothSteps(steps: number);
  70247. private _updateEffectDefines;
  70248. }
  70249. }
  70250. declare module BABYLON {
  70251. /** @hidden */
  70252. export var standardPixelShader: {
  70253. name: string;
  70254. shader: string;
  70255. };
  70256. }
  70257. declare module BABYLON {
  70258. /**
  70259. * Standard rendering pipeline
  70260. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70261. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70262. */
  70263. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70264. /**
  70265. * Public members
  70266. */
  70267. /**
  70268. * Post-process which contains the original scene color before the pipeline applies all the effects
  70269. */
  70270. originalPostProcess: Nullable<PostProcess>;
  70271. /**
  70272. * Post-process used to down scale an image x4
  70273. */
  70274. downSampleX4PostProcess: Nullable<PostProcess>;
  70275. /**
  70276. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70277. */
  70278. brightPassPostProcess: Nullable<PostProcess>;
  70279. /**
  70280. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70281. */
  70282. blurHPostProcesses: PostProcess[];
  70283. /**
  70284. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70285. */
  70286. blurVPostProcesses: PostProcess[];
  70287. /**
  70288. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70289. */
  70290. textureAdderPostProcess: Nullable<PostProcess>;
  70291. /**
  70292. * Post-process used to create volumetric lighting effect
  70293. */
  70294. volumetricLightPostProcess: Nullable<PostProcess>;
  70295. /**
  70296. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70297. */
  70298. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70299. /**
  70300. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70301. */
  70302. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70303. /**
  70304. * Post-process used to merge the volumetric light effect and the real scene color
  70305. */
  70306. volumetricLightMergePostProces: Nullable<PostProcess>;
  70307. /**
  70308. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70309. */
  70310. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70311. /**
  70312. * Base post-process used to calculate the average luminance of the final image for HDR
  70313. */
  70314. luminancePostProcess: Nullable<PostProcess>;
  70315. /**
  70316. * Post-processes used to create down sample post-processes in order to get
  70317. * the average luminance of the final image for HDR
  70318. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70319. */
  70320. luminanceDownSamplePostProcesses: PostProcess[];
  70321. /**
  70322. * Post-process used to create a HDR effect (light adaptation)
  70323. */
  70324. hdrPostProcess: Nullable<PostProcess>;
  70325. /**
  70326. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70327. */
  70328. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70329. /**
  70330. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70331. */
  70332. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70333. /**
  70334. * Post-process used to merge the final HDR post-process and the real scene color
  70335. */
  70336. hdrFinalPostProcess: Nullable<PostProcess>;
  70337. /**
  70338. * Post-process used to create a lens flare effect
  70339. */
  70340. lensFlarePostProcess: Nullable<PostProcess>;
  70341. /**
  70342. * Post-process that merges the result of the lens flare post-process and the real scene color
  70343. */
  70344. lensFlareComposePostProcess: Nullable<PostProcess>;
  70345. /**
  70346. * Post-process used to create a motion blur effect
  70347. */
  70348. motionBlurPostProcess: Nullable<PostProcess>;
  70349. /**
  70350. * Post-process used to create a depth of field effect
  70351. */
  70352. depthOfFieldPostProcess: Nullable<PostProcess>;
  70353. /**
  70354. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70355. */
  70356. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70357. /**
  70358. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70359. */
  70360. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70361. /**
  70362. * Represents the brightness threshold in order to configure the illuminated surfaces
  70363. */
  70364. brightThreshold: number;
  70365. /**
  70366. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70367. */
  70368. blurWidth: number;
  70369. /**
  70370. * Sets if the blur for highlighted surfaces must be only horizontal
  70371. */
  70372. horizontalBlur: boolean;
  70373. /**
  70374. * Gets the overall exposure used by the pipeline
  70375. */
  70376. get exposure(): number;
  70377. /**
  70378. * Sets the overall exposure used by the pipeline
  70379. */
  70380. set exposure(value: number);
  70381. /**
  70382. * Texture used typically to simulate "dirty" on camera lens
  70383. */
  70384. lensTexture: Nullable<Texture>;
  70385. /**
  70386. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70387. */
  70388. volumetricLightCoefficient: number;
  70389. /**
  70390. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70391. */
  70392. volumetricLightPower: number;
  70393. /**
  70394. * Used the set the blur intensity to smooth the volumetric lights
  70395. */
  70396. volumetricLightBlurScale: number;
  70397. /**
  70398. * Light (spot or directional) used to generate the volumetric lights rays
  70399. * The source light must have a shadow generate so the pipeline can get its
  70400. * depth map
  70401. */
  70402. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70403. /**
  70404. * For eye adaptation, represents the minimum luminance the eye can see
  70405. */
  70406. hdrMinimumLuminance: number;
  70407. /**
  70408. * For eye adaptation, represents the decrease luminance speed
  70409. */
  70410. hdrDecreaseRate: number;
  70411. /**
  70412. * For eye adaptation, represents the increase luminance speed
  70413. */
  70414. hdrIncreaseRate: number;
  70415. /**
  70416. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70417. */
  70418. get hdrAutoExposure(): boolean;
  70419. /**
  70420. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70421. */
  70422. set hdrAutoExposure(value: boolean);
  70423. /**
  70424. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70425. */
  70426. lensColorTexture: Nullable<Texture>;
  70427. /**
  70428. * The overall strengh for the lens flare effect
  70429. */
  70430. lensFlareStrength: number;
  70431. /**
  70432. * Dispersion coefficient for lens flare ghosts
  70433. */
  70434. lensFlareGhostDispersal: number;
  70435. /**
  70436. * Main lens flare halo width
  70437. */
  70438. lensFlareHaloWidth: number;
  70439. /**
  70440. * Based on the lens distortion effect, defines how much the lens flare result
  70441. * is distorted
  70442. */
  70443. lensFlareDistortionStrength: number;
  70444. /**
  70445. * Configures the blur intensity used for for lens flare (halo)
  70446. */
  70447. lensFlareBlurWidth: number;
  70448. /**
  70449. * Lens star texture must be used to simulate rays on the flares and is available
  70450. * in the documentation
  70451. */
  70452. lensStarTexture: Nullable<Texture>;
  70453. /**
  70454. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70455. * flare effect by taking account of the dirt texture
  70456. */
  70457. lensFlareDirtTexture: Nullable<Texture>;
  70458. /**
  70459. * Represents the focal length for the depth of field effect
  70460. */
  70461. depthOfFieldDistance: number;
  70462. /**
  70463. * Represents the blur intensity for the blurred part of the depth of field effect
  70464. */
  70465. depthOfFieldBlurWidth: number;
  70466. /**
  70467. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70468. */
  70469. get motionStrength(): number;
  70470. /**
  70471. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70472. */
  70473. set motionStrength(strength: number);
  70474. /**
  70475. * Gets wether or not the motion blur post-process is object based or screen based.
  70476. */
  70477. get objectBasedMotionBlur(): boolean;
  70478. /**
  70479. * Sets wether or not the motion blur post-process should be object based or screen based
  70480. */
  70481. set objectBasedMotionBlur(value: boolean);
  70482. /**
  70483. * List of animations for the pipeline (IAnimatable implementation)
  70484. */
  70485. animations: Animation[];
  70486. /**
  70487. * Private members
  70488. */
  70489. private _scene;
  70490. private _currentDepthOfFieldSource;
  70491. private _basePostProcess;
  70492. private _fixedExposure;
  70493. private _currentExposure;
  70494. private _hdrAutoExposure;
  70495. private _hdrCurrentLuminance;
  70496. private _motionStrength;
  70497. private _isObjectBasedMotionBlur;
  70498. private _floatTextureType;
  70499. private _camerasToBeAttached;
  70500. private _ratio;
  70501. private _bloomEnabled;
  70502. private _depthOfFieldEnabled;
  70503. private _vlsEnabled;
  70504. private _lensFlareEnabled;
  70505. private _hdrEnabled;
  70506. private _motionBlurEnabled;
  70507. private _fxaaEnabled;
  70508. private _screenSpaceReflectionsEnabled;
  70509. private _motionBlurSamples;
  70510. private _volumetricLightStepsCount;
  70511. private _samples;
  70512. /**
  70513. * @ignore
  70514. * Specifies if the bloom pipeline is enabled
  70515. */
  70516. get BloomEnabled(): boolean;
  70517. set BloomEnabled(enabled: boolean);
  70518. /**
  70519. * @ignore
  70520. * Specifies if the depth of field pipeline is enabed
  70521. */
  70522. get DepthOfFieldEnabled(): boolean;
  70523. set DepthOfFieldEnabled(enabled: boolean);
  70524. /**
  70525. * @ignore
  70526. * Specifies if the lens flare pipeline is enabed
  70527. */
  70528. get LensFlareEnabled(): boolean;
  70529. set LensFlareEnabled(enabled: boolean);
  70530. /**
  70531. * @ignore
  70532. * Specifies if the HDR pipeline is enabled
  70533. */
  70534. get HDREnabled(): boolean;
  70535. set HDREnabled(enabled: boolean);
  70536. /**
  70537. * @ignore
  70538. * Specifies if the volumetric lights scattering effect is enabled
  70539. */
  70540. get VLSEnabled(): boolean;
  70541. set VLSEnabled(enabled: boolean);
  70542. /**
  70543. * @ignore
  70544. * Specifies if the motion blur effect is enabled
  70545. */
  70546. get MotionBlurEnabled(): boolean;
  70547. set MotionBlurEnabled(enabled: boolean);
  70548. /**
  70549. * Specifies if anti-aliasing is enabled
  70550. */
  70551. get fxaaEnabled(): boolean;
  70552. set fxaaEnabled(enabled: boolean);
  70553. /**
  70554. * Specifies if screen space reflections are enabled.
  70555. */
  70556. get screenSpaceReflectionsEnabled(): boolean;
  70557. set screenSpaceReflectionsEnabled(enabled: boolean);
  70558. /**
  70559. * Specifies the number of steps used to calculate the volumetric lights
  70560. * Typically in interval [50, 200]
  70561. */
  70562. get volumetricLightStepsCount(): number;
  70563. set volumetricLightStepsCount(count: number);
  70564. /**
  70565. * Specifies the number of samples used for the motion blur effect
  70566. * Typically in interval [16, 64]
  70567. */
  70568. get motionBlurSamples(): number;
  70569. set motionBlurSamples(samples: number);
  70570. /**
  70571. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70572. */
  70573. get samples(): number;
  70574. set samples(sampleCount: number);
  70575. /**
  70576. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70577. * @constructor
  70578. * @param name The rendering pipeline name
  70579. * @param scene The scene linked to this pipeline
  70580. * @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)
  70581. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70582. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70583. */
  70584. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70585. private _buildPipeline;
  70586. private _createDownSampleX4PostProcess;
  70587. private _createBrightPassPostProcess;
  70588. private _createBlurPostProcesses;
  70589. private _createTextureAdderPostProcess;
  70590. private _createVolumetricLightPostProcess;
  70591. private _createLuminancePostProcesses;
  70592. private _createHdrPostProcess;
  70593. private _createLensFlarePostProcess;
  70594. private _createDepthOfFieldPostProcess;
  70595. private _createMotionBlurPostProcess;
  70596. private _getDepthTexture;
  70597. private _disposePostProcesses;
  70598. /**
  70599. * Dispose of the pipeline and stop all post processes
  70600. */
  70601. dispose(): void;
  70602. /**
  70603. * Serialize the rendering pipeline (Used when exporting)
  70604. * @returns the serialized object
  70605. */
  70606. serialize(): any;
  70607. /**
  70608. * Parse the serialized pipeline
  70609. * @param source Source pipeline.
  70610. * @param scene The scene to load the pipeline to.
  70611. * @param rootUrl The URL of the serialized pipeline.
  70612. * @returns An instantiated pipeline from the serialized object.
  70613. */
  70614. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70615. /**
  70616. * Luminance steps
  70617. */
  70618. static LuminanceSteps: number;
  70619. }
  70620. }
  70621. declare module BABYLON {
  70622. /** @hidden */
  70623. export var stereoscopicInterlacePixelShader: {
  70624. name: string;
  70625. shader: string;
  70626. };
  70627. }
  70628. declare module BABYLON {
  70629. /**
  70630. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70631. */
  70632. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70633. private _stepSize;
  70634. private _passedProcess;
  70635. /**
  70636. * Initializes a StereoscopicInterlacePostProcessI
  70637. * @param name The name of the effect.
  70638. * @param rigCameras The rig cameras to be appled to the post process
  70639. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70640. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70642. * @param engine The engine which the post process will be applied. (default: current engine)
  70643. * @param reusable If the post process can be reused on the same frame. (default: false)
  70644. */
  70645. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70646. }
  70647. /**
  70648. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70649. */
  70650. export class StereoscopicInterlacePostProcess extends PostProcess {
  70651. private _stepSize;
  70652. private _passedProcess;
  70653. /**
  70654. * Initializes a StereoscopicInterlacePostProcess
  70655. * @param name The name of the effect.
  70656. * @param rigCameras The rig cameras to be appled to the post process
  70657. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70659. * @param engine The engine which the post process will be applied. (default: current engine)
  70660. * @param reusable If the post process can be reused on the same frame. (default: false)
  70661. */
  70662. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70663. }
  70664. }
  70665. declare module BABYLON {
  70666. /** @hidden */
  70667. export var tonemapPixelShader: {
  70668. name: string;
  70669. shader: string;
  70670. };
  70671. }
  70672. declare module BABYLON {
  70673. /** Defines operator used for tonemapping */
  70674. export enum TonemappingOperator {
  70675. /** Hable */
  70676. Hable = 0,
  70677. /** Reinhard */
  70678. Reinhard = 1,
  70679. /** HejiDawson */
  70680. HejiDawson = 2,
  70681. /** Photographic */
  70682. Photographic = 3
  70683. }
  70684. /**
  70685. * Defines a post process to apply tone mapping
  70686. */
  70687. export class TonemapPostProcess extends PostProcess {
  70688. private _operator;
  70689. /** Defines the required exposure adjustement */
  70690. exposureAdjustment: number;
  70691. /**
  70692. * Creates a new TonemapPostProcess
  70693. * @param name defines the name of the postprocess
  70694. * @param _operator defines the operator to use
  70695. * @param exposureAdjustment defines the required exposure adjustement
  70696. * @param camera defines the camera to use (can be null)
  70697. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70698. * @param engine defines the hosting engine (can be ignore if camera is set)
  70699. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70700. */
  70701. constructor(name: string, _operator: TonemappingOperator,
  70702. /** Defines the required exposure adjustement */
  70703. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70704. }
  70705. }
  70706. declare module BABYLON {
  70707. /** @hidden */
  70708. export var volumetricLightScatteringPixelShader: {
  70709. name: string;
  70710. shader: string;
  70711. };
  70712. }
  70713. declare module BABYLON {
  70714. /** @hidden */
  70715. export var volumetricLightScatteringPassVertexShader: {
  70716. name: string;
  70717. shader: string;
  70718. };
  70719. }
  70720. declare module BABYLON {
  70721. /** @hidden */
  70722. export var volumetricLightScatteringPassPixelShader: {
  70723. name: string;
  70724. shader: string;
  70725. };
  70726. }
  70727. declare module BABYLON {
  70728. /**
  70729. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70730. */
  70731. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70732. private _volumetricLightScatteringPass;
  70733. private _volumetricLightScatteringRTT;
  70734. private _viewPort;
  70735. private _screenCoordinates;
  70736. private _cachedDefines;
  70737. /**
  70738. * If not undefined, the mesh position is computed from the attached node position
  70739. */
  70740. attachedNode: {
  70741. position: Vector3;
  70742. };
  70743. /**
  70744. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70745. */
  70746. customMeshPosition: Vector3;
  70747. /**
  70748. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70749. */
  70750. useCustomMeshPosition: boolean;
  70751. /**
  70752. * If the post-process should inverse the light scattering direction
  70753. */
  70754. invert: boolean;
  70755. /**
  70756. * The internal mesh used by the post-process
  70757. */
  70758. mesh: Mesh;
  70759. /**
  70760. * @hidden
  70761. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70762. */
  70763. get useDiffuseColor(): boolean;
  70764. set useDiffuseColor(useDiffuseColor: boolean);
  70765. /**
  70766. * Array containing the excluded meshes not rendered in the internal pass
  70767. */
  70768. excludedMeshes: AbstractMesh[];
  70769. /**
  70770. * Controls the overall intensity of the post-process
  70771. */
  70772. exposure: number;
  70773. /**
  70774. * Dissipates each sample's contribution in range [0, 1]
  70775. */
  70776. decay: number;
  70777. /**
  70778. * Controls the overall intensity of each sample
  70779. */
  70780. weight: number;
  70781. /**
  70782. * Controls the density of each sample
  70783. */
  70784. density: number;
  70785. /**
  70786. * @constructor
  70787. * @param name The post-process name
  70788. * @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)
  70789. * @param camera The camera that the post-process will be attached to
  70790. * @param mesh The mesh used to create the light scattering
  70791. * @param samples The post-process quality, default 100
  70792. * @param samplingModeThe post-process filtering mode
  70793. * @param engine The babylon engine
  70794. * @param reusable If the post-process is reusable
  70795. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70796. */
  70797. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70798. /**
  70799. * Returns the string "VolumetricLightScatteringPostProcess"
  70800. * @returns "VolumetricLightScatteringPostProcess"
  70801. */
  70802. getClassName(): string;
  70803. private _isReady;
  70804. /**
  70805. * Sets the new light position for light scattering effect
  70806. * @param position The new custom light position
  70807. */
  70808. setCustomMeshPosition(position: Vector3): void;
  70809. /**
  70810. * Returns the light position for light scattering effect
  70811. * @return Vector3 The custom light position
  70812. */
  70813. getCustomMeshPosition(): Vector3;
  70814. /**
  70815. * Disposes the internal assets and detaches the post-process from the camera
  70816. */
  70817. dispose(camera: Camera): void;
  70818. /**
  70819. * Returns the render target texture used by the post-process
  70820. * @return the render target texture used by the post-process
  70821. */
  70822. getPass(): RenderTargetTexture;
  70823. private _meshExcluded;
  70824. private _createPass;
  70825. private _updateMeshScreenCoordinates;
  70826. /**
  70827. * Creates a default mesh for the Volumeric Light Scattering post-process
  70828. * @param name The mesh name
  70829. * @param scene The scene where to create the mesh
  70830. * @return the default mesh
  70831. */
  70832. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70833. }
  70834. }
  70835. declare module BABYLON {
  70836. interface Scene {
  70837. /** @hidden (Backing field) */
  70838. _boundingBoxRenderer: BoundingBoxRenderer;
  70839. /** @hidden (Backing field) */
  70840. _forceShowBoundingBoxes: boolean;
  70841. /**
  70842. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70843. */
  70844. forceShowBoundingBoxes: boolean;
  70845. /**
  70846. * Gets the bounding box renderer associated with the scene
  70847. * @returns a BoundingBoxRenderer
  70848. */
  70849. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70850. }
  70851. interface AbstractMesh {
  70852. /** @hidden (Backing field) */
  70853. _showBoundingBox: boolean;
  70854. /**
  70855. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70856. */
  70857. showBoundingBox: boolean;
  70858. }
  70859. /**
  70860. * Component responsible of rendering the bounding box of the meshes in a scene.
  70861. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70862. */
  70863. export class BoundingBoxRenderer implements ISceneComponent {
  70864. /**
  70865. * The component name helpfull to identify the component in the list of scene components.
  70866. */
  70867. readonly name: string;
  70868. /**
  70869. * The scene the component belongs to.
  70870. */
  70871. scene: Scene;
  70872. /**
  70873. * Color of the bounding box lines placed in front of an object
  70874. */
  70875. frontColor: Color3;
  70876. /**
  70877. * Color of the bounding box lines placed behind an object
  70878. */
  70879. backColor: Color3;
  70880. /**
  70881. * Defines if the renderer should show the back lines or not
  70882. */
  70883. showBackLines: boolean;
  70884. /**
  70885. * Observable raised before rendering a bounding box
  70886. */
  70887. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70888. /**
  70889. * Observable raised after rendering a bounding box
  70890. */
  70891. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70892. /**
  70893. * @hidden
  70894. */
  70895. renderList: SmartArray<BoundingBox>;
  70896. private _colorShader;
  70897. private _vertexBuffers;
  70898. private _indexBuffer;
  70899. private _fillIndexBuffer;
  70900. private _fillIndexData;
  70901. /**
  70902. * Instantiates a new bounding box renderer in a scene.
  70903. * @param scene the scene the renderer renders in
  70904. */
  70905. constructor(scene: Scene);
  70906. /**
  70907. * Registers the component in a given scene
  70908. */
  70909. register(): void;
  70910. private _evaluateSubMesh;
  70911. private _activeMesh;
  70912. private _prepareRessources;
  70913. private _createIndexBuffer;
  70914. /**
  70915. * Rebuilds the elements related to this component in case of
  70916. * context lost for instance.
  70917. */
  70918. rebuild(): void;
  70919. /**
  70920. * @hidden
  70921. */
  70922. reset(): void;
  70923. /**
  70924. * Render the bounding boxes of a specific rendering group
  70925. * @param renderingGroupId defines the rendering group to render
  70926. */
  70927. render(renderingGroupId: number): void;
  70928. /**
  70929. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70930. * @param mesh Define the mesh to render the occlusion bounding box for
  70931. */
  70932. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70933. /**
  70934. * Dispose and release the resources attached to this renderer.
  70935. */
  70936. dispose(): void;
  70937. }
  70938. }
  70939. declare module BABYLON {
  70940. interface Scene {
  70941. /** @hidden (Backing field) */
  70942. _depthRenderer: {
  70943. [id: string]: DepthRenderer;
  70944. };
  70945. /**
  70946. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70947. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70948. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70949. * @returns the created depth renderer
  70950. */
  70951. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70952. /**
  70953. * Disables a depth renderer for a given camera
  70954. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70955. */
  70956. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70957. }
  70958. /**
  70959. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70960. * in several rendering techniques.
  70961. */
  70962. export class DepthRendererSceneComponent implements ISceneComponent {
  70963. /**
  70964. * The component name helpfull to identify the component in the list of scene components.
  70965. */
  70966. readonly name: string;
  70967. /**
  70968. * The scene the component belongs to.
  70969. */
  70970. scene: Scene;
  70971. /**
  70972. * Creates a new instance of the component for the given scene
  70973. * @param scene Defines the scene to register the component in
  70974. */
  70975. constructor(scene: Scene);
  70976. /**
  70977. * Registers the component in a given scene
  70978. */
  70979. register(): void;
  70980. /**
  70981. * Rebuilds the elements related to this component in case of
  70982. * context lost for instance.
  70983. */
  70984. rebuild(): void;
  70985. /**
  70986. * Disposes the component and the associated ressources
  70987. */
  70988. dispose(): void;
  70989. private _gatherRenderTargets;
  70990. private _gatherActiveCameraRenderTargets;
  70991. }
  70992. }
  70993. declare module BABYLON {
  70994. interface AbstractScene {
  70995. /** @hidden (Backing field) */
  70996. _prePassRenderer: Nullable<PrePassRenderer>;
  70997. /**
  70998. * Gets or Sets the current prepass renderer associated to the scene.
  70999. */
  71000. prePassRenderer: Nullable<PrePassRenderer>;
  71001. /**
  71002. * Enables the prepass and associates it with the scene
  71003. * @returns the PrePassRenderer
  71004. */
  71005. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71006. /**
  71007. * Disables the prepass associated with the scene
  71008. */
  71009. disablePrePassRenderer(): void;
  71010. }
  71011. /**
  71012. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71013. * in several rendering techniques.
  71014. */
  71015. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71016. /**
  71017. * The component name helpful to identify the component in the list of scene components.
  71018. */
  71019. readonly name: string;
  71020. /**
  71021. * The scene the component belongs to.
  71022. */
  71023. scene: Scene;
  71024. /**
  71025. * Creates a new instance of the component for the given scene
  71026. * @param scene Defines the scene to register the component in
  71027. */
  71028. constructor(scene: Scene);
  71029. /**
  71030. * Registers the component in a given scene
  71031. */
  71032. register(): void;
  71033. private _beforeCameraDraw;
  71034. private _afterCameraDraw;
  71035. private _beforeClearStage;
  71036. /**
  71037. * Serializes the component data to the specified json object
  71038. * @param serializationObject The object to serialize to
  71039. */
  71040. serialize(serializationObject: any): void;
  71041. /**
  71042. * Adds all the elements from the container to the scene
  71043. * @param container the container holding the elements
  71044. */
  71045. addFromContainer(container: AbstractScene): void;
  71046. /**
  71047. * Removes all the elements in the container from the scene
  71048. * @param container contains the elements to remove
  71049. * @param dispose if the removed element should be disposed (default: false)
  71050. */
  71051. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71052. /**
  71053. * Rebuilds the elements related to this component in case of
  71054. * context lost for instance.
  71055. */
  71056. rebuild(): void;
  71057. /**
  71058. * Disposes the component and the associated ressources
  71059. */
  71060. dispose(): void;
  71061. }
  71062. }
  71063. declare module BABYLON {
  71064. /** @hidden */
  71065. export var outlinePixelShader: {
  71066. name: string;
  71067. shader: string;
  71068. };
  71069. }
  71070. declare module BABYLON {
  71071. /** @hidden */
  71072. export var outlineVertexShader: {
  71073. name: string;
  71074. shader: string;
  71075. };
  71076. }
  71077. declare module BABYLON {
  71078. interface Scene {
  71079. /** @hidden */
  71080. _outlineRenderer: OutlineRenderer;
  71081. /**
  71082. * Gets the outline renderer associated with the scene
  71083. * @returns a OutlineRenderer
  71084. */
  71085. getOutlineRenderer(): OutlineRenderer;
  71086. }
  71087. interface AbstractMesh {
  71088. /** @hidden (Backing field) */
  71089. _renderOutline: boolean;
  71090. /**
  71091. * Gets or sets a boolean indicating if the outline must be rendered as well
  71092. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71093. */
  71094. renderOutline: boolean;
  71095. /** @hidden (Backing field) */
  71096. _renderOverlay: boolean;
  71097. /**
  71098. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71099. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71100. */
  71101. renderOverlay: boolean;
  71102. }
  71103. /**
  71104. * This class is responsible to draw bothe outline/overlay of meshes.
  71105. * It should not be used directly but through the available method on mesh.
  71106. */
  71107. export class OutlineRenderer implements ISceneComponent {
  71108. /**
  71109. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71110. */
  71111. private static _StencilReference;
  71112. /**
  71113. * The name of the component. Each component must have a unique name.
  71114. */
  71115. name: string;
  71116. /**
  71117. * The scene the component belongs to.
  71118. */
  71119. scene: Scene;
  71120. /**
  71121. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71122. */
  71123. zOffset: number;
  71124. private _engine;
  71125. private _effect;
  71126. private _cachedDefines;
  71127. private _savedDepthWrite;
  71128. /**
  71129. * Instantiates a new outline renderer. (There could be only one per scene).
  71130. * @param scene Defines the scene it belongs to
  71131. */
  71132. constructor(scene: Scene);
  71133. /**
  71134. * Register the component to one instance of a scene.
  71135. */
  71136. register(): void;
  71137. /**
  71138. * Rebuilds the elements related to this component in case of
  71139. * context lost for instance.
  71140. */
  71141. rebuild(): void;
  71142. /**
  71143. * Disposes the component and the associated ressources.
  71144. */
  71145. dispose(): void;
  71146. /**
  71147. * Renders the outline in the canvas.
  71148. * @param subMesh Defines the sumesh to render
  71149. * @param batch Defines the batch of meshes in case of instances
  71150. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71151. */
  71152. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71153. /**
  71154. * Returns whether or not the outline renderer is ready for a given submesh.
  71155. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71156. * @param subMesh Defines the submesh to check readyness for
  71157. * @param useInstances Defines wheter wee are trying to render instances or not
  71158. * @returns true if ready otherwise false
  71159. */
  71160. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71161. private _beforeRenderingMesh;
  71162. private _afterRenderingMesh;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /**
  71167. * Defines the basic options interface of a Sprite Frame Source Size.
  71168. */
  71169. export interface ISpriteJSONSpriteSourceSize {
  71170. /**
  71171. * number of the original width of the Frame
  71172. */
  71173. w: number;
  71174. /**
  71175. * number of the original height of the Frame
  71176. */
  71177. h: number;
  71178. }
  71179. /**
  71180. * Defines the basic options interface of a Sprite Frame Data.
  71181. */
  71182. export interface ISpriteJSONSpriteFrameData {
  71183. /**
  71184. * number of the x offset of the Frame
  71185. */
  71186. x: number;
  71187. /**
  71188. * number of the y offset of the Frame
  71189. */
  71190. y: number;
  71191. /**
  71192. * number of the width of the Frame
  71193. */
  71194. w: number;
  71195. /**
  71196. * number of the height of the Frame
  71197. */
  71198. h: number;
  71199. }
  71200. /**
  71201. * Defines the basic options interface of a JSON Sprite.
  71202. */
  71203. export interface ISpriteJSONSprite {
  71204. /**
  71205. * string name of the Frame
  71206. */
  71207. filename: string;
  71208. /**
  71209. * ISpriteJSONSpriteFrame basic object of the frame data
  71210. */
  71211. frame: ISpriteJSONSpriteFrameData;
  71212. /**
  71213. * boolean to flag is the frame was rotated.
  71214. */
  71215. rotated: boolean;
  71216. /**
  71217. * boolean to flag is the frame was trimmed.
  71218. */
  71219. trimmed: boolean;
  71220. /**
  71221. * ISpriteJSONSpriteFrame basic object of the source data
  71222. */
  71223. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71224. /**
  71225. * ISpriteJSONSpriteFrame basic object of the source data
  71226. */
  71227. sourceSize: ISpriteJSONSpriteSourceSize;
  71228. }
  71229. /**
  71230. * Defines the basic options interface of a JSON atlas.
  71231. */
  71232. export interface ISpriteJSONAtlas {
  71233. /**
  71234. * Array of objects that contain the frame data.
  71235. */
  71236. frames: Array<ISpriteJSONSprite>;
  71237. /**
  71238. * object basic object containing the sprite meta data.
  71239. */
  71240. meta?: object;
  71241. }
  71242. }
  71243. declare module BABYLON {
  71244. /** @hidden */
  71245. export var spriteMapPixelShader: {
  71246. name: string;
  71247. shader: string;
  71248. };
  71249. }
  71250. declare module BABYLON {
  71251. /** @hidden */
  71252. export var spriteMapVertexShader: {
  71253. name: string;
  71254. shader: string;
  71255. };
  71256. }
  71257. declare module BABYLON {
  71258. /**
  71259. * Defines the basic options interface of a SpriteMap
  71260. */
  71261. export interface ISpriteMapOptions {
  71262. /**
  71263. * Vector2 of the number of cells in the grid.
  71264. */
  71265. stageSize?: Vector2;
  71266. /**
  71267. * Vector2 of the size of the output plane in World Units.
  71268. */
  71269. outputSize?: Vector2;
  71270. /**
  71271. * Vector3 of the position of the output plane in World Units.
  71272. */
  71273. outputPosition?: Vector3;
  71274. /**
  71275. * Vector3 of the rotation of the output plane.
  71276. */
  71277. outputRotation?: Vector3;
  71278. /**
  71279. * number of layers that the system will reserve in resources.
  71280. */
  71281. layerCount?: number;
  71282. /**
  71283. * number of max animation frames a single cell will reserve in resources.
  71284. */
  71285. maxAnimationFrames?: number;
  71286. /**
  71287. * number cell index of the base tile when the system compiles.
  71288. */
  71289. baseTile?: number;
  71290. /**
  71291. * boolean flip the sprite after its been repositioned by the framing data.
  71292. */
  71293. flipU?: boolean;
  71294. /**
  71295. * Vector3 scalar of the global RGB values of the SpriteMap.
  71296. */
  71297. colorMultiply?: Vector3;
  71298. }
  71299. /**
  71300. * Defines the IDisposable interface in order to be cleanable from resources.
  71301. */
  71302. export interface ISpriteMap extends IDisposable {
  71303. /**
  71304. * String name of the SpriteMap.
  71305. */
  71306. name: string;
  71307. /**
  71308. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71309. */
  71310. atlasJSON: ISpriteJSONAtlas;
  71311. /**
  71312. * Texture of the SpriteMap.
  71313. */
  71314. spriteSheet: Texture;
  71315. /**
  71316. * The parameters to initialize the SpriteMap with.
  71317. */
  71318. options: ISpriteMapOptions;
  71319. }
  71320. /**
  71321. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71322. */
  71323. export class SpriteMap implements ISpriteMap {
  71324. /** The Name of the spriteMap */
  71325. name: string;
  71326. /** The JSON file with the frame and meta data */
  71327. atlasJSON: ISpriteJSONAtlas;
  71328. /** The systems Sprite Sheet Texture */
  71329. spriteSheet: Texture;
  71330. /** Arguments passed with the Constructor */
  71331. options: ISpriteMapOptions;
  71332. /** Public Sprite Storage array, parsed from atlasJSON */
  71333. sprites: Array<ISpriteJSONSprite>;
  71334. /** Returns the Number of Sprites in the System */
  71335. get spriteCount(): number;
  71336. /** Returns the Position of Output Plane*/
  71337. get position(): Vector3;
  71338. /** Returns the Position of Output Plane*/
  71339. set position(v: Vector3);
  71340. /** Returns the Rotation of Output Plane*/
  71341. get rotation(): Vector3;
  71342. /** Returns the Rotation of Output Plane*/
  71343. set rotation(v: Vector3);
  71344. /** Sets the AnimationMap*/
  71345. get animationMap(): RawTexture;
  71346. /** Sets the AnimationMap*/
  71347. set animationMap(v: RawTexture);
  71348. /** Scene that the SpriteMap was created in */
  71349. private _scene;
  71350. /** Texture Buffer of Float32 that holds tile frame data*/
  71351. private _frameMap;
  71352. /** Texture Buffers of Float32 that holds tileMap data*/
  71353. private _tileMaps;
  71354. /** Texture Buffer of Float32 that holds Animation Data*/
  71355. private _animationMap;
  71356. /** Custom ShaderMaterial Central to the System*/
  71357. private _material;
  71358. /** Custom ShaderMaterial Central to the System*/
  71359. private _output;
  71360. /** Systems Time Ticker*/
  71361. private _time;
  71362. /**
  71363. * Creates a new SpriteMap
  71364. * @param name defines the SpriteMaps Name
  71365. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71366. * @param spriteSheet is the Texture that the Sprites are on.
  71367. * @param options a basic deployment configuration
  71368. * @param scene The Scene that the map is deployed on
  71369. */
  71370. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71371. /**
  71372. * Returns tileID location
  71373. * @returns Vector2 the cell position ID
  71374. */
  71375. getTileID(): Vector2;
  71376. /**
  71377. * Gets the UV location of the mouse over the SpriteMap.
  71378. * @returns Vector2 the UV position of the mouse interaction
  71379. */
  71380. getMousePosition(): Vector2;
  71381. /**
  71382. * Creates the "frame" texture Buffer
  71383. * -------------------------------------
  71384. * Structure of frames
  71385. * "filename": "Falling-Water-2.png",
  71386. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71387. * "rotated": true,
  71388. * "trimmed": true,
  71389. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71390. * "sourceSize": {"w":32,"h":32}
  71391. * @returns RawTexture of the frameMap
  71392. */
  71393. private _createFrameBuffer;
  71394. /**
  71395. * Creates the tileMap texture Buffer
  71396. * @param buffer normally and array of numbers, or a false to generate from scratch
  71397. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71398. * @returns RawTexture of the tileMap
  71399. */
  71400. private _createTileBuffer;
  71401. /**
  71402. * Modifies the data of the tileMaps
  71403. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71404. * @param pos is the iVector2 Coordinates of the Tile
  71405. * @param tile The SpriteIndex of the new Tile
  71406. */
  71407. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71408. /**
  71409. * Creates the animationMap texture Buffer
  71410. * @param buffer normally and array of numbers, or a false to generate from scratch
  71411. * @returns RawTexture of the animationMap
  71412. */
  71413. private _createTileAnimationBuffer;
  71414. /**
  71415. * Modifies the data of the animationMap
  71416. * @param cellID is the Index of the Sprite
  71417. * @param _frame is the target Animation frame
  71418. * @param toCell is the Target Index of the next frame of the animation
  71419. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71420. * @param speed is a global scalar of the time variable on the map.
  71421. */
  71422. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71423. /**
  71424. * Exports the .tilemaps file
  71425. */
  71426. saveTileMaps(): void;
  71427. /**
  71428. * Imports the .tilemaps file
  71429. * @param url of the .tilemaps file
  71430. */
  71431. loadTileMaps(url: string): void;
  71432. /**
  71433. * Release associated resources
  71434. */
  71435. dispose(): void;
  71436. }
  71437. }
  71438. declare module BABYLON {
  71439. /**
  71440. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71441. * @see https://doc.babylonjs.com/babylon101/sprites
  71442. */
  71443. export class SpritePackedManager extends SpriteManager {
  71444. /** defines the packed manager's name */
  71445. name: string;
  71446. /**
  71447. * Creates a new sprite manager from a packed sprite sheet
  71448. * @param name defines the manager's name
  71449. * @param imgUrl defines the sprite sheet url
  71450. * @param capacity defines the maximum allowed number of sprites
  71451. * @param scene defines the hosting scene
  71452. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71453. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71454. * @param samplingMode defines the smapling mode to use with spritesheet
  71455. * @param fromPacked set to true; do not alter
  71456. */
  71457. constructor(
  71458. /** defines the packed manager's name */
  71459. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71460. }
  71461. }
  71462. declare module BABYLON {
  71463. /**
  71464. * Defines the list of states available for a task inside a AssetsManager
  71465. */
  71466. export enum AssetTaskState {
  71467. /**
  71468. * Initialization
  71469. */
  71470. INIT = 0,
  71471. /**
  71472. * Running
  71473. */
  71474. RUNNING = 1,
  71475. /**
  71476. * Done
  71477. */
  71478. DONE = 2,
  71479. /**
  71480. * Error
  71481. */
  71482. ERROR = 3
  71483. }
  71484. /**
  71485. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71486. */
  71487. export abstract class AbstractAssetTask {
  71488. /**
  71489. * Task name
  71490. */ name: string;
  71491. /**
  71492. * Callback called when the task is successful
  71493. */
  71494. onSuccess: (task: any) => void;
  71495. /**
  71496. * Callback called when the task is not successful
  71497. */
  71498. onError: (task: any, message?: string, exception?: any) => void;
  71499. /**
  71500. * Creates a new AssetsManager
  71501. * @param name defines the name of the task
  71502. */
  71503. constructor(
  71504. /**
  71505. * Task name
  71506. */ name: string);
  71507. private _isCompleted;
  71508. private _taskState;
  71509. private _errorObject;
  71510. /**
  71511. * Get if the task is completed
  71512. */
  71513. get isCompleted(): boolean;
  71514. /**
  71515. * Gets the current state of the task
  71516. */
  71517. get taskState(): AssetTaskState;
  71518. /**
  71519. * Gets the current error object (if task is in error)
  71520. */
  71521. get errorObject(): {
  71522. message?: string;
  71523. exception?: any;
  71524. };
  71525. /**
  71526. * Internal only
  71527. * @hidden
  71528. */
  71529. _setErrorObject(message?: string, exception?: any): void;
  71530. /**
  71531. * Execute the current task
  71532. * @param scene defines the scene where you want your assets to be loaded
  71533. * @param onSuccess is a callback called when the task is successfully executed
  71534. * @param onError is a callback called if an error occurs
  71535. */
  71536. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71537. /**
  71538. * Execute the current task
  71539. * @param scene defines the scene where you want your assets to be loaded
  71540. * @param onSuccess is a callback called when the task is successfully executed
  71541. * @param onError is a callback called if an error occurs
  71542. */
  71543. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71544. /**
  71545. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71546. * This can be used with failed tasks that have the reason for failure fixed.
  71547. */
  71548. reset(): void;
  71549. private onErrorCallback;
  71550. private onDoneCallback;
  71551. }
  71552. /**
  71553. * Define the interface used by progress events raised during assets loading
  71554. */
  71555. export interface IAssetsProgressEvent {
  71556. /**
  71557. * Defines the number of remaining tasks to process
  71558. */
  71559. remainingCount: number;
  71560. /**
  71561. * Defines the total number of tasks
  71562. */
  71563. totalCount: number;
  71564. /**
  71565. * Defines the task that was just processed
  71566. */
  71567. task: AbstractAssetTask;
  71568. }
  71569. /**
  71570. * Class used to share progress information about assets loading
  71571. */
  71572. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71573. /**
  71574. * Defines the number of remaining tasks to process
  71575. */
  71576. remainingCount: number;
  71577. /**
  71578. * Defines the total number of tasks
  71579. */
  71580. totalCount: number;
  71581. /**
  71582. * Defines the task that was just processed
  71583. */
  71584. task: AbstractAssetTask;
  71585. /**
  71586. * Creates a AssetsProgressEvent
  71587. * @param remainingCount defines the number of remaining tasks to process
  71588. * @param totalCount defines the total number of tasks
  71589. * @param task defines the task that was just processed
  71590. */
  71591. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71592. }
  71593. /**
  71594. * Define a task used by AssetsManager to load meshes
  71595. */
  71596. export class MeshAssetTask extends AbstractAssetTask {
  71597. /**
  71598. * Defines the name of the task
  71599. */
  71600. name: string;
  71601. /**
  71602. * Defines the list of mesh's names you want to load
  71603. */
  71604. meshesNames: any;
  71605. /**
  71606. * Defines the root url to use as a base to load your meshes and associated resources
  71607. */
  71608. rootUrl: string;
  71609. /**
  71610. * Defines the filename or File of the scene to load from
  71611. */
  71612. sceneFilename: string | File;
  71613. /**
  71614. * Gets the list of loaded meshes
  71615. */
  71616. loadedMeshes: Array<AbstractMesh>;
  71617. /**
  71618. * Gets the list of loaded particle systems
  71619. */
  71620. loadedParticleSystems: Array<IParticleSystem>;
  71621. /**
  71622. * Gets the list of loaded skeletons
  71623. */
  71624. loadedSkeletons: Array<Skeleton>;
  71625. /**
  71626. * Gets the list of loaded animation groups
  71627. */
  71628. loadedAnimationGroups: Array<AnimationGroup>;
  71629. /**
  71630. * Callback called when the task is successful
  71631. */
  71632. onSuccess: (task: MeshAssetTask) => void;
  71633. /**
  71634. * Callback called when the task is successful
  71635. */
  71636. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71637. /**
  71638. * Creates a new MeshAssetTask
  71639. * @param name defines the name of the task
  71640. * @param meshesNames defines the list of mesh's names you want to load
  71641. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71642. * @param sceneFilename defines the filename or File of the scene to load from
  71643. */
  71644. constructor(
  71645. /**
  71646. * Defines the name of the task
  71647. */
  71648. name: string,
  71649. /**
  71650. * Defines the list of mesh's names you want to load
  71651. */
  71652. meshesNames: any,
  71653. /**
  71654. * Defines the root url to use as a base to load your meshes and associated resources
  71655. */
  71656. rootUrl: string,
  71657. /**
  71658. * Defines the filename or File of the scene to load from
  71659. */
  71660. sceneFilename: string | File);
  71661. /**
  71662. * Execute the current task
  71663. * @param scene defines the scene where you want your assets to be loaded
  71664. * @param onSuccess is a callback called when the task is successfully executed
  71665. * @param onError is a callback called if an error occurs
  71666. */
  71667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71668. }
  71669. /**
  71670. * Define a task used by AssetsManager to load text content
  71671. */
  71672. export class TextFileAssetTask extends AbstractAssetTask {
  71673. /**
  71674. * Defines the name of the task
  71675. */
  71676. name: string;
  71677. /**
  71678. * Defines the location of the file to load
  71679. */
  71680. url: string;
  71681. /**
  71682. * Gets the loaded text string
  71683. */
  71684. text: string;
  71685. /**
  71686. * Callback called when the task is successful
  71687. */
  71688. onSuccess: (task: TextFileAssetTask) => void;
  71689. /**
  71690. * Callback called when the task is successful
  71691. */
  71692. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71693. /**
  71694. * Creates a new TextFileAssetTask object
  71695. * @param name defines the name of the task
  71696. * @param url defines the location of the file to load
  71697. */
  71698. constructor(
  71699. /**
  71700. * Defines the name of the task
  71701. */
  71702. name: string,
  71703. /**
  71704. * Defines the location of the file to load
  71705. */
  71706. url: string);
  71707. /**
  71708. * Execute the current task
  71709. * @param scene defines the scene where you want your assets to be loaded
  71710. * @param onSuccess is a callback called when the task is successfully executed
  71711. * @param onError is a callback called if an error occurs
  71712. */
  71713. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71714. }
  71715. /**
  71716. * Define a task used by AssetsManager to load binary data
  71717. */
  71718. export class BinaryFileAssetTask extends AbstractAssetTask {
  71719. /**
  71720. * Defines the name of the task
  71721. */
  71722. name: string;
  71723. /**
  71724. * Defines the location of the file to load
  71725. */
  71726. url: string;
  71727. /**
  71728. * Gets the lodaded data (as an array buffer)
  71729. */
  71730. data: ArrayBuffer;
  71731. /**
  71732. * Callback called when the task is successful
  71733. */
  71734. onSuccess: (task: BinaryFileAssetTask) => void;
  71735. /**
  71736. * Callback called when the task is successful
  71737. */
  71738. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71739. /**
  71740. * Creates a new BinaryFileAssetTask object
  71741. * @param name defines the name of the new task
  71742. * @param url defines the location of the file to load
  71743. */
  71744. constructor(
  71745. /**
  71746. * Defines the name of the task
  71747. */
  71748. name: string,
  71749. /**
  71750. * Defines the location of the file to load
  71751. */
  71752. url: string);
  71753. /**
  71754. * Execute the current task
  71755. * @param scene defines the scene where you want your assets to be loaded
  71756. * @param onSuccess is a callback called when the task is successfully executed
  71757. * @param onError is a callback called if an error occurs
  71758. */
  71759. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71760. }
  71761. /**
  71762. * Define a task used by AssetsManager to load images
  71763. */
  71764. export class ImageAssetTask extends AbstractAssetTask {
  71765. /**
  71766. * Defines the name of the task
  71767. */
  71768. name: string;
  71769. /**
  71770. * Defines the location of the image to load
  71771. */
  71772. url: string;
  71773. /**
  71774. * Gets the loaded images
  71775. */
  71776. image: HTMLImageElement;
  71777. /**
  71778. * Callback called when the task is successful
  71779. */
  71780. onSuccess: (task: ImageAssetTask) => void;
  71781. /**
  71782. * Callback called when the task is successful
  71783. */
  71784. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71785. /**
  71786. * Creates a new ImageAssetTask
  71787. * @param name defines the name of the task
  71788. * @param url defines the location of the image to load
  71789. */
  71790. constructor(
  71791. /**
  71792. * Defines the name of the task
  71793. */
  71794. name: string,
  71795. /**
  71796. * Defines the location of the image to load
  71797. */
  71798. url: string);
  71799. /**
  71800. * Execute the current task
  71801. * @param scene defines the scene where you want your assets to be loaded
  71802. * @param onSuccess is a callback called when the task is successfully executed
  71803. * @param onError is a callback called if an error occurs
  71804. */
  71805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71806. }
  71807. /**
  71808. * Defines the interface used by texture loading tasks
  71809. */
  71810. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71811. /**
  71812. * Gets the loaded texture
  71813. */
  71814. texture: TEX;
  71815. }
  71816. /**
  71817. * Define a task used by AssetsManager to load 2D textures
  71818. */
  71819. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71820. /**
  71821. * Defines the name of the task
  71822. */
  71823. name: string;
  71824. /**
  71825. * Defines the location of the file to load
  71826. */
  71827. url: string;
  71828. /**
  71829. * Defines if mipmap should not be generated (default is false)
  71830. */
  71831. noMipmap?: boolean | undefined;
  71832. /**
  71833. * Defines if texture must be inverted on Y axis (default is true)
  71834. */
  71835. invertY: boolean;
  71836. /**
  71837. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71838. */
  71839. samplingMode: number;
  71840. /**
  71841. * Gets the loaded texture
  71842. */
  71843. texture: Texture;
  71844. /**
  71845. * Callback called when the task is successful
  71846. */
  71847. onSuccess: (task: TextureAssetTask) => void;
  71848. /**
  71849. * Callback called when the task is successful
  71850. */
  71851. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71852. /**
  71853. * Creates a new TextureAssetTask object
  71854. * @param name defines the name of the task
  71855. * @param url defines the location of the file to load
  71856. * @param noMipmap defines if mipmap should not be generated (default is false)
  71857. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71858. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71859. */
  71860. constructor(
  71861. /**
  71862. * Defines the name of the task
  71863. */
  71864. name: string,
  71865. /**
  71866. * Defines the location of the file to load
  71867. */
  71868. url: string,
  71869. /**
  71870. * Defines if mipmap should not be generated (default is false)
  71871. */
  71872. noMipmap?: boolean | undefined,
  71873. /**
  71874. * Defines if texture must be inverted on Y axis (default is true)
  71875. */
  71876. invertY?: boolean,
  71877. /**
  71878. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71879. */
  71880. samplingMode?: number);
  71881. /**
  71882. * Execute the current task
  71883. * @param scene defines the scene where you want your assets to be loaded
  71884. * @param onSuccess is a callback called when the task is successfully executed
  71885. * @param onError is a callback called if an error occurs
  71886. */
  71887. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71888. }
  71889. /**
  71890. * Define a task used by AssetsManager to load cube textures
  71891. */
  71892. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71893. /**
  71894. * Defines the name of the task
  71895. */
  71896. name: string;
  71897. /**
  71898. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71899. */
  71900. url: string;
  71901. /**
  71902. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71903. */
  71904. extensions?: string[] | undefined;
  71905. /**
  71906. * Defines if mipmaps should not be generated (default is false)
  71907. */
  71908. noMipmap?: boolean | undefined;
  71909. /**
  71910. * Defines the explicit list of files (undefined by default)
  71911. */
  71912. files?: string[] | undefined;
  71913. /**
  71914. * Gets the loaded texture
  71915. */
  71916. texture: CubeTexture;
  71917. /**
  71918. * Callback called when the task is successful
  71919. */
  71920. onSuccess: (task: CubeTextureAssetTask) => void;
  71921. /**
  71922. * Callback called when the task is successful
  71923. */
  71924. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71925. /**
  71926. * Creates a new CubeTextureAssetTask
  71927. * @param name defines the name of the task
  71928. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71929. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71930. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71931. * @param files defines the explicit list of files (undefined by default)
  71932. */
  71933. constructor(
  71934. /**
  71935. * Defines the name of the task
  71936. */
  71937. name: string,
  71938. /**
  71939. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71940. */
  71941. url: string,
  71942. /**
  71943. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71944. */
  71945. extensions?: string[] | undefined,
  71946. /**
  71947. * Defines if mipmaps should not be generated (default is false)
  71948. */
  71949. noMipmap?: boolean | undefined,
  71950. /**
  71951. * Defines the explicit list of files (undefined by default)
  71952. */
  71953. files?: string[] | undefined);
  71954. /**
  71955. * Execute the current task
  71956. * @param scene defines the scene where you want your assets to be loaded
  71957. * @param onSuccess is a callback called when the task is successfully executed
  71958. * @param onError is a callback called if an error occurs
  71959. */
  71960. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71961. }
  71962. /**
  71963. * Define a task used by AssetsManager to load HDR cube textures
  71964. */
  71965. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71966. /**
  71967. * Defines the name of the task
  71968. */
  71969. name: string;
  71970. /**
  71971. * Defines the location of the file to load
  71972. */
  71973. url: string;
  71974. /**
  71975. * Defines the desired size (the more it increases the longer the generation will be)
  71976. */
  71977. size: number;
  71978. /**
  71979. * Defines if mipmaps should not be generated (default is false)
  71980. */
  71981. noMipmap: boolean;
  71982. /**
  71983. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71984. */
  71985. generateHarmonics: boolean;
  71986. /**
  71987. * 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)
  71988. */
  71989. gammaSpace: boolean;
  71990. /**
  71991. * Internal Use Only
  71992. */
  71993. reserved: boolean;
  71994. /**
  71995. * Gets the loaded texture
  71996. */
  71997. texture: HDRCubeTexture;
  71998. /**
  71999. * Callback called when the task is successful
  72000. */
  72001. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72002. /**
  72003. * Callback called when the task is successful
  72004. */
  72005. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72006. /**
  72007. * Creates a new HDRCubeTextureAssetTask object
  72008. * @param name defines the name of the task
  72009. * @param url defines the location of the file to load
  72010. * @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.
  72011. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72012. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72013. * @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)
  72014. * @param reserved Internal use only
  72015. */
  72016. constructor(
  72017. /**
  72018. * Defines the name of the task
  72019. */
  72020. name: string,
  72021. /**
  72022. * Defines the location of the file to load
  72023. */
  72024. url: string,
  72025. /**
  72026. * Defines the desired size (the more it increases the longer the generation will be)
  72027. */
  72028. size: number,
  72029. /**
  72030. * Defines if mipmaps should not be generated (default is false)
  72031. */
  72032. noMipmap?: boolean,
  72033. /**
  72034. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72035. */
  72036. generateHarmonics?: boolean,
  72037. /**
  72038. * 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)
  72039. */
  72040. gammaSpace?: boolean,
  72041. /**
  72042. * Internal Use Only
  72043. */
  72044. reserved?: boolean);
  72045. /**
  72046. * Execute the current task
  72047. * @param scene defines the scene where you want your assets to be loaded
  72048. * @param onSuccess is a callback called when the task is successfully executed
  72049. * @param onError is a callback called if an error occurs
  72050. */
  72051. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72052. }
  72053. /**
  72054. * Define a task used by AssetsManager to load Equirectangular cube textures
  72055. */
  72056. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72057. /**
  72058. * Defines the name of the task
  72059. */
  72060. name: string;
  72061. /**
  72062. * Defines the location of the file to load
  72063. */
  72064. url: string;
  72065. /**
  72066. * Defines the desired size (the more it increases the longer the generation will be)
  72067. */
  72068. size: number;
  72069. /**
  72070. * Defines if mipmaps should not be generated (default is false)
  72071. */
  72072. noMipmap: boolean;
  72073. /**
  72074. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72075. * but the standard material would require them in Gamma space) (default is true)
  72076. */
  72077. gammaSpace: boolean;
  72078. /**
  72079. * Gets the loaded texture
  72080. */
  72081. texture: EquiRectangularCubeTexture;
  72082. /**
  72083. * Callback called when the task is successful
  72084. */
  72085. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72086. /**
  72087. * Callback called when the task is successful
  72088. */
  72089. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72090. /**
  72091. * Creates a new EquiRectangularCubeTextureAssetTask object
  72092. * @param name defines the name of the task
  72093. * @param url defines the location of the file to load
  72094. * @param size defines the desired size (the more it increases the longer the generation will be)
  72095. * If the size is omitted this implies you are using a preprocessed cubemap.
  72096. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72097. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72098. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72099. * (default is true)
  72100. */
  72101. constructor(
  72102. /**
  72103. * Defines the name of the task
  72104. */
  72105. name: string,
  72106. /**
  72107. * Defines the location of the file to load
  72108. */
  72109. url: string,
  72110. /**
  72111. * Defines the desired size (the more it increases the longer the generation will be)
  72112. */
  72113. size: number,
  72114. /**
  72115. * Defines if mipmaps should not be generated (default is false)
  72116. */
  72117. noMipmap?: boolean,
  72118. /**
  72119. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72120. * but the standard material would require them in Gamma space) (default is true)
  72121. */
  72122. gammaSpace?: boolean);
  72123. /**
  72124. * Execute the current task
  72125. * @param scene defines the scene where you want your assets to be loaded
  72126. * @param onSuccess is a callback called when the task is successfully executed
  72127. * @param onError is a callback called if an error occurs
  72128. */
  72129. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72130. }
  72131. /**
  72132. * This class can be used to easily import assets into a scene
  72133. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72134. */
  72135. export class AssetsManager {
  72136. private _scene;
  72137. private _isLoading;
  72138. protected _tasks: AbstractAssetTask[];
  72139. protected _waitingTasksCount: number;
  72140. protected _totalTasksCount: number;
  72141. /**
  72142. * Callback called when all tasks are processed
  72143. */
  72144. onFinish: (tasks: AbstractAssetTask[]) => void;
  72145. /**
  72146. * Callback called when a task is successful
  72147. */
  72148. onTaskSuccess: (task: AbstractAssetTask) => void;
  72149. /**
  72150. * Callback called when a task had an error
  72151. */
  72152. onTaskError: (task: AbstractAssetTask) => void;
  72153. /**
  72154. * Callback called when a task is done (whatever the result is)
  72155. */
  72156. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72157. /**
  72158. * Observable called when all tasks are processed
  72159. */
  72160. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72161. /**
  72162. * Observable called when a task had an error
  72163. */
  72164. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72165. /**
  72166. * Observable called when all tasks were executed
  72167. */
  72168. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72169. /**
  72170. * Observable called when a task is done (whatever the result is)
  72171. */
  72172. onProgressObservable: Observable<IAssetsProgressEvent>;
  72173. /**
  72174. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72175. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72176. */
  72177. useDefaultLoadingScreen: boolean;
  72178. /**
  72179. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72180. * when all assets have been downloaded.
  72181. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72182. */
  72183. autoHideLoadingUI: boolean;
  72184. /**
  72185. * Creates a new AssetsManager
  72186. * @param scene defines the scene to work on
  72187. */
  72188. constructor(scene: Scene);
  72189. /**
  72190. * Add a MeshAssetTask to the list of active tasks
  72191. * @param taskName defines the name of the new task
  72192. * @param meshesNames defines the name of meshes to load
  72193. * @param rootUrl defines the root url to use to locate files
  72194. * @param sceneFilename defines the filename of the scene file
  72195. * @returns a new MeshAssetTask object
  72196. */
  72197. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72198. /**
  72199. * Add a TextFileAssetTask to the list of active tasks
  72200. * @param taskName defines the name of the new task
  72201. * @param url defines the url of the file to load
  72202. * @returns a new TextFileAssetTask object
  72203. */
  72204. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72205. /**
  72206. * Add a BinaryFileAssetTask to the list of active tasks
  72207. * @param taskName defines the name of the new task
  72208. * @param url defines the url of the file to load
  72209. * @returns a new BinaryFileAssetTask object
  72210. */
  72211. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72212. /**
  72213. * Add a ImageAssetTask to the list of active tasks
  72214. * @param taskName defines the name of the new task
  72215. * @param url defines the url of the file to load
  72216. * @returns a new ImageAssetTask object
  72217. */
  72218. addImageTask(taskName: string, url: string): ImageAssetTask;
  72219. /**
  72220. * Add a TextureAssetTask to the list of active tasks
  72221. * @param taskName defines the name of the new task
  72222. * @param url defines the url of the file to load
  72223. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72224. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72225. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72226. * @returns a new TextureAssetTask object
  72227. */
  72228. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72229. /**
  72230. * Add a CubeTextureAssetTask to the list of active tasks
  72231. * @param taskName defines the name of the new task
  72232. * @param url defines the url of the file to load
  72233. * @param extensions defines the extension to use to load the cube map (can be null)
  72234. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72235. * @param files defines the list of files to load (can be null)
  72236. * @returns a new CubeTextureAssetTask object
  72237. */
  72238. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72239. /**
  72240. *
  72241. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72242. * @param taskName defines the name of the new task
  72243. * @param url defines the url of the file to load
  72244. * @param size defines the size you want for the cubemap (can be null)
  72245. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72246. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72247. * @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)
  72248. * @param reserved Internal use only
  72249. * @returns a new HDRCubeTextureAssetTask object
  72250. */
  72251. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72252. /**
  72253. *
  72254. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72255. * @param taskName defines the name of the new task
  72256. * @param url defines the url of the file to load
  72257. * @param size defines the size you want for the cubemap (can be null)
  72258. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72259. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72260. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72261. * @returns a new EquiRectangularCubeTextureAssetTask object
  72262. */
  72263. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72264. /**
  72265. * Remove a task from the assets manager.
  72266. * @param task the task to remove
  72267. */
  72268. removeTask(task: AbstractAssetTask): void;
  72269. private _decreaseWaitingTasksCount;
  72270. private _runTask;
  72271. /**
  72272. * Reset the AssetsManager and remove all tasks
  72273. * @return the current instance of the AssetsManager
  72274. */
  72275. reset(): AssetsManager;
  72276. /**
  72277. * Start the loading process
  72278. * @return the current instance of the AssetsManager
  72279. */
  72280. load(): AssetsManager;
  72281. /**
  72282. * Start the loading process as an async operation
  72283. * @return a promise returning the list of failed tasks
  72284. */
  72285. loadAsync(): Promise<void>;
  72286. }
  72287. }
  72288. declare module BABYLON {
  72289. /**
  72290. * Wrapper class for promise with external resolve and reject.
  72291. */
  72292. export class Deferred<T> {
  72293. /**
  72294. * The promise associated with this deferred object.
  72295. */
  72296. readonly promise: Promise<T>;
  72297. private _resolve;
  72298. private _reject;
  72299. /**
  72300. * The resolve method of the promise associated with this deferred object.
  72301. */
  72302. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72303. /**
  72304. * The reject method of the promise associated with this deferred object.
  72305. */
  72306. get reject(): (reason?: any) => void;
  72307. /**
  72308. * Constructor for this deferred object.
  72309. */
  72310. constructor();
  72311. }
  72312. }
  72313. declare module BABYLON {
  72314. /**
  72315. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72316. */
  72317. export class MeshExploder {
  72318. private _centerMesh;
  72319. private _meshes;
  72320. private _meshesOrigins;
  72321. private _toCenterVectors;
  72322. private _scaledDirection;
  72323. private _newPosition;
  72324. private _centerPosition;
  72325. /**
  72326. * Explodes meshes from a center mesh.
  72327. * @param meshes The meshes to explode.
  72328. * @param centerMesh The mesh to be center of explosion.
  72329. */
  72330. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72331. private _setCenterMesh;
  72332. /**
  72333. * Get class name
  72334. * @returns "MeshExploder"
  72335. */
  72336. getClassName(): string;
  72337. /**
  72338. * "Exploded meshes"
  72339. * @returns Array of meshes with the centerMesh at index 0.
  72340. */
  72341. getMeshes(): Array<Mesh>;
  72342. /**
  72343. * Explodes meshes giving a specific direction
  72344. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72345. */
  72346. explode(direction?: number): void;
  72347. }
  72348. }
  72349. declare module BABYLON {
  72350. /**
  72351. * Class used to help managing file picking and drag'n'drop
  72352. */
  72353. export class FilesInput {
  72354. /**
  72355. * List of files ready to be loaded
  72356. */
  72357. static get FilesToLoad(): {
  72358. [key: string]: File;
  72359. };
  72360. /**
  72361. * Callback called when a file is processed
  72362. */
  72363. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72364. private _engine;
  72365. private _currentScene;
  72366. private _sceneLoadedCallback;
  72367. private _progressCallback;
  72368. private _additionalRenderLoopLogicCallback;
  72369. private _textureLoadingCallback;
  72370. private _startingProcessingFilesCallback;
  72371. private _onReloadCallback;
  72372. private _errorCallback;
  72373. private _elementToMonitor;
  72374. private _sceneFileToLoad;
  72375. private _filesToLoad;
  72376. /**
  72377. * Creates a new FilesInput
  72378. * @param engine defines the rendering engine
  72379. * @param scene defines the hosting scene
  72380. * @param sceneLoadedCallback callback called when scene is loaded
  72381. * @param progressCallback callback called to track progress
  72382. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72383. * @param textureLoadingCallback callback called when a texture is loading
  72384. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72385. * @param onReloadCallback callback called when a reload is requested
  72386. * @param errorCallback callback call if an error occurs
  72387. */
  72388. 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>);
  72389. private _dragEnterHandler;
  72390. private _dragOverHandler;
  72391. private _dropHandler;
  72392. /**
  72393. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72394. * @param elementToMonitor defines the DOM element to track
  72395. */
  72396. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72397. /** Gets the current list of files to load */
  72398. get filesToLoad(): File[];
  72399. /**
  72400. * Release all associated resources
  72401. */
  72402. dispose(): void;
  72403. private renderFunction;
  72404. private drag;
  72405. private drop;
  72406. private _traverseFolder;
  72407. private _processFiles;
  72408. /**
  72409. * Load files from a drop event
  72410. * @param event defines the drop event to use as source
  72411. */
  72412. loadFiles(event: any): void;
  72413. private _processReload;
  72414. /**
  72415. * Reload the current scene from the loaded files
  72416. */
  72417. reload(): void;
  72418. }
  72419. }
  72420. declare module BABYLON {
  72421. /**
  72422. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72423. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72424. */
  72425. export class SceneOptimization {
  72426. /**
  72427. * Defines the priority of this optimization (0 by default which means first in the list)
  72428. */
  72429. priority: number;
  72430. /**
  72431. * Gets a string describing the action executed by the current optimization
  72432. * @returns description string
  72433. */
  72434. getDescription(): string;
  72435. /**
  72436. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72437. * @param scene defines the current scene where to apply this optimization
  72438. * @param optimizer defines the current optimizer
  72439. * @returns true if everything that can be done was applied
  72440. */
  72441. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72442. /**
  72443. * Creates the SceneOptimization object
  72444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72445. * @param desc defines the description associated with the optimization
  72446. */
  72447. constructor(
  72448. /**
  72449. * Defines the priority of this optimization (0 by default which means first in the list)
  72450. */
  72451. priority?: number);
  72452. }
  72453. /**
  72454. * Defines an optimization used to reduce the size of render target textures
  72455. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72456. */
  72457. export class TextureOptimization extends SceneOptimization {
  72458. /**
  72459. * Defines the priority of this optimization (0 by default which means first in the list)
  72460. */
  72461. priority: number;
  72462. /**
  72463. * 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
  72464. */
  72465. maximumSize: number;
  72466. /**
  72467. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72468. */
  72469. step: number;
  72470. /**
  72471. * Gets a string describing the action executed by the current optimization
  72472. * @returns description string
  72473. */
  72474. getDescription(): string;
  72475. /**
  72476. * Creates the TextureOptimization object
  72477. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72478. * @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
  72479. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72480. */
  72481. constructor(
  72482. /**
  72483. * Defines the priority of this optimization (0 by default which means first in the list)
  72484. */
  72485. priority?: number,
  72486. /**
  72487. * 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
  72488. */
  72489. maximumSize?: number,
  72490. /**
  72491. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72492. */
  72493. step?: number);
  72494. /**
  72495. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72496. * @param scene defines the current scene where to apply this optimization
  72497. * @param optimizer defines the current optimizer
  72498. * @returns true if everything that can be done was applied
  72499. */
  72500. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72501. }
  72502. /**
  72503. * Defines an optimization used to increase or decrease the rendering resolution
  72504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72505. */
  72506. export class HardwareScalingOptimization extends SceneOptimization {
  72507. /**
  72508. * Defines the priority of this optimization (0 by default which means first in the list)
  72509. */
  72510. priority: number;
  72511. /**
  72512. * Defines the maximum scale to use (2 by default)
  72513. */
  72514. maximumScale: number;
  72515. /**
  72516. * Defines the step to use between two passes (0.5 by default)
  72517. */
  72518. step: number;
  72519. private _currentScale;
  72520. private _directionOffset;
  72521. /**
  72522. * Gets a string describing the action executed by the current optimization
  72523. * @return description string
  72524. */
  72525. getDescription(): string;
  72526. /**
  72527. * Creates the HardwareScalingOptimization object
  72528. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72529. * @param maximumScale defines the maximum scale to use (2 by default)
  72530. * @param step defines the step to use between two passes (0.5 by default)
  72531. */
  72532. constructor(
  72533. /**
  72534. * Defines the priority of this optimization (0 by default which means first in the list)
  72535. */
  72536. priority?: number,
  72537. /**
  72538. * Defines the maximum scale to use (2 by default)
  72539. */
  72540. maximumScale?: number,
  72541. /**
  72542. * Defines the step to use between two passes (0.5 by default)
  72543. */
  72544. step?: number);
  72545. /**
  72546. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72547. * @param scene defines the current scene where to apply this optimization
  72548. * @param optimizer defines the current optimizer
  72549. * @returns true if everything that can be done was applied
  72550. */
  72551. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72552. }
  72553. /**
  72554. * Defines an optimization used to remove shadows
  72555. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72556. */
  72557. export class ShadowsOptimization extends SceneOptimization {
  72558. /**
  72559. * Gets a string describing the action executed by the current optimization
  72560. * @return description string
  72561. */
  72562. getDescription(): string;
  72563. /**
  72564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72565. * @param scene defines the current scene where to apply this optimization
  72566. * @param optimizer defines the current optimizer
  72567. * @returns true if everything that can be done was applied
  72568. */
  72569. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72570. }
  72571. /**
  72572. * Defines an optimization used to turn post-processes off
  72573. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72574. */
  72575. export class PostProcessesOptimization extends SceneOptimization {
  72576. /**
  72577. * Gets a string describing the action executed by the current optimization
  72578. * @return description string
  72579. */
  72580. getDescription(): string;
  72581. /**
  72582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72583. * @param scene defines the current scene where to apply this optimization
  72584. * @param optimizer defines the current optimizer
  72585. * @returns true if everything that can be done was applied
  72586. */
  72587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72588. }
  72589. /**
  72590. * Defines an optimization used to turn lens flares off
  72591. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72592. */
  72593. export class LensFlaresOptimization extends SceneOptimization {
  72594. /**
  72595. * Gets a string describing the action executed by the current optimization
  72596. * @return description string
  72597. */
  72598. getDescription(): string;
  72599. /**
  72600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72601. * @param scene defines the current scene where to apply this optimization
  72602. * @param optimizer defines the current optimizer
  72603. * @returns true if everything that can be done was applied
  72604. */
  72605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72606. }
  72607. /**
  72608. * Defines an optimization based on user defined callback.
  72609. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72610. */
  72611. export class CustomOptimization extends SceneOptimization {
  72612. /**
  72613. * Callback called to apply the custom optimization.
  72614. */
  72615. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72616. /**
  72617. * Callback called to get custom description
  72618. */
  72619. onGetDescription: () => string;
  72620. /**
  72621. * Gets a string describing the action executed by the current optimization
  72622. * @returns description string
  72623. */
  72624. getDescription(): string;
  72625. /**
  72626. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72627. * @param scene defines the current scene where to apply this optimization
  72628. * @param optimizer defines the current optimizer
  72629. * @returns true if everything that can be done was applied
  72630. */
  72631. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72632. }
  72633. /**
  72634. * Defines an optimization used to turn particles off
  72635. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72636. */
  72637. export class ParticlesOptimization extends SceneOptimization {
  72638. /**
  72639. * Gets a string describing the action executed by the current optimization
  72640. * @return description string
  72641. */
  72642. getDescription(): string;
  72643. /**
  72644. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72645. * @param scene defines the current scene where to apply this optimization
  72646. * @param optimizer defines the current optimizer
  72647. * @returns true if everything that can be done was applied
  72648. */
  72649. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72650. }
  72651. /**
  72652. * Defines an optimization used to turn render targets off
  72653. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72654. */
  72655. export class RenderTargetsOptimization extends SceneOptimization {
  72656. /**
  72657. * Gets a string describing the action executed by the current optimization
  72658. * @return description string
  72659. */
  72660. getDescription(): string;
  72661. /**
  72662. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72663. * @param scene defines the current scene where to apply this optimization
  72664. * @param optimizer defines the current optimizer
  72665. * @returns true if everything that can be done was applied
  72666. */
  72667. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72668. }
  72669. /**
  72670. * Defines an optimization used to merge meshes with compatible materials
  72671. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72672. */
  72673. export class MergeMeshesOptimization extends SceneOptimization {
  72674. private static _UpdateSelectionTree;
  72675. /**
  72676. * Gets or sets a boolean which defines if optimization octree has to be updated
  72677. */
  72678. static get UpdateSelectionTree(): boolean;
  72679. /**
  72680. * Gets or sets a boolean which defines if optimization octree has to be updated
  72681. */
  72682. static set UpdateSelectionTree(value: boolean);
  72683. /**
  72684. * Gets a string describing the action executed by the current optimization
  72685. * @return description string
  72686. */
  72687. getDescription(): string;
  72688. private _canBeMerged;
  72689. /**
  72690. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72691. * @param scene defines the current scene where to apply this optimization
  72692. * @param optimizer defines the current optimizer
  72693. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72694. * @returns true if everything that can be done was applied
  72695. */
  72696. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72697. }
  72698. /**
  72699. * Defines a list of options used by SceneOptimizer
  72700. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72701. */
  72702. export class SceneOptimizerOptions {
  72703. /**
  72704. * Defines the target frame rate to reach (60 by default)
  72705. */
  72706. targetFrameRate: number;
  72707. /**
  72708. * Defines the interval between two checkes (2000ms by default)
  72709. */
  72710. trackerDuration: number;
  72711. /**
  72712. * Gets the list of optimizations to apply
  72713. */
  72714. optimizations: SceneOptimization[];
  72715. /**
  72716. * Creates a new list of options used by SceneOptimizer
  72717. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72718. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72719. */
  72720. constructor(
  72721. /**
  72722. * Defines the target frame rate to reach (60 by default)
  72723. */
  72724. targetFrameRate?: number,
  72725. /**
  72726. * Defines the interval between two checkes (2000ms by default)
  72727. */
  72728. trackerDuration?: number);
  72729. /**
  72730. * Add a new optimization
  72731. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72732. * @returns the current SceneOptimizerOptions
  72733. */
  72734. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72735. /**
  72736. * Add a new custom optimization
  72737. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72738. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72740. * @returns the current SceneOptimizerOptions
  72741. */
  72742. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72743. /**
  72744. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72745. * @param targetFrameRate defines the target frame rate (60 by default)
  72746. * @returns a SceneOptimizerOptions object
  72747. */
  72748. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72749. /**
  72750. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72751. * @param targetFrameRate defines the target frame rate (60 by default)
  72752. * @returns a SceneOptimizerOptions object
  72753. */
  72754. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72755. /**
  72756. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72757. * @param targetFrameRate defines the target frame rate (60 by default)
  72758. * @returns a SceneOptimizerOptions object
  72759. */
  72760. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72761. }
  72762. /**
  72763. * Class used to run optimizations in order to reach a target frame rate
  72764. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72765. */
  72766. export class SceneOptimizer implements IDisposable {
  72767. private _isRunning;
  72768. private _options;
  72769. private _scene;
  72770. private _currentPriorityLevel;
  72771. private _targetFrameRate;
  72772. private _trackerDuration;
  72773. private _currentFrameRate;
  72774. private _sceneDisposeObserver;
  72775. private _improvementMode;
  72776. /**
  72777. * Defines an observable called when the optimizer reaches the target frame rate
  72778. */
  72779. onSuccessObservable: Observable<SceneOptimizer>;
  72780. /**
  72781. * Defines an observable called when the optimizer enables an optimization
  72782. */
  72783. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72784. /**
  72785. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72786. */
  72787. onFailureObservable: Observable<SceneOptimizer>;
  72788. /**
  72789. * Gets a boolean indicating if the optimizer is in improvement mode
  72790. */
  72791. get isInImprovementMode(): boolean;
  72792. /**
  72793. * Gets the current priority level (0 at start)
  72794. */
  72795. get currentPriorityLevel(): number;
  72796. /**
  72797. * Gets the current frame rate checked by the SceneOptimizer
  72798. */
  72799. get currentFrameRate(): number;
  72800. /**
  72801. * Gets or sets the current target frame rate (60 by default)
  72802. */
  72803. get targetFrameRate(): number;
  72804. /**
  72805. * Gets or sets the current target frame rate (60 by default)
  72806. */
  72807. set targetFrameRate(value: number);
  72808. /**
  72809. * Gets or sets the current interval between two checks (every 2000ms by default)
  72810. */
  72811. get trackerDuration(): number;
  72812. /**
  72813. * Gets or sets the current interval between two checks (every 2000ms by default)
  72814. */
  72815. set trackerDuration(value: number);
  72816. /**
  72817. * Gets the list of active optimizations
  72818. */
  72819. get optimizations(): SceneOptimization[];
  72820. /**
  72821. * Creates a new SceneOptimizer
  72822. * @param scene defines the scene to work on
  72823. * @param options defines the options to use with the SceneOptimizer
  72824. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72825. * @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)
  72826. */
  72827. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72828. /**
  72829. * Stops the current optimizer
  72830. */
  72831. stop(): void;
  72832. /**
  72833. * Reset the optimizer to initial step (current priority level = 0)
  72834. */
  72835. reset(): void;
  72836. /**
  72837. * Start the optimizer. By default it will try to reach a specific framerate
  72838. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72839. */
  72840. start(): void;
  72841. private _checkCurrentState;
  72842. /**
  72843. * Release all resources
  72844. */
  72845. dispose(): void;
  72846. /**
  72847. * Helper function to create a SceneOptimizer with one single line of code
  72848. * @param scene defines the scene to work on
  72849. * @param options defines the options to use with the SceneOptimizer
  72850. * @param onSuccess defines a callback to call on success
  72851. * @param onFailure defines a callback to call on failure
  72852. * @returns the new SceneOptimizer object
  72853. */
  72854. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. /**
  72859. * Class used to serialize a scene into a string
  72860. */
  72861. export class SceneSerializer {
  72862. /**
  72863. * Clear cache used by a previous serialization
  72864. */
  72865. static ClearCache(): void;
  72866. /**
  72867. * Serialize a scene into a JSON compatible object
  72868. * @param scene defines the scene to serialize
  72869. * @returns a JSON compatible object
  72870. */
  72871. static Serialize(scene: Scene): any;
  72872. /**
  72873. * Serialize a mesh into a JSON compatible object
  72874. * @param toSerialize defines the mesh to serialize
  72875. * @param withParents defines if parents must be serialized as well
  72876. * @param withChildren defines if children must be serialized as well
  72877. * @returns a JSON compatible object
  72878. */
  72879. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72880. }
  72881. }
  72882. declare module BABYLON {
  72883. /**
  72884. * Class used to host texture specific utilities
  72885. */
  72886. export class TextureTools {
  72887. /**
  72888. * Uses the GPU to create a copy texture rescaled at a given size
  72889. * @param texture Texture to copy from
  72890. * @param width defines the desired width
  72891. * @param height defines the desired height
  72892. * @param useBilinearMode defines if bilinear mode has to be used
  72893. * @return the generated texture
  72894. */
  72895. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72896. }
  72897. }
  72898. declare module BABYLON {
  72899. /**
  72900. * This represents the different options available for the video capture.
  72901. */
  72902. export interface VideoRecorderOptions {
  72903. /** Defines the mime type of the video. */
  72904. mimeType: string;
  72905. /** Defines the FPS the video should be recorded at. */
  72906. fps: number;
  72907. /** Defines the chunk size for the recording data. */
  72908. recordChunckSize: number;
  72909. /** The audio tracks to attach to the recording. */
  72910. audioTracks?: MediaStreamTrack[];
  72911. }
  72912. /**
  72913. * This can help with recording videos from BabylonJS.
  72914. * This is based on the available WebRTC functionalities of the browser.
  72915. *
  72916. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  72917. */
  72918. export class VideoRecorder {
  72919. private static readonly _defaultOptions;
  72920. /**
  72921. * Returns whether or not the VideoRecorder is available in your browser.
  72922. * @param engine Defines the Babylon Engine.
  72923. * @returns true if supported otherwise false.
  72924. */
  72925. static IsSupported(engine: Engine): boolean;
  72926. private readonly _options;
  72927. private _canvas;
  72928. private _mediaRecorder;
  72929. private _recordedChunks;
  72930. private _fileName;
  72931. private _resolve;
  72932. private _reject;
  72933. /**
  72934. * True when a recording is already in progress.
  72935. */
  72936. get isRecording(): boolean;
  72937. /**
  72938. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72939. * @param engine Defines the BabylonJS Engine you wish to record.
  72940. * @param options Defines options that can be used to customize the capture.
  72941. */
  72942. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72943. /**
  72944. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72945. */
  72946. stopRecording(): void;
  72947. /**
  72948. * Starts recording the canvas for a max duration specified in parameters.
  72949. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72950. * If null no automatic download will start and you can rely on the promise to get the data back.
  72951. * @param maxDuration Defines the maximum recording time in seconds.
  72952. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72953. * @return A promise callback at the end of the recording with the video data in Blob.
  72954. */
  72955. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72956. /**
  72957. * Releases internal resources used during the recording.
  72958. */
  72959. dispose(): void;
  72960. private _handleDataAvailable;
  72961. private _handleError;
  72962. private _handleStop;
  72963. }
  72964. }
  72965. declare module BABYLON {
  72966. /**
  72967. * Class containing a set of static utilities functions for screenshots
  72968. */
  72969. export class ScreenshotTools {
  72970. /**
  72971. * Captures a screenshot of the current rendering
  72972. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72973. * @param engine defines the rendering engine
  72974. * @param camera defines the source camera
  72975. * @param size This parameter can be set to a single number or to an object with the
  72976. * following (optional) properties: precision, width, height. If a single number is passed,
  72977. * it will be used for both width and height. If an object is passed, the screenshot size
  72978. * will be derived from the parameters. The precision property is a multiplier allowing
  72979. * rendering at a higher or lower resolution
  72980. * @param successCallback defines the callback receives a single parameter which contains the
  72981. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72982. * src parameter of an <img> to display it
  72983. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72984. * Check your browser for supported MIME types
  72985. */
  72986. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72987. /**
  72988. * Captures a screenshot of the current rendering
  72989. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  72990. * @param engine defines the rendering engine
  72991. * @param camera defines the source camera
  72992. * @param size This parameter can be set to a single number or to an object with the
  72993. * following (optional) properties: precision, width, height. If a single number is passed,
  72994. * it will be used for both width and height. If an object is passed, the screenshot size
  72995. * will be derived from the parameters. The precision property is a multiplier allowing
  72996. * rendering at a higher or lower resolution
  72997. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72998. * Check your browser for supported MIME types
  72999. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73000. * to the src parameter of an <img> to display it
  73001. */
  73002. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73003. /**
  73004. * Generates an image screenshot from the specified camera.
  73005. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73006. * @param engine The engine to use for rendering
  73007. * @param camera The camera to use for rendering
  73008. * @param size This parameter can be set to a single number or to an object with the
  73009. * following (optional) properties: precision, width, height. If a single number is passed,
  73010. * it will be used for both width and height. If an object is passed, the screenshot size
  73011. * will be derived from the parameters. The precision property is a multiplier allowing
  73012. * rendering at a higher or lower resolution
  73013. * @param successCallback The callback receives a single parameter which contains the
  73014. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73015. * src parameter of an <img> to display it
  73016. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73017. * Check your browser for supported MIME types
  73018. * @param samples Texture samples (default: 1)
  73019. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73020. * @param fileName A name for for the downloaded file.
  73021. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73022. */
  73023. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73024. /**
  73025. * Generates an image screenshot from the specified camera.
  73026. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73027. * @param engine The engine to use for rendering
  73028. * @param camera The camera to use for rendering
  73029. * @param size This parameter can be set to a single number or to an object with the
  73030. * following (optional) properties: precision, width, height. If a single number is passed,
  73031. * it will be used for both width and height. If an object is passed, the screenshot size
  73032. * will be derived from the parameters. The precision property is a multiplier allowing
  73033. * rendering at a higher or lower resolution
  73034. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73035. * Check your browser for supported MIME types
  73036. * @param samples Texture samples (default: 1)
  73037. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73038. * @param fileName A name for for the downloaded file.
  73039. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73040. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73041. * to the src parameter of an <img> to display it
  73042. */
  73043. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73044. /**
  73045. * Gets height and width for screenshot size
  73046. * @private
  73047. */
  73048. private static _getScreenshotSize;
  73049. }
  73050. }
  73051. declare module BABYLON {
  73052. /**
  73053. * Interface for a data buffer
  73054. */
  73055. export interface IDataBuffer {
  73056. /**
  73057. * Reads bytes from the data buffer.
  73058. * @param byteOffset The byte offset to read
  73059. * @param byteLength The byte length to read
  73060. * @returns A promise that resolves when the bytes are read
  73061. */
  73062. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73063. /**
  73064. * The byte length of the buffer.
  73065. */
  73066. readonly byteLength: number;
  73067. }
  73068. /**
  73069. * Utility class for reading from a data buffer
  73070. */
  73071. export class DataReader {
  73072. /**
  73073. * The data buffer associated with this data reader.
  73074. */
  73075. readonly buffer: IDataBuffer;
  73076. /**
  73077. * The current byte offset from the beginning of the data buffer.
  73078. */
  73079. byteOffset: number;
  73080. private _dataView;
  73081. private _dataByteOffset;
  73082. /**
  73083. * Constructor
  73084. * @param buffer The buffer to read
  73085. */
  73086. constructor(buffer: IDataBuffer);
  73087. /**
  73088. * Loads the given byte length.
  73089. * @param byteLength The byte length to load
  73090. * @returns A promise that resolves when the load is complete
  73091. */
  73092. loadAsync(byteLength: number): Promise<void>;
  73093. /**
  73094. * Read a unsigned 32-bit integer from the currently loaded data range.
  73095. * @returns The 32-bit integer read
  73096. */
  73097. readUint32(): number;
  73098. /**
  73099. * Read a byte array from the currently loaded data range.
  73100. * @param byteLength The byte length to read
  73101. * @returns The byte array read
  73102. */
  73103. readUint8Array(byteLength: number): Uint8Array;
  73104. /**
  73105. * Read a string from the currently loaded data range.
  73106. * @param byteLength The byte length to read
  73107. * @returns The string read
  73108. */
  73109. readString(byteLength: number): string;
  73110. /**
  73111. * Skips the given byte length the currently loaded data range.
  73112. * @param byteLength The byte length to skip
  73113. */
  73114. skipBytes(byteLength: number): void;
  73115. }
  73116. }
  73117. declare module BABYLON {
  73118. /**
  73119. * Class for storing data to local storage if available or in-memory storage otherwise
  73120. */
  73121. export class DataStorage {
  73122. private static _Storage;
  73123. private static _GetStorage;
  73124. /**
  73125. * Reads a string from the data storage
  73126. * @param key The key to read
  73127. * @param defaultValue The value if the key doesn't exist
  73128. * @returns The string value
  73129. */
  73130. static ReadString(key: string, defaultValue: string): string;
  73131. /**
  73132. * Writes a string to the data storage
  73133. * @param key The key to write
  73134. * @param value The value to write
  73135. */
  73136. static WriteString(key: string, value: string): void;
  73137. /**
  73138. * Reads a boolean from the data storage
  73139. * @param key The key to read
  73140. * @param defaultValue The value if the key doesn't exist
  73141. * @returns The boolean value
  73142. */
  73143. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73144. /**
  73145. * Writes a boolean to the data storage
  73146. * @param key The key to write
  73147. * @param value The value to write
  73148. */
  73149. static WriteBoolean(key: string, value: boolean): void;
  73150. /**
  73151. * Reads a number from the data storage
  73152. * @param key The key to read
  73153. * @param defaultValue The value if the key doesn't exist
  73154. * @returns The number value
  73155. */
  73156. static ReadNumber(key: string, defaultValue: number): number;
  73157. /**
  73158. * Writes a number to the data storage
  73159. * @param key The key to write
  73160. * @param value The value to write
  73161. */
  73162. static WriteNumber(key: string, value: number): void;
  73163. }
  73164. }
  73165. declare module BABYLON {
  73166. /**
  73167. * An interface for all Hit test features
  73168. */
  73169. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73170. /**
  73171. * Triggered when new babylon (transformed) hit test results are available
  73172. */
  73173. onHitTestResultObservable: Observable<T[]>;
  73174. }
  73175. /**
  73176. * Options used for hit testing
  73177. */
  73178. export interface IWebXRLegacyHitTestOptions {
  73179. /**
  73180. * Only test when user interacted with the scene. Default - hit test every frame
  73181. */
  73182. testOnPointerDownOnly?: boolean;
  73183. /**
  73184. * The node to use to transform the local results to world coordinates
  73185. */
  73186. worldParentNode?: TransformNode;
  73187. }
  73188. /**
  73189. * Interface defining the babylon result of raycasting/hit-test
  73190. */
  73191. export interface IWebXRLegacyHitResult {
  73192. /**
  73193. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73194. */
  73195. transformationMatrix: Matrix;
  73196. /**
  73197. * The native hit test result
  73198. */
  73199. xrHitResult: XRHitResult | XRHitTestResult;
  73200. }
  73201. /**
  73202. * The currently-working hit-test module.
  73203. * Hit test (or Ray-casting) is used to interact with the real world.
  73204. * For further information read here - https://github.com/immersive-web/hit-test
  73205. */
  73206. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73207. /**
  73208. * options to use when constructing this feature
  73209. */
  73210. readonly options: IWebXRLegacyHitTestOptions;
  73211. private _direction;
  73212. private _mat;
  73213. private _onSelectEnabled;
  73214. private _origin;
  73215. /**
  73216. * The module's name
  73217. */
  73218. static readonly Name: string;
  73219. /**
  73220. * The (Babylon) version of this module.
  73221. * This is an integer representing the implementation version.
  73222. * This number does not correspond to the WebXR specs version
  73223. */
  73224. static readonly Version: number;
  73225. /**
  73226. * Populated with the last native XR Hit Results
  73227. */
  73228. lastNativeXRHitResults: XRHitResult[];
  73229. /**
  73230. * Triggered when new babylon (transformed) hit test results are available
  73231. */
  73232. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73233. /**
  73234. * Creates a new instance of the (legacy version) hit test feature
  73235. * @param _xrSessionManager an instance of WebXRSessionManager
  73236. * @param options options to use when constructing this feature
  73237. */
  73238. constructor(_xrSessionManager: WebXRSessionManager,
  73239. /**
  73240. * options to use when constructing this feature
  73241. */
  73242. options?: IWebXRLegacyHitTestOptions);
  73243. /**
  73244. * execute a hit test with an XR Ray
  73245. *
  73246. * @param xrSession a native xrSession that will execute this hit test
  73247. * @param xrRay the ray (position and direction) to use for ray-casting
  73248. * @param referenceSpace native XR reference space to use for the hit-test
  73249. * @param filter filter function that will filter the results
  73250. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73251. */
  73252. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73253. /**
  73254. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73255. * @param event the (select) event to use to select with
  73256. * @param referenceSpace the reference space to use for this hit test
  73257. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73258. */
  73259. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73260. /**
  73261. * attach this feature
  73262. * Will usually be called by the features manager
  73263. *
  73264. * @returns true if successful.
  73265. */
  73266. attach(): boolean;
  73267. /**
  73268. * detach this feature.
  73269. * Will usually be called by the features manager
  73270. *
  73271. * @returns true if successful.
  73272. */
  73273. detach(): boolean;
  73274. /**
  73275. * Dispose this feature and all of the resources attached
  73276. */
  73277. dispose(): void;
  73278. protected _onXRFrame(frame: XRFrame): void;
  73279. private _onHitTestResults;
  73280. private _onSelect;
  73281. }
  73282. }
  73283. declare module BABYLON {
  73284. /**
  73285. * Options used for hit testing (version 2)
  73286. */
  73287. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73288. /**
  73289. * Do not create a permanent hit test. Will usually be used when only
  73290. * transient inputs are needed.
  73291. */
  73292. disablePermanentHitTest?: boolean;
  73293. /**
  73294. * Enable transient (for example touch-based) hit test inspections
  73295. */
  73296. enableTransientHitTest?: boolean;
  73297. /**
  73298. * Offset ray for the permanent hit test
  73299. */
  73300. offsetRay?: Vector3;
  73301. /**
  73302. * Offset ray for the transient hit test
  73303. */
  73304. transientOffsetRay?: Vector3;
  73305. /**
  73306. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73307. */
  73308. useReferenceSpace?: boolean;
  73309. }
  73310. /**
  73311. * Interface defining the babylon result of hit-test
  73312. */
  73313. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73314. /**
  73315. * The input source that generated this hit test (if transient)
  73316. */
  73317. inputSource?: XRInputSource;
  73318. /**
  73319. * Is this a transient hit test
  73320. */
  73321. isTransient?: boolean;
  73322. /**
  73323. * Position of the hit test result
  73324. */
  73325. position: Vector3;
  73326. /**
  73327. * Rotation of the hit test result
  73328. */
  73329. rotationQuaternion: Quaternion;
  73330. /**
  73331. * The native hit test result
  73332. */
  73333. xrHitResult: XRHitTestResult;
  73334. }
  73335. /**
  73336. * The currently-working hit-test module.
  73337. * Hit test (or Ray-casting) is used to interact with the real world.
  73338. * For further information read here - https://github.com/immersive-web/hit-test
  73339. *
  73340. * Tested on chrome (mobile) 80.
  73341. */
  73342. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73343. /**
  73344. * options to use when constructing this feature
  73345. */
  73346. readonly options: IWebXRHitTestOptions;
  73347. private _tmpMat;
  73348. private _tmpPos;
  73349. private _tmpQuat;
  73350. private _transientXrHitTestSource;
  73351. private _xrHitTestSource;
  73352. private initHitTestSource;
  73353. /**
  73354. * The module's name
  73355. */
  73356. static readonly Name: string;
  73357. /**
  73358. * The (Babylon) version of this module.
  73359. * This is an integer representing the implementation version.
  73360. * This number does not correspond to the WebXR specs version
  73361. */
  73362. static readonly Version: number;
  73363. /**
  73364. * When set to true, each hit test will have its own position/rotation objects
  73365. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73366. * the developers will clone them or copy them as they see fit.
  73367. */
  73368. autoCloneTransformation: boolean;
  73369. /**
  73370. * Triggered when new babylon (transformed) hit test results are available
  73371. */
  73372. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73373. /**
  73374. * Use this to temporarily pause hit test checks.
  73375. */
  73376. paused: boolean;
  73377. /**
  73378. * Creates a new instance of the hit test feature
  73379. * @param _xrSessionManager an instance of WebXRSessionManager
  73380. * @param options options to use when constructing this feature
  73381. */
  73382. constructor(_xrSessionManager: WebXRSessionManager,
  73383. /**
  73384. * options to use when constructing this feature
  73385. */
  73386. options?: IWebXRHitTestOptions);
  73387. /**
  73388. * attach this feature
  73389. * Will usually be called by the features manager
  73390. *
  73391. * @returns true if successful.
  73392. */
  73393. attach(): boolean;
  73394. /**
  73395. * detach this feature.
  73396. * Will usually be called by the features manager
  73397. *
  73398. * @returns true if successful.
  73399. */
  73400. detach(): boolean;
  73401. /**
  73402. * Dispose this feature and all of the resources attached
  73403. */
  73404. dispose(): void;
  73405. protected _onXRFrame(frame: XRFrame): void;
  73406. private _processWebXRHitTestResult;
  73407. }
  73408. }
  73409. declare module BABYLON {
  73410. /**
  73411. * Configuration options of the anchor system
  73412. */
  73413. export interface IWebXRAnchorSystemOptions {
  73414. /**
  73415. * a node that will be used to convert local to world coordinates
  73416. */
  73417. worldParentNode?: TransformNode;
  73418. /**
  73419. * If set to true a reference of the created anchors will be kept until the next session starts
  73420. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73421. */
  73422. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73423. }
  73424. /**
  73425. * A babylon container for an XR Anchor
  73426. */
  73427. export interface IWebXRAnchor {
  73428. /**
  73429. * A babylon-assigned ID for this anchor
  73430. */
  73431. id: number;
  73432. /**
  73433. * Transformation matrix to apply to an object attached to this anchor
  73434. */
  73435. transformationMatrix: Matrix;
  73436. /**
  73437. * The native anchor object
  73438. */
  73439. xrAnchor: XRAnchor;
  73440. /**
  73441. * if defined, this object will be constantly updated by the anchor's position and rotation
  73442. */
  73443. attachedNode?: TransformNode;
  73444. }
  73445. /**
  73446. * An implementation of the anchor system for WebXR.
  73447. * For further information see https://github.com/immersive-web/anchors/
  73448. */
  73449. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73450. private _options;
  73451. private _lastFrameDetected;
  73452. private _trackedAnchors;
  73453. private _referenceSpaceForFrameAnchors;
  73454. private _futureAnchors;
  73455. /**
  73456. * The module's name
  73457. */
  73458. static readonly Name: string;
  73459. /**
  73460. * The (Babylon) version of this module.
  73461. * This is an integer representing the implementation version.
  73462. * This number does not correspond to the WebXR specs version
  73463. */
  73464. static readonly Version: number;
  73465. /**
  73466. * Observers registered here will be executed when a new anchor was added to the session
  73467. */
  73468. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73469. /**
  73470. * Observers registered here will be executed when an anchor was removed from the session
  73471. */
  73472. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73473. /**
  73474. * Observers registered here will be executed when an existing anchor updates
  73475. * This can execute N times every frame
  73476. */
  73477. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73478. /**
  73479. * Set the reference space to use for anchor creation, when not using a hit test.
  73480. * Will default to the session's reference space if not defined
  73481. */
  73482. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73483. /**
  73484. * constructs a new anchor system
  73485. * @param _xrSessionManager an instance of WebXRSessionManager
  73486. * @param _options configuration object for this feature
  73487. */
  73488. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73489. private _tmpVector;
  73490. private _tmpQuaternion;
  73491. private _populateTmpTransformation;
  73492. /**
  73493. * Create a new anchor point using a hit test result at a specific point in the scene
  73494. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73495. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73496. *
  73497. * @param hitTestResult The hit test result to use for this anchor creation
  73498. * @param position an optional position offset for this anchor
  73499. * @param rotationQuaternion an optional rotation offset for this anchor
  73500. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73501. */
  73502. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73503. /**
  73504. * Add a new anchor at a specific position and rotation
  73505. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73506. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73507. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73508. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73509. *
  73510. * @param position the position in which to add an anchor
  73511. * @param rotationQuaternion an optional rotation for the anchor transformation
  73512. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73513. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73514. */
  73515. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73516. /**
  73517. * detach this feature.
  73518. * Will usually be called by the features manager
  73519. *
  73520. * @returns true if successful.
  73521. */
  73522. detach(): boolean;
  73523. /**
  73524. * Dispose this feature and all of the resources attached
  73525. */
  73526. dispose(): void;
  73527. protected _onXRFrame(frame: XRFrame): void;
  73528. /**
  73529. * avoiding using Array.find for global support.
  73530. * @param xrAnchor the plane to find in the array
  73531. */
  73532. private _findIndexInAnchorArray;
  73533. private _updateAnchorWithXRFrame;
  73534. private _createAnchorAtTransformation;
  73535. }
  73536. }
  73537. declare module BABYLON {
  73538. /**
  73539. * Options used in the plane detector module
  73540. */
  73541. export interface IWebXRPlaneDetectorOptions {
  73542. /**
  73543. * The node to use to transform the local results to world coordinates
  73544. */
  73545. worldParentNode?: TransformNode;
  73546. /**
  73547. * If set to true a reference of the created planes will be kept until the next session starts
  73548. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73549. */
  73550. doNotRemovePlanesOnSessionEnded?: boolean;
  73551. }
  73552. /**
  73553. * A babylon interface for a WebXR plane.
  73554. * A Plane is actually a polygon, built from N points in space
  73555. *
  73556. * Supported in chrome 79, not supported in canary 81 ATM
  73557. */
  73558. export interface IWebXRPlane {
  73559. /**
  73560. * a babylon-assigned ID for this polygon
  73561. */
  73562. id: number;
  73563. /**
  73564. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73565. */
  73566. polygonDefinition: Array<Vector3>;
  73567. /**
  73568. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73569. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73570. */
  73571. transformationMatrix: Matrix;
  73572. /**
  73573. * the native xr-plane object
  73574. */
  73575. xrPlane: XRPlane;
  73576. }
  73577. /**
  73578. * The plane detector is used to detect planes in the real world when in AR
  73579. * For more information see https://github.com/immersive-web/real-world-geometry/
  73580. */
  73581. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73582. private _options;
  73583. private _detectedPlanes;
  73584. private _enabled;
  73585. private _lastFrameDetected;
  73586. /**
  73587. * The module's name
  73588. */
  73589. static readonly Name: string;
  73590. /**
  73591. * The (Babylon) version of this module.
  73592. * This is an integer representing the implementation version.
  73593. * This number does not correspond to the WebXR specs version
  73594. */
  73595. static readonly Version: number;
  73596. /**
  73597. * Observers registered here will be executed when a new plane was added to the session
  73598. */
  73599. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73600. /**
  73601. * Observers registered here will be executed when a plane is no longer detected in the session
  73602. */
  73603. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73604. /**
  73605. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73606. * This can execute N times every frame
  73607. */
  73608. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73609. /**
  73610. * construct a new Plane Detector
  73611. * @param _xrSessionManager an instance of xr Session manager
  73612. * @param _options configuration to use when constructing this feature
  73613. */
  73614. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73615. /**
  73616. * detach this feature.
  73617. * Will usually be called by the features manager
  73618. *
  73619. * @returns true if successful.
  73620. */
  73621. detach(): boolean;
  73622. /**
  73623. * Dispose this feature and all of the resources attached
  73624. */
  73625. dispose(): void;
  73626. protected _onXRFrame(frame: XRFrame): void;
  73627. private _init;
  73628. private _updatePlaneWithXRPlane;
  73629. /**
  73630. * avoiding using Array.find for global support.
  73631. * @param xrPlane the plane to find in the array
  73632. */
  73633. private findIndexInPlaneArray;
  73634. }
  73635. }
  73636. declare module BABYLON {
  73637. /**
  73638. * Options interface for the background remover plugin
  73639. */
  73640. export interface IWebXRBackgroundRemoverOptions {
  73641. /**
  73642. * Further background meshes to disable when entering AR
  73643. */
  73644. backgroundMeshes?: AbstractMesh[];
  73645. /**
  73646. * flags to configure the removal of the environment helper.
  73647. * If not set, the entire background will be removed. If set, flags should be set as well.
  73648. */
  73649. environmentHelperRemovalFlags?: {
  73650. /**
  73651. * Should the skybox be removed (default false)
  73652. */
  73653. skyBox?: boolean;
  73654. /**
  73655. * Should the ground be removed (default false)
  73656. */
  73657. ground?: boolean;
  73658. };
  73659. /**
  73660. * don't disable the environment helper
  73661. */
  73662. ignoreEnvironmentHelper?: boolean;
  73663. }
  73664. /**
  73665. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73666. */
  73667. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73668. /**
  73669. * read-only options to be used in this module
  73670. */
  73671. readonly options: IWebXRBackgroundRemoverOptions;
  73672. /**
  73673. * The module's name
  73674. */
  73675. static readonly Name: string;
  73676. /**
  73677. * The (Babylon) version of this module.
  73678. * This is an integer representing the implementation version.
  73679. * This number does not correspond to the WebXR specs version
  73680. */
  73681. static readonly Version: number;
  73682. /**
  73683. * registered observers will be triggered when the background state changes
  73684. */
  73685. onBackgroundStateChangedObservable: Observable<boolean>;
  73686. /**
  73687. * constructs a new background remover module
  73688. * @param _xrSessionManager the session manager for this module
  73689. * @param options read-only options to be used in this module
  73690. */
  73691. constructor(_xrSessionManager: WebXRSessionManager,
  73692. /**
  73693. * read-only options to be used in this module
  73694. */
  73695. options?: IWebXRBackgroundRemoverOptions);
  73696. /**
  73697. * attach this feature
  73698. * Will usually be called by the features manager
  73699. *
  73700. * @returns true if successful.
  73701. */
  73702. attach(): boolean;
  73703. /**
  73704. * detach this feature.
  73705. * Will usually be called by the features manager
  73706. *
  73707. * @returns true if successful.
  73708. */
  73709. detach(): boolean;
  73710. /**
  73711. * Dispose this feature and all of the resources attached
  73712. */
  73713. dispose(): void;
  73714. protected _onXRFrame(_xrFrame: XRFrame): void;
  73715. private _setBackgroundState;
  73716. }
  73717. }
  73718. declare module BABYLON {
  73719. /**
  73720. * Options for the controller physics feature
  73721. */
  73722. export class IWebXRControllerPhysicsOptions {
  73723. /**
  73724. * Should the headset get its own impostor
  73725. */
  73726. enableHeadsetImpostor?: boolean;
  73727. /**
  73728. * Optional parameters for the headset impostor
  73729. */
  73730. headsetImpostorParams?: {
  73731. /**
  73732. * The type of impostor to create. Default is sphere
  73733. */
  73734. impostorType: number;
  73735. /**
  73736. * the size of the impostor. Defaults to 10cm
  73737. */
  73738. impostorSize?: number | {
  73739. width: number;
  73740. height: number;
  73741. depth: number;
  73742. };
  73743. /**
  73744. * Friction definitions
  73745. */
  73746. friction?: number;
  73747. /**
  73748. * Restitution
  73749. */
  73750. restitution?: number;
  73751. };
  73752. /**
  73753. * The physics properties of the future impostors
  73754. */
  73755. physicsProperties?: {
  73756. /**
  73757. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73758. * Note that this requires a physics engine that supports mesh impostors!
  73759. */
  73760. useControllerMesh?: boolean;
  73761. /**
  73762. * The type of impostor to create. Default is sphere
  73763. */
  73764. impostorType?: number;
  73765. /**
  73766. * the size of the impostor. Defaults to 10cm
  73767. */
  73768. impostorSize?: number | {
  73769. width: number;
  73770. height: number;
  73771. depth: number;
  73772. };
  73773. /**
  73774. * Friction definitions
  73775. */
  73776. friction?: number;
  73777. /**
  73778. * Restitution
  73779. */
  73780. restitution?: number;
  73781. };
  73782. /**
  73783. * the xr input to use with this pointer selection
  73784. */
  73785. xrInput: WebXRInput;
  73786. }
  73787. /**
  73788. * Add physics impostor to your webxr controllers,
  73789. * including naive calculation of their linear and angular velocity
  73790. */
  73791. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73792. private readonly _options;
  73793. private _attachController;
  73794. private _controllers;
  73795. private _debugMode;
  73796. private _delta;
  73797. private _headsetImpostor?;
  73798. private _headsetMesh?;
  73799. private _lastTimestamp;
  73800. private _tmpQuaternion;
  73801. private _tmpVector;
  73802. /**
  73803. * The module's name
  73804. */
  73805. static readonly Name: string;
  73806. /**
  73807. * The (Babylon) version of this module.
  73808. * This is an integer representing the implementation version.
  73809. * This number does not correspond to the webxr specs version
  73810. */
  73811. static readonly Version: number;
  73812. /**
  73813. * Construct a new Controller Physics Feature
  73814. * @param _xrSessionManager the corresponding xr session manager
  73815. * @param _options options to create this feature with
  73816. */
  73817. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73818. /**
  73819. * @hidden
  73820. * enable debugging - will show console outputs and the impostor mesh
  73821. */
  73822. _enablePhysicsDebug(): void;
  73823. /**
  73824. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73825. * @param xrController the controller to add
  73826. */
  73827. addController(xrController: WebXRInputSource): void;
  73828. /**
  73829. * attach this feature
  73830. * Will usually be called by the features manager
  73831. *
  73832. * @returns true if successful.
  73833. */
  73834. attach(): boolean;
  73835. /**
  73836. * detach this feature.
  73837. * Will usually be called by the features manager
  73838. *
  73839. * @returns true if successful.
  73840. */
  73841. detach(): boolean;
  73842. /**
  73843. * Get the headset impostor, if enabled
  73844. * @returns the impostor
  73845. */
  73846. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73847. /**
  73848. * Get the physics impostor of a specific controller.
  73849. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73850. * @param controller the controller or the controller id of which to get the impostor
  73851. * @returns the impostor or null
  73852. */
  73853. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73854. /**
  73855. * Update the physics properties provided in the constructor
  73856. * @param newProperties the new properties object
  73857. */
  73858. setPhysicsProperties(newProperties: {
  73859. impostorType?: number;
  73860. impostorSize?: number | {
  73861. width: number;
  73862. height: number;
  73863. depth: number;
  73864. };
  73865. friction?: number;
  73866. restitution?: number;
  73867. }): void;
  73868. protected _onXRFrame(_xrFrame: any): void;
  73869. private _detachController;
  73870. }
  73871. }
  73872. declare module BABYLON {
  73873. /**
  73874. * The motion controller class for all microsoft mixed reality controllers
  73875. */
  73876. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73877. protected readonly _mapping: {
  73878. defaultButton: {
  73879. valueNodeName: string;
  73880. unpressedNodeName: string;
  73881. pressedNodeName: string;
  73882. };
  73883. defaultAxis: {
  73884. valueNodeName: string;
  73885. minNodeName: string;
  73886. maxNodeName: string;
  73887. };
  73888. buttons: {
  73889. "xr-standard-trigger": {
  73890. rootNodeName: string;
  73891. componentProperty: string;
  73892. states: string[];
  73893. };
  73894. "xr-standard-squeeze": {
  73895. rootNodeName: string;
  73896. componentProperty: string;
  73897. states: string[];
  73898. };
  73899. "xr-standard-touchpad": {
  73900. rootNodeName: string;
  73901. labelAnchorNodeName: string;
  73902. touchPointNodeName: string;
  73903. };
  73904. "xr-standard-thumbstick": {
  73905. rootNodeName: string;
  73906. componentProperty: string;
  73907. states: string[];
  73908. };
  73909. };
  73910. axes: {
  73911. "xr-standard-touchpad": {
  73912. "x-axis": {
  73913. rootNodeName: string;
  73914. };
  73915. "y-axis": {
  73916. rootNodeName: string;
  73917. };
  73918. };
  73919. "xr-standard-thumbstick": {
  73920. "x-axis": {
  73921. rootNodeName: string;
  73922. };
  73923. "y-axis": {
  73924. rootNodeName: string;
  73925. };
  73926. };
  73927. };
  73928. };
  73929. /**
  73930. * The base url used to load the left and right controller models
  73931. */
  73932. static MODEL_BASE_URL: string;
  73933. /**
  73934. * The name of the left controller model file
  73935. */
  73936. static MODEL_LEFT_FILENAME: string;
  73937. /**
  73938. * The name of the right controller model file
  73939. */
  73940. static MODEL_RIGHT_FILENAME: string;
  73941. profileId: string;
  73942. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73943. protected _getFilenameAndPath(): {
  73944. filename: string;
  73945. path: string;
  73946. };
  73947. protected _getModelLoadingConstraints(): boolean;
  73948. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73949. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73950. protected _updateModel(): void;
  73951. }
  73952. }
  73953. declare module BABYLON {
  73954. /**
  73955. * The motion controller class for oculus touch (quest, rift).
  73956. * This class supports legacy mapping as well the standard xr mapping
  73957. */
  73958. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73959. private _forceLegacyControllers;
  73960. private _modelRootNode;
  73961. /**
  73962. * The base url used to load the left and right controller models
  73963. */
  73964. static MODEL_BASE_URL: string;
  73965. /**
  73966. * The name of the left controller model file
  73967. */
  73968. static MODEL_LEFT_FILENAME: string;
  73969. /**
  73970. * The name of the right controller model file
  73971. */
  73972. static MODEL_RIGHT_FILENAME: string;
  73973. /**
  73974. * Base Url for the Quest controller model.
  73975. */
  73976. static QUEST_MODEL_BASE_URL: string;
  73977. profileId: string;
  73978. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73979. protected _getFilenameAndPath(): {
  73980. filename: string;
  73981. path: string;
  73982. };
  73983. protected _getModelLoadingConstraints(): boolean;
  73984. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73985. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73986. protected _updateModel(): void;
  73987. /**
  73988. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73989. * between the touch and touch 2.
  73990. */
  73991. private _isQuest;
  73992. }
  73993. }
  73994. declare module BABYLON {
  73995. /**
  73996. * The motion controller class for the standard HTC-Vive controllers
  73997. */
  73998. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73999. private _modelRootNode;
  74000. /**
  74001. * The base url used to load the left and right controller models
  74002. */
  74003. static MODEL_BASE_URL: string;
  74004. /**
  74005. * File name for the controller model.
  74006. */
  74007. static MODEL_FILENAME: string;
  74008. profileId: string;
  74009. /**
  74010. * Create a new Vive motion controller object
  74011. * @param scene the scene to use to create this controller
  74012. * @param gamepadObject the corresponding gamepad object
  74013. * @param handedness the handedness of the controller
  74014. */
  74015. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74016. protected _getFilenameAndPath(): {
  74017. filename: string;
  74018. path: string;
  74019. };
  74020. protected _getModelLoadingConstraints(): boolean;
  74021. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74022. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74023. protected _updateModel(): void;
  74024. }
  74025. }
  74026. declare module BABYLON {
  74027. /**
  74028. * A cursor which tracks a point on a path
  74029. */
  74030. export class PathCursor {
  74031. private path;
  74032. /**
  74033. * Stores path cursor callbacks for when an onchange event is triggered
  74034. */
  74035. private _onchange;
  74036. /**
  74037. * The value of the path cursor
  74038. */
  74039. value: number;
  74040. /**
  74041. * The animation array of the path cursor
  74042. */
  74043. animations: Animation[];
  74044. /**
  74045. * Initializes the path cursor
  74046. * @param path The path to track
  74047. */
  74048. constructor(path: Path2);
  74049. /**
  74050. * Gets the cursor point on the path
  74051. * @returns A point on the path cursor at the cursor location
  74052. */
  74053. getPoint(): Vector3;
  74054. /**
  74055. * Moves the cursor ahead by the step amount
  74056. * @param step The amount to move the cursor forward
  74057. * @returns This path cursor
  74058. */
  74059. moveAhead(step?: number): PathCursor;
  74060. /**
  74061. * Moves the cursor behind by the step amount
  74062. * @param step The amount to move the cursor back
  74063. * @returns This path cursor
  74064. */
  74065. moveBack(step?: number): PathCursor;
  74066. /**
  74067. * Moves the cursor by the step amount
  74068. * If the step amount is greater than one, an exception is thrown
  74069. * @param step The amount to move the cursor
  74070. * @returns This path cursor
  74071. */
  74072. move(step: number): PathCursor;
  74073. /**
  74074. * Ensures that the value is limited between zero and one
  74075. * @returns This path cursor
  74076. */
  74077. private ensureLimits;
  74078. /**
  74079. * Runs onchange callbacks on change (used by the animation engine)
  74080. * @returns This path cursor
  74081. */
  74082. private raiseOnChange;
  74083. /**
  74084. * Executes a function on change
  74085. * @param f A path cursor onchange callback
  74086. * @returns This path cursor
  74087. */
  74088. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74089. }
  74090. }
  74091. declare module BABYLON {
  74092. /** @hidden */
  74093. export var blurPixelShader: {
  74094. name: string;
  74095. shader: string;
  74096. };
  74097. }
  74098. declare module BABYLON {
  74099. /** @hidden */
  74100. export var pointCloudVertexDeclaration: {
  74101. name: string;
  74102. shader: string;
  74103. };
  74104. }
  74105. // Mixins
  74106. interface Window {
  74107. mozIndexedDB: IDBFactory;
  74108. webkitIndexedDB: IDBFactory;
  74109. msIndexedDB: IDBFactory;
  74110. webkitURL: typeof URL;
  74111. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74112. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74113. WebGLRenderingContext: WebGLRenderingContext;
  74114. MSGesture: MSGesture;
  74115. CANNON: any;
  74116. AudioContext: AudioContext;
  74117. webkitAudioContext: AudioContext;
  74118. PointerEvent: any;
  74119. Math: Math;
  74120. Uint8Array: Uint8ArrayConstructor;
  74121. Float32Array: Float32ArrayConstructor;
  74122. mozURL: typeof URL;
  74123. msURL: typeof URL;
  74124. VRFrameData: any; // WebVR, from specs 1.1
  74125. DracoDecoderModule: any;
  74126. setImmediate(handler: (...args: any[]) => void): number;
  74127. }
  74128. interface HTMLCanvasElement {
  74129. requestPointerLock(): void;
  74130. msRequestPointerLock?(): void;
  74131. mozRequestPointerLock?(): void;
  74132. webkitRequestPointerLock?(): void;
  74133. /** Track wether a record is in progress */
  74134. isRecording: boolean;
  74135. /** Capture Stream method defined by some browsers */
  74136. captureStream(fps?: number): MediaStream;
  74137. }
  74138. interface CanvasRenderingContext2D {
  74139. msImageSmoothingEnabled: boolean;
  74140. }
  74141. interface MouseEvent {
  74142. mozMovementX: number;
  74143. mozMovementY: number;
  74144. webkitMovementX: number;
  74145. webkitMovementY: number;
  74146. msMovementX: number;
  74147. msMovementY: number;
  74148. }
  74149. interface Navigator {
  74150. mozGetVRDevices: (any: any) => any;
  74151. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74152. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74153. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74154. webkitGetGamepads(): Gamepad[];
  74155. msGetGamepads(): Gamepad[];
  74156. webkitGamepads(): Gamepad[];
  74157. }
  74158. interface HTMLVideoElement {
  74159. mozSrcObject: any;
  74160. }
  74161. interface Math {
  74162. fround(x: number): number;
  74163. imul(a: number, b: number): number;
  74164. }
  74165. interface WebGLRenderingContext {
  74166. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74167. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74168. vertexAttribDivisor(index: number, divisor: number): void;
  74169. createVertexArray(): any;
  74170. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74171. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74172. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74173. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74174. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74175. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74176. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74177. // Queries
  74178. createQuery(): WebGLQuery;
  74179. deleteQuery(query: WebGLQuery): void;
  74180. beginQuery(target: number, query: WebGLQuery): void;
  74181. endQuery(target: number): void;
  74182. getQueryParameter(query: WebGLQuery, pname: number): any;
  74183. getQuery(target: number, pname: number): any;
  74184. MAX_SAMPLES: number;
  74185. RGBA8: number;
  74186. READ_FRAMEBUFFER: number;
  74187. DRAW_FRAMEBUFFER: number;
  74188. UNIFORM_BUFFER: number;
  74189. HALF_FLOAT_OES: number;
  74190. RGBA16F: number;
  74191. RGBA32F: number;
  74192. R32F: number;
  74193. RG32F: number;
  74194. RGB32F: number;
  74195. R16F: number;
  74196. RG16F: number;
  74197. RGB16F: number;
  74198. RED: number;
  74199. RG: number;
  74200. R8: number;
  74201. RG8: number;
  74202. UNSIGNED_INT_24_8: number;
  74203. DEPTH24_STENCIL8: number;
  74204. MIN: number;
  74205. MAX: number;
  74206. /* Multiple Render Targets */
  74207. drawBuffers(buffers: number[]): void;
  74208. readBuffer(src: number): void;
  74209. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74210. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74211. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74212. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74213. // Occlusion Query
  74214. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74215. ANY_SAMPLES_PASSED: number;
  74216. QUERY_RESULT_AVAILABLE: number;
  74217. QUERY_RESULT: number;
  74218. }
  74219. interface WebGLProgram {
  74220. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74221. }
  74222. interface EXT_disjoint_timer_query {
  74223. QUERY_COUNTER_BITS_EXT: number;
  74224. TIME_ELAPSED_EXT: number;
  74225. TIMESTAMP_EXT: number;
  74226. GPU_DISJOINT_EXT: number;
  74227. QUERY_RESULT_EXT: number;
  74228. QUERY_RESULT_AVAILABLE_EXT: number;
  74229. queryCounterEXT(query: WebGLQuery, target: number): void;
  74230. createQueryEXT(): WebGLQuery;
  74231. beginQueryEXT(target: number, query: WebGLQuery): void;
  74232. endQueryEXT(target: number): void;
  74233. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74234. deleteQueryEXT(query: WebGLQuery): void;
  74235. }
  74236. interface WebGLUniformLocation {
  74237. _currentState: any;
  74238. }
  74239. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74240. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74241. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74242. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74243. interface WebGLRenderingContext {
  74244. readonly RASTERIZER_DISCARD: number;
  74245. readonly DEPTH_COMPONENT24: number;
  74246. readonly TEXTURE_3D: number;
  74247. readonly TEXTURE_2D_ARRAY: number;
  74248. readonly TEXTURE_COMPARE_FUNC: number;
  74249. readonly TEXTURE_COMPARE_MODE: number;
  74250. readonly COMPARE_REF_TO_TEXTURE: number;
  74251. readonly TEXTURE_WRAP_R: number;
  74252. readonly HALF_FLOAT: number;
  74253. readonly RGB8: number;
  74254. readonly RED_INTEGER: number;
  74255. readonly RG_INTEGER: number;
  74256. readonly RGB_INTEGER: number;
  74257. readonly RGBA_INTEGER: number;
  74258. readonly R8_SNORM: number;
  74259. readonly RG8_SNORM: number;
  74260. readonly RGB8_SNORM: number;
  74261. readonly RGBA8_SNORM: number;
  74262. readonly R8I: number;
  74263. readonly RG8I: number;
  74264. readonly RGB8I: number;
  74265. readonly RGBA8I: number;
  74266. readonly R8UI: number;
  74267. readonly RG8UI: number;
  74268. readonly RGB8UI: number;
  74269. readonly RGBA8UI: number;
  74270. readonly R16I: number;
  74271. readonly RG16I: number;
  74272. readonly RGB16I: number;
  74273. readonly RGBA16I: number;
  74274. readonly R16UI: number;
  74275. readonly RG16UI: number;
  74276. readonly RGB16UI: number;
  74277. readonly RGBA16UI: number;
  74278. readonly R32I: number;
  74279. readonly RG32I: number;
  74280. readonly RGB32I: number;
  74281. readonly RGBA32I: number;
  74282. readonly R32UI: number;
  74283. readonly RG32UI: number;
  74284. readonly RGB32UI: number;
  74285. readonly RGBA32UI: number;
  74286. readonly RGB10_A2UI: number;
  74287. readonly R11F_G11F_B10F: number;
  74288. readonly RGB9_E5: number;
  74289. readonly RGB10_A2: number;
  74290. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74291. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74292. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74293. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74294. readonly DEPTH_COMPONENT32F: number;
  74295. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74296. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74297. 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;
  74298. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74299. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74300. readonly TRANSFORM_FEEDBACK: number;
  74301. readonly INTERLEAVED_ATTRIBS: number;
  74302. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74303. createTransformFeedback(): WebGLTransformFeedback;
  74304. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74305. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74306. beginTransformFeedback(primitiveMode: number): void;
  74307. endTransformFeedback(): void;
  74308. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74309. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74310. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74311. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74312. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74313. }
  74314. interface ImageBitmap {
  74315. readonly width: number;
  74316. readonly height: number;
  74317. close(): void;
  74318. }
  74319. interface WebGLQuery extends WebGLObject {
  74320. }
  74321. declare var WebGLQuery: {
  74322. prototype: WebGLQuery;
  74323. new(): WebGLQuery;
  74324. };
  74325. interface WebGLSampler extends WebGLObject {
  74326. }
  74327. declare var WebGLSampler: {
  74328. prototype: WebGLSampler;
  74329. new(): WebGLSampler;
  74330. };
  74331. interface WebGLSync extends WebGLObject {
  74332. }
  74333. declare var WebGLSync: {
  74334. prototype: WebGLSync;
  74335. new(): WebGLSync;
  74336. };
  74337. interface WebGLTransformFeedback extends WebGLObject {
  74338. }
  74339. declare var WebGLTransformFeedback: {
  74340. prototype: WebGLTransformFeedback;
  74341. new(): WebGLTransformFeedback;
  74342. };
  74343. interface WebGLVertexArrayObject extends WebGLObject {
  74344. }
  74345. declare var WebGLVertexArrayObject: {
  74346. prototype: WebGLVertexArrayObject;
  74347. new(): WebGLVertexArrayObject;
  74348. };
  74349. // Type definitions for WebVR API
  74350. // Project: https://w3c.github.io/webvr/
  74351. // Definitions by: six a <https://github.com/lostfictions>
  74352. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74353. interface VRDisplay extends EventTarget {
  74354. /**
  74355. * Dictionary of capabilities describing the VRDisplay.
  74356. */
  74357. readonly capabilities: VRDisplayCapabilities;
  74358. /**
  74359. * z-depth defining the far plane of the eye view frustum
  74360. * enables mapping of values in the render target depth
  74361. * attachment to scene coordinates. Initially set to 10000.0.
  74362. */
  74363. depthFar: number;
  74364. /**
  74365. * z-depth defining the near plane of the eye view frustum
  74366. * enables mapping of values in the render target depth
  74367. * attachment to scene coordinates. Initially set to 0.01.
  74368. */
  74369. depthNear: number;
  74370. /**
  74371. * An identifier for this distinct VRDisplay. Used as an
  74372. * association point in the Gamepad API.
  74373. */
  74374. readonly displayId: number;
  74375. /**
  74376. * A display name, a user-readable name identifying it.
  74377. */
  74378. readonly displayName: string;
  74379. readonly isConnected: boolean;
  74380. readonly isPresenting: boolean;
  74381. /**
  74382. * If this VRDisplay supports room-scale experiences, the optional
  74383. * stage attribute contains details on the room-scale parameters.
  74384. */
  74385. readonly stageParameters: VRStageParameters | null;
  74386. /**
  74387. * Passing the value returned by `requestAnimationFrame` to
  74388. * `cancelAnimationFrame` will unregister the callback.
  74389. * @param handle Define the hanle of the request to cancel
  74390. */
  74391. cancelAnimationFrame(handle: number): void;
  74392. /**
  74393. * Stops presenting to the VRDisplay.
  74394. * @returns a promise to know when it stopped
  74395. */
  74396. exitPresent(): Promise<void>;
  74397. /**
  74398. * Return the current VREyeParameters for the given eye.
  74399. * @param whichEye Define the eye we want the parameter for
  74400. * @returns the eye parameters
  74401. */
  74402. getEyeParameters(whichEye: string): VREyeParameters;
  74403. /**
  74404. * Populates the passed VRFrameData with the information required to render
  74405. * the current frame.
  74406. * @param frameData Define the data structure to populate
  74407. * @returns true if ok otherwise false
  74408. */
  74409. getFrameData(frameData: VRFrameData): boolean;
  74410. /**
  74411. * Get the layers currently being presented.
  74412. * @returns the list of VR layers
  74413. */
  74414. getLayers(): VRLayer[];
  74415. /**
  74416. * Return a VRPose containing the future predicted pose of the VRDisplay
  74417. * when the current frame will be presented. The value returned will not
  74418. * change until JavaScript has returned control to the browser.
  74419. *
  74420. * The VRPose will contain the position, orientation, velocity,
  74421. * and acceleration of each of these properties.
  74422. * @returns the pose object
  74423. */
  74424. getPose(): VRPose;
  74425. /**
  74426. * Return the current instantaneous pose of the VRDisplay, with no
  74427. * prediction applied.
  74428. * @returns the current instantaneous pose
  74429. */
  74430. getImmediatePose(): VRPose;
  74431. /**
  74432. * The callback passed to `requestAnimationFrame` will be called
  74433. * any time a new frame should be rendered. When the VRDisplay is
  74434. * presenting the callback will be called at the native refresh
  74435. * rate of the HMD. When not presenting this function acts
  74436. * identically to how window.requestAnimationFrame acts. Content should
  74437. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74438. * asynchronously from other displays and at differing refresh rates.
  74439. * @param callback Define the eaction to run next frame
  74440. * @returns the request handle it
  74441. */
  74442. requestAnimationFrame(callback: FrameRequestCallback): number;
  74443. /**
  74444. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74445. * Repeat calls while already presenting will update the VRLayers being displayed.
  74446. * @param layers Define the list of layer to present
  74447. * @returns a promise to know when the request has been fulfilled
  74448. */
  74449. requestPresent(layers: VRLayer[]): Promise<void>;
  74450. /**
  74451. * Reset the pose for this display, treating its current position and
  74452. * orientation as the "origin/zero" values. VRPose.position,
  74453. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74454. * updated when calling resetPose(). This should be called in only
  74455. * sitting-space experiences.
  74456. */
  74457. resetPose(): void;
  74458. /**
  74459. * The VRLayer provided to the VRDisplay will be captured and presented
  74460. * in the HMD. Calling this function has the same effect on the source
  74461. * canvas as any other operation that uses its source image, and canvases
  74462. * created without preserveDrawingBuffer set to true will be cleared.
  74463. * @param pose Define the pose to submit
  74464. */
  74465. submitFrame(pose?: VRPose): void;
  74466. }
  74467. declare var VRDisplay: {
  74468. prototype: VRDisplay;
  74469. new(): VRDisplay;
  74470. };
  74471. interface VRLayer {
  74472. leftBounds?: number[] | Float32Array | null;
  74473. rightBounds?: number[] | Float32Array | null;
  74474. source?: HTMLCanvasElement | null;
  74475. }
  74476. interface VRDisplayCapabilities {
  74477. readonly canPresent: boolean;
  74478. readonly hasExternalDisplay: boolean;
  74479. readonly hasOrientation: boolean;
  74480. readonly hasPosition: boolean;
  74481. readonly maxLayers: number;
  74482. }
  74483. interface VREyeParameters {
  74484. /** @deprecated */
  74485. readonly fieldOfView: VRFieldOfView;
  74486. readonly offset: Float32Array;
  74487. readonly renderHeight: number;
  74488. readonly renderWidth: number;
  74489. }
  74490. interface VRFieldOfView {
  74491. readonly downDegrees: number;
  74492. readonly leftDegrees: number;
  74493. readonly rightDegrees: number;
  74494. readonly upDegrees: number;
  74495. }
  74496. interface VRFrameData {
  74497. readonly leftProjectionMatrix: Float32Array;
  74498. readonly leftViewMatrix: Float32Array;
  74499. readonly pose: VRPose;
  74500. readonly rightProjectionMatrix: Float32Array;
  74501. readonly rightViewMatrix: Float32Array;
  74502. readonly timestamp: number;
  74503. }
  74504. interface VRPose {
  74505. readonly angularAcceleration: Float32Array | null;
  74506. readonly angularVelocity: Float32Array | null;
  74507. readonly linearAcceleration: Float32Array | null;
  74508. readonly linearVelocity: Float32Array | null;
  74509. readonly orientation: Float32Array | null;
  74510. readonly position: Float32Array | null;
  74511. readonly timestamp: number;
  74512. }
  74513. interface VRStageParameters {
  74514. sittingToStandingTransform?: Float32Array;
  74515. sizeX?: number;
  74516. sizeY?: number;
  74517. }
  74518. interface Navigator {
  74519. getVRDisplays(): Promise<VRDisplay[]>;
  74520. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74521. }
  74522. interface Window {
  74523. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74524. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74525. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74526. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74527. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74528. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74529. }
  74530. interface Gamepad {
  74531. readonly displayId: number;
  74532. }
  74533. type XRSessionMode =
  74534. | "inline"
  74535. | "immersive-vr"
  74536. | "immersive-ar";
  74537. type XRReferenceSpaceType =
  74538. | "viewer"
  74539. | "local"
  74540. | "local-floor"
  74541. | "bounded-floor"
  74542. | "unbounded";
  74543. type XREnvironmentBlendMode =
  74544. | "opaque"
  74545. | "additive"
  74546. | "alpha-blend";
  74547. type XRVisibilityState =
  74548. | "visible"
  74549. | "visible-blurred"
  74550. | "hidden";
  74551. type XRHandedness =
  74552. | "none"
  74553. | "left"
  74554. | "right";
  74555. type XRTargetRayMode =
  74556. | "gaze"
  74557. | "tracked-pointer"
  74558. | "screen";
  74559. type XREye =
  74560. | "none"
  74561. | "left"
  74562. | "right";
  74563. type XREventType =
  74564. | "devicechange"
  74565. | "visibilitychange"
  74566. | "end"
  74567. | "inputsourceschange"
  74568. | "select"
  74569. | "selectstart"
  74570. | "selectend"
  74571. | "squeeze"
  74572. | "squeezestart"
  74573. | "squeezeend"
  74574. | "reset";
  74575. interface XRSpace extends EventTarget {
  74576. }
  74577. interface XRRenderState {
  74578. depthNear?: number;
  74579. depthFar?: number;
  74580. inlineVerticalFieldOfView?: number;
  74581. baseLayer?: XRWebGLLayer;
  74582. }
  74583. interface XRInputSource {
  74584. handedness: XRHandedness;
  74585. targetRayMode: XRTargetRayMode;
  74586. targetRaySpace: XRSpace;
  74587. gripSpace: XRSpace | undefined;
  74588. gamepad: Gamepad | undefined;
  74589. profiles: Array<string>;
  74590. }
  74591. interface XRSessionInit {
  74592. optionalFeatures?: string[];
  74593. requiredFeatures?: string[];
  74594. }
  74595. interface XRSession {
  74596. addEventListener: Function;
  74597. removeEventListener: Function;
  74598. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74599. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74600. requestAnimationFrame: Function;
  74601. end(): Promise<void>;
  74602. renderState: XRRenderState;
  74603. inputSources: Array<XRInputSource>;
  74604. // hit test
  74605. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74606. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74607. // legacy AR hit test
  74608. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74609. // legacy plane detection
  74610. updateWorldTrackingState(options: {
  74611. planeDetectionState?: { enabled: boolean; }
  74612. }): void;
  74613. }
  74614. interface XRReferenceSpace extends XRSpace {
  74615. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74616. onreset: any;
  74617. }
  74618. type XRPlaneSet = Set<XRPlane>;
  74619. type XRAnchorSet = Set<XRAnchor>;
  74620. interface XRFrame {
  74621. session: XRSession;
  74622. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74623. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74624. // AR
  74625. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74626. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74627. // Anchors
  74628. trackedAnchors?: XRAnchorSet;
  74629. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74630. // Planes
  74631. worldInformation: {
  74632. detectedPlanes?: XRPlaneSet;
  74633. };
  74634. }
  74635. interface XRViewerPose extends XRPose {
  74636. views: Array<XRView>;
  74637. }
  74638. interface XRPose {
  74639. transform: XRRigidTransform;
  74640. emulatedPosition: boolean;
  74641. }
  74642. interface XRWebGLLayerOptions {
  74643. antialias?: boolean;
  74644. depth?: boolean;
  74645. stencil?: boolean;
  74646. alpha?: boolean;
  74647. multiview?: boolean;
  74648. framebufferScaleFactor?: number;
  74649. }
  74650. declare var XRWebGLLayer: {
  74651. prototype: XRWebGLLayer;
  74652. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74653. };
  74654. interface XRWebGLLayer {
  74655. framebuffer: WebGLFramebuffer;
  74656. framebufferWidth: number;
  74657. framebufferHeight: number;
  74658. getViewport: Function;
  74659. }
  74660. declare class XRRigidTransform {
  74661. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74662. position: DOMPointReadOnly;
  74663. orientation: DOMPointReadOnly;
  74664. matrix: Float32Array;
  74665. inverse: XRRigidTransform;
  74666. }
  74667. interface XRView {
  74668. eye: XREye;
  74669. projectionMatrix: Float32Array;
  74670. transform: XRRigidTransform;
  74671. }
  74672. interface XRInputSourceChangeEvent {
  74673. session: XRSession;
  74674. removed: Array<XRInputSource>;
  74675. added: Array<XRInputSource>;
  74676. }
  74677. interface XRInputSourceEvent extends Event {
  74678. readonly frame: XRFrame;
  74679. readonly inputSource: XRInputSource;
  74680. }
  74681. // Experimental(er) features
  74682. declare class XRRay {
  74683. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74684. origin: DOMPointReadOnly;
  74685. direction: DOMPointReadOnly;
  74686. matrix: Float32Array;
  74687. }
  74688. declare enum XRHitTestTrackableType {
  74689. "point",
  74690. "plane"
  74691. }
  74692. interface XRHitResult {
  74693. hitMatrix: Float32Array;
  74694. }
  74695. interface XRTransientInputHitTestResult {
  74696. readonly inputSource: XRInputSource;
  74697. readonly results: Array<XRHitTestResult>;
  74698. }
  74699. interface XRHitTestResult {
  74700. getPose(baseSpace: XRSpace): XRPose | undefined;
  74701. // When anchor system is enabled
  74702. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74703. }
  74704. interface XRHitTestSource {
  74705. cancel(): void;
  74706. }
  74707. interface XRTransientInputHitTestSource {
  74708. cancel(): void;
  74709. }
  74710. interface XRHitTestOptionsInit {
  74711. space: XRSpace;
  74712. entityTypes?: Array<XRHitTestTrackableType>;
  74713. offsetRay?: XRRay;
  74714. }
  74715. interface XRTransientInputHitTestOptionsInit {
  74716. profile: string;
  74717. entityTypes?: Array<XRHitTestTrackableType>;
  74718. offsetRay?: XRRay;
  74719. }
  74720. interface XRAnchor {
  74721. anchorSpace: XRSpace;
  74722. delete(): void;
  74723. }
  74724. interface XRPlane {
  74725. orientation: "Horizontal" | "Vertical";
  74726. planeSpace: XRSpace;
  74727. polygon: Array<DOMPointReadOnly>;
  74728. lastChangedTime: number;
  74729. }
  74730. /**
  74731. * @ignore
  74732. */
  74733. declare module BABYLON.GLTF2.Exporter {
  74734. }
  74735. /**
  74736. * @ignore
  74737. */
  74738. declare module BABYLON.GLTF1 {
  74739. }
  74740. declare module BABYLON.GUI {
  74741. /**
  74742. * Class used to specific a value and its associated unit
  74743. */
  74744. export class ValueAndUnit {
  74745. /** defines the unit to store */
  74746. unit: number;
  74747. /** defines a boolean indicating if the value can be negative */
  74748. negativeValueAllowed: boolean;
  74749. private _value;
  74750. private _originalUnit;
  74751. /**
  74752. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74753. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74754. */
  74755. ignoreAdaptiveScaling: boolean;
  74756. /**
  74757. * Creates a new ValueAndUnit
  74758. * @param value defines the value to store
  74759. * @param unit defines the unit to store
  74760. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74761. */
  74762. constructor(value: number,
  74763. /** defines the unit to store */
  74764. unit?: number,
  74765. /** defines a boolean indicating if the value can be negative */
  74766. negativeValueAllowed?: boolean);
  74767. /** Gets a boolean indicating if the value is a percentage */
  74768. get isPercentage(): boolean;
  74769. /** Gets a boolean indicating if the value is store as pixel */
  74770. get isPixel(): boolean;
  74771. /** Gets direct internal value */
  74772. get internalValue(): number;
  74773. /**
  74774. * Gets value as pixel
  74775. * @param host defines the root host
  74776. * @param refValue defines the reference value for percentages
  74777. * @returns the value as pixel
  74778. */
  74779. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74780. /**
  74781. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74782. * @param value defines the value to store
  74783. * @param unit defines the unit to store
  74784. * @returns the current ValueAndUnit
  74785. */
  74786. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74787. /**
  74788. * Gets the value accordingly to its unit
  74789. * @param host defines the root host
  74790. * @returns the value
  74791. */
  74792. getValue(host: AdvancedDynamicTexture): number;
  74793. /**
  74794. * Gets a string representation of the value
  74795. * @param host defines the root host
  74796. * @param decimals defines an optional number of decimals to display
  74797. * @returns a string
  74798. */
  74799. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74800. /**
  74801. * Store a value parsed from a string
  74802. * @param source defines the source string
  74803. * @returns true if the value was successfully parsed
  74804. */
  74805. fromString(source: string | number): boolean;
  74806. private static _Regex;
  74807. private static _UNITMODE_PERCENTAGE;
  74808. private static _UNITMODE_PIXEL;
  74809. /** UNITMODE_PERCENTAGE */
  74810. static get UNITMODE_PERCENTAGE(): number;
  74811. /** UNITMODE_PIXEL */
  74812. static get UNITMODE_PIXEL(): number;
  74813. }
  74814. }
  74815. declare module BABYLON.GUI {
  74816. /**
  74817. * Define a style used by control to automatically setup properties based on a template.
  74818. * Only support font related properties so far
  74819. */
  74820. export class Style implements BABYLON.IDisposable {
  74821. private _fontFamily;
  74822. private _fontStyle;
  74823. private _fontWeight;
  74824. /** @hidden */
  74825. _host: AdvancedDynamicTexture;
  74826. /** @hidden */
  74827. _fontSize: ValueAndUnit;
  74828. /**
  74829. * BABYLON.Observable raised when the style values are changed
  74830. */
  74831. onChangedObservable: BABYLON.Observable<Style>;
  74832. /**
  74833. * Creates a new style object
  74834. * @param host defines the AdvancedDynamicTexture which hosts this style
  74835. */
  74836. constructor(host: AdvancedDynamicTexture);
  74837. /**
  74838. * Gets or sets the font size
  74839. */
  74840. get fontSize(): string | number;
  74841. set fontSize(value: string | number);
  74842. /**
  74843. * Gets or sets the font family
  74844. */
  74845. get fontFamily(): string;
  74846. set fontFamily(value: string);
  74847. /**
  74848. * Gets or sets the font style
  74849. */
  74850. get fontStyle(): string;
  74851. set fontStyle(value: string);
  74852. /** Gets or sets font weight */
  74853. get fontWeight(): string;
  74854. set fontWeight(value: string);
  74855. /** Dispose all associated resources */
  74856. dispose(): void;
  74857. }
  74858. }
  74859. declare module BABYLON.GUI {
  74860. /**
  74861. * Class used to transport BABYLON.Vector2 information for pointer events
  74862. */
  74863. export class Vector2WithInfo extends BABYLON.Vector2 {
  74864. /** defines the current mouse button index */
  74865. buttonIndex: number;
  74866. /**
  74867. * Creates a new Vector2WithInfo
  74868. * @param source defines the vector2 data to transport
  74869. * @param buttonIndex defines the current mouse button index
  74870. */
  74871. constructor(source: BABYLON.Vector2,
  74872. /** defines the current mouse button index */
  74873. buttonIndex?: number);
  74874. }
  74875. /** Class used to provide 2D matrix features */
  74876. export class Matrix2D {
  74877. /** Gets the internal array of 6 floats used to store matrix data */
  74878. m: Float32Array;
  74879. /**
  74880. * Creates a new matrix
  74881. * @param m00 defines value for (0, 0)
  74882. * @param m01 defines value for (0, 1)
  74883. * @param m10 defines value for (1, 0)
  74884. * @param m11 defines value for (1, 1)
  74885. * @param m20 defines value for (2, 0)
  74886. * @param m21 defines value for (2, 1)
  74887. */
  74888. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74889. /**
  74890. * Fills the matrix from direct values
  74891. * @param m00 defines value for (0, 0)
  74892. * @param m01 defines value for (0, 1)
  74893. * @param m10 defines value for (1, 0)
  74894. * @param m11 defines value for (1, 1)
  74895. * @param m20 defines value for (2, 0)
  74896. * @param m21 defines value for (2, 1)
  74897. * @returns the current modified matrix
  74898. */
  74899. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74900. /**
  74901. * Gets matrix determinant
  74902. * @returns the determinant
  74903. */
  74904. determinant(): number;
  74905. /**
  74906. * Inverses the matrix and stores it in a target matrix
  74907. * @param result defines the target matrix
  74908. * @returns the current matrix
  74909. */
  74910. invertToRef(result: Matrix2D): Matrix2D;
  74911. /**
  74912. * Multiplies the current matrix with another one
  74913. * @param other defines the second operand
  74914. * @param result defines the target matrix
  74915. * @returns the current matrix
  74916. */
  74917. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74918. /**
  74919. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74920. * @param x defines the x coordinate to transform
  74921. * @param y defines the x coordinate to transform
  74922. * @param result defines the target vector2
  74923. * @returns the current matrix
  74924. */
  74925. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74926. /**
  74927. * Creates an identity matrix
  74928. * @returns a new matrix
  74929. */
  74930. static Identity(): Matrix2D;
  74931. /**
  74932. * Creates a translation matrix and stores it in a target matrix
  74933. * @param x defines the x coordinate of the translation
  74934. * @param y defines the y coordinate of the translation
  74935. * @param result defines the target matrix
  74936. */
  74937. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74938. /**
  74939. * Creates a scaling matrix and stores it in a target matrix
  74940. * @param x defines the x coordinate of the scaling
  74941. * @param y defines the y coordinate of the scaling
  74942. * @param result defines the target matrix
  74943. */
  74944. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74945. /**
  74946. * Creates a rotation matrix and stores it in a target matrix
  74947. * @param angle defines the rotation angle
  74948. * @param result defines the target matrix
  74949. */
  74950. static RotationToRef(angle: number, result: Matrix2D): void;
  74951. private static _TempPreTranslationMatrix;
  74952. private static _TempPostTranslationMatrix;
  74953. private static _TempRotationMatrix;
  74954. private static _TempScalingMatrix;
  74955. private static _TempCompose0;
  74956. private static _TempCompose1;
  74957. private static _TempCompose2;
  74958. /**
  74959. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74960. * @param tx defines the x coordinate of the translation
  74961. * @param ty defines the y coordinate of the translation
  74962. * @param angle defines the rotation angle
  74963. * @param scaleX defines the x coordinate of the scaling
  74964. * @param scaleY defines the y coordinate of the scaling
  74965. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74966. * @param result defines the target matrix
  74967. */
  74968. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74969. }
  74970. }
  74971. declare module BABYLON.GUI {
  74972. /**
  74973. * Class used to store 2D control sizes
  74974. */
  74975. export class Measure {
  74976. /** defines left coordinate */
  74977. left: number;
  74978. /** defines top coordinate */
  74979. top: number;
  74980. /** defines width dimension */
  74981. width: number;
  74982. /** defines height dimension */
  74983. height: number;
  74984. /**
  74985. * Creates a new measure
  74986. * @param left defines left coordinate
  74987. * @param top defines top coordinate
  74988. * @param width defines width dimension
  74989. * @param height defines height dimension
  74990. */
  74991. constructor(
  74992. /** defines left coordinate */
  74993. left: number,
  74994. /** defines top coordinate */
  74995. top: number,
  74996. /** defines width dimension */
  74997. width: number,
  74998. /** defines height dimension */
  74999. height: number);
  75000. /**
  75001. * Copy from another measure
  75002. * @param other defines the other measure to copy from
  75003. */
  75004. copyFrom(other: Measure): void;
  75005. /**
  75006. * Copy from a group of 4 floats
  75007. * @param left defines left coordinate
  75008. * @param top defines top coordinate
  75009. * @param width defines width dimension
  75010. * @param height defines height dimension
  75011. */
  75012. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75013. /**
  75014. * Computes the axis aligned bounding box measure for two given measures
  75015. * @param a Input measure
  75016. * @param b Input measure
  75017. * @param result the resulting bounding measure
  75018. */
  75019. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75020. /**
  75021. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75022. * @param transform the matrix to transform the measure before computing the AABB
  75023. * @param result the resulting AABB
  75024. */
  75025. transformToRef(transform: Matrix2D, result: Measure): void;
  75026. /**
  75027. * Check equality between this measure and another one
  75028. * @param other defines the other measures
  75029. * @returns true if both measures are equals
  75030. */
  75031. isEqualsTo(other: Measure): boolean;
  75032. /**
  75033. * Creates an empty measure
  75034. * @returns a new measure
  75035. */
  75036. static Empty(): Measure;
  75037. }
  75038. }
  75039. declare module BABYLON.GUI {
  75040. /**
  75041. * Interface used to define a control that can receive focus
  75042. */
  75043. export interface IFocusableControl {
  75044. /**
  75045. * Function called when the control receives the focus
  75046. */
  75047. onFocus(): void;
  75048. /**
  75049. * Function called when the control loses the focus
  75050. */
  75051. onBlur(): void;
  75052. /**
  75053. * Function called to let the control handle keyboard events
  75054. * @param evt defines the current keyboard event
  75055. */
  75056. processKeyboard(evt: KeyboardEvent): void;
  75057. /**
  75058. * Function called to get the list of controls that should not steal the focus from this control
  75059. * @returns an array of controls
  75060. */
  75061. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75062. }
  75063. /**
  75064. * Class used to create texture to support 2D GUI elements
  75065. * @see https://doc.babylonjs.com/how_to/gui
  75066. */
  75067. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75068. private _isDirty;
  75069. private _renderObserver;
  75070. private _resizeObserver;
  75071. private _preKeyboardObserver;
  75072. private _pointerMoveObserver;
  75073. private _pointerObserver;
  75074. private _canvasPointerOutObserver;
  75075. private _background;
  75076. /** @hidden */
  75077. _rootContainer: Container;
  75078. /** @hidden */
  75079. _lastPickedControl: Control;
  75080. /** @hidden */
  75081. _lastControlOver: {
  75082. [pointerId: number]: Control;
  75083. };
  75084. /** @hidden */
  75085. _lastControlDown: {
  75086. [pointerId: number]: Control;
  75087. };
  75088. /** @hidden */
  75089. _capturingControl: {
  75090. [pointerId: number]: Control;
  75091. };
  75092. /** @hidden */
  75093. _shouldBlockPointer: boolean;
  75094. /** @hidden */
  75095. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75096. /** @hidden */
  75097. _linkedControls: Control[];
  75098. private _isFullscreen;
  75099. private _fullscreenViewport;
  75100. private _idealWidth;
  75101. private _idealHeight;
  75102. private _useSmallestIdeal;
  75103. private _renderAtIdealSize;
  75104. private _focusedControl;
  75105. private _blockNextFocusCheck;
  75106. private _renderScale;
  75107. private _rootElement;
  75108. private _cursorChanged;
  75109. private _defaultMousePointerId;
  75110. /** @hidden */
  75111. _numLayoutCalls: number;
  75112. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75113. get numLayoutCalls(): number;
  75114. /** @hidden */
  75115. _numRenderCalls: number;
  75116. /** Gets the number of render calls made the last time the ADT has been rendered */
  75117. get numRenderCalls(): number;
  75118. /**
  75119. * Define type to string to ensure compatibility across browsers
  75120. * Safari doesn't support DataTransfer constructor
  75121. */
  75122. private _clipboardData;
  75123. /**
  75124. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75125. */
  75126. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75127. /**
  75128. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75129. */
  75130. onControlPickedObservable: BABYLON.Observable<Control>;
  75131. /**
  75132. * BABYLON.Observable event triggered before layout is evaluated
  75133. */
  75134. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75135. /**
  75136. * BABYLON.Observable event triggered after the layout was evaluated
  75137. */
  75138. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75139. /**
  75140. * BABYLON.Observable event triggered before the texture is rendered
  75141. */
  75142. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75143. /**
  75144. * BABYLON.Observable event triggered after the texture was rendered
  75145. */
  75146. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75147. /**
  75148. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75149. */
  75150. premulAlpha: boolean;
  75151. /**
  75152. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75153. * Useful when you want more antialiasing
  75154. */
  75155. get renderScale(): number;
  75156. set renderScale(value: number);
  75157. /** Gets or sets the background color */
  75158. get background(): string;
  75159. set background(value: string);
  75160. /**
  75161. * Gets or sets the ideal width used to design controls.
  75162. * The GUI will then rescale everything accordingly
  75163. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75164. */
  75165. get idealWidth(): number;
  75166. set idealWidth(value: number);
  75167. /**
  75168. * Gets or sets the ideal height used to design controls.
  75169. * The GUI will then rescale everything accordingly
  75170. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75171. */
  75172. get idealHeight(): number;
  75173. set idealHeight(value: number);
  75174. /**
  75175. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75176. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75177. */
  75178. get useSmallestIdeal(): boolean;
  75179. set useSmallestIdeal(value: boolean);
  75180. /**
  75181. * Gets or sets a boolean indicating if adaptive scaling must be used
  75182. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75183. */
  75184. get renderAtIdealSize(): boolean;
  75185. set renderAtIdealSize(value: boolean);
  75186. /**
  75187. * Gets the ratio used when in "ideal mode"
  75188. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75189. * */
  75190. get idealRatio(): number;
  75191. /**
  75192. * Gets the underlying layer used to render the texture when in fullscreen mode
  75193. */
  75194. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75195. /**
  75196. * Gets the root container control
  75197. */
  75198. get rootContainer(): Container;
  75199. /**
  75200. * Returns an array containing the root container.
  75201. * This is mostly used to let the Inspector introspects the ADT
  75202. * @returns an array containing the rootContainer
  75203. */
  75204. getChildren(): Array<Container>;
  75205. /**
  75206. * Will return all controls that are inside this texture
  75207. * @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
  75208. * @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
  75209. * @return all child controls
  75210. */
  75211. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75212. /**
  75213. * Gets or sets the current focused control
  75214. */
  75215. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75216. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75217. /**
  75218. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75219. */
  75220. get isForeground(): boolean;
  75221. set isForeground(value: boolean);
  75222. /**
  75223. * Gets or set information about clipboardData
  75224. */
  75225. get clipboardData(): string;
  75226. set clipboardData(value: string);
  75227. /**
  75228. * Creates a new AdvancedDynamicTexture
  75229. * @param name defines the name of the texture
  75230. * @param width defines the width of the texture
  75231. * @param height defines the height of the texture
  75232. * @param scene defines the hosting scene
  75233. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75234. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75235. */
  75236. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75237. /**
  75238. * Get the current class name of the texture useful for serialization or dynamic coding.
  75239. * @returns "AdvancedDynamicTexture"
  75240. */
  75241. getClassName(): string;
  75242. /**
  75243. * Function used to execute a function on all controls
  75244. * @param func defines the function to execute
  75245. * @param container defines the container where controls belong. If null the root container will be used
  75246. */
  75247. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75248. private _useInvalidateRectOptimization;
  75249. /**
  75250. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75251. */
  75252. get useInvalidateRectOptimization(): boolean;
  75253. set useInvalidateRectOptimization(value: boolean);
  75254. private _invalidatedRectangle;
  75255. /**
  75256. * Invalidates a rectangle area on the gui texture
  75257. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75258. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75259. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75260. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75261. */
  75262. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75263. /**
  75264. * Marks the texture as dirty forcing a complete update
  75265. */
  75266. markAsDirty(): void;
  75267. /**
  75268. * Helper function used to create a new style
  75269. * @returns a new style
  75270. * @see https://doc.babylonjs.com/how_to/gui#styles
  75271. */
  75272. createStyle(): Style;
  75273. /**
  75274. * Adds a new control to the root container
  75275. * @param control defines the control to add
  75276. * @returns the current texture
  75277. */
  75278. addControl(control: Control): AdvancedDynamicTexture;
  75279. /**
  75280. * Removes a control from the root container
  75281. * @param control defines the control to remove
  75282. * @returns the current texture
  75283. */
  75284. removeControl(control: Control): AdvancedDynamicTexture;
  75285. /**
  75286. * Release all resources
  75287. */
  75288. dispose(): void;
  75289. private _onResize;
  75290. /** @hidden */
  75291. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75292. /**
  75293. * Get screen coordinates for a vector3
  75294. * @param position defines the position to project
  75295. * @param worldMatrix defines the world matrix to use
  75296. * @returns the projected position
  75297. */
  75298. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75299. private _checkUpdate;
  75300. private _clearMeasure;
  75301. private _render;
  75302. /** @hidden */
  75303. _changeCursor(cursor: string): void;
  75304. /** @hidden */
  75305. _registerLastControlDown(control: Control, pointerId: number): void;
  75306. private _doPicking;
  75307. /** @hidden */
  75308. _cleanControlAfterRemovalFromList(list: {
  75309. [pointerId: number]: Control;
  75310. }, control: Control): void;
  75311. /** @hidden */
  75312. _cleanControlAfterRemoval(control: Control): void;
  75313. /** Attach to all scene events required to support pointer events */
  75314. attach(): void;
  75315. /** @hidden */
  75316. private onClipboardCopy;
  75317. /** @hidden */
  75318. private onClipboardCut;
  75319. /** @hidden */
  75320. private onClipboardPaste;
  75321. /**
  75322. * Register the clipboard Events onto the canvas
  75323. */
  75324. registerClipboardEvents(): void;
  75325. /**
  75326. * Unregister the clipboard Events from the canvas
  75327. */
  75328. unRegisterClipboardEvents(): void;
  75329. /**
  75330. * Connect the texture to a hosting mesh to enable interactions
  75331. * @param mesh defines the mesh to attach to
  75332. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75333. */
  75334. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75335. /**
  75336. * Move the focus to a specific control
  75337. * @param control defines the control which will receive the focus
  75338. */
  75339. moveFocusToControl(control: IFocusableControl): void;
  75340. private _manageFocus;
  75341. private _attachToOnPointerOut;
  75342. /**
  75343. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75344. * @param mesh defines the mesh which will receive the texture
  75345. * @param width defines the texture width (1024 by default)
  75346. * @param height defines the texture height (1024 by default)
  75347. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75348. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75349. * @returns a new AdvancedDynamicTexture
  75350. */
  75351. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75352. /**
  75353. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75354. * In this mode the texture will rely on a layer for its rendering.
  75355. * This allows it to be treated like any other layer.
  75356. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75357. * LayerMask is set through advancedTexture.layer.layerMask
  75358. * @param name defines name for the texture
  75359. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75360. * @param scene defines the hsoting scene
  75361. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75362. * @returns a new AdvancedDynamicTexture
  75363. */
  75364. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75365. }
  75366. }
  75367. declare module BABYLON.GUI {
  75368. /**
  75369. * Root class used for all 2D controls
  75370. * @see https://doc.babylonjs.com/how_to/gui#controls
  75371. */
  75372. export class Control {
  75373. /** defines the name of the control */
  75374. name?: string | undefined;
  75375. /**
  75376. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75377. */
  75378. static AllowAlphaInheritance: boolean;
  75379. private _alpha;
  75380. private _alphaSet;
  75381. private _zIndex;
  75382. /** @hidden */
  75383. _host: AdvancedDynamicTexture;
  75384. /** Gets or sets the control parent */
  75385. parent: BABYLON.Nullable<Container>;
  75386. /** @hidden */
  75387. _currentMeasure: Measure;
  75388. private _fontFamily;
  75389. private _fontStyle;
  75390. private _fontWeight;
  75391. private _fontSize;
  75392. private _font;
  75393. /** @hidden */
  75394. _width: ValueAndUnit;
  75395. /** @hidden */
  75396. _height: ValueAndUnit;
  75397. /** @hidden */
  75398. protected _fontOffset: {
  75399. ascent: number;
  75400. height: number;
  75401. descent: number;
  75402. };
  75403. private _color;
  75404. private _style;
  75405. private _styleObserver;
  75406. /** @hidden */
  75407. protected _horizontalAlignment: number;
  75408. /** @hidden */
  75409. protected _verticalAlignment: number;
  75410. /** @hidden */
  75411. protected _isDirty: boolean;
  75412. /** @hidden */
  75413. protected _wasDirty: boolean;
  75414. /** @hidden */
  75415. _tempParentMeasure: Measure;
  75416. /** @hidden */
  75417. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75418. /** @hidden */
  75419. protected _cachedParentMeasure: Measure;
  75420. private _paddingLeft;
  75421. private _paddingRight;
  75422. private _paddingTop;
  75423. private _paddingBottom;
  75424. /** @hidden */
  75425. _left: ValueAndUnit;
  75426. /** @hidden */
  75427. _top: ValueAndUnit;
  75428. private _scaleX;
  75429. private _scaleY;
  75430. private _rotation;
  75431. private _transformCenterX;
  75432. private _transformCenterY;
  75433. /** @hidden */
  75434. _transformMatrix: Matrix2D;
  75435. /** @hidden */
  75436. protected _invertTransformMatrix: Matrix2D;
  75437. /** @hidden */
  75438. protected _transformedPosition: BABYLON.Vector2;
  75439. private _isMatrixDirty;
  75440. private _cachedOffsetX;
  75441. private _cachedOffsetY;
  75442. private _isVisible;
  75443. private _isHighlighted;
  75444. /** @hidden */
  75445. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75446. private _fontSet;
  75447. private _dummyVector2;
  75448. private _downCount;
  75449. private _enterCount;
  75450. private _doNotRender;
  75451. private _downPointerIds;
  75452. protected _isEnabled: boolean;
  75453. protected _disabledColor: string;
  75454. protected _disabledColorItem: string;
  75455. /** @hidden */
  75456. protected _rebuildLayout: boolean;
  75457. /** @hidden */
  75458. _customData: any;
  75459. /** @hidden */
  75460. _isClipped: boolean;
  75461. /** @hidden */
  75462. _automaticSize: boolean;
  75463. /** @hidden */
  75464. _tag: any;
  75465. /**
  75466. * 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
  75467. */
  75468. uniqueId: number;
  75469. /**
  75470. * Gets or sets an object used to store user defined information for the node
  75471. */
  75472. metadata: any;
  75473. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75474. isHitTestVisible: boolean;
  75475. /** Gets or sets a boolean indicating if the control can block pointer events */
  75476. isPointerBlocker: boolean;
  75477. /** Gets or sets a boolean indicating if the control can be focusable */
  75478. isFocusInvisible: boolean;
  75479. /**
  75480. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75481. * 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
  75482. */
  75483. clipChildren: boolean;
  75484. /**
  75485. * Gets or sets a boolean indicating that control content must be clipped
  75486. * 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
  75487. */
  75488. clipContent: boolean;
  75489. /**
  75490. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75491. */
  75492. useBitmapCache: boolean;
  75493. private _cacheData;
  75494. private _shadowOffsetX;
  75495. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75496. get shadowOffsetX(): number;
  75497. set shadowOffsetX(value: number);
  75498. private _shadowOffsetY;
  75499. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75500. get shadowOffsetY(): number;
  75501. set shadowOffsetY(value: number);
  75502. private _shadowBlur;
  75503. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75504. get shadowBlur(): number;
  75505. set shadowBlur(value: number);
  75506. private _shadowColor;
  75507. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75508. get shadowColor(): string;
  75509. set shadowColor(value: string);
  75510. /** Gets or sets the cursor to use when the control is hovered */
  75511. hoverCursor: string;
  75512. /** @hidden */
  75513. protected _linkOffsetX: ValueAndUnit;
  75514. /** @hidden */
  75515. protected _linkOffsetY: ValueAndUnit;
  75516. /** Gets the control type name */
  75517. get typeName(): string;
  75518. /**
  75519. * Get the current class name of the control.
  75520. * @returns current class name
  75521. */
  75522. getClassName(): string;
  75523. /**
  75524. * An event triggered when pointer wheel is scrolled
  75525. */
  75526. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75527. /**
  75528. * An event triggered when the pointer move over the control.
  75529. */
  75530. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75531. /**
  75532. * An event triggered when the pointer move out of the control.
  75533. */
  75534. onPointerOutObservable: BABYLON.Observable<Control>;
  75535. /**
  75536. * An event triggered when the pointer taps the control
  75537. */
  75538. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75539. /**
  75540. * An event triggered when pointer up
  75541. */
  75542. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75543. /**
  75544. * An event triggered when a control is clicked on
  75545. */
  75546. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75547. /**
  75548. * An event triggered when pointer enters the control
  75549. */
  75550. onPointerEnterObservable: BABYLON.Observable<Control>;
  75551. /**
  75552. * An event triggered when the control is marked as dirty
  75553. */
  75554. onDirtyObservable: BABYLON.Observable<Control>;
  75555. /**
  75556. * An event triggered before drawing the control
  75557. */
  75558. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75559. /**
  75560. * An event triggered after the control was drawn
  75561. */
  75562. onAfterDrawObservable: BABYLON.Observable<Control>;
  75563. /**
  75564. * An event triggered when the control has been disposed
  75565. */
  75566. onDisposeObservable: BABYLON.Observable<Control>;
  75567. /**
  75568. * Get the hosting AdvancedDynamicTexture
  75569. */
  75570. get host(): AdvancedDynamicTexture;
  75571. /** Gets or set information about font offsets (used to render and align text) */
  75572. get fontOffset(): {
  75573. ascent: number;
  75574. height: number;
  75575. descent: number;
  75576. };
  75577. set fontOffset(offset: {
  75578. ascent: number;
  75579. height: number;
  75580. descent: number;
  75581. });
  75582. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75583. get alpha(): number;
  75584. set alpha(value: number);
  75585. /**
  75586. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75587. */
  75588. get isHighlighted(): boolean;
  75589. set isHighlighted(value: boolean);
  75590. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75591. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75592. */
  75593. get scaleX(): number;
  75594. set scaleX(value: number);
  75595. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75596. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75597. */
  75598. get scaleY(): number;
  75599. set scaleY(value: number);
  75600. /** Gets or sets the rotation angle (0 by default)
  75601. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75602. */
  75603. get rotation(): number;
  75604. set rotation(value: number);
  75605. /** Gets or sets the transformation center on Y axis (0 by default)
  75606. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75607. */
  75608. get transformCenterY(): number;
  75609. set transformCenterY(value: number);
  75610. /** Gets or sets the transformation center on X axis (0 by default)
  75611. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75612. */
  75613. get transformCenterX(): number;
  75614. set transformCenterX(value: number);
  75615. /**
  75616. * Gets or sets the horizontal alignment
  75617. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75618. */
  75619. get horizontalAlignment(): number;
  75620. set horizontalAlignment(value: number);
  75621. /**
  75622. * Gets or sets the vertical alignment
  75623. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75624. */
  75625. get verticalAlignment(): number;
  75626. set verticalAlignment(value: number);
  75627. /**
  75628. * Gets or sets control width
  75629. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75630. */
  75631. get width(): string | number;
  75632. set width(value: string | number);
  75633. /**
  75634. * Gets or sets the control width in pixel
  75635. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75636. */
  75637. get widthInPixels(): number;
  75638. set widthInPixels(value: number);
  75639. /**
  75640. * Gets or sets control height
  75641. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75642. */
  75643. get height(): string | number;
  75644. set height(value: string | number);
  75645. /**
  75646. * Gets or sets control height in pixel
  75647. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75648. */
  75649. get heightInPixels(): number;
  75650. set heightInPixels(value: number);
  75651. /** Gets or set font family */
  75652. get fontFamily(): string;
  75653. set fontFamily(value: string);
  75654. /** Gets or sets font style */
  75655. get fontStyle(): string;
  75656. set fontStyle(value: string);
  75657. /** Gets or sets font weight */
  75658. get fontWeight(): string;
  75659. set fontWeight(value: string);
  75660. /**
  75661. * Gets or sets style
  75662. * @see https://doc.babylonjs.com/how_to/gui#styles
  75663. */
  75664. get style(): BABYLON.Nullable<Style>;
  75665. set style(value: BABYLON.Nullable<Style>);
  75666. /** @hidden */
  75667. get _isFontSizeInPercentage(): boolean;
  75668. /** Gets or sets font size in pixels */
  75669. get fontSizeInPixels(): number;
  75670. set fontSizeInPixels(value: number);
  75671. /** Gets or sets font size */
  75672. get fontSize(): string | number;
  75673. set fontSize(value: string | number);
  75674. /** Gets or sets foreground color */
  75675. get color(): string;
  75676. set color(value: string);
  75677. /** Gets or sets z index which is used to reorder controls on the z axis */
  75678. get zIndex(): number;
  75679. set zIndex(value: number);
  75680. /** Gets or sets a boolean indicating if the control can be rendered */
  75681. get notRenderable(): boolean;
  75682. set notRenderable(value: boolean);
  75683. /** Gets or sets a boolean indicating if the control is visible */
  75684. get isVisible(): boolean;
  75685. set isVisible(value: boolean);
  75686. /** Gets a boolean indicating that the control needs to update its rendering */
  75687. get isDirty(): boolean;
  75688. /**
  75689. * Gets the current linked mesh (or null if none)
  75690. */
  75691. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75692. /**
  75693. * Gets or sets a value indicating the padding to use on the left of the control
  75694. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75695. */
  75696. get paddingLeft(): string | number;
  75697. set paddingLeft(value: string | number);
  75698. /**
  75699. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75700. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75701. */
  75702. get paddingLeftInPixels(): number;
  75703. set paddingLeftInPixels(value: number);
  75704. /**
  75705. * Gets or sets a value indicating the padding to use on the right of the control
  75706. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75707. */
  75708. get paddingRight(): string | number;
  75709. set paddingRight(value: string | number);
  75710. /**
  75711. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75712. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75713. */
  75714. get paddingRightInPixels(): number;
  75715. set paddingRightInPixels(value: number);
  75716. /**
  75717. * Gets or sets a value indicating the padding to use on the top of the control
  75718. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75719. */
  75720. get paddingTop(): string | number;
  75721. set paddingTop(value: string | number);
  75722. /**
  75723. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75724. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75725. */
  75726. get paddingTopInPixels(): number;
  75727. set paddingTopInPixels(value: number);
  75728. /**
  75729. * Gets or sets a value indicating the padding to use on the bottom of the control
  75730. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75731. */
  75732. get paddingBottom(): string | number;
  75733. set paddingBottom(value: string | number);
  75734. /**
  75735. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75736. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75737. */
  75738. get paddingBottomInPixels(): number;
  75739. set paddingBottomInPixels(value: number);
  75740. /**
  75741. * Gets or sets a value indicating the left coordinate of the control
  75742. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75743. */
  75744. get left(): string | number;
  75745. set left(value: string | number);
  75746. /**
  75747. * Gets or sets a value indicating the left coordinate in pixels of the control
  75748. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75749. */
  75750. get leftInPixels(): number;
  75751. set leftInPixels(value: number);
  75752. /**
  75753. * Gets or sets a value indicating the top coordinate of the control
  75754. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75755. */
  75756. get top(): string | number;
  75757. set top(value: string | number);
  75758. /**
  75759. * Gets or sets a value indicating the top coordinate in pixels of the control
  75760. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75761. */
  75762. get topInPixels(): number;
  75763. set topInPixels(value: number);
  75764. /**
  75765. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75766. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75767. */
  75768. get linkOffsetX(): string | number;
  75769. set linkOffsetX(value: string | number);
  75770. /**
  75771. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75772. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75773. */
  75774. get linkOffsetXInPixels(): number;
  75775. set linkOffsetXInPixels(value: number);
  75776. /**
  75777. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75778. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75779. */
  75780. get linkOffsetY(): string | number;
  75781. set linkOffsetY(value: string | number);
  75782. /**
  75783. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75784. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75785. */
  75786. get linkOffsetYInPixels(): number;
  75787. set linkOffsetYInPixels(value: number);
  75788. /** Gets the center coordinate on X axis */
  75789. get centerX(): number;
  75790. /** Gets the center coordinate on Y axis */
  75791. get centerY(): number;
  75792. /** Gets or sets if control is Enabled*/
  75793. get isEnabled(): boolean;
  75794. set isEnabled(value: boolean);
  75795. /** Gets or sets background color of control if it's disabled*/
  75796. get disabledColor(): string;
  75797. set disabledColor(value: string);
  75798. /** Gets or sets front color of control if it's disabled*/
  75799. get disabledColorItem(): string;
  75800. set disabledColorItem(value: string);
  75801. /**
  75802. * Creates a new control
  75803. * @param name defines the name of the control
  75804. */
  75805. constructor(
  75806. /** defines the name of the control */
  75807. name?: string | undefined);
  75808. /** @hidden */
  75809. protected _getTypeName(): string;
  75810. /**
  75811. * Gets the first ascendant in the hierarchy of the given type
  75812. * @param className defines the required type
  75813. * @returns the ascendant or null if not found
  75814. */
  75815. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75816. /** @hidden */
  75817. _resetFontCache(): void;
  75818. /**
  75819. * Determines if a container is an ascendant of the current control
  75820. * @param container defines the container to look for
  75821. * @returns true if the container is one of the ascendant of the control
  75822. */
  75823. isAscendant(container: Control): boolean;
  75824. /**
  75825. * Gets coordinates in local control space
  75826. * @param globalCoordinates defines the coordinates to transform
  75827. * @returns the new coordinates in local space
  75828. */
  75829. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75830. /**
  75831. * Gets coordinates in local control space
  75832. * @param globalCoordinates defines the coordinates to transform
  75833. * @param result defines the target vector2 where to store the result
  75834. * @returns the current control
  75835. */
  75836. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75837. /**
  75838. * Gets coordinates in parent local control space
  75839. * @param globalCoordinates defines the coordinates to transform
  75840. * @returns the new coordinates in parent local space
  75841. */
  75842. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75843. /**
  75844. * Move the current control to a vector3 position projected onto the screen.
  75845. * @param position defines the target position
  75846. * @param scene defines the hosting scene
  75847. */
  75848. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75849. /**
  75850. * Will store all controls that have this control as ascendant in a given array
  75851. * @param results defines the array where to store the descendants
  75852. * @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
  75853. * @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
  75854. */
  75855. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75856. /**
  75857. * Will return all controls that have this control as ascendant
  75858. * @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
  75859. * @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
  75860. * @return all child controls
  75861. */
  75862. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75863. /**
  75864. * Link current control with a target mesh
  75865. * @param mesh defines the mesh to link with
  75866. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75867. */
  75868. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75869. /** @hidden */
  75870. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75871. /** @hidden */
  75872. _offsetLeft(offset: number): void;
  75873. /** @hidden */
  75874. _offsetTop(offset: number): void;
  75875. /** @hidden */
  75876. _markMatrixAsDirty(): void;
  75877. /** @hidden */
  75878. _flagDescendantsAsMatrixDirty(): void;
  75879. /** @hidden */
  75880. _intersectsRect(rect: Measure): boolean;
  75881. /** @hidden */
  75882. protected invalidateRect(): void;
  75883. /** @hidden */
  75884. _markAsDirty(force?: boolean): void;
  75885. /** @hidden */
  75886. _markAllAsDirty(): void;
  75887. /** @hidden */
  75888. _link(host: AdvancedDynamicTexture): void;
  75889. /** @hidden */
  75890. protected _transform(context?: CanvasRenderingContext2D): void;
  75891. /** @hidden */
  75892. _renderHighlight(context: CanvasRenderingContext2D): void;
  75893. /** @hidden */
  75894. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75895. /** @hidden */
  75896. protected _applyStates(context: CanvasRenderingContext2D): void;
  75897. /** @hidden */
  75898. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75899. /** @hidden */
  75900. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75901. protected _evaluateClippingState(parentMeasure: Measure): void;
  75902. /** @hidden */
  75903. _measure(): void;
  75904. /** @hidden */
  75905. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75906. /** @hidden */
  75907. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75908. /** @hidden */
  75909. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75910. /** @hidden */
  75911. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75912. private static _ClipMeasure;
  75913. private _tmpMeasureA;
  75914. private _clip;
  75915. /** @hidden */
  75916. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75917. /** @hidden */
  75918. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75919. /**
  75920. * Tests if a given coordinates belong to the current control
  75921. * @param x defines x coordinate to test
  75922. * @param y defines y coordinate to test
  75923. * @returns true if the coordinates are inside the control
  75924. */
  75925. contains(x: number, y: number): boolean;
  75926. /** @hidden */
  75927. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75928. /** @hidden */
  75929. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75930. /** @hidden */
  75931. _onPointerEnter(target: Control): boolean;
  75932. /** @hidden */
  75933. _onPointerOut(target: Control, force?: boolean): void;
  75934. /** @hidden */
  75935. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75936. /** @hidden */
  75937. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75938. /** @hidden */
  75939. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75940. /** @hidden */
  75941. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75942. /** @hidden */
  75943. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75944. private _prepareFont;
  75945. /** Releases associated resources */
  75946. dispose(): void;
  75947. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75948. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75949. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75950. private static _VERTICAL_ALIGNMENT_TOP;
  75951. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75952. private static _VERTICAL_ALIGNMENT_CENTER;
  75953. /** HORIZONTAL_ALIGNMENT_LEFT */
  75954. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75955. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75956. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75957. /** HORIZONTAL_ALIGNMENT_CENTER */
  75958. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75959. /** VERTICAL_ALIGNMENT_TOP */
  75960. static get VERTICAL_ALIGNMENT_TOP(): number;
  75961. /** VERTICAL_ALIGNMENT_BOTTOM */
  75962. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75963. /** VERTICAL_ALIGNMENT_CENTER */
  75964. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75965. private static _FontHeightSizes;
  75966. /** @hidden */
  75967. static _GetFontOffset(font: string): {
  75968. ascent: number;
  75969. height: number;
  75970. descent: number;
  75971. };
  75972. /**
  75973. * Creates a stack panel that can be used to render headers
  75974. * @param control defines the control to associate with the header
  75975. * @param text defines the text of the header
  75976. * @param size defines the size of the header
  75977. * @param options defines options used to configure the header
  75978. * @returns a new StackPanel
  75979. * @ignore
  75980. * @hidden
  75981. */
  75982. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75983. isHorizontal: boolean;
  75984. controlFirst: boolean;
  75985. }) => any;
  75986. /** @hidden */
  75987. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75988. }
  75989. }
  75990. declare module BABYLON.GUI {
  75991. /**
  75992. * Root class for 2D containers
  75993. * @see https://doc.babylonjs.com/how_to/gui#containers
  75994. */
  75995. export class Container extends Control {
  75996. name?: string | undefined;
  75997. /** @hidden */
  75998. _children: Control[];
  75999. /** @hidden */
  76000. protected _measureForChildren: Measure;
  76001. /** @hidden */
  76002. protected _background: string;
  76003. /** @hidden */
  76004. protected _adaptWidthToChildren: boolean;
  76005. /** @hidden */
  76006. protected _adaptHeightToChildren: boolean;
  76007. /**
  76008. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76009. */
  76010. logLayoutCycleErrors: boolean;
  76011. /**
  76012. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76013. */
  76014. maxLayoutCycle: number;
  76015. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76016. get adaptHeightToChildren(): boolean;
  76017. set adaptHeightToChildren(value: boolean);
  76018. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76019. get adaptWidthToChildren(): boolean;
  76020. set adaptWidthToChildren(value: boolean);
  76021. /** Gets or sets background color */
  76022. get background(): string;
  76023. set background(value: string);
  76024. /** Gets the list of children */
  76025. get children(): Control[];
  76026. /**
  76027. * Creates a new Container
  76028. * @param name defines the name of the container
  76029. */
  76030. constructor(name?: string | undefined);
  76031. protected _getTypeName(): string;
  76032. _flagDescendantsAsMatrixDirty(): void;
  76033. /**
  76034. * Gets a child using its name
  76035. * @param name defines the child name to look for
  76036. * @returns the child control if found
  76037. */
  76038. getChildByName(name: string): BABYLON.Nullable<Control>;
  76039. /**
  76040. * Gets a child using its type and its name
  76041. * @param name defines the child name to look for
  76042. * @param type defines the child type to look for
  76043. * @returns the child control if found
  76044. */
  76045. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76046. /**
  76047. * Search for a specific control in children
  76048. * @param control defines the control to look for
  76049. * @returns true if the control is in child list
  76050. */
  76051. containsControl(control: Control): boolean;
  76052. /**
  76053. * Adds a new control to the current container
  76054. * @param control defines the control to add
  76055. * @returns the current container
  76056. */
  76057. addControl(control: BABYLON.Nullable<Control>): Container;
  76058. /**
  76059. * Removes all controls from the current container
  76060. * @returns the current container
  76061. */
  76062. clearControls(): Container;
  76063. /**
  76064. * Removes a control from the current container
  76065. * @param control defines the control to remove
  76066. * @returns the current container
  76067. */
  76068. removeControl(control: Control): Container;
  76069. /** @hidden */
  76070. _reOrderControl(control: Control): void;
  76071. /** @hidden */
  76072. _offsetLeft(offset: number): void;
  76073. /** @hidden */
  76074. _offsetTop(offset: number): void;
  76075. /** @hidden */
  76076. _markAllAsDirty(): void;
  76077. /** @hidden */
  76078. protected _localDraw(context: CanvasRenderingContext2D): void;
  76079. /** @hidden */
  76080. _link(host: AdvancedDynamicTexture): void;
  76081. /** @hidden */
  76082. protected _beforeLayout(): void;
  76083. /** @hidden */
  76084. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76085. /** @hidden */
  76086. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76087. protected _postMeasure(): void;
  76088. /** @hidden */
  76089. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76090. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76091. /** @hidden */
  76092. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76093. /** @hidden */
  76094. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76095. /** Releases associated resources */
  76096. dispose(): void;
  76097. }
  76098. }
  76099. declare module BABYLON.GUI {
  76100. /** Class used to create rectangle container */
  76101. export class Rectangle extends Container {
  76102. name?: string | undefined;
  76103. private _thickness;
  76104. private _cornerRadius;
  76105. /** Gets or sets border thickness */
  76106. get thickness(): number;
  76107. set thickness(value: number);
  76108. /** Gets or sets the corner radius angle */
  76109. get cornerRadius(): number;
  76110. set cornerRadius(value: number);
  76111. /**
  76112. * Creates a new Rectangle
  76113. * @param name defines the control name
  76114. */
  76115. constructor(name?: string | undefined);
  76116. protected _getTypeName(): string;
  76117. protected _localDraw(context: CanvasRenderingContext2D): void;
  76118. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76119. private _drawRoundedRect;
  76120. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76121. }
  76122. }
  76123. declare module BABYLON.GUI {
  76124. /**
  76125. * Enum that determines the text-wrapping mode to use.
  76126. */
  76127. export enum TextWrapping {
  76128. /**
  76129. * Clip the text when it's larger than Control.width; this is the default mode.
  76130. */
  76131. Clip = 0,
  76132. /**
  76133. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76134. */
  76135. WordWrap = 1,
  76136. /**
  76137. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76138. */
  76139. Ellipsis = 2
  76140. }
  76141. /**
  76142. * Class used to create text block control
  76143. */
  76144. export class TextBlock extends Control {
  76145. /**
  76146. * Defines the name of the control
  76147. */
  76148. name?: string | undefined;
  76149. private _text;
  76150. private _textWrapping;
  76151. private _textHorizontalAlignment;
  76152. private _textVerticalAlignment;
  76153. private _lines;
  76154. private _resizeToFit;
  76155. private _lineSpacing;
  76156. private _outlineWidth;
  76157. private _outlineColor;
  76158. /**
  76159. * An event triggered after the text is changed
  76160. */
  76161. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76162. /**
  76163. * An event triggered after the text was broken up into lines
  76164. */
  76165. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76166. /**
  76167. * Function used to split a string into words. By default, a string is split at each space character found
  76168. */
  76169. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76170. /**
  76171. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76172. */
  76173. get lines(): any[];
  76174. /**
  76175. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76176. */
  76177. get resizeToFit(): boolean;
  76178. /**
  76179. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76180. */
  76181. set resizeToFit(value: boolean);
  76182. /**
  76183. * Gets or sets a boolean indicating if text must be wrapped
  76184. */
  76185. get textWrapping(): TextWrapping | boolean;
  76186. /**
  76187. * Gets or sets a boolean indicating if text must be wrapped
  76188. */
  76189. set textWrapping(value: TextWrapping | boolean);
  76190. /**
  76191. * Gets or sets text to display
  76192. */
  76193. get text(): string;
  76194. /**
  76195. * Gets or sets text to display
  76196. */
  76197. set text(value: string);
  76198. /**
  76199. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76200. */
  76201. get textHorizontalAlignment(): number;
  76202. /**
  76203. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76204. */
  76205. set textHorizontalAlignment(value: number);
  76206. /**
  76207. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76208. */
  76209. get textVerticalAlignment(): number;
  76210. /**
  76211. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76212. */
  76213. set textVerticalAlignment(value: number);
  76214. /**
  76215. * Gets or sets line spacing value
  76216. */
  76217. set lineSpacing(value: string | number);
  76218. /**
  76219. * Gets or sets line spacing value
  76220. */
  76221. get lineSpacing(): string | number;
  76222. /**
  76223. * Gets or sets outlineWidth of the text to display
  76224. */
  76225. get outlineWidth(): number;
  76226. /**
  76227. * Gets or sets outlineWidth of the text to display
  76228. */
  76229. set outlineWidth(value: number);
  76230. /**
  76231. * Gets or sets outlineColor of the text to display
  76232. */
  76233. get outlineColor(): string;
  76234. /**
  76235. * Gets or sets outlineColor of the text to display
  76236. */
  76237. set outlineColor(value: string);
  76238. /**
  76239. * Creates a new TextBlock object
  76240. * @param name defines the name of the control
  76241. * @param text defines the text to display (emptry string by default)
  76242. */
  76243. constructor(
  76244. /**
  76245. * Defines the name of the control
  76246. */
  76247. name?: string | undefined, text?: string);
  76248. protected _getTypeName(): string;
  76249. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76250. private _drawText;
  76251. /** @hidden */
  76252. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76253. protected _applyStates(context: CanvasRenderingContext2D): void;
  76254. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76255. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76256. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76257. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76258. protected _renderLines(context: CanvasRenderingContext2D): void;
  76259. /**
  76260. * Given a width constraint applied on the text block, find the expected height
  76261. * @returns expected height
  76262. */
  76263. computeExpectedHeight(): number;
  76264. dispose(): void;
  76265. }
  76266. }
  76267. declare module BABYLON.GUI {
  76268. /**
  76269. * Class used to create 2D images
  76270. */
  76271. export class Image extends Control {
  76272. name?: string | undefined;
  76273. private _workingCanvas;
  76274. private _domImage;
  76275. private _imageWidth;
  76276. private _imageHeight;
  76277. private _loaded;
  76278. private _stretch;
  76279. private _source;
  76280. private _autoScale;
  76281. private _sourceLeft;
  76282. private _sourceTop;
  76283. private _sourceWidth;
  76284. private _sourceHeight;
  76285. private _svgAttributesComputationCompleted;
  76286. private _isSVG;
  76287. private _cellWidth;
  76288. private _cellHeight;
  76289. private _cellId;
  76290. private _populateNinePatchSlicesFromImage;
  76291. private _sliceLeft;
  76292. private _sliceRight;
  76293. private _sliceTop;
  76294. private _sliceBottom;
  76295. private _detectPointerOnOpaqueOnly;
  76296. /**
  76297. * BABYLON.Observable notified when the content is loaded
  76298. */
  76299. onImageLoadedObservable: BABYLON.Observable<Image>;
  76300. /**
  76301. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76302. */
  76303. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76304. /**
  76305. * Gets a boolean indicating that the content is loaded
  76306. */
  76307. get isLoaded(): boolean;
  76308. /**
  76309. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76310. */
  76311. get populateNinePatchSlicesFromImage(): boolean;
  76312. set populateNinePatchSlicesFromImage(value: boolean);
  76313. /**
  76314. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76315. * Beware using this as this will comsume more memory as the image has to be stored twice
  76316. */
  76317. get detectPointerOnOpaqueOnly(): boolean;
  76318. set detectPointerOnOpaqueOnly(value: boolean);
  76319. /**
  76320. * Gets or sets the left value for slicing (9-patch)
  76321. */
  76322. get sliceLeft(): number;
  76323. set sliceLeft(value: number);
  76324. /**
  76325. * Gets or sets the right value for slicing (9-patch)
  76326. */
  76327. get sliceRight(): number;
  76328. set sliceRight(value: number);
  76329. /**
  76330. * Gets or sets the top value for slicing (9-patch)
  76331. */
  76332. get sliceTop(): number;
  76333. set sliceTop(value: number);
  76334. /**
  76335. * Gets or sets the bottom value for slicing (9-patch)
  76336. */
  76337. get sliceBottom(): number;
  76338. set sliceBottom(value: number);
  76339. /**
  76340. * Gets or sets the left coordinate in the source image
  76341. */
  76342. get sourceLeft(): number;
  76343. set sourceLeft(value: number);
  76344. /**
  76345. * Gets or sets the top coordinate in the source image
  76346. */
  76347. get sourceTop(): number;
  76348. set sourceTop(value: number);
  76349. /**
  76350. * Gets or sets the width to capture in the source image
  76351. */
  76352. get sourceWidth(): number;
  76353. set sourceWidth(value: number);
  76354. /**
  76355. * Gets or sets the height to capture in the source image
  76356. */
  76357. get sourceHeight(): number;
  76358. set sourceHeight(value: number);
  76359. /** Indicates if the format of the image is SVG */
  76360. get isSVG(): boolean;
  76361. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76362. get svgAttributesComputationCompleted(): boolean;
  76363. /**
  76364. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76365. * @see https://doc.babylonjs.com/how_to/gui#image
  76366. */
  76367. get autoScale(): boolean;
  76368. set autoScale(value: boolean);
  76369. /** Gets or sets the streching mode used by the image */
  76370. get stretch(): number;
  76371. set stretch(value: number);
  76372. /** @hidden */
  76373. _rotate90(n: number, preserveProperties?: boolean): Image;
  76374. private _handleRotationForSVGImage;
  76375. private _rotate90SourceProperties;
  76376. /**
  76377. * Gets or sets the internal DOM image used to render the control
  76378. */
  76379. set domImage(value: HTMLImageElement);
  76380. get domImage(): HTMLImageElement;
  76381. private _onImageLoaded;
  76382. private _extractNinePatchSliceDataFromImage;
  76383. /**
  76384. * Gets or sets image source url
  76385. */
  76386. set source(value: BABYLON.Nullable<string>);
  76387. /**
  76388. * Checks for svg document with icon id present
  76389. */
  76390. private _svgCheck;
  76391. /**
  76392. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76393. * given external svg file and icon id
  76394. */
  76395. private _getSVGAttribs;
  76396. /**
  76397. * Gets or sets the cell width to use when animation sheet is enabled
  76398. * @see https://doc.babylonjs.com/how_to/gui#image
  76399. */
  76400. get cellWidth(): number;
  76401. set cellWidth(value: number);
  76402. /**
  76403. * Gets or sets the cell height to use when animation sheet is enabled
  76404. * @see https://doc.babylonjs.com/how_to/gui#image
  76405. */
  76406. get cellHeight(): number;
  76407. set cellHeight(value: number);
  76408. /**
  76409. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76410. * @see https://doc.babylonjs.com/how_to/gui#image
  76411. */
  76412. get cellId(): number;
  76413. set cellId(value: number);
  76414. /**
  76415. * Creates a new Image
  76416. * @param name defines the control name
  76417. * @param url defines the image url
  76418. */
  76419. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76420. /**
  76421. * Tests if a given coordinates belong to the current control
  76422. * @param x defines x coordinate to test
  76423. * @param y defines y coordinate to test
  76424. * @returns true if the coordinates are inside the control
  76425. */
  76426. contains(x: number, y: number): boolean;
  76427. protected _getTypeName(): string;
  76428. /** Force the control to synchronize with its content */
  76429. synchronizeSizeWithContent(): void;
  76430. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76431. private _prepareWorkingCanvasForOpaqueDetection;
  76432. private _drawImage;
  76433. _draw(context: CanvasRenderingContext2D): void;
  76434. private _renderCornerPatch;
  76435. private _renderNinePatch;
  76436. dispose(): void;
  76437. /** STRETCH_NONE */
  76438. static readonly STRETCH_NONE: number;
  76439. /** STRETCH_FILL */
  76440. static readonly STRETCH_FILL: number;
  76441. /** STRETCH_UNIFORM */
  76442. static readonly STRETCH_UNIFORM: number;
  76443. /** STRETCH_EXTEND */
  76444. static readonly STRETCH_EXTEND: number;
  76445. /** NINE_PATCH */
  76446. static readonly STRETCH_NINE_PATCH: number;
  76447. }
  76448. }
  76449. declare module BABYLON.GUI {
  76450. /**
  76451. * Class used to create 2D buttons
  76452. */
  76453. export class Button extends Rectangle {
  76454. name?: string | undefined;
  76455. /**
  76456. * Function called to generate a pointer enter animation
  76457. */
  76458. pointerEnterAnimation: () => void;
  76459. /**
  76460. * Function called to generate a pointer out animation
  76461. */
  76462. pointerOutAnimation: () => void;
  76463. /**
  76464. * Function called to generate a pointer down animation
  76465. */
  76466. pointerDownAnimation: () => void;
  76467. /**
  76468. * Function called to generate a pointer up animation
  76469. */
  76470. pointerUpAnimation: () => void;
  76471. /**
  76472. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76473. */
  76474. delegatePickingToChildren: boolean;
  76475. private _image;
  76476. /**
  76477. * Returns the image part of the button (if any)
  76478. */
  76479. get image(): BABYLON.Nullable<Image>;
  76480. private _textBlock;
  76481. /**
  76482. * Returns the image part of the button (if any)
  76483. */
  76484. get textBlock(): BABYLON.Nullable<TextBlock>;
  76485. /**
  76486. * Creates a new Button
  76487. * @param name defines the name of the button
  76488. */
  76489. constructor(name?: string | undefined);
  76490. protected _getTypeName(): string;
  76491. /** @hidden */
  76492. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76493. /** @hidden */
  76494. _onPointerEnter(target: Control): boolean;
  76495. /** @hidden */
  76496. _onPointerOut(target: Control, force?: boolean): void;
  76497. /** @hidden */
  76498. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76499. /** @hidden */
  76500. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76501. /**
  76502. * Creates a new button made with an image and a text
  76503. * @param name defines the name of the button
  76504. * @param text defines the text of the button
  76505. * @param imageUrl defines the url of the image
  76506. * @returns a new Button
  76507. */
  76508. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76509. /**
  76510. * Creates a new button made with an image
  76511. * @param name defines the name of the button
  76512. * @param imageUrl defines the url of the image
  76513. * @returns a new Button
  76514. */
  76515. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76516. /**
  76517. * Creates a new button made with a text
  76518. * @param name defines the name of the button
  76519. * @param text defines the text of the button
  76520. * @returns a new Button
  76521. */
  76522. static CreateSimpleButton(name: string, text: string): Button;
  76523. /**
  76524. * Creates a new button made with an image and a centered text
  76525. * @param name defines the name of the button
  76526. * @param text defines the text of the button
  76527. * @param imageUrl defines the url of the image
  76528. * @returns a new Button
  76529. */
  76530. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76531. }
  76532. }
  76533. declare module BABYLON.GUI {
  76534. /**
  76535. * Class used to create a 2D stack panel container
  76536. */
  76537. export class StackPanel extends Container {
  76538. name?: string | undefined;
  76539. private _isVertical;
  76540. private _manualWidth;
  76541. private _manualHeight;
  76542. private _doNotTrackManualChanges;
  76543. /**
  76544. * Gets or sets a boolean indicating that layou warnings should be ignored
  76545. */
  76546. ignoreLayoutWarnings: boolean;
  76547. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76548. get isVertical(): boolean;
  76549. set isVertical(value: boolean);
  76550. /**
  76551. * Gets or sets panel width.
  76552. * This value should not be set when in horizontal mode as it will be computed automatically
  76553. */
  76554. set width(value: string | number);
  76555. get width(): string | number;
  76556. /**
  76557. * Gets or sets panel height.
  76558. * This value should not be set when in vertical mode as it will be computed automatically
  76559. */
  76560. set height(value: string | number);
  76561. get height(): string | number;
  76562. /**
  76563. * Creates a new StackPanel
  76564. * @param name defines control name
  76565. */
  76566. constructor(name?: string | undefined);
  76567. protected _getTypeName(): string;
  76568. /** @hidden */
  76569. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76570. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76571. protected _postMeasure(): void;
  76572. }
  76573. }
  76574. declare module BABYLON.GUI {
  76575. /**
  76576. * Class used to represent a 2D checkbox
  76577. */
  76578. export class Checkbox extends Control {
  76579. name?: string | undefined;
  76580. private _isChecked;
  76581. private _background;
  76582. private _checkSizeRatio;
  76583. private _thickness;
  76584. /** Gets or sets border thickness */
  76585. get thickness(): number;
  76586. set thickness(value: number);
  76587. /**
  76588. * BABYLON.Observable raised when isChecked property changes
  76589. */
  76590. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76591. /** Gets or sets a value indicating the ratio between overall size and check size */
  76592. get checkSizeRatio(): number;
  76593. set checkSizeRatio(value: number);
  76594. /** Gets or sets background color */
  76595. get background(): string;
  76596. set background(value: string);
  76597. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76598. get isChecked(): boolean;
  76599. set isChecked(value: boolean);
  76600. /**
  76601. * Creates a new CheckBox
  76602. * @param name defines the control name
  76603. */
  76604. constructor(name?: string | undefined);
  76605. protected _getTypeName(): string;
  76606. /** @hidden */
  76607. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76608. /** @hidden */
  76609. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76610. /**
  76611. * Utility function to easily create a checkbox with a header
  76612. * @param title defines the label to use for the header
  76613. * @param onValueChanged defines the callback to call when value changes
  76614. * @returns a StackPanel containing the checkbox and a textBlock
  76615. */
  76616. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76617. }
  76618. }
  76619. declare module BABYLON.GUI {
  76620. /**
  76621. * Class used to store key control properties
  76622. */
  76623. export class KeyPropertySet {
  76624. /** Width */
  76625. width?: string;
  76626. /** Height */
  76627. height?: string;
  76628. /** Left padding */
  76629. paddingLeft?: string;
  76630. /** Right padding */
  76631. paddingRight?: string;
  76632. /** Top padding */
  76633. paddingTop?: string;
  76634. /** Bottom padding */
  76635. paddingBottom?: string;
  76636. /** Foreground color */
  76637. color?: string;
  76638. /** Background color */
  76639. background?: string;
  76640. }
  76641. /**
  76642. * Class used to create virtual keyboard
  76643. */
  76644. export class VirtualKeyboard extends StackPanel {
  76645. /** BABYLON.Observable raised when a key is pressed */
  76646. onKeyPressObservable: BABYLON.Observable<string>;
  76647. /** Gets or sets default key button width */
  76648. defaultButtonWidth: string;
  76649. /** Gets or sets default key button height */
  76650. defaultButtonHeight: string;
  76651. /** Gets or sets default key button left padding */
  76652. defaultButtonPaddingLeft: string;
  76653. /** Gets or sets default key button right padding */
  76654. defaultButtonPaddingRight: string;
  76655. /** Gets or sets default key button top padding */
  76656. defaultButtonPaddingTop: string;
  76657. /** Gets or sets default key button bottom padding */
  76658. defaultButtonPaddingBottom: string;
  76659. /** Gets or sets default key button foreground color */
  76660. defaultButtonColor: string;
  76661. /** Gets or sets default key button background color */
  76662. defaultButtonBackground: string;
  76663. /** Gets or sets shift button foreground color */
  76664. shiftButtonColor: string;
  76665. /** Gets or sets shift button thickness*/
  76666. selectedShiftThickness: number;
  76667. /** Gets shift key state */
  76668. shiftState: number;
  76669. protected _getTypeName(): string;
  76670. private _createKey;
  76671. /**
  76672. * Adds a new row of keys
  76673. * @param keys defines the list of keys to add
  76674. * @param propertySets defines the associated property sets
  76675. */
  76676. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76677. /**
  76678. * Set the shift key to a specific state
  76679. * @param shiftState defines the new shift state
  76680. */
  76681. applyShiftState(shiftState: number): void;
  76682. private _currentlyConnectedInputText;
  76683. private _connectedInputTexts;
  76684. private _onKeyPressObserver;
  76685. /** Gets the input text control currently attached to the keyboard */
  76686. get connectedInputText(): BABYLON.Nullable<InputText>;
  76687. /**
  76688. * Connects the keyboard with an input text control
  76689. *
  76690. * @param input defines the target control
  76691. */
  76692. connect(input: InputText): void;
  76693. /**
  76694. * Disconnects the keyboard from connected InputText controls
  76695. *
  76696. * @param input optionally defines a target control, otherwise all are disconnected
  76697. */
  76698. disconnect(input?: InputText): void;
  76699. private _removeConnectedInputObservables;
  76700. /**
  76701. * Release all resources
  76702. */
  76703. dispose(): void;
  76704. /**
  76705. * Creates a new keyboard using a default layout
  76706. *
  76707. * @param name defines control name
  76708. * @returns a new VirtualKeyboard
  76709. */
  76710. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76711. }
  76712. }
  76713. declare module BABYLON.GUI {
  76714. /**
  76715. * Class used to create input text control
  76716. */
  76717. export class InputText extends Control implements IFocusableControl {
  76718. name?: string | undefined;
  76719. private _text;
  76720. private _placeholderText;
  76721. private _background;
  76722. private _focusedBackground;
  76723. private _focusedColor;
  76724. private _placeholderColor;
  76725. private _thickness;
  76726. private _margin;
  76727. private _autoStretchWidth;
  76728. private _maxWidth;
  76729. private _isFocused;
  76730. private _blinkTimeout;
  76731. private _blinkIsEven;
  76732. private _cursorOffset;
  76733. private _scrollLeft;
  76734. private _textWidth;
  76735. private _clickedCoordinate;
  76736. private _deadKey;
  76737. private _addKey;
  76738. private _currentKey;
  76739. private _isTextHighlightOn;
  76740. private _textHighlightColor;
  76741. private _highligherOpacity;
  76742. private _highlightedText;
  76743. private _startHighlightIndex;
  76744. private _endHighlightIndex;
  76745. private _cursorIndex;
  76746. private _onFocusSelectAll;
  76747. private _isPointerDown;
  76748. private _onClipboardObserver;
  76749. private _onPointerDblTapObserver;
  76750. /** @hidden */
  76751. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76752. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76753. promptMessage: string;
  76754. /** Force disable prompt on mobile device */
  76755. disableMobilePrompt: boolean;
  76756. /** BABYLON.Observable raised when the text changes */
  76757. onTextChangedObservable: BABYLON.Observable<InputText>;
  76758. /** BABYLON.Observable raised just before an entered character is to be added */
  76759. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76760. /** BABYLON.Observable raised when the control gets the focus */
  76761. onFocusObservable: BABYLON.Observable<InputText>;
  76762. /** BABYLON.Observable raised when the control loses the focus */
  76763. onBlurObservable: BABYLON.Observable<InputText>;
  76764. /**Observable raised when the text is highlighted */
  76765. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76766. /**Observable raised when copy event is triggered */
  76767. onTextCopyObservable: BABYLON.Observable<InputText>;
  76768. /** BABYLON.Observable raised when cut event is triggered */
  76769. onTextCutObservable: BABYLON.Observable<InputText>;
  76770. /** BABYLON.Observable raised when paste event is triggered */
  76771. onTextPasteObservable: BABYLON.Observable<InputText>;
  76772. /** BABYLON.Observable raised when a key event was processed */
  76773. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76774. /** Gets or sets the maximum width allowed by the control */
  76775. get maxWidth(): string | number;
  76776. /** Gets the maximum width allowed by the control in pixels */
  76777. get maxWidthInPixels(): number;
  76778. set maxWidth(value: string | number);
  76779. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76780. get highligherOpacity(): number;
  76781. set highligherOpacity(value: number);
  76782. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76783. get onFocusSelectAll(): boolean;
  76784. set onFocusSelectAll(value: boolean);
  76785. /** Gets or sets the text hightlight color */
  76786. get textHighlightColor(): string;
  76787. set textHighlightColor(value: string);
  76788. /** Gets or sets control margin */
  76789. get margin(): string;
  76790. /** Gets control margin in pixels */
  76791. get marginInPixels(): number;
  76792. set margin(value: string);
  76793. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76794. get autoStretchWidth(): boolean;
  76795. set autoStretchWidth(value: boolean);
  76796. /** Gets or sets border thickness */
  76797. get thickness(): number;
  76798. set thickness(value: number);
  76799. /** Gets or sets the background color when focused */
  76800. get focusedBackground(): string;
  76801. set focusedBackground(value: string);
  76802. /** Gets or sets the background color when focused */
  76803. get focusedColor(): string;
  76804. set focusedColor(value: string);
  76805. /** Gets or sets the background color */
  76806. get background(): string;
  76807. set background(value: string);
  76808. /** Gets or sets the placeholder color */
  76809. get placeholderColor(): string;
  76810. set placeholderColor(value: string);
  76811. /** Gets or sets the text displayed when the control is empty */
  76812. get placeholderText(): string;
  76813. set placeholderText(value: string);
  76814. /** Gets or sets the dead key flag */
  76815. get deadKey(): boolean;
  76816. set deadKey(flag: boolean);
  76817. /** Gets or sets the highlight text */
  76818. get highlightedText(): string;
  76819. set highlightedText(text: string);
  76820. /** Gets or sets if the current key should be added */
  76821. get addKey(): boolean;
  76822. set addKey(flag: boolean);
  76823. /** Gets or sets the value of the current key being entered */
  76824. get currentKey(): string;
  76825. set currentKey(key: string);
  76826. /** Gets or sets the text displayed in the control */
  76827. get text(): string;
  76828. set text(value: string);
  76829. /** Gets or sets control width */
  76830. get width(): string | number;
  76831. set width(value: string | number);
  76832. /**
  76833. * Creates a new InputText
  76834. * @param name defines the control name
  76835. * @param text defines the text of the control
  76836. */
  76837. constructor(name?: string | undefined, text?: string);
  76838. /** @hidden */
  76839. onBlur(): void;
  76840. /** @hidden */
  76841. onFocus(): void;
  76842. protected _getTypeName(): string;
  76843. /**
  76844. * Function called to get the list of controls that should not steal the focus from this control
  76845. * @returns an array of controls
  76846. */
  76847. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76848. /** @hidden */
  76849. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76850. /** @hidden */
  76851. private _updateValueFromCursorIndex;
  76852. /** @hidden */
  76853. private _processDblClick;
  76854. /** @hidden */
  76855. private _selectAllText;
  76856. /**
  76857. * Handles the keyboard event
  76858. * @param evt Defines the KeyboardEvent
  76859. */
  76860. processKeyboard(evt: KeyboardEvent): void;
  76861. /** @hidden */
  76862. private _onCopyText;
  76863. /** @hidden */
  76864. private _onCutText;
  76865. /** @hidden */
  76866. private _onPasteText;
  76867. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76868. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76869. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76870. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76871. protected _beforeRenderText(text: string): string;
  76872. dispose(): void;
  76873. }
  76874. }
  76875. declare module BABYLON.GUI {
  76876. /**
  76877. * Class used to create a 2D grid container
  76878. */
  76879. export class Grid extends Container {
  76880. name?: string | undefined;
  76881. private _rowDefinitions;
  76882. private _columnDefinitions;
  76883. private _cells;
  76884. private _childControls;
  76885. /**
  76886. * Gets the number of columns
  76887. */
  76888. get columnCount(): number;
  76889. /**
  76890. * Gets the number of rows
  76891. */
  76892. get rowCount(): number;
  76893. /** Gets the list of children */
  76894. get children(): Control[];
  76895. /** Gets the list of cells (e.g. the containers) */
  76896. get cells(): {
  76897. [key: string]: Container;
  76898. };
  76899. /**
  76900. * Gets the definition of a specific row
  76901. * @param index defines the index of the row
  76902. * @returns the row definition
  76903. */
  76904. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76905. /**
  76906. * Gets the definition of a specific column
  76907. * @param index defines the index of the column
  76908. * @returns the column definition
  76909. */
  76910. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76911. /**
  76912. * Adds a new row to the grid
  76913. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76914. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76915. * @returns the current grid
  76916. */
  76917. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76918. /**
  76919. * Adds a new column to the grid
  76920. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76921. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76922. * @returns the current grid
  76923. */
  76924. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76925. /**
  76926. * Update a row definition
  76927. * @param index defines the index of the row to update
  76928. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76929. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76930. * @returns the current grid
  76931. */
  76932. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76933. /**
  76934. * Update a column definition
  76935. * @param index defines the index of the column to update
  76936. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76937. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76938. * @returns the current grid
  76939. */
  76940. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76941. /**
  76942. * Gets the list of children stored in a specific cell
  76943. * @param row defines the row to check
  76944. * @param column defines the column to check
  76945. * @returns the list of controls
  76946. */
  76947. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76948. /**
  76949. * Gets a string representing the child cell info (row x column)
  76950. * @param child defines the control to get info from
  76951. * @returns a string containing the child cell info (row x column)
  76952. */
  76953. getChildCellInfo(child: Control): string;
  76954. private _removeCell;
  76955. private _offsetCell;
  76956. /**
  76957. * Remove a column definition at specified index
  76958. * @param index defines the index of the column to remove
  76959. * @returns the current grid
  76960. */
  76961. removeColumnDefinition(index: number): Grid;
  76962. /**
  76963. * Remove a row definition at specified index
  76964. * @param index defines the index of the row to remove
  76965. * @returns the current grid
  76966. */
  76967. removeRowDefinition(index: number): Grid;
  76968. /**
  76969. * Adds a new control to the current grid
  76970. * @param control defines the control to add
  76971. * @param row defines the row where to add the control (0 by default)
  76972. * @param column defines the column where to add the control (0 by default)
  76973. * @returns the current grid
  76974. */
  76975. addControl(control: Control, row?: number, column?: number): Grid;
  76976. /**
  76977. * Removes a control from the current container
  76978. * @param control defines the control to remove
  76979. * @returns the current container
  76980. */
  76981. removeControl(control: Control): Container;
  76982. /**
  76983. * Creates a new Grid
  76984. * @param name defines control name
  76985. */
  76986. constructor(name?: string | undefined);
  76987. protected _getTypeName(): string;
  76988. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76989. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76990. _flagDescendantsAsMatrixDirty(): void;
  76991. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76992. /** Releases associated resources */
  76993. dispose(): void;
  76994. }
  76995. }
  76996. declare module BABYLON.GUI {
  76997. /** Class used to create color pickers */
  76998. export class ColorPicker extends Control {
  76999. name?: string | undefined;
  77000. private static _Epsilon;
  77001. private _colorWheelCanvas;
  77002. private _value;
  77003. private _tmpColor;
  77004. private _pointerStartedOnSquare;
  77005. private _pointerStartedOnWheel;
  77006. private _squareLeft;
  77007. private _squareTop;
  77008. private _squareSize;
  77009. private _h;
  77010. private _s;
  77011. private _v;
  77012. private _lastPointerDownID;
  77013. /**
  77014. * BABYLON.Observable raised when the value changes
  77015. */
  77016. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77017. /** Gets or sets the color of the color picker */
  77018. get value(): BABYLON.Color3;
  77019. set value(value: BABYLON.Color3);
  77020. /**
  77021. * Gets or sets control width
  77022. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77023. */
  77024. get width(): string | number;
  77025. set width(value: string | number);
  77026. /**
  77027. * Gets or sets control height
  77028. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77029. */
  77030. get height(): string | number;
  77031. /** Gets or sets control height */
  77032. set height(value: string | number);
  77033. /** Gets or sets control size */
  77034. get size(): string | number;
  77035. set size(value: string | number);
  77036. /**
  77037. * Creates a new ColorPicker
  77038. * @param name defines the control name
  77039. */
  77040. constructor(name?: string | undefined);
  77041. protected _getTypeName(): string;
  77042. /** @hidden */
  77043. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77044. private _updateSquareProps;
  77045. private _drawGradientSquare;
  77046. private _drawCircle;
  77047. private _createColorWheelCanvas;
  77048. /** @hidden */
  77049. _draw(context: CanvasRenderingContext2D): void;
  77050. private _pointerIsDown;
  77051. private _updateValueFromPointer;
  77052. private _isPointOnSquare;
  77053. private _isPointOnWheel;
  77054. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77055. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77056. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77057. /**
  77058. * This function expands the color picker by creating a color picker dialog with manual
  77059. * color value input and the ability to save colors into an array to be used later in
  77060. * subsequent launches of the dialogue.
  77061. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77062. * @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.
  77063. * @returns picked color as a hex string and the saved colors array as hex strings.
  77064. */
  77065. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77066. pickerWidth?: string;
  77067. pickerHeight?: string;
  77068. headerHeight?: string;
  77069. lastColor?: string;
  77070. swatchLimit?: number;
  77071. numSwatchesPerLine?: number;
  77072. savedColors?: Array<string>;
  77073. }): Promise<{
  77074. savedColors?: string[];
  77075. pickedColor: string;
  77076. }>;
  77077. }
  77078. }
  77079. declare module BABYLON.GUI {
  77080. /** Class used to create 2D ellipse containers */
  77081. export class Ellipse extends Container {
  77082. name?: string | undefined;
  77083. private _thickness;
  77084. /** Gets or sets border thickness */
  77085. get thickness(): number;
  77086. set thickness(value: number);
  77087. /**
  77088. * Creates a new Ellipse
  77089. * @param name defines the control name
  77090. */
  77091. constructor(name?: string | undefined);
  77092. protected _getTypeName(): string;
  77093. protected _localDraw(context: CanvasRenderingContext2D): void;
  77094. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77095. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77096. }
  77097. }
  77098. declare module BABYLON.GUI {
  77099. /**
  77100. * Class used to create a password control
  77101. */
  77102. export class InputPassword extends InputText {
  77103. protected _beforeRenderText(text: string): string;
  77104. }
  77105. }
  77106. declare module BABYLON.GUI {
  77107. /** Class used to render 2D lines */
  77108. export class Line extends Control {
  77109. name?: string | undefined;
  77110. private _lineWidth;
  77111. private _x1;
  77112. private _y1;
  77113. private _x2;
  77114. private _y2;
  77115. private _dash;
  77116. private _connectedControl;
  77117. private _connectedControlDirtyObserver;
  77118. /** Gets or sets the dash pattern */
  77119. get dash(): Array<number>;
  77120. set dash(value: Array<number>);
  77121. /** Gets or sets the control connected with the line end */
  77122. get connectedControl(): Control;
  77123. set connectedControl(value: Control);
  77124. /** Gets or sets start coordinates on X axis */
  77125. get x1(): string | number;
  77126. set x1(value: string | number);
  77127. /** Gets or sets start coordinates on Y axis */
  77128. get y1(): string | number;
  77129. set y1(value: string | number);
  77130. /** Gets or sets end coordinates on X axis */
  77131. get x2(): string | number;
  77132. set x2(value: string | number);
  77133. /** Gets or sets end coordinates on Y axis */
  77134. get y2(): string | number;
  77135. set y2(value: string | number);
  77136. /** Gets or sets line width */
  77137. get lineWidth(): number;
  77138. set lineWidth(value: number);
  77139. /** Gets or sets horizontal alignment */
  77140. set horizontalAlignment(value: number);
  77141. /** Gets or sets vertical alignment */
  77142. set verticalAlignment(value: number);
  77143. private get _effectiveX2();
  77144. private get _effectiveY2();
  77145. /**
  77146. * Creates a new Line
  77147. * @param name defines the control name
  77148. */
  77149. constructor(name?: string | undefined);
  77150. protected _getTypeName(): string;
  77151. _draw(context: CanvasRenderingContext2D): void;
  77152. _measure(): void;
  77153. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77154. /**
  77155. * Move one end of the line given 3D cartesian coordinates.
  77156. * @param position Targeted world position
  77157. * @param scene BABYLON.Scene
  77158. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77159. */
  77160. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77161. /**
  77162. * Move one end of the line to a position in screen absolute space.
  77163. * @param projectedPosition Position in screen absolute space (X, Y)
  77164. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77165. */
  77166. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77167. }
  77168. }
  77169. declare module BABYLON.GUI {
  77170. /**
  77171. * Class used to store a point for a MultiLine object.
  77172. * The point can be pure 2D coordinates, a mesh or a control
  77173. */
  77174. export class MultiLinePoint {
  77175. private _multiLine;
  77176. private _x;
  77177. private _y;
  77178. private _control;
  77179. private _mesh;
  77180. private _controlObserver;
  77181. private _meshObserver;
  77182. /** @hidden */
  77183. _point: BABYLON.Vector2;
  77184. /**
  77185. * Creates a new MultiLinePoint
  77186. * @param multiLine defines the source MultiLine object
  77187. */
  77188. constructor(multiLine: MultiLine);
  77189. /** Gets or sets x coordinate */
  77190. get x(): string | number;
  77191. set x(value: string | number);
  77192. /** Gets or sets y coordinate */
  77193. get y(): string | number;
  77194. set y(value: string | number);
  77195. /** Gets or sets the control associated with this point */
  77196. get control(): BABYLON.Nullable<Control>;
  77197. set control(value: BABYLON.Nullable<Control>);
  77198. /** Gets or sets the mesh associated with this point */
  77199. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77200. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77201. /** Resets links */
  77202. resetLinks(): void;
  77203. /**
  77204. * Gets a translation vector
  77205. * @returns the translation vector
  77206. */
  77207. translate(): BABYLON.Vector2;
  77208. private _translatePoint;
  77209. /** Release associated resources */
  77210. dispose(): void;
  77211. }
  77212. }
  77213. declare module BABYLON.GUI {
  77214. /**
  77215. * Class used to create multi line control
  77216. */
  77217. export class MultiLine extends Control {
  77218. name?: string | undefined;
  77219. private _lineWidth;
  77220. private _dash;
  77221. private _points;
  77222. private _minX;
  77223. private _minY;
  77224. private _maxX;
  77225. private _maxY;
  77226. /**
  77227. * Creates a new MultiLine
  77228. * @param name defines the control name
  77229. */
  77230. constructor(name?: string | undefined);
  77231. /** Gets or sets dash pattern */
  77232. get dash(): Array<number>;
  77233. set dash(value: Array<number>);
  77234. /**
  77235. * Gets point stored at specified index
  77236. * @param index defines the index to look for
  77237. * @returns the requested point if found
  77238. */
  77239. getAt(index: number): MultiLinePoint;
  77240. /** Function called when a point is updated */
  77241. onPointUpdate: () => void;
  77242. /**
  77243. * Adds new points to the point collection
  77244. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77245. * @returns the list of created MultiLinePoint
  77246. */
  77247. add(...items: (AbstractMesh | Control | {
  77248. x: string | number;
  77249. y: string | number;
  77250. })[]): MultiLinePoint[];
  77251. /**
  77252. * Adds a new point to the point collection
  77253. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77254. * @returns the created MultiLinePoint
  77255. */
  77256. push(item?: (AbstractMesh | Control | {
  77257. x: string | number;
  77258. y: string | number;
  77259. })): MultiLinePoint;
  77260. /**
  77261. * Remove a specific value or point from the active point collection
  77262. * @param value defines the value or point to remove
  77263. */
  77264. remove(value: number | MultiLinePoint): void;
  77265. /**
  77266. * Resets this object to initial state (no point)
  77267. */
  77268. reset(): void;
  77269. /**
  77270. * Resets all links
  77271. */
  77272. resetLinks(): void;
  77273. /** Gets or sets line width */
  77274. get lineWidth(): number;
  77275. set lineWidth(value: number);
  77276. set horizontalAlignment(value: number);
  77277. set verticalAlignment(value: number);
  77278. protected _getTypeName(): string;
  77279. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77280. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77281. _measure(): void;
  77282. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77283. dispose(): void;
  77284. }
  77285. }
  77286. declare module BABYLON.GUI {
  77287. /**
  77288. * Class used to create radio button controls
  77289. */
  77290. export class RadioButton extends Control {
  77291. name?: string | undefined;
  77292. private _isChecked;
  77293. private _background;
  77294. private _checkSizeRatio;
  77295. private _thickness;
  77296. /** Gets or sets border thickness */
  77297. get thickness(): number;
  77298. set thickness(value: number);
  77299. /** Gets or sets group name */
  77300. group: string;
  77301. /** BABYLON.Observable raised when isChecked is changed */
  77302. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77303. /** Gets or sets a value indicating the ratio between overall size and check size */
  77304. get checkSizeRatio(): number;
  77305. set checkSizeRatio(value: number);
  77306. /** Gets or sets background color */
  77307. get background(): string;
  77308. set background(value: string);
  77309. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77310. get isChecked(): boolean;
  77311. set isChecked(value: boolean);
  77312. /**
  77313. * Creates a new RadioButton
  77314. * @param name defines the control name
  77315. */
  77316. constructor(name?: string | undefined);
  77317. protected _getTypeName(): string;
  77318. _draw(context: CanvasRenderingContext2D): void;
  77319. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77320. /**
  77321. * Utility function to easily create a radio button with a header
  77322. * @param title defines the label to use for the header
  77323. * @param group defines the group to use for the radio button
  77324. * @param isChecked defines the initial state of the radio button
  77325. * @param onValueChanged defines the callback to call when value changes
  77326. * @returns a StackPanel containing the radio button and a textBlock
  77327. */
  77328. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77329. }
  77330. }
  77331. declare module BABYLON.GUI {
  77332. /**
  77333. * Class used to create slider controls
  77334. */
  77335. export class BaseSlider extends Control {
  77336. name?: string | undefined;
  77337. protected _thumbWidth: ValueAndUnit;
  77338. private _minimum;
  77339. private _maximum;
  77340. private _value;
  77341. private _isVertical;
  77342. protected _barOffset: ValueAndUnit;
  77343. private _isThumbClamped;
  77344. protected _displayThumb: boolean;
  77345. private _step;
  77346. private _lastPointerDownID;
  77347. protected _effectiveBarOffset: number;
  77348. protected _renderLeft: number;
  77349. protected _renderTop: number;
  77350. protected _renderWidth: number;
  77351. protected _renderHeight: number;
  77352. protected _backgroundBoxLength: number;
  77353. protected _backgroundBoxThickness: number;
  77354. protected _effectiveThumbThickness: number;
  77355. /** BABYLON.Observable raised when the sldier value changes */
  77356. onValueChangedObservable: BABYLON.Observable<number>;
  77357. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77358. get displayThumb(): boolean;
  77359. set displayThumb(value: boolean);
  77360. /** Gets or sets a step to apply to values (0 by default) */
  77361. get step(): number;
  77362. set step(value: number);
  77363. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77364. get barOffset(): string | number;
  77365. /** Gets main bar offset in pixels*/
  77366. get barOffsetInPixels(): number;
  77367. set barOffset(value: string | number);
  77368. /** Gets or sets thumb width */
  77369. get thumbWidth(): string | number;
  77370. /** Gets thumb width in pixels */
  77371. get thumbWidthInPixels(): number;
  77372. set thumbWidth(value: string | number);
  77373. /** Gets or sets minimum value */
  77374. get minimum(): number;
  77375. set minimum(value: number);
  77376. /** Gets or sets maximum value */
  77377. get maximum(): number;
  77378. set maximum(value: number);
  77379. /** Gets or sets current value */
  77380. get value(): number;
  77381. set value(value: number);
  77382. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77383. get isVertical(): boolean;
  77384. set isVertical(value: boolean);
  77385. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77386. get isThumbClamped(): boolean;
  77387. set isThumbClamped(value: boolean);
  77388. /**
  77389. * Creates a new BaseSlider
  77390. * @param name defines the control name
  77391. */
  77392. constructor(name?: string | undefined);
  77393. protected _getTypeName(): string;
  77394. protected _getThumbPosition(): number;
  77395. protected _getThumbThickness(type: string): number;
  77396. protected _prepareRenderingData(type: string): void;
  77397. private _pointerIsDown;
  77398. /** @hidden */
  77399. protected _updateValueFromPointer(x: number, y: number): void;
  77400. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77401. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77402. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77403. }
  77404. }
  77405. declare module BABYLON.GUI {
  77406. /**
  77407. * Class used to create slider controls
  77408. */
  77409. export class Slider extends BaseSlider {
  77410. name?: string | undefined;
  77411. private _background;
  77412. private _borderColor;
  77413. private _isThumbCircle;
  77414. protected _displayValueBar: boolean;
  77415. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77416. get displayValueBar(): boolean;
  77417. set displayValueBar(value: boolean);
  77418. /** Gets or sets border color */
  77419. get borderColor(): string;
  77420. set borderColor(value: string);
  77421. /** Gets or sets background color */
  77422. get background(): string;
  77423. set background(value: string);
  77424. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77425. get isThumbCircle(): boolean;
  77426. set isThumbCircle(value: boolean);
  77427. /**
  77428. * Creates a new Slider
  77429. * @param name defines the control name
  77430. */
  77431. constructor(name?: string | undefined);
  77432. protected _getTypeName(): string;
  77433. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77434. }
  77435. }
  77436. declare module BABYLON.GUI {
  77437. /** Class used to create a RadioGroup
  77438. * which contains groups of radio buttons
  77439. */
  77440. export class SelectorGroup {
  77441. /** name of SelectorGroup */
  77442. name: string;
  77443. private _groupPanel;
  77444. private _selectors;
  77445. private _groupHeader;
  77446. /**
  77447. * Creates a new SelectorGroup
  77448. * @param name of group, used as a group heading
  77449. */
  77450. constructor(
  77451. /** name of SelectorGroup */
  77452. name: string);
  77453. /** Gets the groupPanel of the SelectorGroup */
  77454. get groupPanel(): StackPanel;
  77455. /** Gets the selectors array */
  77456. get selectors(): StackPanel[];
  77457. /** Gets and sets the group header */
  77458. get header(): string;
  77459. set header(label: string);
  77460. /** @hidden */
  77461. private _addGroupHeader;
  77462. /** @hidden*/
  77463. _getSelector(selectorNb: number): StackPanel | undefined;
  77464. /** Removes the selector at the given position
  77465. * @param selectorNb the position of the selector within the group
  77466. */
  77467. removeSelector(selectorNb: number): void;
  77468. }
  77469. /** Class used to create a CheckboxGroup
  77470. * which contains groups of checkbox buttons
  77471. */
  77472. export class CheckboxGroup extends SelectorGroup {
  77473. /** Adds a checkbox as a control
  77474. * @param text is the label for the selector
  77475. * @param func is the function called when the Selector is checked
  77476. * @param checked is true when Selector is checked
  77477. */
  77478. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77479. /** @hidden */
  77480. _setSelectorLabel(selectorNb: number, label: string): void;
  77481. /** @hidden */
  77482. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77483. /** @hidden */
  77484. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77485. /** @hidden */
  77486. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77487. }
  77488. /** Class used to create a RadioGroup
  77489. * which contains groups of radio buttons
  77490. */
  77491. export class RadioGroup extends SelectorGroup {
  77492. private _selectNb;
  77493. /** Adds a radio button as a control
  77494. * @param label is the label for the selector
  77495. * @param func is the function called when the Selector is checked
  77496. * @param checked is true when Selector is checked
  77497. */
  77498. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77499. /** @hidden */
  77500. _setSelectorLabel(selectorNb: number, label: string): void;
  77501. /** @hidden */
  77502. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77503. /** @hidden */
  77504. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77505. /** @hidden */
  77506. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77507. }
  77508. /** Class used to create a SliderGroup
  77509. * which contains groups of slider buttons
  77510. */
  77511. export class SliderGroup extends SelectorGroup {
  77512. /**
  77513. * Adds a slider to the SelectorGroup
  77514. * @param label is the label for the SliderBar
  77515. * @param func is the function called when the Slider moves
  77516. * @param unit is a string describing the units used, eg degrees or metres
  77517. * @param min is the minimum value for the Slider
  77518. * @param max is the maximum value for the Slider
  77519. * @param value is the start value for the Slider between min and max
  77520. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77521. */
  77522. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77523. /** @hidden */
  77524. _setSelectorLabel(selectorNb: number, label: string): void;
  77525. /** @hidden */
  77526. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77527. /** @hidden */
  77528. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77529. /** @hidden */
  77530. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77531. }
  77532. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77533. * @see https://doc.babylonjs.com/how_to/selector
  77534. */
  77535. export class SelectionPanel extends Rectangle {
  77536. /** name of SelectionPanel */
  77537. name: string;
  77538. /** an array of SelectionGroups */
  77539. groups: SelectorGroup[];
  77540. private _panel;
  77541. private _buttonColor;
  77542. private _buttonBackground;
  77543. private _headerColor;
  77544. private _barColor;
  77545. private _barHeight;
  77546. private _spacerHeight;
  77547. private _labelColor;
  77548. private _groups;
  77549. private _bars;
  77550. /**
  77551. * Creates a new SelectionPanel
  77552. * @param name of SelectionPanel
  77553. * @param groups is an array of SelectionGroups
  77554. */
  77555. constructor(
  77556. /** name of SelectionPanel */
  77557. name: string,
  77558. /** an array of SelectionGroups */
  77559. groups?: SelectorGroup[]);
  77560. protected _getTypeName(): string;
  77561. /** Gets or sets the headerColor */
  77562. get headerColor(): string;
  77563. set headerColor(color: string);
  77564. private _setHeaderColor;
  77565. /** Gets or sets the button color */
  77566. get buttonColor(): string;
  77567. set buttonColor(color: string);
  77568. private _setbuttonColor;
  77569. /** Gets or sets the label color */
  77570. get labelColor(): string;
  77571. set labelColor(color: string);
  77572. private _setLabelColor;
  77573. /** Gets or sets the button background */
  77574. get buttonBackground(): string;
  77575. set buttonBackground(color: string);
  77576. private _setButtonBackground;
  77577. /** Gets or sets the color of separator bar */
  77578. get barColor(): string;
  77579. set barColor(color: string);
  77580. private _setBarColor;
  77581. /** Gets or sets the height of separator bar */
  77582. get barHeight(): string;
  77583. set barHeight(value: string);
  77584. private _setBarHeight;
  77585. /** Gets or sets the height of spacers*/
  77586. get spacerHeight(): string;
  77587. set spacerHeight(value: string);
  77588. private _setSpacerHeight;
  77589. /** Adds a bar between groups */
  77590. private _addSpacer;
  77591. /** Add a group to the selection panel
  77592. * @param group is the selector group to add
  77593. */
  77594. addGroup(group: SelectorGroup): void;
  77595. /** Remove the group from the given position
  77596. * @param groupNb is the position of the group in the list
  77597. */
  77598. removeGroup(groupNb: number): void;
  77599. /** Change a group header label
  77600. * @param label is the new group header label
  77601. * @param groupNb is the number of the group to relabel
  77602. * */
  77603. setHeaderName(label: string, groupNb: number): void;
  77604. /** Change selector label to the one given
  77605. * @param label is the new selector label
  77606. * @param groupNb is the number of the groupcontaining the selector
  77607. * @param selectorNb is the number of the selector within a group to relabel
  77608. * */
  77609. relabel(label: string, groupNb: number, selectorNb: number): void;
  77610. /** For a given group position remove the selector at the given position
  77611. * @param groupNb is the number of the group to remove the selector from
  77612. * @param selectorNb is the number of the selector within the group
  77613. */
  77614. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77615. /** For a given group position of correct type add a checkbox button
  77616. * @param groupNb is the number of the group to remove the selector from
  77617. * @param label is the label for the selector
  77618. * @param func is the function called when the Selector is checked
  77619. * @param checked is true when Selector is checked
  77620. */
  77621. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77622. /** For a given group position of correct type add a radio button
  77623. * @param groupNb is the number of the group to remove the selector from
  77624. * @param label is the label for the selector
  77625. * @param func is the function called when the Selector is checked
  77626. * @param checked is true when Selector is checked
  77627. */
  77628. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77629. /**
  77630. * For a given slider group add a slider
  77631. * @param groupNb is the number of the group to add the slider to
  77632. * @param label is the label for the Slider
  77633. * @param func is the function called when the Slider moves
  77634. * @param unit is a string describing the units used, eg degrees or metres
  77635. * @param min is the minimum value for the Slider
  77636. * @param max is the maximum value for the Slider
  77637. * @param value is the start value for the Slider between min and max
  77638. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77639. */
  77640. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77641. }
  77642. }
  77643. declare module BABYLON.GUI {
  77644. /**
  77645. * Class used to hold a the container for ScrollViewer
  77646. * @hidden
  77647. */
  77648. export class _ScrollViewerWindow extends Container {
  77649. parentClientWidth: number;
  77650. parentClientHeight: number;
  77651. private _freezeControls;
  77652. private _parentMeasure;
  77653. private _oldLeft;
  77654. private _oldTop;
  77655. get freezeControls(): boolean;
  77656. set freezeControls(value: boolean);
  77657. private _bucketWidth;
  77658. private _bucketHeight;
  77659. private _buckets;
  77660. private _bucketLen;
  77661. get bucketWidth(): number;
  77662. get bucketHeight(): number;
  77663. setBucketSizes(width: number, height: number): void;
  77664. private _useBuckets;
  77665. private _makeBuckets;
  77666. private _dispatchInBuckets;
  77667. private _updateMeasures;
  77668. private _updateChildrenMeasures;
  77669. private _restoreMeasures;
  77670. /**
  77671. * Creates a new ScrollViewerWindow
  77672. * @param name of ScrollViewerWindow
  77673. */
  77674. constructor(name?: string);
  77675. protected _getTypeName(): string;
  77676. /** @hidden */
  77677. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77678. /** @hidden */
  77679. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77680. private _scrollChildren;
  77681. private _scrollChildrenWithBuckets;
  77682. /** @hidden */
  77683. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77684. protected _postMeasure(): void;
  77685. }
  77686. }
  77687. declare module BABYLON.GUI {
  77688. /**
  77689. * Class used to create slider controls
  77690. */
  77691. export class ScrollBar extends BaseSlider {
  77692. name?: string | undefined;
  77693. private _background;
  77694. private _borderColor;
  77695. private _tempMeasure;
  77696. /** Gets or sets border color */
  77697. get borderColor(): string;
  77698. set borderColor(value: string);
  77699. /** Gets or sets background color */
  77700. get background(): string;
  77701. set background(value: string);
  77702. /**
  77703. * Creates a new Slider
  77704. * @param name defines the control name
  77705. */
  77706. constructor(name?: string | undefined);
  77707. protected _getTypeName(): string;
  77708. protected _getThumbThickness(): number;
  77709. _draw(context: CanvasRenderingContext2D): void;
  77710. private _first;
  77711. private _originX;
  77712. private _originY;
  77713. /** @hidden */
  77714. protected _updateValueFromPointer(x: number, y: number): void;
  77715. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77716. }
  77717. }
  77718. declare module BABYLON.GUI {
  77719. /**
  77720. * Class used to create slider controls
  77721. */
  77722. export class ImageScrollBar extends BaseSlider {
  77723. name?: string | undefined;
  77724. private _backgroundBaseImage;
  77725. private _backgroundImage;
  77726. private _thumbImage;
  77727. private _thumbBaseImage;
  77728. private _thumbLength;
  77729. private _thumbHeight;
  77730. private _barImageHeight;
  77731. private _tempMeasure;
  77732. /** Number of 90° rotation to apply on the images when in vertical mode */
  77733. num90RotationInVerticalMode: number;
  77734. /**
  77735. * Gets or sets the image used to render the background for horizontal bar
  77736. */
  77737. get backgroundImage(): Image;
  77738. set backgroundImage(value: Image);
  77739. /**
  77740. * Gets or sets the image used to render the thumb
  77741. */
  77742. get thumbImage(): Image;
  77743. set thumbImage(value: Image);
  77744. /**
  77745. * Gets or sets the length of the thumb
  77746. */
  77747. get thumbLength(): number;
  77748. set thumbLength(value: number);
  77749. /**
  77750. * Gets or sets the height of the thumb
  77751. */
  77752. get thumbHeight(): number;
  77753. set thumbHeight(value: number);
  77754. /**
  77755. * Gets or sets the height of the bar image
  77756. */
  77757. get barImageHeight(): number;
  77758. set barImageHeight(value: number);
  77759. /**
  77760. * Creates a new ImageScrollBar
  77761. * @param name defines the control name
  77762. */
  77763. constructor(name?: string | undefined);
  77764. protected _getTypeName(): string;
  77765. protected _getThumbThickness(): number;
  77766. _draw(context: CanvasRenderingContext2D): void;
  77767. private _first;
  77768. private _originX;
  77769. private _originY;
  77770. /** @hidden */
  77771. protected _updateValueFromPointer(x: number, y: number): void;
  77772. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77773. }
  77774. }
  77775. declare module BABYLON.GUI {
  77776. /**
  77777. * Class used to hold a viewer window and sliders in a grid
  77778. */
  77779. export class ScrollViewer extends Rectangle {
  77780. private _grid;
  77781. private _horizontalBarSpace;
  77782. private _verticalBarSpace;
  77783. private _dragSpace;
  77784. private _horizontalBar;
  77785. private _verticalBar;
  77786. private _barColor;
  77787. private _barBackground;
  77788. private _barImage;
  77789. private _horizontalBarImage;
  77790. private _verticalBarImage;
  77791. private _barBackgroundImage;
  77792. private _horizontalBarBackgroundImage;
  77793. private _verticalBarBackgroundImage;
  77794. private _barSize;
  77795. private _window;
  77796. private _pointerIsOver;
  77797. private _wheelPrecision;
  77798. private _onWheelObserver;
  77799. private _clientWidth;
  77800. private _clientHeight;
  77801. private _useImageBar;
  77802. private _thumbLength;
  77803. private _thumbHeight;
  77804. private _barImageHeight;
  77805. private _horizontalBarImageHeight;
  77806. private _verticalBarImageHeight;
  77807. private _oldWindowContentsWidth;
  77808. private _oldWindowContentsHeight;
  77809. /**
  77810. * Gets the horizontal scrollbar
  77811. */
  77812. get horizontalBar(): ScrollBar | ImageScrollBar;
  77813. /**
  77814. * Gets the vertical scrollbar
  77815. */
  77816. get verticalBar(): ScrollBar | ImageScrollBar;
  77817. /**
  77818. * Adds a new control to the current container
  77819. * @param control defines the control to add
  77820. * @returns the current container
  77821. */
  77822. addControl(control: BABYLON.Nullable<Control>): Container;
  77823. /**
  77824. * Removes a control from the current container
  77825. * @param control defines the control to remove
  77826. * @returns the current container
  77827. */
  77828. removeControl(control: Control): Container;
  77829. /** Gets the list of children */
  77830. get children(): Control[];
  77831. _flagDescendantsAsMatrixDirty(): void;
  77832. /**
  77833. * Freezes or unfreezes the controls in the window.
  77834. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77835. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77836. */
  77837. get freezeControls(): boolean;
  77838. set freezeControls(value: boolean);
  77839. /** Gets the bucket width */
  77840. get bucketWidth(): number;
  77841. /** Gets the bucket height */
  77842. get bucketHeight(): number;
  77843. /**
  77844. * Sets the bucket sizes.
  77845. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77846. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77847. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77848. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77849. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77850. * used), that's why it is not enabled by default.
  77851. * @param width width of the bucket
  77852. * @param height height of the bucket
  77853. */
  77854. setBucketSizes(width: number, height: number): void;
  77855. private _forceHorizontalBar;
  77856. private _forceVerticalBar;
  77857. /**
  77858. * Forces the horizontal scroll bar to be displayed
  77859. */
  77860. get forceHorizontalBar(): boolean;
  77861. set forceHorizontalBar(value: boolean);
  77862. /**
  77863. * Forces the vertical scroll bar to be displayed
  77864. */
  77865. get forceVerticalBar(): boolean;
  77866. set forceVerticalBar(value: boolean);
  77867. /**
  77868. * Creates a new ScrollViewer
  77869. * @param name of ScrollViewer
  77870. */
  77871. constructor(name?: string, isImageBased?: boolean);
  77872. /** Reset the scroll viewer window to initial size */
  77873. resetWindow(): void;
  77874. protected _getTypeName(): string;
  77875. private _buildClientSizes;
  77876. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77877. protected _postMeasure(): void;
  77878. /**
  77879. * Gets or sets the mouse wheel precision
  77880. * from 0 to 1 with a default value of 0.05
  77881. * */
  77882. get wheelPrecision(): number;
  77883. set wheelPrecision(value: number);
  77884. /** Gets or sets the scroll bar container background color */
  77885. get scrollBackground(): string;
  77886. set scrollBackground(color: string);
  77887. /** Gets or sets the bar color */
  77888. get barColor(): string;
  77889. set barColor(color: string);
  77890. /** Gets or sets the bar image */
  77891. get thumbImage(): Image;
  77892. set thumbImage(value: Image);
  77893. /** Gets or sets the horizontal bar image */
  77894. get horizontalThumbImage(): Image;
  77895. set horizontalThumbImage(value: Image);
  77896. /** Gets or sets the vertical bar image */
  77897. get verticalThumbImage(): Image;
  77898. set verticalThumbImage(value: Image);
  77899. /** Gets or sets the size of the bar */
  77900. get barSize(): number;
  77901. set barSize(value: number);
  77902. /** Gets or sets the length of the thumb */
  77903. get thumbLength(): number;
  77904. set thumbLength(value: number);
  77905. /** Gets or sets the height of the thumb */
  77906. get thumbHeight(): number;
  77907. set thumbHeight(value: number);
  77908. /** Gets or sets the height of the bar image */
  77909. get barImageHeight(): number;
  77910. set barImageHeight(value: number);
  77911. /** Gets or sets the height of the horizontal bar image */
  77912. get horizontalBarImageHeight(): number;
  77913. set horizontalBarImageHeight(value: number);
  77914. /** Gets or sets the height of the vertical bar image */
  77915. get verticalBarImageHeight(): number;
  77916. set verticalBarImageHeight(value: number);
  77917. /** Gets or sets the bar background */
  77918. get barBackground(): string;
  77919. set barBackground(color: string);
  77920. /** Gets or sets the bar background image */
  77921. get barImage(): Image;
  77922. set barImage(value: Image);
  77923. /** Gets or sets the horizontal bar background image */
  77924. get horizontalBarImage(): Image;
  77925. set horizontalBarImage(value: Image);
  77926. /** Gets or sets the vertical bar background image */
  77927. get verticalBarImage(): Image;
  77928. set verticalBarImage(value: Image);
  77929. private _setWindowPosition;
  77930. /** @hidden */
  77931. private _updateScroller;
  77932. _link(host: AdvancedDynamicTexture): void;
  77933. /** @hidden */
  77934. private _addBar;
  77935. /** @hidden */
  77936. private _attachWheel;
  77937. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77938. /** Releases associated resources */
  77939. dispose(): void;
  77940. }
  77941. }
  77942. declare module BABYLON.GUI {
  77943. /** Class used to render a grid */
  77944. export class DisplayGrid extends Control {
  77945. name?: string | undefined;
  77946. private _cellWidth;
  77947. private _cellHeight;
  77948. private _minorLineTickness;
  77949. private _minorLineColor;
  77950. private _majorLineTickness;
  77951. private _majorLineColor;
  77952. private _majorLineFrequency;
  77953. private _background;
  77954. private _displayMajorLines;
  77955. private _displayMinorLines;
  77956. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77957. get displayMinorLines(): boolean;
  77958. set displayMinorLines(value: boolean);
  77959. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77960. get displayMajorLines(): boolean;
  77961. set displayMajorLines(value: boolean);
  77962. /** Gets or sets background color (Black by default) */
  77963. get background(): string;
  77964. set background(value: string);
  77965. /** Gets or sets the width of each cell (20 by default) */
  77966. get cellWidth(): number;
  77967. set cellWidth(value: number);
  77968. /** Gets or sets the height of each cell (20 by default) */
  77969. get cellHeight(): number;
  77970. set cellHeight(value: number);
  77971. /** Gets or sets the tickness of minor lines (1 by default) */
  77972. get minorLineTickness(): number;
  77973. set minorLineTickness(value: number);
  77974. /** Gets or sets the color of minor lines (DarkGray by default) */
  77975. get minorLineColor(): string;
  77976. set minorLineColor(value: string);
  77977. /** Gets or sets the tickness of major lines (2 by default) */
  77978. get majorLineTickness(): number;
  77979. set majorLineTickness(value: number);
  77980. /** Gets or sets the color of major lines (White by default) */
  77981. get majorLineColor(): string;
  77982. set majorLineColor(value: string);
  77983. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77984. get majorLineFrequency(): number;
  77985. set majorLineFrequency(value: number);
  77986. /**
  77987. * Creates a new GridDisplayRectangle
  77988. * @param name defines the control name
  77989. */
  77990. constructor(name?: string | undefined);
  77991. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77992. protected _getTypeName(): string;
  77993. }
  77994. }
  77995. declare module BABYLON.GUI {
  77996. /**
  77997. * Class used to create slider controls based on images
  77998. */
  77999. export class ImageBasedSlider extends BaseSlider {
  78000. name?: string | undefined;
  78001. private _backgroundImage;
  78002. private _thumbImage;
  78003. private _valueBarImage;
  78004. private _tempMeasure;
  78005. get displayThumb(): boolean;
  78006. set displayThumb(value: boolean);
  78007. /**
  78008. * Gets or sets the image used to render the background
  78009. */
  78010. get backgroundImage(): Image;
  78011. set backgroundImage(value: Image);
  78012. /**
  78013. * Gets or sets the image used to render the value bar
  78014. */
  78015. get valueBarImage(): Image;
  78016. set valueBarImage(value: Image);
  78017. /**
  78018. * Gets or sets the image used to render the thumb
  78019. */
  78020. get thumbImage(): Image;
  78021. set thumbImage(value: Image);
  78022. /**
  78023. * Creates a new ImageBasedSlider
  78024. * @param name defines the control name
  78025. */
  78026. constructor(name?: string | undefined);
  78027. protected _getTypeName(): string;
  78028. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78029. }
  78030. }
  78031. declare module BABYLON.GUI {
  78032. /**
  78033. * Forcing an export so that this code will execute
  78034. * @hidden
  78035. */
  78036. const name = "Statics";
  78037. }
  78038. declare module BABYLON.GUI {
  78039. /**
  78040. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78041. */
  78042. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78043. /**
  78044. * Define the instrumented AdvancedDynamicTexture.
  78045. */
  78046. texture: AdvancedDynamicTexture;
  78047. private _captureRenderTime;
  78048. private _renderTime;
  78049. private _captureLayoutTime;
  78050. private _layoutTime;
  78051. private _onBeginRenderObserver;
  78052. private _onEndRenderObserver;
  78053. private _onBeginLayoutObserver;
  78054. private _onEndLayoutObserver;
  78055. /**
  78056. * Gets the perf counter used to capture render time
  78057. */
  78058. get renderTimeCounter(): BABYLON.PerfCounter;
  78059. /**
  78060. * Gets the perf counter used to capture layout time
  78061. */
  78062. get layoutTimeCounter(): BABYLON.PerfCounter;
  78063. /**
  78064. * Enable or disable the render time capture
  78065. */
  78066. get captureRenderTime(): boolean;
  78067. set captureRenderTime(value: boolean);
  78068. /**
  78069. * Enable or disable the layout time capture
  78070. */
  78071. get captureLayoutTime(): boolean;
  78072. set captureLayoutTime(value: boolean);
  78073. /**
  78074. * Instantiates a new advanced dynamic texture instrumentation.
  78075. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78076. * @param texture Defines the AdvancedDynamicTexture to instrument
  78077. */
  78078. constructor(
  78079. /**
  78080. * Define the instrumented AdvancedDynamicTexture.
  78081. */
  78082. texture: AdvancedDynamicTexture);
  78083. /**
  78084. * Dispose and release associated resources.
  78085. */
  78086. dispose(): void;
  78087. }
  78088. }
  78089. declare module BABYLON.GUI {
  78090. /**
  78091. * Class used to load GUI via XML.
  78092. */
  78093. export class XmlLoader {
  78094. private _nodes;
  78095. private _nodeTypes;
  78096. private _isLoaded;
  78097. private _objectAttributes;
  78098. private _parentClass;
  78099. /**
  78100. * Create a new xml loader
  78101. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78102. */
  78103. constructor(parentClass?: null);
  78104. private _getChainElement;
  78105. private _getClassAttribute;
  78106. private _createGuiElement;
  78107. private _parseGrid;
  78108. private _parseElement;
  78109. private _prepareSourceElement;
  78110. private _parseElementsFromSource;
  78111. private _parseXml;
  78112. /**
  78113. * Gets if the loading has finished.
  78114. * @returns whether the loading has finished or not
  78115. */
  78116. isLoaded(): boolean;
  78117. /**
  78118. * Gets a loaded node / control by id.
  78119. * @param id the Controls id set in the xml
  78120. * @returns element of type Control
  78121. */
  78122. getNodeById(id: string): any;
  78123. /**
  78124. * Gets all loaded nodes / controls
  78125. * @returns Array of controls
  78126. */
  78127. getNodes(): any;
  78128. /**
  78129. * Initiates the xml layout loading
  78130. * @param xmlFile defines the xml layout to load
  78131. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78132. * @param callback defines the callback called on layout load.
  78133. */
  78134. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78135. }
  78136. }
  78137. declare module BABYLON.GUI {
  78138. /**
  78139. * Class used to create containers for controls
  78140. */
  78141. export class Container3D extends Control3D {
  78142. private _blockLayout;
  78143. /**
  78144. * Gets the list of child controls
  78145. */
  78146. protected _children: Control3D[];
  78147. /**
  78148. * Gets the list of child controls
  78149. */
  78150. get children(): Array<Control3D>;
  78151. /**
  78152. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78153. * This is helpful to optimize layout operation when adding multiple children in a row
  78154. */
  78155. get blockLayout(): boolean;
  78156. set blockLayout(value: boolean);
  78157. /**
  78158. * Creates a new container
  78159. * @param name defines the container name
  78160. */
  78161. constructor(name?: string);
  78162. /**
  78163. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78164. * @returns the current container
  78165. */
  78166. updateLayout(): Container3D;
  78167. /**
  78168. * Gets a boolean indicating if the given control is in the children of this control
  78169. * @param control defines the control to check
  78170. * @returns true if the control is in the child list
  78171. */
  78172. containsControl(control: Control3D): boolean;
  78173. /**
  78174. * Adds a control to the children of this control
  78175. * @param control defines the control to add
  78176. * @returns the current container
  78177. */
  78178. addControl(control: Control3D): Container3D;
  78179. /**
  78180. * This function will be called everytime a new control is added
  78181. */
  78182. protected _arrangeChildren(): void;
  78183. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78184. /**
  78185. * Removes a control from the children of this control
  78186. * @param control defines the control to remove
  78187. * @returns the current container
  78188. */
  78189. removeControl(control: Control3D): Container3D;
  78190. protected _getTypeName(): string;
  78191. /**
  78192. * Releases all associated resources
  78193. */
  78194. dispose(): void;
  78195. /** Control rotation will remain unchanged */
  78196. static readonly UNSET_ORIENTATION: number;
  78197. /** Control will rotate to make it look at sphere central axis */
  78198. static readonly FACEORIGIN_ORIENTATION: number;
  78199. /** Control will rotate to make it look back at sphere central axis */
  78200. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78201. /** Control will rotate to look at z axis (0, 0, 1) */
  78202. static readonly FACEFORWARD_ORIENTATION: number;
  78203. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78204. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78205. }
  78206. }
  78207. declare module BABYLON.GUI {
  78208. /**
  78209. * Class used to manage 3D user interface
  78210. * @see https://doc.babylonjs.com/how_to/gui3d
  78211. */
  78212. export class GUI3DManager implements BABYLON.IDisposable {
  78213. private _scene;
  78214. private _sceneDisposeObserver;
  78215. private _utilityLayer;
  78216. private _rootContainer;
  78217. private _pointerObserver;
  78218. private _pointerOutObserver;
  78219. /** @hidden */
  78220. _lastPickedControl: Control3D;
  78221. /** @hidden */
  78222. _lastControlOver: {
  78223. [pointerId: number]: Control3D;
  78224. };
  78225. /** @hidden */
  78226. _lastControlDown: {
  78227. [pointerId: number]: Control3D;
  78228. };
  78229. /**
  78230. * BABYLON.Observable raised when the point picked by the pointer events changed
  78231. */
  78232. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78233. /** @hidden */
  78234. _sharedMaterials: {
  78235. [key: string]: BABYLON.Material;
  78236. };
  78237. /** Gets the hosting scene */
  78238. get scene(): BABYLON.Scene;
  78239. /** Gets associated utility layer */
  78240. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78241. /**
  78242. * Creates a new GUI3DManager
  78243. * @param scene
  78244. */
  78245. constructor(scene?: BABYLON.Scene);
  78246. private _handlePointerOut;
  78247. private _doPicking;
  78248. /**
  78249. * Gets the root container
  78250. */
  78251. get rootContainer(): Container3D;
  78252. /**
  78253. * Gets a boolean indicating if the given control is in the root child list
  78254. * @param control defines the control to check
  78255. * @returns true if the control is in the root child list
  78256. */
  78257. containsControl(control: Control3D): boolean;
  78258. /**
  78259. * Adds a control to the root child list
  78260. * @param control defines the control to add
  78261. * @returns the current manager
  78262. */
  78263. addControl(control: Control3D): GUI3DManager;
  78264. /**
  78265. * Removes a control from the root child list
  78266. * @param control defines the control to remove
  78267. * @returns the current container
  78268. */
  78269. removeControl(control: Control3D): GUI3DManager;
  78270. /**
  78271. * Releases all associated resources
  78272. */
  78273. dispose(): void;
  78274. }
  78275. }
  78276. declare module BABYLON.GUI {
  78277. /**
  78278. * Class used to transport BABYLON.Vector3 information for pointer events
  78279. */
  78280. export class Vector3WithInfo extends BABYLON.Vector3 {
  78281. /** defines the current mouse button index */
  78282. buttonIndex: number;
  78283. /**
  78284. * Creates a new Vector3WithInfo
  78285. * @param source defines the vector3 data to transport
  78286. * @param buttonIndex defines the current mouse button index
  78287. */
  78288. constructor(source: BABYLON.Vector3,
  78289. /** defines the current mouse button index */
  78290. buttonIndex?: number);
  78291. }
  78292. }
  78293. declare module BABYLON.GUI {
  78294. /**
  78295. * Class used as base class for controls
  78296. */
  78297. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78298. /** Defines the control name */
  78299. name?: string | undefined;
  78300. /** @hidden */
  78301. _host: GUI3DManager;
  78302. private _node;
  78303. private _downCount;
  78304. private _enterCount;
  78305. private _downPointerIds;
  78306. private _isVisible;
  78307. /** Gets or sets the control position in world space */
  78308. get position(): BABYLON.Vector3;
  78309. set position(value: BABYLON.Vector3);
  78310. /** Gets or sets the control scaling in world space */
  78311. get scaling(): BABYLON.Vector3;
  78312. set scaling(value: BABYLON.Vector3);
  78313. /** Callback used to start pointer enter animation */
  78314. pointerEnterAnimation: () => void;
  78315. /** Callback used to start pointer out animation */
  78316. pointerOutAnimation: () => void;
  78317. /** Callback used to start pointer down animation */
  78318. pointerDownAnimation: () => void;
  78319. /** Callback used to start pointer up animation */
  78320. pointerUpAnimation: () => void;
  78321. /**
  78322. * An event triggered when the pointer move over the control
  78323. */
  78324. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78325. /**
  78326. * An event triggered when the pointer move out of the control
  78327. */
  78328. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78329. /**
  78330. * An event triggered when the pointer taps the control
  78331. */
  78332. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78333. /**
  78334. * An event triggered when pointer is up
  78335. */
  78336. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78337. /**
  78338. * An event triggered when a control is clicked on (with a mouse)
  78339. */
  78340. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78341. /**
  78342. * An event triggered when pointer enters the control
  78343. */
  78344. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78345. /**
  78346. * Gets or sets the parent container
  78347. */
  78348. parent: BABYLON.Nullable<Container3D>;
  78349. private _behaviors;
  78350. /**
  78351. * Gets the list of attached behaviors
  78352. * @see https://doc.babylonjs.com/features/behaviour
  78353. */
  78354. get behaviors(): BABYLON.Behavior<Control3D>[];
  78355. /**
  78356. * Attach a behavior to the control
  78357. * @see https://doc.babylonjs.com/features/behaviour
  78358. * @param behavior defines the behavior to attach
  78359. * @returns the current control
  78360. */
  78361. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78362. /**
  78363. * Remove an attached behavior
  78364. * @see https://doc.babylonjs.com/features/behaviour
  78365. * @param behavior defines the behavior to attach
  78366. * @returns the current control
  78367. */
  78368. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78369. /**
  78370. * Gets an attached behavior by name
  78371. * @param name defines the name of the behavior to look for
  78372. * @see https://doc.babylonjs.com/features/behaviour
  78373. * @returns null if behavior was not found else the requested behavior
  78374. */
  78375. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78376. /** Gets or sets a boolean indicating if the control is visible */
  78377. get isVisible(): boolean;
  78378. set isVisible(value: boolean);
  78379. /**
  78380. * Creates a new control
  78381. * @param name defines the control name
  78382. */
  78383. constructor(
  78384. /** Defines the control name */
  78385. name?: string | undefined);
  78386. /**
  78387. * Gets a string representing the class name
  78388. */
  78389. get typeName(): string;
  78390. /**
  78391. * Get the current class name of the control.
  78392. * @returns current class name
  78393. */
  78394. getClassName(): string;
  78395. protected _getTypeName(): string;
  78396. /**
  78397. * Gets the transform node used by this control
  78398. */
  78399. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78400. /**
  78401. * Gets the mesh used to render this control
  78402. */
  78403. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78404. /**
  78405. * Link the control as child of the given node
  78406. * @param node defines the node to link to. Use null to unlink the control
  78407. * @returns the current control
  78408. */
  78409. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78410. /** @hidden **/
  78411. _prepareNode(scene: BABYLON.Scene): void;
  78412. /**
  78413. * Node creation.
  78414. * Can be overriden by children
  78415. * @param scene defines the scene where the node must be attached
  78416. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78417. */
  78418. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78419. /**
  78420. * Affect a material to the given mesh
  78421. * @param mesh defines the mesh which will represent the control
  78422. */
  78423. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78424. /** @hidden */
  78425. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78426. /** @hidden */
  78427. _onPointerEnter(target: Control3D): boolean;
  78428. /** @hidden */
  78429. _onPointerOut(target: Control3D): void;
  78430. /** @hidden */
  78431. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78432. /** @hidden */
  78433. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78434. /** @hidden */
  78435. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78436. /** @hidden */
  78437. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78438. /** @hidden */
  78439. _disposeNode(): void;
  78440. /**
  78441. * Releases all associated resources
  78442. */
  78443. dispose(): void;
  78444. }
  78445. }
  78446. declare module BABYLON.GUI {
  78447. /**
  78448. * Class used as a root to all buttons
  78449. */
  78450. export class AbstractButton3D extends Control3D {
  78451. /**
  78452. * Creates a new button
  78453. * @param name defines the control name
  78454. */
  78455. constructor(name?: string);
  78456. protected _getTypeName(): string;
  78457. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78458. }
  78459. }
  78460. declare module BABYLON.GUI {
  78461. /**
  78462. * Class used to create a button in 3D
  78463. */
  78464. export class Button3D extends AbstractButton3D {
  78465. /** @hidden */
  78466. protected _currentMaterial: BABYLON.Material;
  78467. private _facadeTexture;
  78468. private _content;
  78469. private _contentResolution;
  78470. private _contentScaleRatio;
  78471. /**
  78472. * Gets or sets the texture resolution used to render content (512 by default)
  78473. */
  78474. get contentResolution(): BABYLON.int;
  78475. set contentResolution(value: BABYLON.int);
  78476. /**
  78477. * Gets or sets the texture scale ratio used to render content (2 by default)
  78478. */
  78479. get contentScaleRatio(): number;
  78480. set contentScaleRatio(value: number);
  78481. protected _disposeFacadeTexture(): void;
  78482. protected _resetContent(): void;
  78483. /**
  78484. * Creates a new button
  78485. * @param name defines the control name
  78486. */
  78487. constructor(name?: string);
  78488. /**
  78489. * Gets or sets the GUI 2D content used to display the button's facade
  78490. */
  78491. get content(): Control;
  78492. set content(value: Control);
  78493. /**
  78494. * Apply the facade texture (created from the content property).
  78495. * This function can be overloaded by child classes
  78496. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78497. */
  78498. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78499. protected _getTypeName(): string;
  78500. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78501. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78502. /**
  78503. * Releases all associated resources
  78504. */
  78505. dispose(): void;
  78506. }
  78507. }
  78508. declare module BABYLON.GUI {
  78509. /**
  78510. * Abstract class used to create a container panel deployed on the surface of a volume
  78511. */
  78512. export abstract class VolumeBasedPanel extends Container3D {
  78513. private _columns;
  78514. private _rows;
  78515. private _rowThenColum;
  78516. private _orientation;
  78517. protected _cellWidth: number;
  78518. protected _cellHeight: number;
  78519. /**
  78520. * Gets or sets the distance between elements
  78521. */
  78522. margin: number;
  78523. /**
  78524. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78525. * | Value | Type | Description |
  78526. * | ----- | ----------------------------------- | ----------- |
  78527. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78528. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78529. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78530. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78531. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78532. */
  78533. get orientation(): number;
  78534. set orientation(value: number);
  78535. /**
  78536. * Gets or sets the number of columns requested (10 by default).
  78537. * The panel will automatically compute the number of rows based on number of child controls.
  78538. */
  78539. get columns(): BABYLON.int;
  78540. set columns(value: BABYLON.int);
  78541. /**
  78542. * Gets or sets a the number of rows requested.
  78543. * The panel will automatically compute the number of columns based on number of child controls.
  78544. */
  78545. get rows(): BABYLON.int;
  78546. set rows(value: BABYLON.int);
  78547. /**
  78548. * Creates new VolumeBasedPanel
  78549. */
  78550. constructor();
  78551. protected _arrangeChildren(): void;
  78552. /** Child classes must implement this function to provide correct control positioning */
  78553. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78554. /** Child classes can implement this function to provide additional processing */
  78555. protected _finalProcessing(): void;
  78556. }
  78557. }
  78558. declare module BABYLON.GUI {
  78559. /**
  78560. * Class used to create a container panel deployed on the surface of a cylinder
  78561. */
  78562. export class CylinderPanel extends VolumeBasedPanel {
  78563. private _radius;
  78564. /**
  78565. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78566. */
  78567. get radius(): BABYLON.float;
  78568. set radius(value: BABYLON.float);
  78569. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78570. private _cylindricalMapping;
  78571. }
  78572. }
  78573. declare module BABYLON.GUI {
  78574. /** @hidden */
  78575. export var fluentVertexShader: {
  78576. name: string;
  78577. shader: string;
  78578. };
  78579. }
  78580. declare module BABYLON.GUI {
  78581. /** @hidden */
  78582. export var fluentPixelShader: {
  78583. name: string;
  78584. shader: string;
  78585. };
  78586. }
  78587. declare module BABYLON.GUI {
  78588. /** @hidden */
  78589. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78590. INNERGLOW: boolean;
  78591. BORDER: boolean;
  78592. HOVERLIGHT: boolean;
  78593. TEXTURE: boolean;
  78594. constructor();
  78595. }
  78596. /**
  78597. * Class used to render controls with fluent desgin
  78598. */
  78599. export class FluentMaterial extends BABYLON.PushMaterial {
  78600. /**
  78601. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78602. */
  78603. innerGlowColorIntensity: number;
  78604. /**
  78605. * Gets or sets the inner glow color (white by default)
  78606. */
  78607. innerGlowColor: BABYLON.Color3;
  78608. /**
  78609. * Gets or sets alpha value (default is 1.0)
  78610. */
  78611. alpha: number;
  78612. /**
  78613. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78614. */
  78615. albedoColor: BABYLON.Color3;
  78616. /**
  78617. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78618. */
  78619. renderBorders: boolean;
  78620. /**
  78621. * Gets or sets border width (default is 0.5)
  78622. */
  78623. borderWidth: number;
  78624. /**
  78625. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78626. */
  78627. edgeSmoothingValue: number;
  78628. /**
  78629. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78630. */
  78631. borderMinValue: number;
  78632. /**
  78633. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78634. */
  78635. renderHoverLight: boolean;
  78636. /**
  78637. * Gets or sets the radius used to render the hover light (default is 1.0)
  78638. */
  78639. hoverRadius: number;
  78640. /**
  78641. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78642. */
  78643. hoverColor: BABYLON.Color4;
  78644. /**
  78645. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78646. */
  78647. hoverPosition: BABYLON.Vector3;
  78648. private _albedoTexture;
  78649. /** Gets or sets the texture to use for albedo color */
  78650. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78651. /**
  78652. * Creates a new Fluent material
  78653. * @param name defines the name of the material
  78654. * @param scene defines the hosting scene
  78655. */
  78656. constructor(name: string, scene: BABYLON.Scene);
  78657. needAlphaBlending(): boolean;
  78658. needAlphaTesting(): boolean;
  78659. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78660. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78661. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78662. getActiveTextures(): BABYLON.BaseTexture[];
  78663. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78664. dispose(forceDisposeEffect?: boolean): void;
  78665. clone(name: string): FluentMaterial;
  78666. serialize(): any;
  78667. getClassName(): string;
  78668. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78669. }
  78670. }
  78671. declare module BABYLON.GUI {
  78672. /**
  78673. * Class used to create a holographic button in 3D
  78674. */
  78675. export class HolographicButton extends Button3D {
  78676. private _backPlate;
  78677. private _textPlate;
  78678. private _frontPlate;
  78679. private _text;
  78680. private _imageUrl;
  78681. private _shareMaterials;
  78682. private _frontMaterial;
  78683. private _backMaterial;
  78684. private _plateMaterial;
  78685. private _pickedPointObserver;
  78686. private _tooltipFade;
  78687. private _tooltipTextBlock;
  78688. private _tooltipTexture;
  78689. private _tooltipMesh;
  78690. private _tooltipHoverObserver;
  78691. private _tooltipOutObserver;
  78692. private _disposeTooltip;
  78693. /**
  78694. * Rendering ground id of all the mesh in the button
  78695. */
  78696. set renderingGroupId(id: number);
  78697. get renderingGroupId(): number;
  78698. /**
  78699. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78700. */
  78701. set tooltipText(text: BABYLON.Nullable<string>);
  78702. get tooltipText(): BABYLON.Nullable<string>;
  78703. /**
  78704. * Gets or sets text for the button
  78705. */
  78706. get text(): string;
  78707. set text(value: string);
  78708. /**
  78709. * Gets or sets the image url for the button
  78710. */
  78711. get imageUrl(): string;
  78712. set imageUrl(value: string);
  78713. /**
  78714. * Gets the back material used by this button
  78715. */
  78716. get backMaterial(): FluentMaterial;
  78717. /**
  78718. * Gets the front material used by this button
  78719. */
  78720. get frontMaterial(): FluentMaterial;
  78721. /**
  78722. * Gets the plate material used by this button
  78723. */
  78724. get plateMaterial(): BABYLON.StandardMaterial;
  78725. /**
  78726. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78727. */
  78728. get shareMaterials(): boolean;
  78729. /**
  78730. * Creates a new button
  78731. * @param name defines the control name
  78732. */
  78733. constructor(name?: string, shareMaterials?: boolean);
  78734. protected _getTypeName(): string;
  78735. private _rebuildContent;
  78736. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78737. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78738. private _createBackMaterial;
  78739. private _createFrontMaterial;
  78740. private _createPlateMaterial;
  78741. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78742. /**
  78743. * Releases all associated resources
  78744. */
  78745. dispose(): void;
  78746. }
  78747. }
  78748. declare module BABYLON.GUI {
  78749. /**
  78750. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78751. */
  78752. export class MeshButton3D extends Button3D {
  78753. /** @hidden */
  78754. protected _currentMesh: BABYLON.Mesh;
  78755. /**
  78756. * Creates a new 3D button based on a mesh
  78757. * @param mesh mesh to become a 3D button
  78758. * @param name defines the control name
  78759. */
  78760. constructor(mesh: BABYLON.Mesh, name?: string);
  78761. protected _getTypeName(): string;
  78762. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78763. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78764. }
  78765. }
  78766. declare module BABYLON.GUI {
  78767. /**
  78768. * Class used to create a container panel deployed on the surface of a plane
  78769. */
  78770. export class PlanePanel extends VolumeBasedPanel {
  78771. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78772. }
  78773. }
  78774. declare module BABYLON.GUI {
  78775. /**
  78776. * Class used to create a container panel where items get randomized planar mapping
  78777. */
  78778. export class ScatterPanel extends VolumeBasedPanel {
  78779. private _iteration;
  78780. /**
  78781. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78782. */
  78783. get iteration(): BABYLON.float;
  78784. set iteration(value: BABYLON.float);
  78785. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78786. private _scatterMapping;
  78787. protected _finalProcessing(): void;
  78788. }
  78789. }
  78790. declare module BABYLON.GUI {
  78791. /**
  78792. * Class used to create a container panel deployed on the surface of a sphere
  78793. */
  78794. export class SpherePanel extends VolumeBasedPanel {
  78795. private _radius;
  78796. /**
  78797. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78798. */
  78799. get radius(): BABYLON.float;
  78800. set radius(value: BABYLON.float);
  78801. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78802. private _sphericalMapping;
  78803. }
  78804. }
  78805. declare module BABYLON.GUI {
  78806. /**
  78807. * Class used to create a stack panel in 3D on XY plane
  78808. */
  78809. export class StackPanel3D extends Container3D {
  78810. private _isVertical;
  78811. /**
  78812. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78813. */
  78814. get isVertical(): boolean;
  78815. set isVertical(value: boolean);
  78816. /**
  78817. * Gets or sets the distance between elements
  78818. */
  78819. margin: number;
  78820. /**
  78821. * Creates new StackPanel
  78822. * @param isVertical
  78823. */
  78824. constructor(isVertical?: boolean);
  78825. protected _arrangeChildren(): void;
  78826. }
  78827. }
  78828. declare module BABYLON {
  78829. /**
  78830. * Configuration for glTF validation
  78831. */
  78832. export interface IGLTFValidationConfiguration {
  78833. /**
  78834. * The url of the glTF validator.
  78835. */
  78836. url: string;
  78837. }
  78838. /**
  78839. * glTF validation
  78840. */
  78841. export class GLTFValidation {
  78842. /**
  78843. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78844. */
  78845. static Configuration: IGLTFValidationConfiguration;
  78846. private static _LoadScriptPromise;
  78847. /**
  78848. * Validate a glTF asset using the glTF-Validator.
  78849. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78850. * @param rootUrl The root url for the glTF
  78851. * @param fileName The file name for the glTF
  78852. * @param getExternalResource The callback to get external resources for the glTF validator
  78853. * @returns A promise that resolves with the glTF validation results once complete
  78854. */
  78855. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78856. }
  78857. }
  78858. declare module BABYLON {
  78859. /**
  78860. * Mode that determines the coordinate system to use.
  78861. */
  78862. export enum GLTFLoaderCoordinateSystemMode {
  78863. /**
  78864. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78865. */
  78866. AUTO = 0,
  78867. /**
  78868. * Sets the useRightHandedSystem flag on the scene.
  78869. */
  78870. FORCE_RIGHT_HANDED = 1
  78871. }
  78872. /**
  78873. * Mode that determines what animations will start.
  78874. */
  78875. export enum GLTFLoaderAnimationStartMode {
  78876. /**
  78877. * No animation will start.
  78878. */
  78879. NONE = 0,
  78880. /**
  78881. * The first animation will start.
  78882. */
  78883. FIRST = 1,
  78884. /**
  78885. * All animations will start.
  78886. */
  78887. ALL = 2
  78888. }
  78889. /**
  78890. * Interface that contains the data for the glTF asset.
  78891. */
  78892. export interface IGLTFLoaderData {
  78893. /**
  78894. * The object that represents the glTF JSON.
  78895. */
  78896. json: Object;
  78897. /**
  78898. * The BIN chunk of a binary glTF.
  78899. */
  78900. bin: Nullable<IDataBuffer>;
  78901. }
  78902. /**
  78903. * Interface for extending the loader.
  78904. */
  78905. export interface IGLTFLoaderExtension {
  78906. /**
  78907. * The name of this extension.
  78908. */
  78909. readonly name: string;
  78910. /**
  78911. * Defines whether this extension is enabled.
  78912. */
  78913. enabled: boolean;
  78914. /**
  78915. * Defines the order of this extension.
  78916. * The loader sorts the extensions using these values when loading.
  78917. */
  78918. order?: number;
  78919. }
  78920. /**
  78921. * Loader state.
  78922. */
  78923. export enum GLTFLoaderState {
  78924. /**
  78925. * The asset is loading.
  78926. */
  78927. LOADING = 0,
  78928. /**
  78929. * The asset is ready for rendering.
  78930. */
  78931. READY = 1,
  78932. /**
  78933. * The asset is completely loaded.
  78934. */
  78935. COMPLETE = 2
  78936. }
  78937. /** @hidden */
  78938. export interface IImportMeshAsyncOutput {
  78939. meshes: AbstractMesh[];
  78940. particleSystems: IParticleSystem[];
  78941. skeletons: Skeleton[];
  78942. animationGroups: AnimationGroup[];
  78943. lights: Light[];
  78944. transformNodes: TransformNode[];
  78945. }
  78946. /** @hidden */
  78947. export interface IGLTFLoader extends IDisposable {
  78948. readonly state: Nullable<GLTFLoaderState>;
  78949. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78950. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78951. }
  78952. /**
  78953. * File loader for loading glTF files into a scene.
  78954. */
  78955. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78956. /** @hidden */
  78957. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78958. /** @hidden */
  78959. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78960. /**
  78961. * Raised when the asset has been parsed
  78962. */
  78963. onParsedObservable: Observable<IGLTFLoaderData>;
  78964. private _onParsedObserver;
  78965. /**
  78966. * Raised when the asset has been parsed
  78967. */
  78968. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78969. /**
  78970. * 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.
  78971. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78972. * Defaults to true.
  78973. * @hidden
  78974. */
  78975. static IncrementalLoading: boolean;
  78976. /**
  78977. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78978. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78979. * @hidden
  78980. */
  78981. static HomogeneousCoordinates: boolean;
  78982. /**
  78983. * The coordinate system mode. Defaults to AUTO.
  78984. */
  78985. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78986. /**
  78987. * The animation start mode. Defaults to FIRST.
  78988. */
  78989. animationStartMode: GLTFLoaderAnimationStartMode;
  78990. /**
  78991. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78992. */
  78993. compileMaterials: boolean;
  78994. /**
  78995. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78996. */
  78997. useClipPlane: boolean;
  78998. /**
  78999. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79000. */
  79001. compileShadowGenerators: boolean;
  79002. /**
  79003. * Defines if the Alpha blended materials are only applied as coverage.
  79004. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79005. * If true, no extra effects are applied to transparent pixels.
  79006. */
  79007. transparencyAsCoverage: boolean;
  79008. /**
  79009. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79010. * Enabling will disable offline support and glTF validator.
  79011. * Defaults to false.
  79012. */
  79013. useRangeRequests: boolean;
  79014. /**
  79015. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79016. */
  79017. createInstances: boolean;
  79018. /**
  79019. * 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.
  79020. */
  79021. alwaysComputeBoundingBox: boolean;
  79022. /**
  79023. * Function called before loading a url referenced by the asset.
  79024. */
  79025. preprocessUrlAsync: (url: string) => Promise<string>;
  79026. /**
  79027. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79028. */
  79029. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79030. private _onMeshLoadedObserver;
  79031. /**
  79032. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79033. */
  79034. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79035. /**
  79036. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79037. */
  79038. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79039. private _onTextureLoadedObserver;
  79040. /**
  79041. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79042. */
  79043. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79044. /**
  79045. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79046. */
  79047. readonly onMaterialLoadedObservable: Observable<Material>;
  79048. private _onMaterialLoadedObserver;
  79049. /**
  79050. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79051. */
  79052. set onMaterialLoaded(callback: (material: Material) => void);
  79053. /**
  79054. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79055. */
  79056. readonly onCameraLoadedObservable: Observable<Camera>;
  79057. private _onCameraLoadedObserver;
  79058. /**
  79059. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79060. */
  79061. set onCameraLoaded(callback: (camera: Camera) => void);
  79062. /**
  79063. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79064. * For assets with LODs, raised when all of the LODs are complete.
  79065. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79066. */
  79067. readonly onCompleteObservable: Observable<void>;
  79068. private _onCompleteObserver;
  79069. /**
  79070. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79071. * For assets with LODs, raised when all of the LODs are complete.
  79072. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79073. */
  79074. set onComplete(callback: () => void);
  79075. /**
  79076. * Observable raised when an error occurs.
  79077. */
  79078. readonly onErrorObservable: Observable<any>;
  79079. private _onErrorObserver;
  79080. /**
  79081. * Callback raised when an error occurs.
  79082. */
  79083. set onError(callback: (reason: any) => void);
  79084. /**
  79085. * Observable raised after the loader is disposed.
  79086. */
  79087. readonly onDisposeObservable: Observable<void>;
  79088. private _onDisposeObserver;
  79089. /**
  79090. * Callback raised after the loader is disposed.
  79091. */
  79092. set onDispose(callback: () => void);
  79093. /**
  79094. * Observable raised after a loader extension is created.
  79095. * Set additional options for a loader extension in this event.
  79096. */
  79097. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79098. private _onExtensionLoadedObserver;
  79099. /**
  79100. * Callback raised after a loader extension is created.
  79101. */
  79102. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79103. /**
  79104. * Defines if the loader logging is enabled.
  79105. */
  79106. get loggingEnabled(): boolean;
  79107. set loggingEnabled(value: boolean);
  79108. /**
  79109. * Defines if the loader should capture performance counters.
  79110. */
  79111. get capturePerformanceCounters(): boolean;
  79112. set capturePerformanceCounters(value: boolean);
  79113. /**
  79114. * Defines if the loader should validate the asset.
  79115. */
  79116. validate: boolean;
  79117. /**
  79118. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79119. */
  79120. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79121. private _onValidatedObserver;
  79122. /**
  79123. * Callback raised after a loader extension is created.
  79124. */
  79125. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79126. private _loader;
  79127. private _progressCallback?;
  79128. private _requests;
  79129. private static magicBase64Encoded;
  79130. /**
  79131. * Name of the loader ("gltf")
  79132. */
  79133. name: string;
  79134. /** @hidden */
  79135. extensions: ISceneLoaderPluginExtensions;
  79136. /**
  79137. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79138. */
  79139. dispose(): void;
  79140. /** @hidden */
  79141. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79142. /** @hidden */
  79143. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79144. /** @hidden */
  79145. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79146. meshes: AbstractMesh[];
  79147. particleSystems: IParticleSystem[];
  79148. skeletons: Skeleton[];
  79149. animationGroups: AnimationGroup[];
  79150. }>;
  79151. /** @hidden */
  79152. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79153. /** @hidden */
  79154. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79155. /** @hidden */
  79156. canDirectLoad(data: string): boolean;
  79157. /** @hidden */
  79158. directLoad(scene: Scene, data: string): Promise<any>;
  79159. /**
  79160. * The callback that allows custom handling of the root url based on the response url.
  79161. * @param rootUrl the original root url
  79162. * @param responseURL the response url if available
  79163. * @returns the new root url
  79164. */
  79165. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79166. /** @hidden */
  79167. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79168. /**
  79169. * The loader state or null if the loader is not active.
  79170. */
  79171. get loaderState(): Nullable<GLTFLoaderState>;
  79172. /**
  79173. * Returns a promise that resolves when the asset is completely loaded.
  79174. * @returns a promise that resolves when the asset is completely loaded.
  79175. */
  79176. whenCompleteAsync(): Promise<void>;
  79177. /** @hidden */
  79178. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79179. /** @hidden */
  79180. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79181. private _onProgress;
  79182. private _validate;
  79183. private _getLoader;
  79184. private _parseJson;
  79185. private _unpackBinaryAsync;
  79186. private _unpackBinaryV1Async;
  79187. private _unpackBinaryV2Async;
  79188. private static _parseVersion;
  79189. private static _compareVersion;
  79190. private static readonly _logSpaces;
  79191. private _logIndentLevel;
  79192. private _loggingEnabled;
  79193. /** @hidden */
  79194. _log: (message: string) => void;
  79195. /** @hidden */
  79196. _logOpen(message: string): void;
  79197. /** @hidden */
  79198. _logClose(): void;
  79199. private _logEnabled;
  79200. private _logDisabled;
  79201. private _capturePerformanceCounters;
  79202. /** @hidden */
  79203. _startPerformanceCounter: (counterName: string) => void;
  79204. /** @hidden */
  79205. _endPerformanceCounter: (counterName: string) => void;
  79206. private _startPerformanceCounterEnabled;
  79207. private _startPerformanceCounterDisabled;
  79208. private _endPerformanceCounterEnabled;
  79209. private _endPerformanceCounterDisabled;
  79210. }
  79211. }
  79212. declare module BABYLON.GLTF1 {
  79213. /**
  79214. * Enums
  79215. * @hidden
  79216. */
  79217. export enum EComponentType {
  79218. BYTE = 5120,
  79219. UNSIGNED_BYTE = 5121,
  79220. SHORT = 5122,
  79221. UNSIGNED_SHORT = 5123,
  79222. FLOAT = 5126
  79223. }
  79224. /** @hidden */
  79225. export enum EShaderType {
  79226. FRAGMENT = 35632,
  79227. VERTEX = 35633
  79228. }
  79229. /** @hidden */
  79230. export enum EParameterType {
  79231. BYTE = 5120,
  79232. UNSIGNED_BYTE = 5121,
  79233. SHORT = 5122,
  79234. UNSIGNED_SHORT = 5123,
  79235. INT = 5124,
  79236. UNSIGNED_INT = 5125,
  79237. FLOAT = 5126,
  79238. FLOAT_VEC2 = 35664,
  79239. FLOAT_VEC3 = 35665,
  79240. FLOAT_VEC4 = 35666,
  79241. INT_VEC2 = 35667,
  79242. INT_VEC3 = 35668,
  79243. INT_VEC4 = 35669,
  79244. BOOL = 35670,
  79245. BOOL_VEC2 = 35671,
  79246. BOOL_VEC3 = 35672,
  79247. BOOL_VEC4 = 35673,
  79248. FLOAT_MAT2 = 35674,
  79249. FLOAT_MAT3 = 35675,
  79250. FLOAT_MAT4 = 35676,
  79251. SAMPLER_2D = 35678
  79252. }
  79253. /** @hidden */
  79254. export enum ETextureWrapMode {
  79255. CLAMP_TO_EDGE = 33071,
  79256. MIRRORED_REPEAT = 33648,
  79257. REPEAT = 10497
  79258. }
  79259. /** @hidden */
  79260. export enum ETextureFilterType {
  79261. NEAREST = 9728,
  79262. LINEAR = 9728,
  79263. NEAREST_MIPMAP_NEAREST = 9984,
  79264. LINEAR_MIPMAP_NEAREST = 9985,
  79265. NEAREST_MIPMAP_LINEAR = 9986,
  79266. LINEAR_MIPMAP_LINEAR = 9987
  79267. }
  79268. /** @hidden */
  79269. export enum ETextureFormat {
  79270. ALPHA = 6406,
  79271. RGB = 6407,
  79272. RGBA = 6408,
  79273. LUMINANCE = 6409,
  79274. LUMINANCE_ALPHA = 6410
  79275. }
  79276. /** @hidden */
  79277. export enum ECullingType {
  79278. FRONT = 1028,
  79279. BACK = 1029,
  79280. FRONT_AND_BACK = 1032
  79281. }
  79282. /** @hidden */
  79283. export enum EBlendingFunction {
  79284. ZERO = 0,
  79285. ONE = 1,
  79286. SRC_COLOR = 768,
  79287. ONE_MINUS_SRC_COLOR = 769,
  79288. DST_COLOR = 774,
  79289. ONE_MINUS_DST_COLOR = 775,
  79290. SRC_ALPHA = 770,
  79291. ONE_MINUS_SRC_ALPHA = 771,
  79292. DST_ALPHA = 772,
  79293. ONE_MINUS_DST_ALPHA = 773,
  79294. CONSTANT_COLOR = 32769,
  79295. ONE_MINUS_CONSTANT_COLOR = 32770,
  79296. CONSTANT_ALPHA = 32771,
  79297. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79298. SRC_ALPHA_SATURATE = 776
  79299. }
  79300. /** @hidden */
  79301. export interface IGLTFProperty {
  79302. extensions?: {
  79303. [key: string]: any;
  79304. };
  79305. extras?: Object;
  79306. }
  79307. /** @hidden */
  79308. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79309. name?: string;
  79310. }
  79311. /** @hidden */
  79312. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79313. bufferView: string;
  79314. byteOffset: number;
  79315. byteStride: number;
  79316. count: number;
  79317. type: string;
  79318. componentType: EComponentType;
  79319. max?: number[];
  79320. min?: number[];
  79321. name?: string;
  79322. }
  79323. /** @hidden */
  79324. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79325. buffer: string;
  79326. byteOffset: number;
  79327. byteLength: number;
  79328. byteStride: number;
  79329. target?: number;
  79330. }
  79331. /** @hidden */
  79332. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79333. uri: string;
  79334. byteLength?: number;
  79335. type?: string;
  79336. }
  79337. /** @hidden */
  79338. export interface IGLTFShader extends IGLTFChildRootProperty {
  79339. uri: string;
  79340. type: EShaderType;
  79341. }
  79342. /** @hidden */
  79343. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79344. attributes: string[];
  79345. fragmentShader: string;
  79346. vertexShader: string;
  79347. }
  79348. /** @hidden */
  79349. export interface IGLTFTechniqueParameter {
  79350. type: number;
  79351. count?: number;
  79352. semantic?: string;
  79353. node?: string;
  79354. value?: number | boolean | string | Array<any>;
  79355. source?: string;
  79356. babylonValue?: any;
  79357. }
  79358. /** @hidden */
  79359. export interface IGLTFTechniqueCommonProfile {
  79360. lightingModel: string;
  79361. texcoordBindings: Object;
  79362. parameters?: Array<any>;
  79363. }
  79364. /** @hidden */
  79365. export interface IGLTFTechniqueStatesFunctions {
  79366. blendColor?: number[];
  79367. blendEquationSeparate?: number[];
  79368. blendFuncSeparate?: number[];
  79369. colorMask: boolean[];
  79370. cullFace: number[];
  79371. }
  79372. /** @hidden */
  79373. export interface IGLTFTechniqueStates {
  79374. enable: number[];
  79375. functions: IGLTFTechniqueStatesFunctions;
  79376. }
  79377. /** @hidden */
  79378. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79379. parameters: {
  79380. [key: string]: IGLTFTechniqueParameter;
  79381. };
  79382. program: string;
  79383. attributes: {
  79384. [key: string]: string;
  79385. };
  79386. uniforms: {
  79387. [key: string]: string;
  79388. };
  79389. states: IGLTFTechniqueStates;
  79390. }
  79391. /** @hidden */
  79392. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79393. technique?: string;
  79394. values: string[];
  79395. }
  79396. /** @hidden */
  79397. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79398. attributes: {
  79399. [key: string]: string;
  79400. };
  79401. indices: string;
  79402. material: string;
  79403. mode?: number;
  79404. }
  79405. /** @hidden */
  79406. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79407. primitives: IGLTFMeshPrimitive[];
  79408. }
  79409. /** @hidden */
  79410. export interface IGLTFImage extends IGLTFChildRootProperty {
  79411. uri: string;
  79412. }
  79413. /** @hidden */
  79414. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79415. magFilter?: number;
  79416. minFilter?: number;
  79417. wrapS?: number;
  79418. wrapT?: number;
  79419. }
  79420. /** @hidden */
  79421. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79422. sampler: string;
  79423. source: string;
  79424. format?: ETextureFormat;
  79425. internalFormat?: ETextureFormat;
  79426. target?: number;
  79427. type?: number;
  79428. babylonTexture?: Texture;
  79429. }
  79430. /** @hidden */
  79431. export interface IGLTFAmbienLight {
  79432. color?: number[];
  79433. }
  79434. /** @hidden */
  79435. export interface IGLTFDirectionalLight {
  79436. color?: number[];
  79437. }
  79438. /** @hidden */
  79439. export interface IGLTFPointLight {
  79440. color?: number[];
  79441. constantAttenuation?: number;
  79442. linearAttenuation?: number;
  79443. quadraticAttenuation?: number;
  79444. }
  79445. /** @hidden */
  79446. export interface IGLTFSpotLight {
  79447. color?: number[];
  79448. constantAttenuation?: number;
  79449. fallOfAngle?: number;
  79450. fallOffExponent?: number;
  79451. linearAttenuation?: number;
  79452. quadraticAttenuation?: number;
  79453. }
  79454. /** @hidden */
  79455. export interface IGLTFLight extends IGLTFChildRootProperty {
  79456. type: string;
  79457. }
  79458. /** @hidden */
  79459. export interface IGLTFCameraOrthographic {
  79460. xmag: number;
  79461. ymag: number;
  79462. zfar: number;
  79463. znear: number;
  79464. }
  79465. /** @hidden */
  79466. export interface IGLTFCameraPerspective {
  79467. aspectRatio: number;
  79468. yfov: number;
  79469. zfar: number;
  79470. znear: number;
  79471. }
  79472. /** @hidden */
  79473. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79474. type: string;
  79475. }
  79476. /** @hidden */
  79477. export interface IGLTFAnimationChannelTarget {
  79478. id: string;
  79479. path: string;
  79480. }
  79481. /** @hidden */
  79482. export interface IGLTFAnimationChannel {
  79483. sampler: string;
  79484. target: IGLTFAnimationChannelTarget;
  79485. }
  79486. /** @hidden */
  79487. export interface IGLTFAnimationSampler {
  79488. input: string;
  79489. output: string;
  79490. interpolation?: string;
  79491. }
  79492. /** @hidden */
  79493. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79494. channels?: IGLTFAnimationChannel[];
  79495. parameters?: {
  79496. [key: string]: string;
  79497. };
  79498. samplers?: {
  79499. [key: string]: IGLTFAnimationSampler;
  79500. };
  79501. }
  79502. /** @hidden */
  79503. export interface IGLTFNodeInstanceSkin {
  79504. skeletons: string[];
  79505. skin: string;
  79506. meshes: string[];
  79507. }
  79508. /** @hidden */
  79509. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79510. bindShapeMatrix: number[];
  79511. inverseBindMatrices: string;
  79512. jointNames: string[];
  79513. babylonSkeleton?: Skeleton;
  79514. }
  79515. /** @hidden */
  79516. export interface IGLTFNode extends IGLTFChildRootProperty {
  79517. camera?: string;
  79518. children: string[];
  79519. skin?: string;
  79520. jointName?: string;
  79521. light?: string;
  79522. matrix: number[];
  79523. mesh?: string;
  79524. meshes?: string[];
  79525. rotation?: number[];
  79526. scale?: number[];
  79527. translation?: number[];
  79528. babylonNode?: Node;
  79529. }
  79530. /** @hidden */
  79531. export interface IGLTFScene extends IGLTFChildRootProperty {
  79532. nodes: string[];
  79533. }
  79534. /** @hidden */
  79535. export interface IGLTFRuntime {
  79536. extensions: {
  79537. [key: string]: any;
  79538. };
  79539. accessors: {
  79540. [key: string]: IGLTFAccessor;
  79541. };
  79542. buffers: {
  79543. [key: string]: IGLTFBuffer;
  79544. };
  79545. bufferViews: {
  79546. [key: string]: IGLTFBufferView;
  79547. };
  79548. meshes: {
  79549. [key: string]: IGLTFMesh;
  79550. };
  79551. lights: {
  79552. [key: string]: IGLTFLight;
  79553. };
  79554. cameras: {
  79555. [key: string]: IGLTFCamera;
  79556. };
  79557. nodes: {
  79558. [key: string]: IGLTFNode;
  79559. };
  79560. images: {
  79561. [key: string]: IGLTFImage;
  79562. };
  79563. textures: {
  79564. [key: string]: IGLTFTexture;
  79565. };
  79566. shaders: {
  79567. [key: string]: IGLTFShader;
  79568. };
  79569. programs: {
  79570. [key: string]: IGLTFProgram;
  79571. };
  79572. samplers: {
  79573. [key: string]: IGLTFSampler;
  79574. };
  79575. techniques: {
  79576. [key: string]: IGLTFTechnique;
  79577. };
  79578. materials: {
  79579. [key: string]: IGLTFMaterial;
  79580. };
  79581. animations: {
  79582. [key: string]: IGLTFAnimation;
  79583. };
  79584. skins: {
  79585. [key: string]: IGLTFSkins;
  79586. };
  79587. currentScene?: Object;
  79588. scenes: {
  79589. [key: string]: IGLTFScene;
  79590. };
  79591. extensionsUsed: string[];
  79592. extensionsRequired?: string[];
  79593. buffersCount: number;
  79594. shaderscount: number;
  79595. scene: Scene;
  79596. rootUrl: string;
  79597. loadedBufferCount: number;
  79598. loadedBufferViews: {
  79599. [name: string]: ArrayBufferView;
  79600. };
  79601. loadedShaderCount: number;
  79602. importOnlyMeshes: boolean;
  79603. importMeshesNames?: string[];
  79604. dummyNodes: Node[];
  79605. forAssetContainer: boolean;
  79606. }
  79607. /** @hidden */
  79608. export interface INodeToRoot {
  79609. bone: Bone;
  79610. node: IGLTFNode;
  79611. id: string;
  79612. }
  79613. /** @hidden */
  79614. export interface IJointNode {
  79615. node: IGLTFNode;
  79616. id: string;
  79617. }
  79618. }
  79619. declare module BABYLON.GLTF1 {
  79620. /**
  79621. * Utils functions for GLTF
  79622. * @hidden
  79623. */
  79624. export class GLTFUtils {
  79625. /**
  79626. * Sets the given "parameter" matrix
  79627. * @param scene: the Scene object
  79628. * @param source: the source node where to pick the matrix
  79629. * @param parameter: the GLTF technique parameter
  79630. * @param uniformName: the name of the shader's uniform
  79631. * @param shaderMaterial: the shader material
  79632. */
  79633. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79634. /**
  79635. * Sets the given "parameter" matrix
  79636. * @param shaderMaterial: the shader material
  79637. * @param uniform: the name of the shader's uniform
  79638. * @param value: the value of the uniform
  79639. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79640. */
  79641. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79642. /**
  79643. * Returns the wrap mode of the texture
  79644. * @param mode: the mode value
  79645. */
  79646. static GetWrapMode(mode: number): number;
  79647. /**
  79648. * Returns the byte stride giving an accessor
  79649. * @param accessor: the GLTF accessor objet
  79650. */
  79651. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79652. /**
  79653. * Returns the texture filter mode giving a mode value
  79654. * @param mode: the filter mode value
  79655. */
  79656. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79657. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79658. /**
  79659. * Returns a buffer from its accessor
  79660. * @param gltfRuntime: the GLTF runtime
  79661. * @param accessor: the GLTF accessor
  79662. */
  79663. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79664. /**
  79665. * Decodes a buffer view into a string
  79666. * @param view: the buffer view
  79667. */
  79668. static DecodeBufferToText(view: ArrayBufferView): string;
  79669. /**
  79670. * Returns the default material of gltf. Related to
  79671. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79672. * @param scene: the Babylon.js scene
  79673. */
  79674. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79675. private static _DefaultMaterial;
  79676. }
  79677. }
  79678. declare module BABYLON.GLTF1 {
  79679. /**
  79680. * Implementation of the base glTF spec
  79681. * @hidden
  79682. */
  79683. export class GLTFLoaderBase {
  79684. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79685. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79686. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79687. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79688. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79689. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79690. }
  79691. /**
  79692. * glTF V1 Loader
  79693. * @hidden
  79694. */
  79695. export class GLTFLoader implements IGLTFLoader {
  79696. static Extensions: {
  79697. [name: string]: GLTFLoaderExtension;
  79698. };
  79699. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79700. state: Nullable<GLTFLoaderState>;
  79701. dispose(): void;
  79702. private _importMeshAsync;
  79703. /**
  79704. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79705. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79706. * @param scene the scene the meshes should be added to
  79707. * @param forAssetContainer defines if the entities must be stored in the scene
  79708. * @param data gltf data containing information of the meshes in a loaded file
  79709. * @param rootUrl root url to load from
  79710. * @param onProgress event that fires when loading progress has occured
  79711. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79712. */
  79713. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79714. private _loadAsync;
  79715. /**
  79716. * Imports all objects from a loaded gltf file and adds them to the scene
  79717. * @param scene the scene the objects should be added to
  79718. * @param data gltf data containing information of the meshes in a loaded file
  79719. * @param rootUrl root url to load from
  79720. * @param onProgress event that fires when loading progress has occured
  79721. * @returns a promise which completes when objects have been loaded to the scene
  79722. */
  79723. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79724. private _loadShadersAsync;
  79725. private _loadBuffersAsync;
  79726. private _createNodes;
  79727. }
  79728. /** @hidden */
  79729. export abstract class GLTFLoaderExtension {
  79730. private _name;
  79731. constructor(name: string);
  79732. get name(): string;
  79733. /**
  79734. * Defines an override for loading the runtime
  79735. * Return true to stop further extensions from loading the runtime
  79736. */
  79737. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79738. /**
  79739. * Defines an onverride for creating gltf runtime
  79740. * Return true to stop further extensions from creating the runtime
  79741. */
  79742. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79743. /**
  79744. * Defines an override for loading buffers
  79745. * Return true to stop further extensions from loading this buffer
  79746. */
  79747. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79748. /**
  79749. * Defines an override for loading texture buffers
  79750. * Return true to stop further extensions from loading this texture data
  79751. */
  79752. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79753. /**
  79754. * Defines an override for creating textures
  79755. * Return true to stop further extensions from loading this texture
  79756. */
  79757. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79758. /**
  79759. * Defines an override for loading shader strings
  79760. * Return true to stop further extensions from loading this shader data
  79761. */
  79762. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79763. /**
  79764. * Defines an override for loading materials
  79765. * Return true to stop further extensions from loading this material
  79766. */
  79767. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79768. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79769. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79770. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79771. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79772. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79773. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79774. private static LoadTextureBufferAsync;
  79775. private static CreateTextureAsync;
  79776. private static ApplyExtensions;
  79777. }
  79778. }
  79779. declare module BABYLON.GLTF1 {
  79780. /** @hidden */
  79781. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79782. private _bin;
  79783. constructor();
  79784. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79785. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79786. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79787. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79788. }
  79789. }
  79790. declare module BABYLON.GLTF1 {
  79791. /** @hidden */
  79792. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79793. constructor();
  79794. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79795. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79796. private _loadTexture;
  79797. }
  79798. }
  79799. declare module BABYLON.GLTF2.Loader {
  79800. /**
  79801. * Loader interface with an index field.
  79802. */
  79803. export interface IArrayItem {
  79804. /**
  79805. * The index of this item in the array.
  79806. */
  79807. index: number;
  79808. }
  79809. /**
  79810. * Loader interface with additional members.
  79811. */
  79812. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79813. /** @hidden */
  79814. _data?: Promise<ArrayBufferView>;
  79815. /** @hidden */
  79816. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79817. }
  79818. /**
  79819. * Loader interface with additional members.
  79820. */
  79821. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79822. }
  79823. /** @hidden */
  79824. export interface _IAnimationSamplerData {
  79825. input: Float32Array;
  79826. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79827. output: Float32Array;
  79828. }
  79829. /**
  79830. * Loader interface with additional members.
  79831. */
  79832. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79833. /** @hidden */
  79834. _data?: Promise<_IAnimationSamplerData>;
  79835. }
  79836. /**
  79837. * Loader interface with additional members.
  79838. */
  79839. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79840. channels: IAnimationChannel[];
  79841. samplers: IAnimationSampler[];
  79842. /** @hidden */
  79843. _babylonAnimationGroup?: AnimationGroup;
  79844. }
  79845. /**
  79846. * Loader interface with additional members.
  79847. */
  79848. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79849. /** @hidden */
  79850. _data?: Promise<ArrayBufferView>;
  79851. }
  79852. /**
  79853. * Loader interface with additional members.
  79854. */
  79855. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79856. /** @hidden */
  79857. _data?: Promise<ArrayBufferView>;
  79858. /** @hidden */
  79859. _babylonBuffer?: Promise<Buffer>;
  79860. }
  79861. /**
  79862. * Loader interface with additional members.
  79863. */
  79864. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79865. }
  79866. /**
  79867. * Loader interface with additional members.
  79868. */
  79869. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79870. /** @hidden */
  79871. _data?: Promise<ArrayBufferView>;
  79872. }
  79873. /**
  79874. * Loader interface with additional members.
  79875. */
  79876. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79877. }
  79878. /**
  79879. * Loader interface with additional members.
  79880. */
  79881. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79882. }
  79883. /**
  79884. * Loader interface with additional members.
  79885. */
  79886. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79887. baseColorTexture?: ITextureInfo;
  79888. metallicRoughnessTexture?: ITextureInfo;
  79889. }
  79890. /**
  79891. * Loader interface with additional members.
  79892. */
  79893. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79894. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79895. normalTexture?: IMaterialNormalTextureInfo;
  79896. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79897. emissiveTexture?: ITextureInfo;
  79898. /** @hidden */
  79899. _data?: {
  79900. [babylonDrawMode: number]: {
  79901. babylonMaterial: Material;
  79902. babylonMeshes: AbstractMesh[];
  79903. promise: Promise<void>;
  79904. };
  79905. };
  79906. }
  79907. /**
  79908. * Loader interface with additional members.
  79909. */
  79910. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79911. primitives: IMeshPrimitive[];
  79912. }
  79913. /**
  79914. * Loader interface with additional members.
  79915. */
  79916. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79917. /** @hidden */
  79918. _instanceData?: {
  79919. babylonSourceMesh: Mesh;
  79920. promise: Promise<any>;
  79921. };
  79922. }
  79923. /**
  79924. * Loader interface with additional members.
  79925. */
  79926. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79927. /**
  79928. * The parent glTF node.
  79929. */
  79930. parent?: INode;
  79931. /** @hidden */
  79932. _babylonTransformNode?: TransformNode;
  79933. /** @hidden */
  79934. _primitiveBabylonMeshes?: AbstractMesh[];
  79935. /** @hidden */
  79936. _babylonBones?: Bone[];
  79937. /** @hidden */
  79938. _numMorphTargets?: number;
  79939. }
  79940. /** @hidden */
  79941. export interface _ISamplerData {
  79942. noMipMaps: boolean;
  79943. samplingMode: number;
  79944. wrapU: number;
  79945. wrapV: number;
  79946. }
  79947. /**
  79948. * Loader interface with additional members.
  79949. */
  79950. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79951. /** @hidden */
  79952. _data?: _ISamplerData;
  79953. }
  79954. /**
  79955. * Loader interface with additional members.
  79956. */
  79957. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79958. }
  79959. /**
  79960. * Loader interface with additional members.
  79961. */
  79962. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79963. /** @hidden */
  79964. _data?: {
  79965. babylonSkeleton: Skeleton;
  79966. promise: Promise<void>;
  79967. };
  79968. }
  79969. /**
  79970. * Loader interface with additional members.
  79971. */
  79972. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79973. }
  79974. /**
  79975. * Loader interface with additional members.
  79976. */
  79977. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79978. }
  79979. /**
  79980. * Loader interface with additional members.
  79981. */
  79982. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79983. accessors?: IAccessor[];
  79984. animations?: IAnimation[];
  79985. buffers?: IBuffer[];
  79986. bufferViews?: IBufferView[];
  79987. cameras?: ICamera[];
  79988. images?: IImage[];
  79989. materials?: IMaterial[];
  79990. meshes?: IMesh[];
  79991. nodes?: INode[];
  79992. samplers?: ISampler[];
  79993. scenes?: IScene[];
  79994. skins?: ISkin[];
  79995. textures?: ITexture[];
  79996. }
  79997. }
  79998. declare module BABYLON.GLTF2 {
  79999. /**
  80000. * Interface for a glTF loader extension.
  80001. */
  80002. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80003. /**
  80004. * Called after the loader state changes to LOADING.
  80005. */
  80006. onLoading?(): void;
  80007. /**
  80008. * Called after the loader state changes to READY.
  80009. */
  80010. onReady?(): void;
  80011. /**
  80012. * Define this method to modify the default behavior when loading scenes.
  80013. * @param context The context when loading the asset
  80014. * @param scene The glTF scene property
  80015. * @returns A promise that resolves when the load is complete or null if not handled
  80016. */
  80017. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80018. /**
  80019. * Define this method to modify the default behavior when loading nodes.
  80020. * @param context The context when loading the asset
  80021. * @param node The glTF node property
  80022. * @param assign A function called synchronously after parsing the glTF properties
  80023. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80024. */
  80025. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80026. /**
  80027. * Define this method to modify the default behavior when loading cameras.
  80028. * @param context The context when loading the asset
  80029. * @param camera The glTF camera property
  80030. * @param assign A function called synchronously after parsing the glTF properties
  80031. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80032. */
  80033. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80034. /**
  80035. * @hidden
  80036. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80037. * @param context The context when loading the asset
  80038. * @param primitive The glTF mesh primitive property
  80039. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80040. */
  80041. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80042. /**
  80043. * @hidden
  80044. * Define this method to modify the default behavior when loading data for mesh primitives.
  80045. * @param context The context when loading the asset
  80046. * @param name The mesh name when loading the asset
  80047. * @param node The glTF node when loading the asset
  80048. * @param mesh The glTF mesh when loading the asset
  80049. * @param primitive The glTF mesh primitive property
  80050. * @param assign A function called synchronously after parsing the glTF properties
  80051. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80052. */
  80053. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80054. /**
  80055. * @hidden
  80056. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80057. * @param context The context when loading the asset
  80058. * @param material The glTF material property
  80059. * @param assign A function called synchronously after parsing the glTF properties
  80060. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80061. */
  80062. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80063. /**
  80064. * Define this method to modify the default behavior when creating materials.
  80065. * @param context The context when loading the asset
  80066. * @param material The glTF material property
  80067. * @param babylonDrawMode The draw mode for the Babylon material
  80068. * @returns The Babylon material or null if not handled
  80069. */
  80070. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80071. /**
  80072. * Define this method to modify the default behavior when loading material properties.
  80073. * @param context The context when loading the asset
  80074. * @param material The glTF material property
  80075. * @param babylonMaterial The Babylon material
  80076. * @returns A promise that resolves when the load is complete or null if not handled
  80077. */
  80078. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80079. /**
  80080. * Define this method to modify the default behavior when loading texture infos.
  80081. * @param context The context when loading the asset
  80082. * @param textureInfo The glTF texture info property
  80083. * @param assign A function called synchronously after parsing the glTF properties
  80084. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80085. */
  80086. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80087. /**
  80088. * @hidden
  80089. * Define this method to modify the default behavior when loading textures.
  80090. * @param context The context when loading the asset
  80091. * @param texture The glTF texture property
  80092. * @param assign A function called synchronously after parsing the glTF properties
  80093. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80094. */
  80095. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80096. /**
  80097. * Define this method to modify the default behavior when loading animations.
  80098. * @param context The context when loading the asset
  80099. * @param animation The glTF animation property
  80100. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80101. */
  80102. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80103. /**
  80104. * @hidden
  80105. * Define this method to modify the default behavior when loading skins.
  80106. * @param context The context when loading the asset
  80107. * @param node The glTF node property
  80108. * @param skin The glTF skin property
  80109. * @returns A promise that resolves when the load is complete or null if not handled
  80110. */
  80111. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80112. /**
  80113. * @hidden
  80114. * Define this method to modify the default behavior when loading uris.
  80115. * @param context The context when loading the asset
  80116. * @param property The glTF property associated with the uri
  80117. * @param uri The uri to load
  80118. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80119. */
  80120. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80121. /**
  80122. * Define this method to modify the default behavior when loading buffer views.
  80123. * @param context The context when loading the asset
  80124. * @param bufferView The glTF buffer view property
  80125. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80126. */
  80127. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80128. /**
  80129. * Define this method to modify the default behavior when loading buffers.
  80130. * @param context The context when loading the asset
  80131. * @param buffer The glTF buffer property
  80132. * @param byteOffset The byte offset to load
  80133. * @param byteLength The byte length to load
  80134. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80135. */
  80136. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80137. }
  80138. }
  80139. declare module BABYLON.GLTF2 {
  80140. /**
  80141. * Helper class for working with arrays when loading the glTF asset
  80142. */
  80143. export class ArrayItem {
  80144. /**
  80145. * Gets an item from the given array.
  80146. * @param context The context when loading the asset
  80147. * @param array The array to get the item from
  80148. * @param index The index to the array
  80149. * @returns The array item
  80150. */
  80151. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80152. /**
  80153. * Assign an `index` field to each item of the given array.
  80154. * @param array The array of items
  80155. */
  80156. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80157. }
  80158. /**
  80159. * The glTF 2.0 loader
  80160. */
  80161. export class GLTFLoader implements IGLTFLoader {
  80162. /** @hidden */
  80163. _completePromises: Promise<any>[];
  80164. /** @hidden */
  80165. _forAssetContainer: boolean;
  80166. /** Storage */
  80167. _babylonLights: Light[];
  80168. /** @hidden */
  80169. _disableInstancedMesh: number;
  80170. private _disposed;
  80171. private _parent;
  80172. private _state;
  80173. private _extensions;
  80174. private _rootUrl;
  80175. private _fileName;
  80176. private _uniqueRootUrl;
  80177. private _gltf;
  80178. private _bin;
  80179. private _babylonScene;
  80180. private _rootBabylonMesh;
  80181. private _defaultBabylonMaterialData;
  80182. private static _RegisteredExtensions;
  80183. /**
  80184. * The default glTF sampler.
  80185. */
  80186. static readonly DefaultSampler: ISampler;
  80187. /**
  80188. * Registers a loader extension.
  80189. * @param name The name of the loader extension.
  80190. * @param factory The factory function that creates the loader extension.
  80191. */
  80192. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80193. /**
  80194. * Unregisters a loader extension.
  80195. * @param name The name of the loader extension.
  80196. * @returns A boolean indicating whether the extension has been unregistered
  80197. */
  80198. static UnregisterExtension(name: string): boolean;
  80199. /**
  80200. * The loader state.
  80201. */
  80202. get state(): Nullable<GLTFLoaderState>;
  80203. /**
  80204. * The object that represents the glTF JSON.
  80205. */
  80206. get gltf(): IGLTF;
  80207. /**
  80208. * The BIN chunk of a binary glTF.
  80209. */
  80210. get bin(): Nullable<IDataBuffer>;
  80211. /**
  80212. * The parent file loader.
  80213. */
  80214. get parent(): GLTFFileLoader;
  80215. /**
  80216. * The Babylon scene when loading the asset.
  80217. */
  80218. get babylonScene(): Scene;
  80219. /**
  80220. * The root Babylon mesh when loading the asset.
  80221. */
  80222. get rootBabylonMesh(): Mesh;
  80223. /** @hidden */
  80224. constructor(parent: GLTFFileLoader);
  80225. /** @hidden */
  80226. dispose(): void;
  80227. /** @hidden */
  80228. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80229. /** @hidden */
  80230. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80231. private _loadAsync;
  80232. private _loadData;
  80233. private _setupData;
  80234. private _loadExtensions;
  80235. private _checkExtensions;
  80236. private _setState;
  80237. private _createRootNode;
  80238. /**
  80239. * Loads a glTF scene.
  80240. * @param context The context when loading the asset
  80241. * @param scene The glTF scene property
  80242. * @returns A promise that resolves when the load is complete
  80243. */
  80244. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80245. private _forEachPrimitive;
  80246. private _getMeshes;
  80247. private _getTransformNodes;
  80248. private _getSkeletons;
  80249. private _getAnimationGroups;
  80250. private _startAnimations;
  80251. /**
  80252. * Loads a glTF node.
  80253. * @param context The context when loading the asset
  80254. * @param node The glTF node property
  80255. * @param assign A function called synchronously after parsing the glTF properties
  80256. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80257. */
  80258. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80259. private _loadMeshAsync;
  80260. /**
  80261. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80262. * @param context The context when loading the asset
  80263. * @param name The mesh name when loading the asset
  80264. * @param node The glTF node when loading the asset
  80265. * @param mesh The glTF mesh when loading the asset
  80266. * @param primitive The glTF mesh primitive property
  80267. * @param assign A function called synchronously after parsing the glTF properties
  80268. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80269. */
  80270. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80271. private _loadVertexDataAsync;
  80272. private _createMorphTargets;
  80273. private _loadMorphTargetsAsync;
  80274. private _loadMorphTargetVertexDataAsync;
  80275. private static _LoadTransform;
  80276. private _loadSkinAsync;
  80277. private _loadBones;
  80278. private _loadBone;
  80279. private _loadSkinInverseBindMatricesDataAsync;
  80280. private _updateBoneMatrices;
  80281. private _getNodeMatrix;
  80282. /**
  80283. * Loads a glTF camera.
  80284. * @param context The context when loading the asset
  80285. * @param camera The glTF camera property
  80286. * @param assign A function called synchronously after parsing the glTF properties
  80287. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80288. */
  80289. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80290. private _loadAnimationsAsync;
  80291. /**
  80292. * Loads a glTF animation.
  80293. * @param context The context when loading the asset
  80294. * @param animation The glTF animation property
  80295. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80296. */
  80297. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80298. /**
  80299. * @hidden Loads a glTF animation channel.
  80300. * @param context The context when loading the asset
  80301. * @param animationContext The context of the animation when loading the asset
  80302. * @param animation The glTF animation property
  80303. * @param channel The glTF animation channel property
  80304. * @param babylonAnimationGroup The babylon animation group property
  80305. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80306. * @returns A void promise when the channel load is complete
  80307. */
  80308. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80309. private _loadAnimationSamplerAsync;
  80310. private _loadBufferAsync;
  80311. /**
  80312. * Loads a glTF buffer view.
  80313. * @param context The context when loading the asset
  80314. * @param bufferView The glTF buffer view property
  80315. * @returns A promise that resolves with the loaded data when the load is complete
  80316. */
  80317. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80318. private _loadAccessorAsync;
  80319. /** @hidden */
  80320. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80321. private _loadIndicesAccessorAsync;
  80322. private _loadVertexBufferViewAsync;
  80323. private _loadVertexAccessorAsync;
  80324. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80325. /** @hidden */
  80326. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80327. private _createDefaultMaterial;
  80328. /**
  80329. * Creates a Babylon material from a glTF material.
  80330. * @param context The context when loading the asset
  80331. * @param material The glTF material property
  80332. * @param babylonDrawMode The draw mode for the Babylon material
  80333. * @returns The Babylon material
  80334. */
  80335. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80336. /**
  80337. * Loads properties from a glTF material into a Babylon material.
  80338. * @param context The context when loading the asset
  80339. * @param material The glTF material property
  80340. * @param babylonMaterial The Babylon material
  80341. * @returns A promise that resolves when the load is complete
  80342. */
  80343. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80344. /**
  80345. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80346. * @param context The context when loading the asset
  80347. * @param material The glTF material property
  80348. * @param babylonMaterial The Babylon material
  80349. * @returns A promise that resolves when the load is complete
  80350. */
  80351. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80352. /**
  80353. * Loads the alpha properties from a glTF material into a Babylon material.
  80354. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80355. * @param context The context when loading the asset
  80356. * @param material The glTF material property
  80357. * @param babylonMaterial The Babylon material
  80358. */
  80359. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80360. /**
  80361. * Loads a glTF texture info.
  80362. * @param context The context when loading the asset
  80363. * @param textureInfo The glTF texture info property
  80364. * @param assign A function called synchronously after parsing the glTF properties
  80365. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80366. */
  80367. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80368. /** @hidden */
  80369. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80370. /** @hidden */
  80371. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80372. private _loadSampler;
  80373. /**
  80374. * Loads a glTF image.
  80375. * @param context The context when loading the asset
  80376. * @param image The glTF image property
  80377. * @returns A promise that resolves with the loaded data when the load is complete
  80378. */
  80379. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80380. /**
  80381. * Loads a glTF uri.
  80382. * @param context The context when loading the asset
  80383. * @param property The glTF property associated with the uri
  80384. * @param uri The base64 or relative uri
  80385. * @returns A promise that resolves with the loaded data when the load is complete
  80386. */
  80387. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80388. /**
  80389. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80390. * @param babylonObject the Babylon object with metadata
  80391. * @param pointer the JSON pointer
  80392. */
  80393. static AddPointerMetadata(babylonObject: {
  80394. metadata: any;
  80395. }, pointer: string): void;
  80396. private static _GetTextureWrapMode;
  80397. private static _GetTextureSamplingMode;
  80398. private static _GetTypedArrayConstructor;
  80399. private static _GetTypedArray;
  80400. private static _GetNumComponents;
  80401. private static _ValidateUri;
  80402. /** @hidden */
  80403. static _GetDrawMode(context: string, mode: number | undefined): number;
  80404. private _compileMaterialsAsync;
  80405. private _compileShadowGeneratorsAsync;
  80406. private _forEachExtensions;
  80407. private _applyExtensions;
  80408. private _extensionsOnLoading;
  80409. private _extensionsOnReady;
  80410. private _extensionsLoadSceneAsync;
  80411. private _extensionsLoadNodeAsync;
  80412. private _extensionsLoadCameraAsync;
  80413. private _extensionsLoadVertexDataAsync;
  80414. private _extensionsLoadMeshPrimitiveAsync;
  80415. private _extensionsLoadMaterialAsync;
  80416. private _extensionsCreateMaterial;
  80417. private _extensionsLoadMaterialPropertiesAsync;
  80418. private _extensionsLoadTextureInfoAsync;
  80419. private _extensionsLoadTextureAsync;
  80420. private _extensionsLoadAnimationAsync;
  80421. private _extensionsLoadSkinAsync;
  80422. private _extensionsLoadUriAsync;
  80423. private _extensionsLoadBufferViewAsync;
  80424. private _extensionsLoadBufferAsync;
  80425. /**
  80426. * Helper method called by a loader extension to load an glTF extension.
  80427. * @param context The context when loading the asset
  80428. * @param property The glTF property to load the extension from
  80429. * @param extensionName The name of the extension to load
  80430. * @param actionAsync The action to run
  80431. * @returns The promise returned by actionAsync or null if the extension does not exist
  80432. */
  80433. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80434. /**
  80435. * Helper method called by a loader extension to load a glTF extra.
  80436. * @param context The context when loading the asset
  80437. * @param property The glTF property to load the extra from
  80438. * @param extensionName The name of the extension to load
  80439. * @param actionAsync The action to run
  80440. * @returns The promise returned by actionAsync or null if the extra does not exist
  80441. */
  80442. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80443. /**
  80444. * Checks for presence of an extension.
  80445. * @param name The name of the extension to check
  80446. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80447. */
  80448. isExtensionUsed(name: string): boolean;
  80449. /**
  80450. * Increments the indentation level and logs a message.
  80451. * @param message The message to log
  80452. */
  80453. logOpen(message: string): void;
  80454. /**
  80455. * Decrements the indentation level.
  80456. */
  80457. logClose(): void;
  80458. /**
  80459. * Logs a message
  80460. * @param message The message to log
  80461. */
  80462. log(message: string): void;
  80463. /**
  80464. * Starts a performance counter.
  80465. * @param counterName The name of the performance counter
  80466. */
  80467. startPerformanceCounter(counterName: string): void;
  80468. /**
  80469. * Ends a performance counter.
  80470. * @param counterName The name of the performance counter
  80471. */
  80472. endPerformanceCounter(counterName: string): void;
  80473. }
  80474. }
  80475. declare module BABYLON.GLTF2.Loader.Extensions {
  80476. /** @hidden */
  80477. interface IEXTLightsImageBased_LightImageBased {
  80478. _babylonTexture?: BaseTexture;
  80479. _loaded?: Promise<void>;
  80480. }
  80481. /**
  80482. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80483. */
  80484. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80485. /**
  80486. * The name of this extension.
  80487. */
  80488. readonly name: string;
  80489. /**
  80490. * Defines whether this extension is enabled.
  80491. */
  80492. enabled: boolean;
  80493. private _loader;
  80494. private _lights?;
  80495. /** @hidden */
  80496. constructor(loader: GLTFLoader);
  80497. /** @hidden */
  80498. dispose(): void;
  80499. /** @hidden */
  80500. onLoading(): void;
  80501. /** @hidden */
  80502. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80503. private _loadLightAsync;
  80504. }
  80505. }
  80506. declare module BABYLON.GLTF2.Loader.Extensions {
  80507. /**
  80508. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80509. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80510. * !!! Experimental Extension Subject to Changes !!!
  80511. */
  80512. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80513. /**
  80514. * The name of this extension.
  80515. */
  80516. readonly name: string;
  80517. /**
  80518. * Defines whether this extension is enabled.
  80519. */
  80520. enabled: boolean;
  80521. private _loader;
  80522. /** @hidden */
  80523. constructor(loader: GLTFLoader);
  80524. /** @hidden */
  80525. dispose(): void;
  80526. /** @hidden */
  80527. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80528. }
  80529. }
  80530. declare module BABYLON.GLTF2.Loader.Extensions {
  80531. /**
  80532. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80533. */
  80534. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80535. /**
  80536. * The name of this extension.
  80537. */
  80538. readonly name: string;
  80539. /**
  80540. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80541. */
  80542. dracoCompression?: DracoCompression;
  80543. /**
  80544. * Defines whether this extension is enabled.
  80545. */
  80546. enabled: boolean;
  80547. private _loader;
  80548. /** @hidden */
  80549. constructor(loader: GLTFLoader);
  80550. /** @hidden */
  80551. dispose(): void;
  80552. /** @hidden */
  80553. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80554. }
  80555. }
  80556. declare module BABYLON.GLTF2.Loader.Extensions {
  80557. /**
  80558. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80559. */
  80560. export class KHR_lights implements IGLTFLoaderExtension {
  80561. /**
  80562. * The name of this extension.
  80563. */
  80564. readonly name: string;
  80565. /**
  80566. * Defines whether this extension is enabled.
  80567. */
  80568. enabled: boolean;
  80569. private _loader;
  80570. private _lights?;
  80571. /** @hidden */
  80572. constructor(loader: GLTFLoader);
  80573. /** @hidden */
  80574. dispose(): void;
  80575. /** @hidden */
  80576. onLoading(): void;
  80577. /** @hidden */
  80578. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80579. }
  80580. }
  80581. declare module BABYLON.GLTF2.Loader.Extensions {
  80582. /**
  80583. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80584. */
  80585. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80586. /**
  80587. * The name of this extension.
  80588. */
  80589. readonly name: string;
  80590. /**
  80591. * Defines whether this extension is enabled.
  80592. */
  80593. enabled: boolean;
  80594. /**
  80595. * Defines a number that determines the order the extensions are applied.
  80596. */
  80597. order: number;
  80598. private _loader;
  80599. /** @hidden */
  80600. constructor(loader: GLTFLoader);
  80601. /** @hidden */
  80602. dispose(): void;
  80603. /** @hidden */
  80604. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80605. private _loadSpecularGlossinessPropertiesAsync;
  80606. }
  80607. }
  80608. declare module BABYLON.GLTF2.Loader.Extensions {
  80609. /**
  80610. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80611. */
  80612. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80613. /**
  80614. * The name of this extension.
  80615. */
  80616. readonly name: string;
  80617. /**
  80618. * Defines whether this extension is enabled.
  80619. */
  80620. enabled: boolean;
  80621. /**
  80622. * Defines a number that determines the order the extensions are applied.
  80623. */
  80624. order: number;
  80625. private _loader;
  80626. /** @hidden */
  80627. constructor(loader: GLTFLoader);
  80628. /** @hidden */
  80629. dispose(): void;
  80630. /** @hidden */
  80631. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80632. private _loadUnlitPropertiesAsync;
  80633. }
  80634. }
  80635. declare module BABYLON.GLTF2.Loader.Extensions {
  80636. /**
  80637. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80638. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80639. * !!! Experimental Extension Subject to Changes !!!
  80640. */
  80641. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80642. /**
  80643. * The name of this extension.
  80644. */
  80645. readonly name: string;
  80646. /**
  80647. * Defines whether this extension is enabled.
  80648. */
  80649. enabled: boolean;
  80650. /**
  80651. * Defines a number that determines the order the extensions are applied.
  80652. */
  80653. order: number;
  80654. private _loader;
  80655. /** @hidden */
  80656. constructor(loader: GLTFLoader);
  80657. /** @hidden */
  80658. dispose(): void;
  80659. /** @hidden */
  80660. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80661. private _loadClearCoatPropertiesAsync;
  80662. }
  80663. }
  80664. declare module BABYLON.GLTF2.Loader.Extensions {
  80665. /**
  80666. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80667. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80668. * !!! Experimental Extension Subject to Changes !!!
  80669. */
  80670. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80671. /**
  80672. * The name of this extension.
  80673. */
  80674. readonly name: string;
  80675. /**
  80676. * Defines whether this extension is enabled.
  80677. */
  80678. enabled: boolean;
  80679. /**
  80680. * Defines a number that determines the order the extensions are applied.
  80681. */
  80682. order: number;
  80683. private _loader;
  80684. /** @hidden */
  80685. constructor(loader: GLTFLoader);
  80686. /** @hidden */
  80687. dispose(): void;
  80688. /** @hidden */
  80689. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80690. private _loadSheenPropertiesAsync;
  80691. }
  80692. }
  80693. declare module BABYLON.GLTF2.Loader.Extensions {
  80694. /**
  80695. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80696. * !!! Experimental Extension Subject to Changes !!!
  80697. */
  80698. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80699. /**
  80700. * The name of this extension.
  80701. */
  80702. readonly name: string;
  80703. /**
  80704. * Defines whether this extension is enabled.
  80705. */
  80706. enabled: boolean;
  80707. /**
  80708. * Defines a number that determines the order the extensions are applied.
  80709. */
  80710. order: number;
  80711. private _loader;
  80712. /** @hidden */
  80713. constructor(loader: GLTFLoader);
  80714. /** @hidden */
  80715. dispose(): void;
  80716. /** @hidden */
  80717. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80718. private _loadSpecularPropertiesAsync;
  80719. }
  80720. }
  80721. declare module BABYLON.GLTF2.Loader.Extensions {
  80722. /**
  80723. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80724. * !!! Experimental Extension Subject to Changes !!!
  80725. */
  80726. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80727. /**
  80728. * Default ior Value from the spec.
  80729. */
  80730. private static readonly _DEFAULT_IOR;
  80731. /**
  80732. * The name of this extension.
  80733. */
  80734. readonly name: string;
  80735. /**
  80736. * Defines whether this extension is enabled.
  80737. */
  80738. enabled: boolean;
  80739. /**
  80740. * Defines a number that determines the order the extensions are applied.
  80741. */
  80742. order: number;
  80743. private _loader;
  80744. /** @hidden */
  80745. constructor(loader: GLTFLoader);
  80746. /** @hidden */
  80747. dispose(): void;
  80748. /** @hidden */
  80749. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80750. private _loadIorPropertiesAsync;
  80751. }
  80752. }
  80753. declare module BABYLON.GLTF2.Loader.Extensions {
  80754. /**
  80755. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80756. * !!! Experimental Extension Subject to Changes !!!
  80757. */
  80758. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80759. /**
  80760. * The name of this extension.
  80761. */
  80762. readonly name: string;
  80763. /**
  80764. * Defines whether this extension is enabled.
  80765. */
  80766. enabled: boolean;
  80767. private _loader;
  80768. /** @hidden */
  80769. constructor(loader: GLTFLoader);
  80770. /** @hidden */
  80771. dispose(): void;
  80772. /**
  80773. * Gets the list of available variant tag names for this asset.
  80774. * @param rootMesh The glTF root mesh
  80775. * @returns the list of all the variant names for this model
  80776. */
  80777. static GetAvailableVariants(rootMesh: Mesh): string[];
  80778. /**
  80779. * Gets the list of available variant tag names for this asset.
  80780. * @param rootMesh The glTF root mesh
  80781. * @returns the list of all the variant names for this model
  80782. */
  80783. getAvailableVariants(rootMesh: Mesh): string[];
  80784. /**
  80785. * Select a variant given a variant tag name or a list of variant tag names.
  80786. * @param rootMesh The glTF root mesh
  80787. * @param variantName The variant name(s) to select.
  80788. */
  80789. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80790. /**
  80791. * Select a variant given a variant tag name or a list of variant tag names.
  80792. * @param rootMesh The glTF root mesh
  80793. * @param variantName The variant name(s) to select.
  80794. */
  80795. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80796. /**
  80797. * Reset back to the original before selecting a variant.
  80798. * @param rootMesh The glTF root mesh
  80799. */
  80800. static Reset(rootMesh: Mesh): void;
  80801. /**
  80802. * Reset back to the original before selecting a variant.
  80803. * @param rootMesh The glTF root mesh
  80804. */
  80805. reset(rootMesh: Mesh): void;
  80806. /**
  80807. * Gets the last selected variant tag name(s) or null if original.
  80808. * @param rootMesh The glTF root mesh
  80809. * @returns The selected variant tag name(s).
  80810. */
  80811. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80812. /**
  80813. * Gets the last selected variant tag name(s) or null if original.
  80814. * @param rootMesh The glTF root mesh
  80815. * @returns The selected variant tag name(s).
  80816. */
  80817. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80818. private static _GetExtensionMetadata;
  80819. /** @hidden */
  80820. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80821. }
  80822. }
  80823. declare module BABYLON.GLTF2.Loader.Extensions {
  80824. /**
  80825. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80826. * !!! Experimental Extension Subject to Changes !!!
  80827. */
  80828. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80829. /**
  80830. * The name of this extension.
  80831. */
  80832. readonly name: string;
  80833. /**
  80834. * Defines whether this extension is enabled.
  80835. */
  80836. enabled: boolean;
  80837. /**
  80838. * Defines a number that determines the order the extensions are applied.
  80839. */
  80840. order: number;
  80841. private _loader;
  80842. /** @hidden */
  80843. constructor(loader: GLTFLoader);
  80844. /** @hidden */
  80845. dispose(): void;
  80846. /** @hidden */
  80847. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80848. private _loadTransparentPropertiesAsync;
  80849. }
  80850. }
  80851. declare module BABYLON.GLTF2.Loader.Extensions {
  80852. /**
  80853. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80854. */
  80855. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80856. /**
  80857. * The name of this extension.
  80858. */
  80859. readonly name: string;
  80860. /**
  80861. * Defines whether this extension is enabled.
  80862. */
  80863. enabled: boolean;
  80864. /** @hidden */
  80865. constructor(loader: GLTFLoader);
  80866. /** @hidden */
  80867. dispose(): void;
  80868. }
  80869. }
  80870. declare module BABYLON.GLTF2.Loader.Extensions {
  80871. /**
  80872. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80873. * !!! Experimental Extension Subject to Changes !!!
  80874. */
  80875. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80876. /** The name of this extension. */
  80877. readonly name: string;
  80878. /** Defines whether this extension is enabled. */
  80879. enabled: boolean;
  80880. private _loader;
  80881. /** @hidden */
  80882. constructor(loader: GLTFLoader);
  80883. /** @hidden */
  80884. dispose(): void;
  80885. /** @hidden */
  80886. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80887. }
  80888. }
  80889. declare module BABYLON.GLTF2.Loader.Extensions {
  80890. /**
  80891. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80892. */
  80893. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80894. /**
  80895. * The name of this extension.
  80896. */
  80897. readonly name: string;
  80898. /**
  80899. * Defines whether this extension is enabled.
  80900. */
  80901. enabled: boolean;
  80902. private _loader;
  80903. /** @hidden */
  80904. constructor(loader: GLTFLoader);
  80905. /** @hidden */
  80906. dispose(): void;
  80907. /** @hidden */
  80908. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80909. }
  80910. }
  80911. declare module BABYLON.GLTF2.Loader.Extensions {
  80912. /**
  80913. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80914. * !!! Experimental Extension Subject to Changes !!!
  80915. */
  80916. export class KHR_xmp implements IGLTFLoaderExtension {
  80917. /**
  80918. * The name of this extension.
  80919. */
  80920. readonly name: string;
  80921. /**
  80922. * Defines whether this extension is enabled.
  80923. */
  80924. enabled: boolean;
  80925. /**
  80926. * Defines a number that determines the order the extensions are applied.
  80927. */
  80928. order: number;
  80929. private _loader;
  80930. /** @hidden */
  80931. constructor(loader: GLTFLoader);
  80932. /** @hidden */
  80933. dispose(): void;
  80934. /**
  80935. * Called after the loader state changes to LOADING.
  80936. */
  80937. onLoading(): void;
  80938. }
  80939. }
  80940. declare module BABYLON.GLTF2.Loader.Extensions {
  80941. /**
  80942. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80943. */
  80944. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80945. /**
  80946. * The name of this extension.
  80947. */
  80948. readonly name: string;
  80949. /**
  80950. * Defines whether this extension is enabled.
  80951. */
  80952. enabled: boolean;
  80953. private _loader;
  80954. private _clips;
  80955. private _emitters;
  80956. /** @hidden */
  80957. constructor(loader: GLTFLoader);
  80958. /** @hidden */
  80959. dispose(): void;
  80960. /** @hidden */
  80961. onLoading(): void;
  80962. /** @hidden */
  80963. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80964. /** @hidden */
  80965. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80966. /** @hidden */
  80967. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80968. private _loadClipAsync;
  80969. private _loadEmitterAsync;
  80970. private _getEventAction;
  80971. private _loadAnimationEventAsync;
  80972. }
  80973. }
  80974. declare module BABYLON.GLTF2.Loader.Extensions {
  80975. /**
  80976. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80977. */
  80978. export class MSFT_lod implements IGLTFLoaderExtension {
  80979. /**
  80980. * The name of this extension.
  80981. */
  80982. readonly name: string;
  80983. /**
  80984. * Defines whether this extension is enabled.
  80985. */
  80986. enabled: boolean;
  80987. /**
  80988. * Defines a number that determines the order the extensions are applied.
  80989. */
  80990. order: number;
  80991. /**
  80992. * Maximum number of LODs to load, starting from the lowest LOD.
  80993. */
  80994. maxLODsToLoad: number;
  80995. /**
  80996. * Observable raised when all node LODs of one level are loaded.
  80997. * The event data is the index of the loaded LOD starting from zero.
  80998. * Dispose the loader to cancel the loading of the next level of LODs.
  80999. */
  81000. onNodeLODsLoadedObservable: Observable<number>;
  81001. /**
  81002. * Observable raised when all material LODs of one level are loaded.
  81003. * The event data is the index of the loaded LOD starting from zero.
  81004. * Dispose the loader to cancel the loading of the next level of LODs.
  81005. */
  81006. onMaterialLODsLoadedObservable: Observable<number>;
  81007. private _loader;
  81008. private _bufferLODs;
  81009. private _nodeIndexLOD;
  81010. private _nodeSignalLODs;
  81011. private _nodePromiseLODs;
  81012. private _nodeBufferLODs;
  81013. private _materialIndexLOD;
  81014. private _materialSignalLODs;
  81015. private _materialPromiseLODs;
  81016. private _materialBufferLODs;
  81017. /** @hidden */
  81018. constructor(loader: GLTFLoader);
  81019. /** @hidden */
  81020. dispose(): void;
  81021. /** @hidden */
  81022. onReady(): void;
  81023. /** @hidden */
  81024. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81025. /** @hidden */
  81026. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81027. /** @hidden */
  81028. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81029. /** @hidden */
  81030. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81031. /** @hidden */
  81032. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81033. private _loadBufferLOD;
  81034. /**
  81035. * Gets an array of LOD properties from lowest to highest.
  81036. */
  81037. private _getLODs;
  81038. private _disposeTransformNode;
  81039. private _disposeMaterials;
  81040. }
  81041. }
  81042. declare module BABYLON.GLTF2.Loader.Extensions {
  81043. /** @hidden */
  81044. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81045. readonly name: string;
  81046. enabled: boolean;
  81047. private _loader;
  81048. constructor(loader: GLTFLoader);
  81049. dispose(): void;
  81050. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81051. }
  81052. }
  81053. declare module BABYLON.GLTF2.Loader.Extensions {
  81054. /** @hidden */
  81055. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81056. readonly name: string;
  81057. enabled: boolean;
  81058. private _loader;
  81059. constructor(loader: GLTFLoader);
  81060. dispose(): void;
  81061. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81062. }
  81063. }
  81064. declare module BABYLON.GLTF2.Loader.Extensions {
  81065. /**
  81066. * Store glTF extras (if present) in BJS objects' metadata
  81067. */
  81068. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81069. /**
  81070. * The name of this extension.
  81071. */
  81072. readonly name: string;
  81073. /**
  81074. * Defines whether this extension is enabled.
  81075. */
  81076. enabled: boolean;
  81077. private _loader;
  81078. private _assignExtras;
  81079. /** @hidden */
  81080. constructor(loader: GLTFLoader);
  81081. /** @hidden */
  81082. dispose(): void;
  81083. /** @hidden */
  81084. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81085. /** @hidden */
  81086. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81087. /** @hidden */
  81088. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81089. }
  81090. }
  81091. declare module BABYLON {
  81092. /**
  81093. * Class reading and parsing the MTL file bundled with the obj file.
  81094. */
  81095. export class MTLFileLoader {
  81096. /**
  81097. * Invert Y-Axis of referenced textures on load
  81098. */
  81099. static INVERT_TEXTURE_Y: boolean;
  81100. /**
  81101. * All material loaded from the mtl will be set here
  81102. */
  81103. materials: StandardMaterial[];
  81104. /**
  81105. * This function will read the mtl file and create each material described inside
  81106. * This function could be improve by adding :
  81107. * -some component missing (Ni, Tf...)
  81108. * -including the specific options available
  81109. *
  81110. * @param scene defines the scene the material will be created in
  81111. * @param data defines the mtl data to parse
  81112. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81113. * @param forAssetContainer defines if the material should be registered in the scene
  81114. */
  81115. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81116. /**
  81117. * Gets the texture for the material.
  81118. *
  81119. * If the material is imported from input file,
  81120. * We sanitize the url to ensure it takes the textre from aside the material.
  81121. *
  81122. * @param rootUrl The root url to load from
  81123. * @param value The value stored in the mtl
  81124. * @return The Texture
  81125. */
  81126. private static _getTexture;
  81127. }
  81128. }
  81129. declare module BABYLON {
  81130. /**
  81131. * Options for loading OBJ/MTL files
  81132. */
  81133. type MeshLoadOptions = {
  81134. /**
  81135. * Defines if UVs are optimized by default during load.
  81136. */
  81137. OptimizeWithUV: boolean;
  81138. /**
  81139. * Defines custom scaling of UV coordinates of loaded meshes.
  81140. */
  81141. UVScaling: Vector2;
  81142. /**
  81143. * Invert model on y-axis (does a model scaling inversion)
  81144. */
  81145. InvertY: boolean;
  81146. /**
  81147. * Invert Y-Axis of referenced textures on load
  81148. */
  81149. InvertTextureY: boolean;
  81150. /**
  81151. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81152. */
  81153. ImportVertexColors: boolean;
  81154. /**
  81155. * Compute the normals for the model, even if normals are present in the file.
  81156. */
  81157. ComputeNormals: boolean;
  81158. /**
  81159. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81160. */
  81161. SkipMaterials: boolean;
  81162. /**
  81163. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81164. */
  81165. MaterialLoadingFailsSilently: boolean;
  81166. };
  81167. /**
  81168. * OBJ file type loader.
  81169. * This is a babylon scene loader plugin.
  81170. */
  81171. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81172. /**
  81173. * Defines if UVs are optimized by default during load.
  81174. */
  81175. static OPTIMIZE_WITH_UV: boolean;
  81176. /**
  81177. * Invert model on y-axis (does a model scaling inversion)
  81178. */
  81179. static INVERT_Y: boolean;
  81180. /**
  81181. * Invert Y-Axis of referenced textures on load
  81182. */
  81183. static get INVERT_TEXTURE_Y(): boolean;
  81184. static set INVERT_TEXTURE_Y(value: boolean);
  81185. /**
  81186. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81187. */
  81188. static IMPORT_VERTEX_COLORS: boolean;
  81189. /**
  81190. * Compute the normals for the model, even if normals are present in the file.
  81191. */
  81192. static COMPUTE_NORMALS: boolean;
  81193. /**
  81194. * Defines custom scaling of UV coordinates of loaded meshes.
  81195. */
  81196. static UV_SCALING: Vector2;
  81197. /**
  81198. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81199. */
  81200. static SKIP_MATERIALS: boolean;
  81201. /**
  81202. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81203. *
  81204. * Defaults to true for backwards compatibility.
  81205. */
  81206. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81207. /**
  81208. * Defines the name of the plugin.
  81209. */
  81210. name: string;
  81211. /**
  81212. * Defines the extension the plugin is able to load.
  81213. */
  81214. extensions: string;
  81215. /** @hidden */
  81216. obj: RegExp;
  81217. /** @hidden */
  81218. group: RegExp;
  81219. /** @hidden */
  81220. mtllib: RegExp;
  81221. /** @hidden */
  81222. usemtl: RegExp;
  81223. /** @hidden */
  81224. smooth: RegExp;
  81225. /** @hidden */
  81226. vertexPattern: RegExp;
  81227. /** @hidden */
  81228. normalPattern: RegExp;
  81229. /** @hidden */
  81230. uvPattern: RegExp;
  81231. /** @hidden */
  81232. facePattern1: RegExp;
  81233. /** @hidden */
  81234. facePattern2: RegExp;
  81235. /** @hidden */
  81236. facePattern3: RegExp;
  81237. /** @hidden */
  81238. facePattern4: RegExp;
  81239. /** @hidden */
  81240. facePattern5: RegExp;
  81241. private _forAssetContainer;
  81242. private _meshLoadOptions;
  81243. /**
  81244. * Creates loader for .OBJ files
  81245. *
  81246. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81247. */
  81248. constructor(meshLoadOptions?: MeshLoadOptions);
  81249. private static get currentMeshLoadOptions();
  81250. /**
  81251. * Calls synchronously the MTL file attached to this obj.
  81252. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81253. * Without this function materials are not displayed in the first frame (but displayed after).
  81254. * In consequence it is impossible to get material information in your HTML file
  81255. *
  81256. * @param url The URL of the MTL file
  81257. * @param rootUrl
  81258. * @param onSuccess Callback function to be called when the MTL file is loaded
  81259. * @private
  81260. */
  81261. private _loadMTL;
  81262. /**
  81263. * Instantiates a OBJ file loader plugin.
  81264. * @returns the created plugin
  81265. */
  81266. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81267. /**
  81268. * If the data string can be loaded directly.
  81269. *
  81270. * @param data string containing the file data
  81271. * @returns if the data can be loaded directly
  81272. */
  81273. canDirectLoad(data: string): boolean;
  81274. /**
  81275. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81276. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81277. * @param scene the scene the meshes should be added to
  81278. * @param data the OBJ data to load
  81279. * @param rootUrl root url to load from
  81280. * @param onProgress event that fires when loading progress has occured
  81281. * @param fileName Defines the name of the file to load
  81282. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81283. */
  81284. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81285. meshes: AbstractMesh[];
  81286. particleSystems: IParticleSystem[];
  81287. skeletons: Skeleton[];
  81288. animationGroups: AnimationGroup[];
  81289. }>;
  81290. /**
  81291. * Imports all objects from the loaded OBJ data and adds them to the scene
  81292. * @param scene the scene the objects should be added to
  81293. * @param data the OBJ data to load
  81294. * @param rootUrl root url to load from
  81295. * @param onProgress event that fires when loading progress has occured
  81296. * @param fileName Defines the name of the file to load
  81297. * @returns a promise which completes when objects have been loaded to the scene
  81298. */
  81299. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81300. /**
  81301. * Load into an asset container.
  81302. * @param scene The scene to load into
  81303. * @param data The data to import
  81304. * @param rootUrl The root url for scene and resources
  81305. * @param onProgress The callback when the load progresses
  81306. * @param fileName Defines the name of the file to load
  81307. * @returns The loaded asset container
  81308. */
  81309. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81310. /**
  81311. * Read the OBJ file and create an Array of meshes.
  81312. * Each mesh contains all information given by the OBJ and the MTL file.
  81313. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81314. *
  81315. * @param meshesNames
  81316. * @param scene Scene The scene where are displayed the data
  81317. * @param data String The content of the obj file
  81318. * @param rootUrl String The path to the folder
  81319. * @returns Array<AbstractMesh>
  81320. * @private
  81321. */
  81322. private _parseSolid;
  81323. }
  81324. }
  81325. declare module BABYLON {
  81326. /**
  81327. * STL file type loader.
  81328. * This is a babylon scene loader plugin.
  81329. */
  81330. export class STLFileLoader implements ISceneLoaderPlugin {
  81331. /** @hidden */
  81332. solidPattern: RegExp;
  81333. /** @hidden */
  81334. facetsPattern: RegExp;
  81335. /** @hidden */
  81336. normalPattern: RegExp;
  81337. /** @hidden */
  81338. vertexPattern: RegExp;
  81339. /**
  81340. * Defines the name of the plugin.
  81341. */
  81342. name: string;
  81343. /**
  81344. * Defines the extensions the stl loader is able to load.
  81345. * force data to come in as an ArrayBuffer
  81346. * we'll convert to string if it looks like it's an ASCII .stl
  81347. */
  81348. extensions: ISceneLoaderPluginExtensions;
  81349. /**
  81350. * Import meshes into a scene.
  81351. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81352. * @param scene The scene to import into
  81353. * @param data The data to import
  81354. * @param rootUrl The root url for scene and resources
  81355. * @param meshes The meshes array to import into
  81356. * @param particleSystems The particle systems array to import into
  81357. * @param skeletons The skeletons array to import into
  81358. * @param onError The callback when import fails
  81359. * @returns True if successful or false otherwise
  81360. */
  81361. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81362. /**
  81363. * Load into a scene.
  81364. * @param scene The scene to load into
  81365. * @param data The data to import
  81366. * @param rootUrl The root url for scene and resources
  81367. * @param onError The callback when import fails
  81368. * @returns true if successful or false otherwise
  81369. */
  81370. load(scene: Scene, data: any, rootUrl: string): boolean;
  81371. /**
  81372. * Load into an asset container.
  81373. * @param scene The scene to load into
  81374. * @param data The data to import
  81375. * @param rootUrl The root url for scene and resources
  81376. * @param onError The callback when import fails
  81377. * @returns The loaded asset container
  81378. */
  81379. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81380. private _isBinary;
  81381. private _parseBinary;
  81382. private _parseASCII;
  81383. }
  81384. }
  81385. declare module BABYLON {
  81386. /**
  81387. * Class for generating OBJ data from a Babylon scene.
  81388. */
  81389. export class OBJExport {
  81390. /**
  81391. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81392. * @param mesh defines the list of meshes to serialize
  81393. * @param materials defines if materials should be exported
  81394. * @param matlibname defines the name of the associated mtl file
  81395. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81396. * @returns the OBJ content
  81397. */
  81398. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81399. /**
  81400. * Exports the material(s) of a mesh in .MTL file format (text)
  81401. * @param mesh defines the mesh to extract the material from
  81402. * @returns the mtl content
  81403. */
  81404. static MTL(mesh: Mesh): string;
  81405. }
  81406. }
  81407. declare module BABYLON {
  81408. /** @hidden */
  81409. export var __IGLTFExporterExtension: number;
  81410. /**
  81411. * Interface for extending the exporter
  81412. * @hidden
  81413. */
  81414. export interface IGLTFExporterExtension {
  81415. /**
  81416. * The name of this extension
  81417. */
  81418. readonly name: string;
  81419. /**
  81420. * Defines whether this extension is enabled
  81421. */
  81422. enabled: boolean;
  81423. /**
  81424. * Defines whether this extension is required
  81425. */
  81426. required: boolean;
  81427. }
  81428. }
  81429. declare module BABYLON.GLTF2.Exporter {
  81430. /** @hidden */
  81431. export var __IGLTFExporterExtensionV2: number;
  81432. /**
  81433. * Interface for a glTF exporter extension
  81434. * @hidden
  81435. */
  81436. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81437. /**
  81438. * Define this method to modify the default behavior before exporting a texture
  81439. * @param context The context when loading the asset
  81440. * @param babylonTexture The Babylon.js texture
  81441. * @param mimeType The mime-type of the generated image
  81442. * @returns A promise that resolves with the exported texture
  81443. */
  81444. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81445. /**
  81446. * Define this method to get notified when a texture info is created
  81447. * @param context The context when loading the asset
  81448. * @param textureInfo The glTF texture info
  81449. * @param babylonTexture The Babylon.js texture
  81450. */
  81451. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81452. /**
  81453. * Define this method to modify the default behavior when exporting texture info
  81454. * @param context The context when loading the asset
  81455. * @param meshPrimitive glTF mesh primitive
  81456. * @param babylonSubMesh Babylon submesh
  81457. * @param binaryWriter glTF serializer binary writer instance
  81458. * @returns nullable IMeshPrimitive promise
  81459. */
  81460. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81461. /**
  81462. * Define this method to modify the default behavior when exporting a node
  81463. * @param context The context when exporting the node
  81464. * @param node glTF node
  81465. * @param babylonNode BabylonJS node
  81466. * @returns nullable INode promise
  81467. */
  81468. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81469. [key: number]: number;
  81470. }): Promise<Nullable<INode>>;
  81471. /**
  81472. * Define this method to modify the default behavior when exporting a material
  81473. * @param material glTF material
  81474. * @param babylonMaterial BabylonJS material
  81475. * @returns nullable IMaterial promise
  81476. */
  81477. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81478. /**
  81479. * Define this method to return additional textures to export from a material
  81480. * @param material glTF material
  81481. * @param babylonMaterial BabylonJS material
  81482. * @returns List of textures
  81483. */
  81484. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81485. /** Gets a boolean indicating that this extension was used */
  81486. wasUsed: boolean;
  81487. /** Gets a boolean indicating that this extension is required for the file to work */
  81488. required: boolean;
  81489. /**
  81490. * Called after the exporter state changes to EXPORTING
  81491. */
  81492. onExporting?(): void;
  81493. }
  81494. }
  81495. declare module BABYLON.GLTF2.Exporter {
  81496. /**
  81497. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81498. * @hidden
  81499. */
  81500. export class _GLTFMaterialExporter {
  81501. /**
  81502. * Represents the dielectric specular values for R, G and B
  81503. */
  81504. private static readonly _DielectricSpecular;
  81505. /**
  81506. * Allows the maximum specular power to be defined for material calculations
  81507. */
  81508. private static readonly _MaxSpecularPower;
  81509. /**
  81510. * Mapping to store textures
  81511. */
  81512. private _textureMap;
  81513. /**
  81514. * Numeric tolerance value
  81515. */
  81516. private static readonly _Epsilon;
  81517. /**
  81518. * Reference to the glTF Exporter
  81519. */
  81520. private _exporter;
  81521. constructor(exporter: _Exporter);
  81522. /**
  81523. * Specifies if two colors are approximately equal in value
  81524. * @param color1 first color to compare to
  81525. * @param color2 second color to compare to
  81526. * @param epsilon threshold value
  81527. */
  81528. private static FuzzyEquals;
  81529. /**
  81530. * Gets the materials from a Babylon scene and converts them to glTF materials
  81531. * @param scene babylonjs scene
  81532. * @param mimeType texture mime type
  81533. * @param images array of images
  81534. * @param textures array of textures
  81535. * @param materials array of materials
  81536. * @param imageData mapping of texture names to base64 textures
  81537. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81538. */
  81539. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81540. /**
  81541. * Makes a copy of the glTF material without the texture parameters
  81542. * @param originalMaterial original glTF material
  81543. * @returns glTF material without texture parameters
  81544. */
  81545. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81546. /**
  81547. * Specifies if the material has any texture parameters present
  81548. * @param material glTF Material
  81549. * @returns boolean specifying if texture parameters are present
  81550. */
  81551. _hasTexturesPresent(material: IMaterial): boolean;
  81552. /**
  81553. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81554. * @param babylonStandardMaterial
  81555. * @returns glTF Metallic Roughness Material representation
  81556. */
  81557. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81558. /**
  81559. * Computes the metallic factor
  81560. * @param diffuse diffused value
  81561. * @param specular specular value
  81562. * @param oneMinusSpecularStrength one minus the specular strength
  81563. * @returns metallic value
  81564. */
  81565. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81566. /**
  81567. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81568. * @param glTFMaterial glTF material
  81569. * @param babylonMaterial Babylon material
  81570. */
  81571. private static _SetAlphaMode;
  81572. /**
  81573. * Converts a Babylon Standard Material to a glTF Material
  81574. * @param babylonStandardMaterial BJS Standard Material
  81575. * @param mimeType mime type to use for the textures
  81576. * @param images array of glTF image interfaces
  81577. * @param textures array of glTF texture interfaces
  81578. * @param materials array of glTF material interfaces
  81579. * @param imageData map of image file name to data
  81580. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81581. */
  81582. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81583. private _finishMaterial;
  81584. /**
  81585. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81586. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81587. * @param mimeType mime type to use for the textures
  81588. * @param images array of glTF image interfaces
  81589. * @param textures array of glTF texture interfaces
  81590. * @param materials array of glTF material interfaces
  81591. * @param imageData map of image file name to data
  81592. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81593. */
  81594. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81595. /**
  81596. * Converts an image typed array buffer to a base64 image
  81597. * @param buffer typed array buffer
  81598. * @param width width of the image
  81599. * @param height height of the image
  81600. * @param mimeType mimetype of the image
  81601. * @returns base64 image string
  81602. */
  81603. private _createBase64FromCanvasAsync;
  81604. /**
  81605. * Generates a white texture based on the specified width and height
  81606. * @param width width of the texture in pixels
  81607. * @param height height of the texture in pixels
  81608. * @param scene babylonjs scene
  81609. * @returns white texture
  81610. */
  81611. private _createWhiteTexture;
  81612. /**
  81613. * 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
  81614. * @param texture1 first texture to resize
  81615. * @param texture2 second texture to resize
  81616. * @param scene babylonjs scene
  81617. * @returns resized textures or null
  81618. */
  81619. private _resizeTexturesToSameDimensions;
  81620. /**
  81621. * Converts an array of pixels to a Float32Array
  81622. * Throws an error if the pixel format is not supported
  81623. * @param pixels - array buffer containing pixel values
  81624. * @returns Float32 of pixels
  81625. */
  81626. private _convertPixelArrayToFloat32;
  81627. /**
  81628. * Convert Specular Glossiness Textures to Metallic Roughness
  81629. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81630. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81631. * @param diffuseTexture texture used to store diffuse information
  81632. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81633. * @param factors specular glossiness material factors
  81634. * @param mimeType the mime type to use for the texture
  81635. * @returns pbr metallic roughness interface or null
  81636. */
  81637. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81638. /**
  81639. * Converts specular glossiness material properties to metallic roughness
  81640. * @param specularGlossiness interface with specular glossiness material properties
  81641. * @returns interface with metallic roughness material properties
  81642. */
  81643. private _convertSpecularGlossinessToMetallicRoughness;
  81644. /**
  81645. * Calculates the surface reflectance, independent of lighting conditions
  81646. * @param color Color source to calculate brightness from
  81647. * @returns number representing the perceived brightness, or zero if color is undefined
  81648. */
  81649. private _getPerceivedBrightness;
  81650. /**
  81651. * Returns the maximum color component value
  81652. * @param color
  81653. * @returns maximum color component value, or zero if color is null or undefined
  81654. */
  81655. private _getMaxComponent;
  81656. /**
  81657. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81658. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81659. * @param mimeType mime type to use for the textures
  81660. * @param images array of glTF image interfaces
  81661. * @param textures array of glTF texture interfaces
  81662. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81663. * @param imageData map of image file name to data
  81664. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81665. * @returns glTF PBR Metallic Roughness factors
  81666. */
  81667. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81668. private _getGLTFTextureSampler;
  81669. private _getGLTFTextureWrapMode;
  81670. private _getGLTFTextureWrapModesSampler;
  81671. /**
  81672. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81673. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81674. * @param mimeType mime type to use for the textures
  81675. * @param images array of glTF image interfaces
  81676. * @param textures array of glTF texture interfaces
  81677. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81678. * @param imageData map of image file name to data
  81679. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81680. * @returns glTF PBR Metallic Roughness factors
  81681. */
  81682. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81683. /**
  81684. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81685. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81686. * @param mimeType mime type to use for the textures
  81687. * @param images array of glTF image interfaces
  81688. * @param textures array of glTF texture interfaces
  81689. * @param materials array of glTF material interfaces
  81690. * @param imageData map of image file name to data
  81691. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81692. */
  81693. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81694. private setMetallicRoughnessPbrMaterial;
  81695. private getPixelsFromTexture;
  81696. /**
  81697. * Extracts a texture from a Babylon texture into file data and glTF data
  81698. * @param babylonTexture Babylon texture to extract
  81699. * @param mimeType Mime Type of the babylonTexture
  81700. * @return glTF texture info, or null if the texture format is not supported
  81701. */
  81702. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81703. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81704. /**
  81705. * Builds a texture from base64 string
  81706. * @param base64Texture base64 texture string
  81707. * @param baseTextureName Name to use for the texture
  81708. * @param mimeType image mime type for the texture
  81709. * @param images array of images
  81710. * @param textures array of textures
  81711. * @param imageData map of image data
  81712. * @returns glTF texture info, or null if the texture format is not supported
  81713. */
  81714. private _getTextureInfoFromBase64;
  81715. }
  81716. }
  81717. declare module BABYLON {
  81718. /**
  81719. * Class for holding and downloading glTF file data
  81720. */
  81721. export class GLTFData {
  81722. /**
  81723. * Object which contains the file name as the key and its data as the value
  81724. */
  81725. glTFFiles: {
  81726. [fileName: string]: string | Blob;
  81727. };
  81728. /**
  81729. * Initializes the glTF file object
  81730. */
  81731. constructor();
  81732. /**
  81733. * Downloads the glTF data as files based on their names and data
  81734. */
  81735. downloadFiles(): void;
  81736. }
  81737. }
  81738. declare module BABYLON {
  81739. /**
  81740. * Holds a collection of exporter options and parameters
  81741. */
  81742. export interface IExportOptions {
  81743. /**
  81744. * Function which indicates whether a babylon node should be exported or not
  81745. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81746. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81747. */
  81748. shouldExportNode?(node: Node): boolean;
  81749. /**
  81750. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81751. * @param metadata source metadata to read from
  81752. * @returns the data to store to glTF node extras
  81753. */
  81754. metadataSelector?(metadata: any): any;
  81755. /**
  81756. * The sample rate to bake animation curves
  81757. */
  81758. animationSampleRate?: number;
  81759. /**
  81760. * Begin serialization without waiting for the scene to be ready
  81761. */
  81762. exportWithoutWaitingForScene?: boolean;
  81763. /**
  81764. * Indicates if coordinate system swapping root nodes should be included in export
  81765. */
  81766. includeCoordinateSystemConversionNodes?: boolean;
  81767. }
  81768. /**
  81769. * Class for generating glTF data from a Babylon scene.
  81770. */
  81771. export class GLTF2Export {
  81772. /**
  81773. * Exports the geometry of the scene to .gltf file format asynchronously
  81774. * @param scene Babylon scene with scene hierarchy information
  81775. * @param filePrefix File prefix to use when generating the glTF file
  81776. * @param options Exporter options
  81777. * @returns Returns an object with a .gltf file and associates texture names
  81778. * as keys and their data and paths as values
  81779. */
  81780. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81781. private static _PreExportAsync;
  81782. private static _PostExportAsync;
  81783. /**
  81784. * Exports the geometry of the scene to .glb file format asychronously
  81785. * @param scene Babylon scene with scene hierarchy information
  81786. * @param filePrefix File prefix to use when generating glb file
  81787. * @param options Exporter options
  81788. * @returns Returns an object with a .glb filename as key and data as value
  81789. */
  81790. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81791. }
  81792. }
  81793. declare module BABYLON.GLTF2.Exporter {
  81794. /**
  81795. * @hidden
  81796. */
  81797. export class _GLTFUtilities {
  81798. /**
  81799. * Creates a buffer view based on the supplied arguments
  81800. * @param bufferIndex index value of the specified buffer
  81801. * @param byteOffset byte offset value
  81802. * @param byteLength byte length of the bufferView
  81803. * @param byteStride byte distance between conequential elements
  81804. * @param name name of the buffer view
  81805. * @returns bufferView for glTF
  81806. */
  81807. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81808. /**
  81809. * Creates an accessor based on the supplied arguments
  81810. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81811. * @param name The name of the accessor
  81812. * @param type The type of the accessor
  81813. * @param componentType The datatype of components in the attribute
  81814. * @param count The number of attributes referenced by this accessor
  81815. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81816. * @param min Minimum value of each component in this attribute
  81817. * @param max Maximum value of each component in this attribute
  81818. * @returns accessor for glTF
  81819. */
  81820. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81821. /**
  81822. * Calculates the minimum and maximum values of an array of position floats
  81823. * @param positions Positions array of a mesh
  81824. * @param vertexStart Starting vertex offset to calculate min and max values
  81825. * @param vertexCount Number of vertices to check for min and max values
  81826. * @returns min number array and max number array
  81827. */
  81828. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81829. min: number[];
  81830. max: number[];
  81831. };
  81832. /**
  81833. * Converts a new right-handed Vector3
  81834. * @param vector vector3 array
  81835. * @returns right-handed Vector3
  81836. */
  81837. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81838. /**
  81839. * Converts a Vector3 to right-handed
  81840. * @param vector Vector3 to convert to right-handed
  81841. */
  81842. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81843. /**
  81844. * Converts a three element number array to right-handed
  81845. * @param vector number array to convert to right-handed
  81846. */
  81847. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81848. /**
  81849. * Converts a new right-handed Vector3
  81850. * @param vector vector3 array
  81851. * @returns right-handed Vector3
  81852. */
  81853. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81854. /**
  81855. * Converts a Vector3 to right-handed
  81856. * @param vector Vector3 to convert to right-handed
  81857. */
  81858. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81859. /**
  81860. * Converts a three element number array to right-handed
  81861. * @param vector number array to convert to right-handed
  81862. */
  81863. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81864. /**
  81865. * Converts a Vector4 to right-handed
  81866. * @param vector Vector4 to convert to right-handed
  81867. */
  81868. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81869. /**
  81870. * Converts a Vector4 to right-handed
  81871. * @param vector Vector4 to convert to right-handed
  81872. */
  81873. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81874. /**
  81875. * Converts a Quaternion to right-handed
  81876. * @param quaternion Source quaternion to convert to right-handed
  81877. */
  81878. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81879. /**
  81880. * Converts a Quaternion to right-handed
  81881. * @param quaternion Source quaternion to convert to right-handed
  81882. */
  81883. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81884. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81885. }
  81886. }
  81887. declare module BABYLON.GLTF2.Exporter {
  81888. /**
  81889. * Converts Babylon Scene into glTF 2.0.
  81890. * @hidden
  81891. */
  81892. export class _Exporter {
  81893. /**
  81894. * Stores the glTF to export
  81895. */
  81896. _glTF: IGLTF;
  81897. /**
  81898. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81899. */
  81900. _bufferViews: IBufferView[];
  81901. /**
  81902. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81903. */
  81904. _accessors: IAccessor[];
  81905. /**
  81906. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81907. */
  81908. _nodes: INode[];
  81909. /**
  81910. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81911. */
  81912. private _scenes;
  81913. /**
  81914. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81915. */
  81916. private _meshes;
  81917. /**
  81918. * Stores all the generated material information, which represents the appearance of each primitive
  81919. */
  81920. _materials: IMaterial[];
  81921. _materialMap: {
  81922. [materialID: number]: number;
  81923. };
  81924. /**
  81925. * Stores all the generated texture information, which is referenced by glTF materials
  81926. */
  81927. _textures: ITexture[];
  81928. /**
  81929. * Stores all the generated image information, which is referenced by glTF textures
  81930. */
  81931. _images: IImage[];
  81932. /**
  81933. * Stores all the texture samplers
  81934. */
  81935. _samplers: ISampler[];
  81936. /**
  81937. * Stores all the generated animation samplers, which is referenced by glTF animations
  81938. */
  81939. /**
  81940. * Stores the animations for glTF models
  81941. */
  81942. private _animations;
  81943. /**
  81944. * Stores the total amount of bytes stored in the glTF buffer
  81945. */
  81946. private _totalByteLength;
  81947. /**
  81948. * Stores a reference to the Babylon scene containing the source geometry and material information
  81949. */
  81950. _babylonScene: Scene;
  81951. /**
  81952. * Stores a map of the image data, where the key is the file name and the value
  81953. * is the image data
  81954. */
  81955. _imageData: {
  81956. [fileName: string]: {
  81957. data: Uint8Array;
  81958. mimeType: ImageMimeType;
  81959. };
  81960. };
  81961. /**
  81962. * Stores a map of the unique id of a node to its index in the node array
  81963. */
  81964. _nodeMap: {
  81965. [key: number]: number;
  81966. };
  81967. /**
  81968. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81969. */
  81970. _convertToRightHandedSystem: boolean;
  81971. /**
  81972. * Specifies if a Babylon node should be converted to right-handed on export
  81973. */
  81974. _convertToRightHandedSystemMap: {
  81975. [nodeId: number]: boolean;
  81976. };
  81977. _includeCoordinateSystemConversionNodes: boolean;
  81978. /**
  81979. * Baked animation sample rate
  81980. */
  81981. private _animationSampleRate;
  81982. private _options;
  81983. private _localEngine;
  81984. _glTFMaterialExporter: _GLTFMaterialExporter;
  81985. private _extensions;
  81986. private static _ExtensionNames;
  81987. private static _ExtensionFactories;
  81988. private _applyExtension;
  81989. private _applyExtensions;
  81990. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81991. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81992. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81993. [key: number]: number;
  81994. }): Promise<Nullable<INode>>;
  81995. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81996. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81997. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81998. private _forEachExtensions;
  81999. private _extensionsOnExporting;
  82000. /**
  82001. * Load glTF serializer extensions
  82002. */
  82003. private _loadExtensions;
  82004. /**
  82005. * Creates a glTF Exporter instance, which can accept optional exporter options
  82006. * @param babylonScene Babylon scene object
  82007. * @param options Options to modify the behavior of the exporter
  82008. */
  82009. constructor(babylonScene: Scene, options?: IExportOptions);
  82010. dispose(): void;
  82011. /**
  82012. * Registers a glTF exporter extension
  82013. * @param name Name of the extension to export
  82014. * @param factory The factory function that creates the exporter extension
  82015. */
  82016. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82017. /**
  82018. * Un-registers an exporter extension
  82019. * @param name The name fo the exporter extension
  82020. * @returns A boolean indicating whether the extension has been un-registered
  82021. */
  82022. static UnregisterExtension(name: string): boolean;
  82023. /**
  82024. * Lazy load a local engine
  82025. */
  82026. _getLocalEngine(): Engine;
  82027. private reorderIndicesBasedOnPrimitiveMode;
  82028. /**
  82029. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82030. * clock-wise during export to glTF
  82031. * @param submesh BabylonJS submesh
  82032. * @param primitiveMode Primitive mode of the mesh
  82033. * @param sideOrientation the winding order of the submesh
  82034. * @param vertexBufferKind The type of vertex attribute
  82035. * @param meshAttributeArray The vertex attribute data
  82036. * @param byteOffset The offset to the binary data
  82037. * @param binaryWriter The binary data for the glTF file
  82038. * @param convertToRightHandedSystem Converts the values to right-handed
  82039. */
  82040. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82041. /**
  82042. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82043. * clock-wise during export to glTF
  82044. * @param submesh BabylonJS submesh
  82045. * @param primitiveMode Primitive mode of the mesh
  82046. * @param sideOrientation the winding order of the submesh
  82047. * @param vertexBufferKind The type of vertex attribute
  82048. * @param meshAttributeArray The vertex attribute data
  82049. * @param byteOffset The offset to the binary data
  82050. * @param binaryWriter The binary data for the glTF file
  82051. * @param convertToRightHandedSystem Converts the values to right-handed
  82052. */
  82053. private reorderTriangleFillMode;
  82054. /**
  82055. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82056. * clock-wise during export to glTF
  82057. * @param submesh BabylonJS submesh
  82058. * @param primitiveMode Primitive mode of the mesh
  82059. * @param sideOrientation the winding order of the submesh
  82060. * @param vertexBufferKind The type of vertex attribute
  82061. * @param meshAttributeArray The vertex attribute data
  82062. * @param byteOffset The offset to the binary data
  82063. * @param binaryWriter The binary data for the glTF file
  82064. * @param convertToRightHandedSystem Converts the values to right-handed
  82065. */
  82066. private reorderTriangleStripDrawMode;
  82067. /**
  82068. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82069. * clock-wise during export to glTF
  82070. * @param submesh BabylonJS submesh
  82071. * @param primitiveMode Primitive mode of the mesh
  82072. * @param sideOrientation the winding order of the submesh
  82073. * @param vertexBufferKind The type of vertex attribute
  82074. * @param meshAttributeArray The vertex attribute data
  82075. * @param byteOffset The offset to the binary data
  82076. * @param binaryWriter The binary data for the glTF file
  82077. * @param convertToRightHandedSystem Converts the values to right-handed
  82078. */
  82079. private reorderTriangleFanMode;
  82080. /**
  82081. * Writes the vertex attribute data to binary
  82082. * @param vertices The vertices to write to the binary writer
  82083. * @param byteOffset The offset into the binary writer to overwrite binary data
  82084. * @param vertexAttributeKind The vertex attribute type
  82085. * @param meshAttributeArray The vertex attribute data
  82086. * @param binaryWriter The writer containing the binary data
  82087. * @param convertToRightHandedSystem Converts the values to right-handed
  82088. */
  82089. private writeVertexAttributeData;
  82090. /**
  82091. * Writes mesh attribute data to a data buffer
  82092. * Returns the bytelength of the data
  82093. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82094. * @param meshAttributeArray Array containing the attribute data
  82095. * @param binaryWriter The buffer to write the binary data to
  82096. * @param indices Used to specify the order of the vertex data
  82097. * @param convertToRightHandedSystem Converts the values to right-handed
  82098. */
  82099. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  82100. /**
  82101. * Generates glTF json data
  82102. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82103. * @param glTFPrefix Text to use when prefixing a glTF file
  82104. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82105. * @returns json data as string
  82106. */
  82107. private generateJSON;
  82108. /**
  82109. * Generates data for .gltf and .bin files based on the glTF prefix string
  82110. * @param glTFPrefix Text to use when prefixing a glTF file
  82111. * @param dispose Dispose the exporter
  82112. * @returns GLTFData with glTF file data
  82113. */
  82114. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82115. /**
  82116. * Creates a binary buffer for glTF
  82117. * @returns array buffer for binary data
  82118. */
  82119. private _generateBinaryAsync;
  82120. /**
  82121. * Pads the number to a multiple of 4
  82122. * @param num number to pad
  82123. * @returns padded number
  82124. */
  82125. private _getPadding;
  82126. /**
  82127. * @hidden
  82128. */
  82129. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82130. /**
  82131. * Sets the TRS for each node
  82132. * @param node glTF Node for storing the transformation data
  82133. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82134. * @param convertToRightHandedSystem Converts the values to right-handed
  82135. */
  82136. private setNodeTransformation;
  82137. private getVertexBufferFromMesh;
  82138. /**
  82139. * Creates a bufferview based on the vertices type for the Babylon mesh
  82140. * @param kind Indicates the type of vertices data
  82141. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82142. * @param binaryWriter The buffer to write the bufferview data to
  82143. * @param convertToRightHandedSystem Converts the values to right-handed
  82144. */
  82145. private createBufferViewKind;
  82146. /**
  82147. * The primitive mode of the Babylon mesh
  82148. * @param babylonMesh The BabylonJS mesh
  82149. */
  82150. private getMeshPrimitiveMode;
  82151. /**
  82152. * Sets the primitive mode of the glTF mesh primitive
  82153. * @param meshPrimitive glTF mesh primitive
  82154. * @param primitiveMode The primitive mode
  82155. */
  82156. private setPrimitiveMode;
  82157. /**
  82158. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82159. * @param meshPrimitive glTF mesh primitive
  82160. * @param attributeKind vertex attribute
  82161. * @returns boolean specifying if uv coordinates are present
  82162. */
  82163. private setAttributeKind;
  82164. /**
  82165. * Sets data for the primitive attributes of each submesh
  82166. * @param mesh glTF Mesh object to store the primitive attribute information
  82167. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82168. * @param binaryWriter Buffer to write the attribute data to
  82169. * @param convertToRightHandedSystem Converts the values to right-handed
  82170. */
  82171. private setPrimitiveAttributesAsync;
  82172. /**
  82173. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82174. * @param node The node to check
  82175. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82176. */
  82177. private isBabylonCoordinateSystemConvertingNode;
  82178. /**
  82179. * Creates a glTF scene based on the array of meshes
  82180. * Returns the the total byte offset
  82181. * @param babylonScene Babylon scene to get the mesh data from
  82182. * @param binaryWriter Buffer to write binary data to
  82183. */
  82184. private createSceneAsync;
  82185. /**
  82186. * Creates a mapping of Node unique id to node index and handles animations
  82187. * @param babylonScene Babylon Scene
  82188. * @param nodes Babylon transform nodes
  82189. * @param binaryWriter Buffer to write binary data to
  82190. * @returns Node mapping of unique id to index
  82191. */
  82192. private createNodeMapAndAnimationsAsync;
  82193. /**
  82194. * Creates a glTF node from a Babylon mesh
  82195. * @param babylonMesh Source Babylon mesh
  82196. * @param binaryWriter Buffer for storing geometry data
  82197. * @param convertToRightHandedSystem Converts the values to right-handed
  82198. * @param nodeMap Node mapping of unique id to glTF node index
  82199. * @returns glTF node
  82200. */
  82201. private createNodeAsync;
  82202. }
  82203. /**
  82204. * @hidden
  82205. *
  82206. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82207. */
  82208. export class _BinaryWriter {
  82209. /**
  82210. * Array buffer which stores all binary data
  82211. */
  82212. private _arrayBuffer;
  82213. /**
  82214. * View of the array buffer
  82215. */
  82216. private _dataView;
  82217. /**
  82218. * byte offset of data in array buffer
  82219. */
  82220. private _byteOffset;
  82221. /**
  82222. * Initialize binary writer with an initial byte length
  82223. * @param byteLength Initial byte length of the array buffer
  82224. */
  82225. constructor(byteLength: number);
  82226. /**
  82227. * Resize the array buffer to the specified byte length
  82228. * @param byteLength
  82229. */
  82230. private resizeBuffer;
  82231. /**
  82232. * Get an array buffer with the length of the byte offset
  82233. * @returns ArrayBuffer resized to the byte offset
  82234. */
  82235. getArrayBuffer(): ArrayBuffer;
  82236. /**
  82237. * Get the byte offset of the array buffer
  82238. * @returns byte offset
  82239. */
  82240. getByteOffset(): number;
  82241. /**
  82242. * Stores an UInt8 in the array buffer
  82243. * @param entry
  82244. * @param byteOffset If defined, specifies where to set the value as an offset.
  82245. */
  82246. setUInt8(entry: number, byteOffset?: number): void;
  82247. /**
  82248. * Gets an UInt32 in the array buffer
  82249. * @param entry
  82250. * @param byteOffset If defined, specifies where to set the value as an offset.
  82251. */
  82252. getUInt32(byteOffset: number): number;
  82253. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82254. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82255. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82256. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82257. /**
  82258. * Stores a Float32 in the array buffer
  82259. * @param entry
  82260. */
  82261. setFloat32(entry: number, byteOffset?: number): void;
  82262. /**
  82263. * Stores an UInt32 in the array buffer
  82264. * @param entry
  82265. * @param byteOffset If defined, specifies where to set the value as an offset.
  82266. */
  82267. setUInt32(entry: number, byteOffset?: number): void;
  82268. }
  82269. }
  82270. declare module BABYLON.GLTF2.Exporter {
  82271. /**
  82272. * @hidden
  82273. * Interface to store animation data.
  82274. */
  82275. export interface _IAnimationData {
  82276. /**
  82277. * Keyframe data.
  82278. */
  82279. inputs: number[];
  82280. /**
  82281. * Value data.
  82282. */
  82283. outputs: number[][];
  82284. /**
  82285. * Animation interpolation data.
  82286. */
  82287. samplerInterpolation: AnimationSamplerInterpolation;
  82288. /**
  82289. * Minimum keyframe value.
  82290. */
  82291. inputsMin: number;
  82292. /**
  82293. * Maximum keyframe value.
  82294. */
  82295. inputsMax: number;
  82296. }
  82297. /**
  82298. * @hidden
  82299. */
  82300. export interface _IAnimationInfo {
  82301. /**
  82302. * The target channel for the animation
  82303. */
  82304. animationChannelTargetPath: AnimationChannelTargetPath;
  82305. /**
  82306. * The glTF accessor type for the data.
  82307. */
  82308. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82309. /**
  82310. * Specifies if quaternions should be used.
  82311. */
  82312. useQuaternion: boolean;
  82313. }
  82314. /**
  82315. * @hidden
  82316. * Utility class for generating glTF animation data from BabylonJS.
  82317. */
  82318. export class _GLTFAnimation {
  82319. /**
  82320. * @ignore
  82321. *
  82322. * Creates glTF channel animation from BabylonJS animation.
  82323. * @param babylonTransformNode - BabylonJS mesh.
  82324. * @param animation - animation.
  82325. * @param animationChannelTargetPath - The target animation channel.
  82326. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82327. * @param useQuaternion - Specifies if quaternions are used.
  82328. * @returns nullable IAnimationData
  82329. */
  82330. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82331. private static _DeduceAnimationInfo;
  82332. /**
  82333. * @ignore
  82334. * Create node animations from the transform node animations
  82335. * @param babylonNode
  82336. * @param runtimeGLTFAnimation
  82337. * @param idleGLTFAnimations
  82338. * @param nodeMap
  82339. * @param nodes
  82340. * @param binaryWriter
  82341. * @param bufferViews
  82342. * @param accessors
  82343. * @param convertToRightHandedSystem
  82344. * @param animationSampleRate
  82345. */
  82346. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82347. [key: number]: number;
  82348. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82349. /**
  82350. * @ignore
  82351. * Create node animations from the animation groups
  82352. * @param babylonScene
  82353. * @param glTFAnimations
  82354. * @param nodeMap
  82355. * @param nodes
  82356. * @param binaryWriter
  82357. * @param bufferViews
  82358. * @param accessors
  82359. * @param convertToRightHandedSystemMap
  82360. * @param animationSampleRate
  82361. */
  82362. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82363. [key: number]: number;
  82364. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82365. [nodeId: number]: boolean;
  82366. }, animationSampleRate: number): void;
  82367. private static AddAnimation;
  82368. /**
  82369. * Create a baked animation
  82370. * @param babylonTransformNode BabylonJS mesh
  82371. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82372. * @param animationChannelTargetPath animation target channel
  82373. * @param minFrame minimum animation frame
  82374. * @param maxFrame maximum animation frame
  82375. * @param fps frames per second of the animation
  82376. * @param inputs input key frames of the animation
  82377. * @param outputs output key frame data of the animation
  82378. * @param convertToRightHandedSystem converts the values to right-handed
  82379. * @param useQuaternion specifies if quaternions should be used
  82380. */
  82381. private static _CreateBakedAnimation;
  82382. private static _ConvertFactorToVector3OrQuaternion;
  82383. private static _SetInterpolatedValue;
  82384. /**
  82385. * Creates linear animation from the animation key frames
  82386. * @param babylonTransformNode BabylonJS mesh
  82387. * @param animation BabylonJS animation
  82388. * @param animationChannelTargetPath The target animation channel
  82389. * @param frameDelta The difference between the last and first frame of the animation
  82390. * @param inputs Array to store the key frame times
  82391. * @param outputs Array to store the key frame data
  82392. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82393. * @param useQuaternion Specifies if quaternions are used in the animation
  82394. */
  82395. private static _CreateLinearOrStepAnimation;
  82396. /**
  82397. * Creates cubic spline animation from the animation key frames
  82398. * @param babylonTransformNode BabylonJS mesh
  82399. * @param animation BabylonJS animation
  82400. * @param animationChannelTargetPath The target animation channel
  82401. * @param frameDelta The difference between the last and first frame of the animation
  82402. * @param inputs Array to store the key frame times
  82403. * @param outputs Array to store the key frame data
  82404. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82405. * @param useQuaternion Specifies if quaternions are used in the animation
  82406. */
  82407. private static _CreateCubicSplineAnimation;
  82408. private static _GetBasePositionRotationOrScale;
  82409. /**
  82410. * Adds a key frame value
  82411. * @param keyFrame
  82412. * @param animation
  82413. * @param outputs
  82414. * @param animationChannelTargetPath
  82415. * @param basePositionRotationOrScale
  82416. * @param convertToRightHandedSystem
  82417. * @param useQuaternion
  82418. */
  82419. private static _AddKeyframeValue;
  82420. /**
  82421. * Determine the interpolation based on the key frames
  82422. * @param keyFrames
  82423. * @param animationChannelTargetPath
  82424. * @param useQuaternion
  82425. */
  82426. private static _DeduceInterpolation;
  82427. /**
  82428. * Adds an input tangent or output tangent to the output data
  82429. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82430. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82431. * @param outputs The animation data by keyframe
  82432. * @param animationChannelTargetPath The target animation channel
  82433. * @param interpolation The interpolation type
  82434. * @param keyFrame The key frame with the animation data
  82435. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82436. * @param useQuaternion Specifies if quaternions are used
  82437. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82438. */
  82439. private static AddSplineTangent;
  82440. /**
  82441. * Get the minimum and maximum key frames' frame values
  82442. * @param keyFrames animation key frames
  82443. * @returns the minimum and maximum key frame value
  82444. */
  82445. private static calculateMinMaxKeyFrames;
  82446. }
  82447. }
  82448. declare module BABYLON.GLTF2.Exporter {
  82449. /** @hidden */
  82450. export var textureTransformPixelShader: {
  82451. name: string;
  82452. shader: string;
  82453. };
  82454. }
  82455. declare module BABYLON.GLTF2.Exporter.Extensions {
  82456. /**
  82457. * @hidden
  82458. */
  82459. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82460. private _recordedTextures;
  82461. /** Name of this extension */
  82462. readonly name: string;
  82463. /** Defines whether this extension is enabled */
  82464. enabled: boolean;
  82465. /** Defines whether this extension is required */
  82466. required: boolean;
  82467. /** Reference to the glTF exporter */
  82468. private _wasUsed;
  82469. constructor(exporter: _Exporter);
  82470. dispose(): void;
  82471. /** @hidden */
  82472. get wasUsed(): boolean;
  82473. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82474. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82475. /**
  82476. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82477. * @param babylonTexture
  82478. * @param offset
  82479. * @param rotation
  82480. * @param scale
  82481. * @param scene
  82482. */
  82483. private _textureTransformTextureAsync;
  82484. }
  82485. }
  82486. declare module BABYLON.GLTF2.Exporter.Extensions {
  82487. /**
  82488. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82489. */
  82490. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82491. /** The name of this extension. */
  82492. readonly name: string;
  82493. /** Defines whether this extension is enabled. */
  82494. enabled: boolean;
  82495. /** Defines whether this extension is required */
  82496. required: boolean;
  82497. /** Reference to the glTF exporter */
  82498. private _exporter;
  82499. private _lights;
  82500. /** @hidden */
  82501. constructor(exporter: _Exporter);
  82502. /** @hidden */
  82503. dispose(): void;
  82504. /** @hidden */
  82505. get wasUsed(): boolean;
  82506. /** @hidden */
  82507. onExporting(): void;
  82508. /**
  82509. * Define this method to modify the default behavior when exporting a node
  82510. * @param context The context when exporting the node
  82511. * @param node glTF node
  82512. * @param babylonNode BabylonJS node
  82513. * @param nodeMap Node mapping of unique id to glTF node index
  82514. * @returns nullable INode promise
  82515. */
  82516. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82517. [key: number]: number;
  82518. }): Promise<Nullable<INode>>;
  82519. }
  82520. }
  82521. declare module BABYLON.GLTF2.Exporter.Extensions {
  82522. /**
  82523. * @hidden
  82524. */
  82525. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82526. /** Name of this extension */
  82527. readonly name: string;
  82528. /** Defines whether this extension is enabled */
  82529. enabled: boolean;
  82530. /** Defines whether this extension is required */
  82531. required: boolean;
  82532. /** Reference to the glTF exporter */
  82533. private _textureInfos;
  82534. private _exportedTextures;
  82535. private _wasUsed;
  82536. constructor(exporter: _Exporter);
  82537. dispose(): void;
  82538. /** @hidden */
  82539. get wasUsed(): boolean;
  82540. private _getTextureIndex;
  82541. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82542. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82543. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82544. }
  82545. }
  82546. declare module BABYLON.GLTF2.Exporter.Extensions {
  82547. /**
  82548. * @hidden
  82549. */
  82550. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82551. /** Name of this extension */
  82552. readonly name: string;
  82553. /** Defines whether this extension is enabled */
  82554. enabled: boolean;
  82555. /** Defines whether this extension is required */
  82556. required: boolean;
  82557. private _wasUsed;
  82558. constructor(exporter: _Exporter);
  82559. /** @hidden */
  82560. get wasUsed(): boolean;
  82561. dispose(): void;
  82562. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82563. }
  82564. }
  82565. declare module BABYLON {
  82566. /**
  82567. * Class for generating STL data from a Babylon scene.
  82568. */
  82569. export class STLExport {
  82570. /**
  82571. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82572. * @param meshes list defines the mesh to serialize
  82573. * @param download triggers the automatic download of the file.
  82574. * @param fileName changes the downloads fileName.
  82575. * @param binary changes the STL to a binary type.
  82576. * @param isLittleEndian toggle for binary type exporter.
  82577. * @returns the STL as UTF8 string
  82578. */
  82579. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82580. }
  82581. }
  82582. declare module "babylonjs-gltf2interface" {
  82583. export = BABYLON.GLTF2;
  82584. }
  82585. /**
  82586. * Module for glTF 2.0 Interface
  82587. */
  82588. declare module BABYLON.GLTF2 {
  82589. /**
  82590. * The datatype of the components in the attribute
  82591. */
  82592. const enum AccessorComponentType {
  82593. /**
  82594. * Byte
  82595. */
  82596. BYTE = 5120,
  82597. /**
  82598. * Unsigned Byte
  82599. */
  82600. UNSIGNED_BYTE = 5121,
  82601. /**
  82602. * Short
  82603. */
  82604. SHORT = 5122,
  82605. /**
  82606. * Unsigned Short
  82607. */
  82608. UNSIGNED_SHORT = 5123,
  82609. /**
  82610. * Unsigned Int
  82611. */
  82612. UNSIGNED_INT = 5125,
  82613. /**
  82614. * Float
  82615. */
  82616. FLOAT = 5126,
  82617. }
  82618. /**
  82619. * Specifies if the attirbute is a scalar, vector, or matrix
  82620. */
  82621. const enum AccessorType {
  82622. /**
  82623. * Scalar
  82624. */
  82625. SCALAR = "SCALAR",
  82626. /**
  82627. * Vector2
  82628. */
  82629. VEC2 = "VEC2",
  82630. /**
  82631. * Vector3
  82632. */
  82633. VEC3 = "VEC3",
  82634. /**
  82635. * Vector4
  82636. */
  82637. VEC4 = "VEC4",
  82638. /**
  82639. * Matrix2x2
  82640. */
  82641. MAT2 = "MAT2",
  82642. /**
  82643. * Matrix3x3
  82644. */
  82645. MAT3 = "MAT3",
  82646. /**
  82647. * Matrix4x4
  82648. */
  82649. MAT4 = "MAT4",
  82650. }
  82651. /**
  82652. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82653. */
  82654. const enum AnimationChannelTargetPath {
  82655. /**
  82656. * Translation
  82657. */
  82658. TRANSLATION = "translation",
  82659. /**
  82660. * Rotation
  82661. */
  82662. ROTATION = "rotation",
  82663. /**
  82664. * Scale
  82665. */
  82666. SCALE = "scale",
  82667. /**
  82668. * Weights
  82669. */
  82670. WEIGHTS = "weights",
  82671. }
  82672. /**
  82673. * Interpolation algorithm
  82674. */
  82675. const enum AnimationSamplerInterpolation {
  82676. /**
  82677. * The animated values are linearly interpolated between keyframes
  82678. */
  82679. LINEAR = "LINEAR",
  82680. /**
  82681. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82682. */
  82683. STEP = "STEP",
  82684. /**
  82685. * The animation's interpolation is computed using a cubic spline with specified tangents
  82686. */
  82687. CUBICSPLINE = "CUBICSPLINE",
  82688. }
  82689. /**
  82690. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82691. */
  82692. const enum CameraType {
  82693. /**
  82694. * A perspective camera containing properties to create a perspective projection matrix
  82695. */
  82696. PERSPECTIVE = "perspective",
  82697. /**
  82698. * An orthographic camera containing properties to create an orthographic projection matrix
  82699. */
  82700. ORTHOGRAPHIC = "orthographic",
  82701. }
  82702. /**
  82703. * The mime-type of the image
  82704. */
  82705. const enum ImageMimeType {
  82706. /**
  82707. * JPEG Mime-type
  82708. */
  82709. JPEG = "image/jpeg",
  82710. /**
  82711. * PNG Mime-type
  82712. */
  82713. PNG = "image/png",
  82714. }
  82715. /**
  82716. * The alpha rendering mode of the material
  82717. */
  82718. const enum MaterialAlphaMode {
  82719. /**
  82720. * The alpha value is ignored and the rendered output is fully opaque
  82721. */
  82722. OPAQUE = "OPAQUE",
  82723. /**
  82724. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82725. */
  82726. MASK = "MASK",
  82727. /**
  82728. * 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)
  82729. */
  82730. BLEND = "BLEND",
  82731. }
  82732. /**
  82733. * The type of the primitives to render
  82734. */
  82735. const enum MeshPrimitiveMode {
  82736. /**
  82737. * Points
  82738. */
  82739. POINTS = 0,
  82740. /**
  82741. * Lines
  82742. */
  82743. LINES = 1,
  82744. /**
  82745. * Line Loop
  82746. */
  82747. LINE_LOOP = 2,
  82748. /**
  82749. * Line Strip
  82750. */
  82751. LINE_STRIP = 3,
  82752. /**
  82753. * Triangles
  82754. */
  82755. TRIANGLES = 4,
  82756. /**
  82757. * Triangle Strip
  82758. */
  82759. TRIANGLE_STRIP = 5,
  82760. /**
  82761. * Triangle Fan
  82762. */
  82763. TRIANGLE_FAN = 6,
  82764. }
  82765. /**
  82766. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82767. */
  82768. const enum TextureMagFilter {
  82769. /**
  82770. * Nearest
  82771. */
  82772. NEAREST = 9728,
  82773. /**
  82774. * Linear
  82775. */
  82776. LINEAR = 9729,
  82777. }
  82778. /**
  82779. * Minification filter. All valid values correspond to WebGL enums
  82780. */
  82781. const enum TextureMinFilter {
  82782. /**
  82783. * Nearest
  82784. */
  82785. NEAREST = 9728,
  82786. /**
  82787. * Linear
  82788. */
  82789. LINEAR = 9729,
  82790. /**
  82791. * Nearest Mip-Map Nearest
  82792. */
  82793. NEAREST_MIPMAP_NEAREST = 9984,
  82794. /**
  82795. * Linear Mipmap Nearest
  82796. */
  82797. LINEAR_MIPMAP_NEAREST = 9985,
  82798. /**
  82799. * Nearest Mipmap Linear
  82800. */
  82801. NEAREST_MIPMAP_LINEAR = 9986,
  82802. /**
  82803. * Linear Mipmap Linear
  82804. */
  82805. LINEAR_MIPMAP_LINEAR = 9987,
  82806. }
  82807. /**
  82808. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82809. */
  82810. const enum TextureWrapMode {
  82811. /**
  82812. * Clamp to Edge
  82813. */
  82814. CLAMP_TO_EDGE = 33071,
  82815. /**
  82816. * Mirrored Repeat
  82817. */
  82818. MIRRORED_REPEAT = 33648,
  82819. /**
  82820. * Repeat
  82821. */
  82822. REPEAT = 10497,
  82823. }
  82824. /**
  82825. * glTF Property
  82826. */
  82827. interface IProperty {
  82828. /**
  82829. * Dictionary object with extension-specific objects
  82830. */
  82831. extensions?: {
  82832. [key: string]: any;
  82833. };
  82834. /**
  82835. * Application-Specific data
  82836. */
  82837. extras?: any;
  82838. }
  82839. /**
  82840. * glTF Child of Root Property
  82841. */
  82842. interface IChildRootProperty extends IProperty {
  82843. /**
  82844. * The user-defined name of this object
  82845. */
  82846. name?: string;
  82847. }
  82848. /**
  82849. * Indices of those attributes that deviate from their initialization value
  82850. */
  82851. interface IAccessorSparseIndices extends IProperty {
  82852. /**
  82853. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82854. */
  82855. bufferView: number;
  82856. /**
  82857. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82858. */
  82859. byteOffset?: number;
  82860. /**
  82861. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82862. */
  82863. componentType: AccessorComponentType;
  82864. }
  82865. /**
  82866. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82867. */
  82868. interface IAccessorSparseValues extends IProperty {
  82869. /**
  82870. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82871. */
  82872. bufferView: number;
  82873. /**
  82874. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82875. */
  82876. byteOffset?: number;
  82877. }
  82878. /**
  82879. * Sparse storage of attributes that deviate from their initialization value
  82880. */
  82881. interface IAccessorSparse extends IProperty {
  82882. /**
  82883. * The number of attributes encoded in this sparse accessor
  82884. */
  82885. count: number;
  82886. /**
  82887. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82888. */
  82889. indices: IAccessorSparseIndices;
  82890. /**
  82891. * 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
  82892. */
  82893. values: IAccessorSparseValues;
  82894. }
  82895. /**
  82896. * 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
  82897. */
  82898. interface IAccessor extends IChildRootProperty {
  82899. /**
  82900. * The index of the bufferview
  82901. */
  82902. bufferView?: number;
  82903. /**
  82904. * The offset relative to the start of the bufferView in bytes
  82905. */
  82906. byteOffset?: number;
  82907. /**
  82908. * The datatype of components in the attribute
  82909. */
  82910. componentType: AccessorComponentType;
  82911. /**
  82912. * Specifies whether integer data values should be normalized
  82913. */
  82914. normalized?: boolean;
  82915. /**
  82916. * The number of attributes referenced by this accessor
  82917. */
  82918. count: number;
  82919. /**
  82920. * Specifies if the attribute is a scalar, vector, or matrix
  82921. */
  82922. type: AccessorType;
  82923. /**
  82924. * Maximum value of each component in this attribute
  82925. */
  82926. max?: number[];
  82927. /**
  82928. * Minimum value of each component in this attribute
  82929. */
  82930. min?: number[];
  82931. /**
  82932. * Sparse storage of attributes that deviate from their initialization value
  82933. */
  82934. sparse?: IAccessorSparse;
  82935. }
  82936. /**
  82937. * Targets an animation's sampler at a node's property
  82938. */
  82939. interface IAnimationChannel extends IProperty {
  82940. /**
  82941. * The index of a sampler in this animation used to compute the value for the target
  82942. */
  82943. sampler: number;
  82944. /**
  82945. * The index of the node and TRS property to target
  82946. */
  82947. target: IAnimationChannelTarget;
  82948. }
  82949. /**
  82950. * The index of the node and TRS property that an animation channel targets
  82951. */
  82952. interface IAnimationChannelTarget extends IProperty {
  82953. /**
  82954. * The index of the node to target
  82955. */
  82956. node: number;
  82957. /**
  82958. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82959. */
  82960. path: AnimationChannelTargetPath;
  82961. }
  82962. /**
  82963. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82964. */
  82965. interface IAnimationSampler extends IProperty {
  82966. /**
  82967. * The index of an accessor containing keyframe input values, e.g., time
  82968. */
  82969. input: number;
  82970. /**
  82971. * Interpolation algorithm
  82972. */
  82973. interpolation?: AnimationSamplerInterpolation;
  82974. /**
  82975. * The index of an accessor, containing keyframe output values
  82976. */
  82977. output: number;
  82978. }
  82979. /**
  82980. * A keyframe animation
  82981. */
  82982. interface IAnimation extends IChildRootProperty {
  82983. /**
  82984. * An array of channels, each of which targets an animation's sampler at a node's property
  82985. */
  82986. channels: IAnimationChannel[];
  82987. /**
  82988. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82989. */
  82990. samplers: IAnimationSampler[];
  82991. }
  82992. /**
  82993. * Metadata about the glTF asset
  82994. */
  82995. interface IAsset extends IChildRootProperty {
  82996. /**
  82997. * A copyright message suitable for display to credit the content creator
  82998. */
  82999. copyright?: string;
  83000. /**
  83001. * Tool that generated this glTF model. Useful for debugging
  83002. */
  83003. generator?: string;
  83004. /**
  83005. * The glTF version that this asset targets
  83006. */
  83007. version: string;
  83008. /**
  83009. * The minimum glTF version that this asset targets
  83010. */
  83011. minVersion?: string;
  83012. }
  83013. /**
  83014. * A buffer points to binary geometry, animation, or skins
  83015. */
  83016. interface IBuffer extends IChildRootProperty {
  83017. /**
  83018. * 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
  83019. */
  83020. uri?: string;
  83021. /**
  83022. * The length of the buffer in bytes
  83023. */
  83024. byteLength: number;
  83025. }
  83026. /**
  83027. * A view into a buffer generally representing a subset of the buffer
  83028. */
  83029. interface IBufferView extends IChildRootProperty {
  83030. /**
  83031. * The index of the buffer
  83032. */
  83033. buffer: number;
  83034. /**
  83035. * The offset into the buffer in bytes
  83036. */
  83037. byteOffset?: number;
  83038. /**
  83039. * The lenth of the bufferView in bytes
  83040. */
  83041. byteLength: number;
  83042. /**
  83043. * The stride, in bytes
  83044. */
  83045. byteStride?: number;
  83046. }
  83047. /**
  83048. * An orthographic camera containing properties to create an orthographic projection matrix
  83049. */
  83050. interface ICameraOrthographic extends IProperty {
  83051. /**
  83052. * The floating-point horizontal magnification of the view. Must not be zero
  83053. */
  83054. xmag: number;
  83055. /**
  83056. * The floating-point vertical magnification of the view. Must not be zero
  83057. */
  83058. ymag: number;
  83059. /**
  83060. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83061. */
  83062. zfar: number;
  83063. /**
  83064. * The floating-point distance to the near clipping plane
  83065. */
  83066. znear: number;
  83067. }
  83068. /**
  83069. * A perspective camera containing properties to create a perspective projection matrix
  83070. */
  83071. interface ICameraPerspective extends IProperty {
  83072. /**
  83073. * The floating-point aspect ratio of the field of view
  83074. */
  83075. aspectRatio?: number;
  83076. /**
  83077. * The floating-point vertical field of view in radians
  83078. */
  83079. yfov: number;
  83080. /**
  83081. * The floating-point distance to the far clipping plane
  83082. */
  83083. zfar?: number;
  83084. /**
  83085. * The floating-point distance to the near clipping plane
  83086. */
  83087. znear: number;
  83088. }
  83089. /**
  83090. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83091. */
  83092. interface ICamera extends IChildRootProperty {
  83093. /**
  83094. * An orthographic camera containing properties to create an orthographic projection matrix
  83095. */
  83096. orthographic?: ICameraOrthographic;
  83097. /**
  83098. * A perspective camera containing properties to create a perspective projection matrix
  83099. */
  83100. perspective?: ICameraPerspective;
  83101. /**
  83102. * Specifies if the camera uses a perspective or orthographic projection
  83103. */
  83104. type: CameraType;
  83105. }
  83106. /**
  83107. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83108. */
  83109. interface IImage extends IChildRootProperty {
  83110. /**
  83111. * 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
  83112. */
  83113. uri?: string;
  83114. /**
  83115. * The image's MIME type
  83116. */
  83117. mimeType?: ImageMimeType;
  83118. /**
  83119. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83120. */
  83121. bufferView?: number;
  83122. }
  83123. /**
  83124. * Material Normal Texture Info
  83125. */
  83126. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83127. /**
  83128. * The scalar multiplier applied to each normal vector of the normal texture
  83129. */
  83130. scale?: number;
  83131. }
  83132. /**
  83133. * Material Occlusion Texture Info
  83134. */
  83135. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83136. /**
  83137. * A scalar multiplier controlling the amount of occlusion applied
  83138. */
  83139. strength?: number;
  83140. }
  83141. /**
  83142. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83143. */
  83144. interface IMaterialPbrMetallicRoughness {
  83145. /**
  83146. * The material's base color factor
  83147. */
  83148. baseColorFactor?: number[];
  83149. /**
  83150. * The base color texture
  83151. */
  83152. baseColorTexture?: ITextureInfo;
  83153. /**
  83154. * The metalness of the material
  83155. */
  83156. metallicFactor?: number;
  83157. /**
  83158. * The roughness of the material
  83159. */
  83160. roughnessFactor?: number;
  83161. /**
  83162. * The metallic-roughness texture
  83163. */
  83164. metallicRoughnessTexture?: ITextureInfo;
  83165. }
  83166. /**
  83167. * The material appearance of a primitive
  83168. */
  83169. interface IMaterial extends IChildRootProperty {
  83170. /**
  83171. * 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
  83172. */
  83173. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83174. /**
  83175. * The normal map texture
  83176. */
  83177. normalTexture?: IMaterialNormalTextureInfo;
  83178. /**
  83179. * The occlusion map texture
  83180. */
  83181. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83182. /**
  83183. * The emissive map texture
  83184. */
  83185. emissiveTexture?: ITextureInfo;
  83186. /**
  83187. * 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
  83188. */
  83189. emissiveFactor?: number[];
  83190. /**
  83191. * The alpha rendering mode of the material
  83192. */
  83193. alphaMode?: MaterialAlphaMode;
  83194. /**
  83195. * The alpha cutoff value of the material
  83196. */
  83197. alphaCutoff?: number;
  83198. /**
  83199. * Specifies whether the material is double sided
  83200. */
  83201. doubleSided?: boolean;
  83202. }
  83203. /**
  83204. * Geometry to be rendered with the given material
  83205. */
  83206. interface IMeshPrimitive extends IProperty {
  83207. /**
  83208. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83209. */
  83210. attributes: {
  83211. [name: string]: number;
  83212. };
  83213. /**
  83214. * The index of the accessor that contains the indices
  83215. */
  83216. indices?: number;
  83217. /**
  83218. * The index of the material to apply to this primitive when rendering
  83219. */
  83220. material?: number;
  83221. /**
  83222. * The type of primitives to render. All valid values correspond to WebGL enums
  83223. */
  83224. mode?: MeshPrimitiveMode;
  83225. /**
  83226. * 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
  83227. */
  83228. targets?: {
  83229. [name: string]: number;
  83230. }[];
  83231. }
  83232. /**
  83233. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83234. */
  83235. interface IMesh extends IChildRootProperty {
  83236. /**
  83237. * An array of primitives, each defining geometry to be rendered with a material
  83238. */
  83239. primitives: IMeshPrimitive[];
  83240. /**
  83241. * Array of weights to be applied to the Morph Targets
  83242. */
  83243. weights?: number[];
  83244. }
  83245. /**
  83246. * A node in the node hierarchy
  83247. */
  83248. interface INode extends IChildRootProperty {
  83249. /**
  83250. * The index of the camera referenced by this node
  83251. */
  83252. camera?: number;
  83253. /**
  83254. * The indices of this node's children
  83255. */
  83256. children?: number[];
  83257. /**
  83258. * The index of the skin referenced by this node
  83259. */
  83260. skin?: number;
  83261. /**
  83262. * A floating-point 4x4 transformation matrix stored in column-major order
  83263. */
  83264. matrix?: number[];
  83265. /**
  83266. * The index of the mesh in this node
  83267. */
  83268. mesh?: number;
  83269. /**
  83270. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83271. */
  83272. rotation?: number[];
  83273. /**
  83274. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83275. */
  83276. scale?: number[];
  83277. /**
  83278. * The node's translation along the x, y, and z axes
  83279. */
  83280. translation?: number[];
  83281. /**
  83282. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83283. */
  83284. weights?: number[];
  83285. }
  83286. /**
  83287. * Texture sampler properties for filtering and wrapping modes
  83288. */
  83289. interface ISampler extends IChildRootProperty {
  83290. /**
  83291. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83292. */
  83293. magFilter?: TextureMagFilter;
  83294. /**
  83295. * Minification filter. All valid values correspond to WebGL enums
  83296. */
  83297. minFilter?: TextureMinFilter;
  83298. /**
  83299. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83300. */
  83301. wrapS?: TextureWrapMode;
  83302. /**
  83303. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83304. */
  83305. wrapT?: TextureWrapMode;
  83306. }
  83307. /**
  83308. * The root nodes of a scene
  83309. */
  83310. interface IScene extends IChildRootProperty {
  83311. /**
  83312. * The indices of each root node
  83313. */
  83314. nodes: number[];
  83315. }
  83316. /**
  83317. * Joints and matrices defining a skin
  83318. */
  83319. interface ISkin extends IChildRootProperty {
  83320. /**
  83321. * 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
  83322. */
  83323. inverseBindMatrices?: number;
  83324. /**
  83325. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83326. */
  83327. skeleton?: number;
  83328. /**
  83329. * 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)
  83330. */
  83331. joints: number[];
  83332. }
  83333. /**
  83334. * A texture and its sampler
  83335. */
  83336. interface ITexture extends IChildRootProperty {
  83337. /**
  83338. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83339. */
  83340. sampler?: number;
  83341. /**
  83342. * The index of the image used by this texture
  83343. */
  83344. source: number;
  83345. }
  83346. /**
  83347. * Reference to a texture
  83348. */
  83349. interface ITextureInfo extends IProperty {
  83350. /**
  83351. * The index of the texture
  83352. */
  83353. index: number;
  83354. /**
  83355. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83356. */
  83357. texCoord?: number;
  83358. }
  83359. /**
  83360. * The root object for a glTF asset
  83361. */
  83362. interface IGLTF extends IProperty {
  83363. /**
  83364. * An array of accessors. An accessor is a typed view into a bufferView
  83365. */
  83366. accessors?: IAccessor[];
  83367. /**
  83368. * An array of keyframe animations
  83369. */
  83370. animations?: IAnimation[];
  83371. /**
  83372. * Metadata about the glTF asset
  83373. */
  83374. asset: IAsset;
  83375. /**
  83376. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83377. */
  83378. buffers?: IBuffer[];
  83379. /**
  83380. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83381. */
  83382. bufferViews?: IBufferView[];
  83383. /**
  83384. * An array of cameras
  83385. */
  83386. cameras?: ICamera[];
  83387. /**
  83388. * Names of glTF extensions used somewhere in this asset
  83389. */
  83390. extensionsUsed?: string[];
  83391. /**
  83392. * Names of glTF extensions required to properly load this asset
  83393. */
  83394. extensionsRequired?: string[];
  83395. /**
  83396. * An array of images. An image defines data used to create a texture
  83397. */
  83398. images?: IImage[];
  83399. /**
  83400. * An array of materials. A material defines the appearance of a primitive
  83401. */
  83402. materials?: IMaterial[];
  83403. /**
  83404. * An array of meshes. A mesh is a set of primitives to be rendered
  83405. */
  83406. meshes?: IMesh[];
  83407. /**
  83408. * An array of nodes
  83409. */
  83410. nodes?: INode[];
  83411. /**
  83412. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83413. */
  83414. samplers?: ISampler[];
  83415. /**
  83416. * The index of the default scene
  83417. */
  83418. scene?: number;
  83419. /**
  83420. * An array of scenes
  83421. */
  83422. scenes?: IScene[];
  83423. /**
  83424. * An array of skins. A skin is defined by joints and matrices
  83425. */
  83426. skins?: ISkin[];
  83427. /**
  83428. * An array of textures
  83429. */
  83430. textures?: ITexture[];
  83431. }
  83432. /**
  83433. * The glTF validation results
  83434. * @ignore
  83435. */
  83436. interface IGLTFValidationResults {
  83437. info: {
  83438. generator: string;
  83439. hasAnimations: boolean;
  83440. hasDefaultScene: boolean;
  83441. hasMaterials: boolean;
  83442. hasMorphTargets: boolean;
  83443. hasSkins: boolean;
  83444. hasTextures: boolean;
  83445. maxAttributesUsed: number;
  83446. primitivesCount: number
  83447. };
  83448. issues: {
  83449. messages: Array<string>;
  83450. numErrors: number;
  83451. numHints: number;
  83452. numInfos: number;
  83453. numWarnings: number;
  83454. truncated: boolean
  83455. };
  83456. mimeType: string;
  83457. uri: string;
  83458. validatedAt: string;
  83459. validatorVersion: string;
  83460. }
  83461. /**
  83462. * The glTF validation options
  83463. */
  83464. interface IGLTFValidationOptions {
  83465. /** Uri to use */
  83466. uri?: string;
  83467. /** Function used to load external resources */
  83468. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83469. /** Boolean indicating that we need to validate accessor data */
  83470. validateAccessorData?: boolean;
  83471. /** max number of issues allowed */
  83472. maxIssues?: number;
  83473. /** Ignored issues */
  83474. ignoredIssues?: Array<string>;
  83475. /** Value to override severy settings */
  83476. severityOverrides?: Object;
  83477. }
  83478. /**
  83479. * The glTF validator object
  83480. * @ignore
  83481. */
  83482. interface IGLTFValidator {
  83483. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83484. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83485. }
  83486. /**
  83487. * Interfaces from the EXT_lights_image_based extension
  83488. */
  83489. /** @hidden */
  83490. interface IEXTLightsImageBased_LightReferenceImageBased {
  83491. light: number;
  83492. }
  83493. /** @hidden */
  83494. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83495. intensity: number;
  83496. rotation: number[];
  83497. specularImageSize: number;
  83498. specularImages: number[][];
  83499. irradianceCoefficients: number[][];
  83500. }
  83501. /** @hidden */
  83502. interface IEXTLightsImageBased {
  83503. lights: IEXTLightsImageBased_LightImageBased[];
  83504. }
  83505. /**
  83506. * Interfaces from the EXT_mesh_gpu_instancing extension
  83507. * !!! Experimental Extension Subject to Changes !!!
  83508. */
  83509. /** @hidden */
  83510. interface IEXTMeshGpuInstancing {
  83511. mesh?: number;
  83512. attributes: { [name: string]: number };
  83513. }
  83514. /**
  83515. * Interfaces from the KHR_draco_mesh_compression extension
  83516. */
  83517. /** @hidden */
  83518. interface IKHRDracoMeshCompression {
  83519. bufferView: number;
  83520. attributes: { [name: string]: number };
  83521. }
  83522. /**
  83523. * Interfaces from the KHR_lights_punctual extension
  83524. */
  83525. /** @hidden */
  83526. const enum IKHRLightsPunctual_LightType {
  83527. DIRECTIONAL = "directional",
  83528. POINT = "point",
  83529. SPOT = "spot"
  83530. }
  83531. /** @hidden */
  83532. interface IKHRLightsPunctual_LightReference {
  83533. light: number;
  83534. }
  83535. /** @hidden */
  83536. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83537. type: IKHRLightsPunctual_LightType;
  83538. color?: number[];
  83539. intensity?: number;
  83540. range?: number;
  83541. spot?: {
  83542. innerConeAngle?: number;
  83543. outerConeAngle?: number;
  83544. };
  83545. }
  83546. /** @hidden */
  83547. interface IKHRLightsPunctual {
  83548. lights: IKHRLightsPunctual_Light[];
  83549. }
  83550. /**
  83551. * Interfaces from the KHR_materials_clearcoat extension
  83552. * !!! Experimental Extension Subject to Changes !!!
  83553. */
  83554. /** @hidden */
  83555. interface IKHRMaterialsClearcoat {
  83556. clearcoatFactor: number;
  83557. clearcoatTexture: ITextureInfo;
  83558. clearcoatRoughnessFactor: number;
  83559. clearcoatRoughnessTexture: ITextureInfo;
  83560. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83561. }
  83562. /**
  83563. * Interfaces from the KHR_materials_ior extension
  83564. * !!! Experimental Extension Subject to Changes !!!
  83565. */
  83566. /** @hidden */
  83567. interface IKHRMaterialsIor {
  83568. ior: number;
  83569. }
  83570. /**
  83571. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83572. */
  83573. /** @hidden */
  83574. interface IKHRMaterialsPbrSpecularGlossiness {
  83575. diffuseFactor: number[];
  83576. diffuseTexture: ITextureInfo;
  83577. specularFactor: number[];
  83578. glossinessFactor: number;
  83579. specularGlossinessTexture: ITextureInfo;
  83580. }
  83581. /**
  83582. * Interfaces from the KHR_materials_sheen extension
  83583. * !!! Experimental Extension Subject to Changes !!!
  83584. */
  83585. /** @hidden */
  83586. interface IKHRMaterialsSheen {
  83587. sheenColorFactor?: number[];
  83588. sheenTexture?: ITextureInfo;
  83589. sheenRoughnessFactor?: number;
  83590. }
  83591. /**
  83592. * Interfaces from the KHR_materials_specular extension
  83593. * !!! Experimental Extension Subject to Changes !!!
  83594. */
  83595. /** @hidden */
  83596. interface IKHRMaterialsSpecular {
  83597. specularFactor: number;
  83598. specularColorFactor: number[];
  83599. specularTexture: ITextureInfo;
  83600. }
  83601. /**
  83602. * Interfaces from the KHR_materials_transmission extension
  83603. * !!! Experimental Extension Subject to Changes !!!
  83604. */
  83605. /** @hidden */
  83606. interface IKHRMaterialsTransmission {
  83607. transmissionFactor?: number;
  83608. transmissionTexture?: ITextureInfo;
  83609. }
  83610. /**
  83611. * Interfaces from the KHR_materials_variants extension
  83612. * !!! Experimental Extension Subject to Changes !!!
  83613. */
  83614. /** @hidden */
  83615. interface IKHRMaterialVariants_Mapping {
  83616. tags: string[];
  83617. material: number;
  83618. }
  83619. /** @hidden */
  83620. interface IKHRMaterialVariants {
  83621. mapping: IKHRMaterialVariants_Mapping[];
  83622. }
  83623. /**
  83624. * Interfaces from the KHR_texture_basisu extension
  83625. * !!! Experimental Extension Subject to Changes !!!
  83626. */
  83627. /** @hidden */
  83628. interface IKHRTextureBasisU {
  83629. source: number;
  83630. }
  83631. /**
  83632. * Interfaces from the KHR_texture_transform extension
  83633. */
  83634. /** @hidden */
  83635. interface IKHRTextureTransform {
  83636. offset?: number[];
  83637. rotation?: number;
  83638. scale?: number[];
  83639. texCoord?: number;
  83640. }
  83641. /**
  83642. * Interfaces from the KHR_xmp extension
  83643. * !!! Experimental Extension Subject to Changes !!!
  83644. */
  83645. /** @hidden */
  83646. interface IKHRXmp_Data {
  83647. [key: string]: unknown;
  83648. }
  83649. /** @hidden */
  83650. interface IKHRXmp_Gltf {
  83651. packets: IKHRXmp_Data[];
  83652. }
  83653. /** @hidden */
  83654. interface IKHRXmp_Node {
  83655. packet: number;
  83656. }
  83657. /**
  83658. * Interfaces from the MSFT_audio_emitter extension
  83659. */
  83660. /** @hidden */
  83661. interface IMSFTAudioEmitter_ClipReference {
  83662. clip: number;
  83663. weight?: number;
  83664. }
  83665. /** @hidden */
  83666. interface IMSFTAudioEmitter_EmittersReference {
  83667. emitters: number[];
  83668. }
  83669. /** @hidden */
  83670. const enum IMSFTAudioEmitter_DistanceModel {
  83671. linear = "linear",
  83672. inverse = "inverse",
  83673. exponential = "exponential",
  83674. }
  83675. /** @hidden */
  83676. interface IMSFTAudioEmitter_Emitter {
  83677. name?: string;
  83678. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83679. refDistance?: number;
  83680. maxDistance?: number;
  83681. rolloffFactor?: number;
  83682. innerAngle?: number;
  83683. outerAngle?: number;
  83684. loop?: boolean;
  83685. volume?: number;
  83686. clips: IMSFTAudioEmitter_ClipReference[];
  83687. }
  83688. /** @hidden */
  83689. const enum IMSFTAudioEmitter_AudioMimeType {
  83690. WAV = "audio/wav",
  83691. }
  83692. /** @hidden */
  83693. interface IMSFTAudioEmitter_Clip extends IProperty {
  83694. uri?: string;
  83695. bufferView?: number;
  83696. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83697. }
  83698. /** @hidden */
  83699. const enum IMSFTAudioEmitter_AnimationEventAction {
  83700. play = "play",
  83701. pause = "pause",
  83702. stop = "stop",
  83703. }
  83704. /** @hidden */
  83705. interface IMSFTAudioEmitter_AnimationEvent {
  83706. action: IMSFTAudioEmitter_AnimationEventAction;
  83707. emitter: number;
  83708. time: number;
  83709. startOffset?: number;
  83710. }
  83711. /**
  83712. * Interfaces from the MSFT_lod extension
  83713. */
  83714. /** @hidden */
  83715. interface IMSFTLOD {
  83716. ids: number[];
  83717. }
  83718. }
  83719. declare module BABYLON {
  83720. /** @hidden */
  83721. export var cellPixelShader: {
  83722. name: string;
  83723. shader: string;
  83724. };
  83725. }
  83726. declare module BABYLON {
  83727. /** @hidden */
  83728. export var cellVertexShader: {
  83729. name: string;
  83730. shader: string;
  83731. };
  83732. }
  83733. declare module BABYLON {
  83734. export class CellMaterial extends BABYLON.PushMaterial {
  83735. private _diffuseTexture;
  83736. diffuseTexture: BABYLON.BaseTexture;
  83737. diffuseColor: BABYLON.Color3;
  83738. _computeHighLevel: boolean;
  83739. computeHighLevel: boolean;
  83740. private _disableLighting;
  83741. disableLighting: boolean;
  83742. private _maxSimultaneousLights;
  83743. maxSimultaneousLights: number;
  83744. constructor(name: string, scene: BABYLON.Scene);
  83745. needAlphaBlending(): boolean;
  83746. needAlphaTesting(): boolean;
  83747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83748. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83749. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83750. getAnimatables(): BABYLON.IAnimatable[];
  83751. getActiveTextures(): BABYLON.BaseTexture[];
  83752. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83753. dispose(forceDisposeEffect?: boolean): void;
  83754. getClassName(): string;
  83755. clone(name: string): CellMaterial;
  83756. serialize(): any;
  83757. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83758. }
  83759. }
  83760. declare module BABYLON {
  83761. export class CustomShaderStructure {
  83762. FragmentStore: string;
  83763. VertexStore: string;
  83764. constructor();
  83765. }
  83766. export class ShaderSpecialParts {
  83767. constructor();
  83768. Fragment_Begin: string;
  83769. Fragment_Definitions: string;
  83770. Fragment_MainBegin: string;
  83771. Fragment_Custom_Diffuse: string;
  83772. Fragment_Before_Lights: string;
  83773. Fragment_Before_Fog: string;
  83774. Fragment_Custom_Alpha: string;
  83775. Fragment_Before_FragColor: string;
  83776. Vertex_Begin: string;
  83777. Vertex_Definitions: string;
  83778. Vertex_MainBegin: string;
  83779. Vertex_Before_PositionUpdated: string;
  83780. Vertex_Before_NormalUpdated: string;
  83781. Vertex_After_WorldPosComputed: string;
  83782. Vertex_MainEnd: string;
  83783. }
  83784. export class CustomMaterial extends BABYLON.StandardMaterial {
  83785. static ShaderIndexer: number;
  83786. CustomParts: ShaderSpecialParts;
  83787. _isCreatedShader: boolean;
  83788. _createdShaderName: string;
  83789. _customUniform: string[];
  83790. _newUniforms: string[];
  83791. _newUniformInstances: {
  83792. [name: string]: any;
  83793. };
  83794. _newSamplerInstances: {
  83795. [name: string]: BABYLON.Texture;
  83796. };
  83797. _customAttributes: string[];
  83798. FragmentShader: string;
  83799. VertexShader: string;
  83800. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83801. ReviewUniform(name: string, arr: string[]): string[];
  83802. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83803. constructor(name: string, scene: BABYLON.Scene);
  83804. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83805. AddAttribute(name: string): CustomMaterial;
  83806. Fragment_Begin(shaderPart: string): CustomMaterial;
  83807. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83808. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83809. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83810. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83811. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83812. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83813. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83814. Vertex_Begin(shaderPart: string): CustomMaterial;
  83815. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83816. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83817. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83818. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83819. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83820. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83821. }
  83822. }
  83823. declare module BABYLON {
  83824. export class ShaderAlebdoParts {
  83825. constructor();
  83826. Fragment_Begin: string;
  83827. Fragment_Definitions: string;
  83828. Fragment_MainBegin: string;
  83829. Fragment_Custom_Albedo: string;
  83830. Fragment_Before_Lights: string;
  83831. Fragment_Custom_MetallicRoughness: string;
  83832. Fragment_Custom_MicroSurface: string;
  83833. Fragment_Before_Fog: string;
  83834. Fragment_Custom_Alpha: string;
  83835. Fragment_Before_FragColor: string;
  83836. Vertex_Begin: string;
  83837. Vertex_Definitions: string;
  83838. Vertex_MainBegin: string;
  83839. Vertex_Before_PositionUpdated: string;
  83840. Vertex_Before_NormalUpdated: string;
  83841. Vertex_After_WorldPosComputed: string;
  83842. Vertex_MainEnd: string;
  83843. }
  83844. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83845. static ShaderIndexer: number;
  83846. CustomParts: ShaderAlebdoParts;
  83847. _isCreatedShader: boolean;
  83848. _createdShaderName: string;
  83849. _customUniform: string[];
  83850. _newUniforms: string[];
  83851. _newUniformInstances: {
  83852. [name: string]: any;
  83853. };
  83854. _newSamplerInstances: {
  83855. [name: string]: BABYLON.Texture;
  83856. };
  83857. _customAttributes: string[];
  83858. FragmentShader: string;
  83859. VertexShader: string;
  83860. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83861. ReviewUniform(name: string, arr: string[]): string[];
  83862. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83863. constructor(name: string, scene: BABYLON.Scene);
  83864. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83865. AddAttribute(name: string): PBRCustomMaterial;
  83866. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83867. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83868. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83869. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83870. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83871. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83872. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83873. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83874. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83875. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83876. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83877. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83878. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83879. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83880. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83881. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83882. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83883. }
  83884. }
  83885. declare module BABYLON {
  83886. /** @hidden */
  83887. export var firePixelShader: {
  83888. name: string;
  83889. shader: string;
  83890. };
  83891. }
  83892. declare module BABYLON {
  83893. /** @hidden */
  83894. export var fireVertexShader: {
  83895. name: string;
  83896. shader: string;
  83897. };
  83898. }
  83899. declare module BABYLON {
  83900. export class FireMaterial extends BABYLON.PushMaterial {
  83901. private _diffuseTexture;
  83902. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83903. private _distortionTexture;
  83904. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83905. private _opacityTexture;
  83906. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83907. diffuseColor: BABYLON.Color3;
  83908. speed: number;
  83909. private _scaledDiffuse;
  83910. private _lastTime;
  83911. constructor(name: string, scene: BABYLON.Scene);
  83912. needAlphaBlending(): boolean;
  83913. needAlphaTesting(): boolean;
  83914. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83915. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83916. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83917. getAnimatables(): BABYLON.IAnimatable[];
  83918. getActiveTextures(): BABYLON.BaseTexture[];
  83919. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83920. getClassName(): string;
  83921. dispose(forceDisposeEffect?: boolean): void;
  83922. clone(name: string): FireMaterial;
  83923. serialize(): any;
  83924. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83925. }
  83926. }
  83927. declare module BABYLON {
  83928. /** @hidden */
  83929. export var furPixelShader: {
  83930. name: string;
  83931. shader: string;
  83932. };
  83933. }
  83934. declare module BABYLON {
  83935. /** @hidden */
  83936. export var furVertexShader: {
  83937. name: string;
  83938. shader: string;
  83939. };
  83940. }
  83941. declare module BABYLON {
  83942. export class FurMaterial extends BABYLON.PushMaterial {
  83943. private _diffuseTexture;
  83944. diffuseTexture: BABYLON.BaseTexture;
  83945. private _heightTexture;
  83946. heightTexture: BABYLON.BaseTexture;
  83947. diffuseColor: BABYLON.Color3;
  83948. furLength: number;
  83949. furAngle: number;
  83950. furColor: BABYLON.Color3;
  83951. furOffset: number;
  83952. furSpacing: number;
  83953. furGravity: BABYLON.Vector3;
  83954. furSpeed: number;
  83955. furDensity: number;
  83956. furOcclusion: number;
  83957. furTexture: BABYLON.DynamicTexture;
  83958. private _disableLighting;
  83959. disableLighting: boolean;
  83960. private _maxSimultaneousLights;
  83961. maxSimultaneousLights: number;
  83962. highLevelFur: boolean;
  83963. _meshes: BABYLON.AbstractMesh[];
  83964. private _furTime;
  83965. constructor(name: string, scene: BABYLON.Scene);
  83966. get furTime(): number;
  83967. set furTime(furTime: number);
  83968. needAlphaBlending(): boolean;
  83969. needAlphaTesting(): boolean;
  83970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83971. updateFur(): void;
  83972. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83973. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83974. getAnimatables(): BABYLON.IAnimatable[];
  83975. getActiveTextures(): BABYLON.BaseTexture[];
  83976. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83977. dispose(forceDisposeEffect?: boolean): void;
  83978. clone(name: string): FurMaterial;
  83979. serialize(): any;
  83980. getClassName(): string;
  83981. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83982. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83983. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83984. }
  83985. }
  83986. declare module BABYLON {
  83987. /** @hidden */
  83988. export var gradientPixelShader: {
  83989. name: string;
  83990. shader: string;
  83991. };
  83992. }
  83993. declare module BABYLON {
  83994. /** @hidden */
  83995. export var gradientVertexShader: {
  83996. name: string;
  83997. shader: string;
  83998. };
  83999. }
  84000. declare module BABYLON {
  84001. export class GradientMaterial extends BABYLON.PushMaterial {
  84002. private _maxSimultaneousLights;
  84003. maxSimultaneousLights: number;
  84004. topColor: BABYLON.Color3;
  84005. topColorAlpha: number;
  84006. bottomColor: BABYLON.Color3;
  84007. bottomColorAlpha: number;
  84008. offset: number;
  84009. scale: number;
  84010. smoothness: number;
  84011. private _disableLighting;
  84012. disableLighting: boolean;
  84013. constructor(name: string, scene: BABYLON.Scene);
  84014. needAlphaBlending(): boolean;
  84015. needAlphaTesting(): boolean;
  84016. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84017. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84018. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84019. getAnimatables(): BABYLON.IAnimatable[];
  84020. dispose(forceDisposeEffect?: boolean): void;
  84021. clone(name: string): GradientMaterial;
  84022. serialize(): any;
  84023. getClassName(): string;
  84024. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84025. }
  84026. }
  84027. declare module BABYLON {
  84028. /** @hidden */
  84029. export var gridPixelShader: {
  84030. name: string;
  84031. shader: string;
  84032. };
  84033. }
  84034. declare module BABYLON {
  84035. /** @hidden */
  84036. export var gridVertexShader: {
  84037. name: string;
  84038. shader: string;
  84039. };
  84040. }
  84041. declare module BABYLON {
  84042. /**
  84043. * The grid materials allows you to wrap any shape with a grid.
  84044. * Colors are customizable.
  84045. */
  84046. export class GridMaterial extends BABYLON.PushMaterial {
  84047. /**
  84048. * Main color of the grid (e.g. between lines)
  84049. */
  84050. mainColor: BABYLON.Color3;
  84051. /**
  84052. * Color of the grid lines.
  84053. */
  84054. lineColor: BABYLON.Color3;
  84055. /**
  84056. * The scale of the grid compared to unit.
  84057. */
  84058. gridRatio: number;
  84059. /**
  84060. * Allows setting an offset for the grid lines.
  84061. */
  84062. gridOffset: BABYLON.Vector3;
  84063. /**
  84064. * The frequency of thicker lines.
  84065. */
  84066. majorUnitFrequency: number;
  84067. /**
  84068. * The visibility of minor units in the grid.
  84069. */
  84070. minorUnitVisibility: number;
  84071. /**
  84072. * The grid opacity outside of the lines.
  84073. */
  84074. opacity: number;
  84075. /**
  84076. * Determine RBG output is premultiplied by alpha value.
  84077. */
  84078. preMultiplyAlpha: boolean;
  84079. private _opacityTexture;
  84080. opacityTexture: BABYLON.BaseTexture;
  84081. private _gridControl;
  84082. /**
  84083. * constructor
  84084. * @param name The name given to the material in order to identify it afterwards.
  84085. * @param scene The scene the material is used in.
  84086. */
  84087. constructor(name: string, scene: BABYLON.Scene);
  84088. /**
  84089. * Returns wehter or not the grid requires alpha blending.
  84090. */
  84091. needAlphaBlending(): boolean;
  84092. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84093. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84094. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84095. /**
  84096. * Dispose the material and its associated resources.
  84097. * @param forceDisposeEffect will also dispose the used effect when true
  84098. */
  84099. dispose(forceDisposeEffect?: boolean): void;
  84100. clone(name: string): GridMaterial;
  84101. serialize(): any;
  84102. getClassName(): string;
  84103. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84104. }
  84105. }
  84106. declare module BABYLON {
  84107. /** @hidden */
  84108. export var lavaPixelShader: {
  84109. name: string;
  84110. shader: string;
  84111. };
  84112. }
  84113. declare module BABYLON {
  84114. /** @hidden */
  84115. export var lavaVertexShader: {
  84116. name: string;
  84117. shader: string;
  84118. };
  84119. }
  84120. declare module BABYLON {
  84121. export class LavaMaterial extends BABYLON.PushMaterial {
  84122. private _diffuseTexture;
  84123. diffuseTexture: BABYLON.BaseTexture;
  84124. noiseTexture: BABYLON.BaseTexture;
  84125. fogColor: BABYLON.Color3;
  84126. speed: number;
  84127. movingSpeed: number;
  84128. lowFrequencySpeed: number;
  84129. fogDensity: number;
  84130. private _lastTime;
  84131. diffuseColor: BABYLON.Color3;
  84132. private _disableLighting;
  84133. disableLighting: boolean;
  84134. private _unlit;
  84135. unlit: boolean;
  84136. private _maxSimultaneousLights;
  84137. maxSimultaneousLights: number;
  84138. private _scaledDiffuse;
  84139. constructor(name: string, scene: BABYLON.Scene);
  84140. needAlphaBlending(): boolean;
  84141. needAlphaTesting(): boolean;
  84142. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84143. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84144. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84145. getAnimatables(): BABYLON.IAnimatable[];
  84146. getActiveTextures(): BABYLON.BaseTexture[];
  84147. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84148. dispose(forceDisposeEffect?: boolean): void;
  84149. clone(name: string): LavaMaterial;
  84150. serialize(): any;
  84151. getClassName(): string;
  84152. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84153. }
  84154. }
  84155. declare module BABYLON {
  84156. /** @hidden */
  84157. export var mixPixelShader: {
  84158. name: string;
  84159. shader: string;
  84160. };
  84161. }
  84162. declare module BABYLON {
  84163. /** @hidden */
  84164. export var mixVertexShader: {
  84165. name: string;
  84166. shader: string;
  84167. };
  84168. }
  84169. declare module BABYLON {
  84170. export class MixMaterial extends BABYLON.PushMaterial {
  84171. /**
  84172. * Mix textures
  84173. */
  84174. private _mixTexture1;
  84175. mixTexture1: BABYLON.BaseTexture;
  84176. private _mixTexture2;
  84177. mixTexture2: BABYLON.BaseTexture;
  84178. /**
  84179. * Diffuse textures
  84180. */
  84181. private _diffuseTexture1;
  84182. diffuseTexture1: BABYLON.Texture;
  84183. private _diffuseTexture2;
  84184. diffuseTexture2: BABYLON.Texture;
  84185. private _diffuseTexture3;
  84186. diffuseTexture3: BABYLON.Texture;
  84187. private _diffuseTexture4;
  84188. diffuseTexture4: BABYLON.Texture;
  84189. private _diffuseTexture5;
  84190. diffuseTexture5: BABYLON.Texture;
  84191. private _diffuseTexture6;
  84192. diffuseTexture6: BABYLON.Texture;
  84193. private _diffuseTexture7;
  84194. diffuseTexture7: BABYLON.Texture;
  84195. private _diffuseTexture8;
  84196. diffuseTexture8: BABYLON.Texture;
  84197. /**
  84198. * Uniforms
  84199. */
  84200. diffuseColor: BABYLON.Color3;
  84201. specularColor: BABYLON.Color3;
  84202. specularPower: number;
  84203. private _disableLighting;
  84204. disableLighting: boolean;
  84205. private _maxSimultaneousLights;
  84206. maxSimultaneousLights: number;
  84207. constructor(name: string, scene: BABYLON.Scene);
  84208. needAlphaBlending(): boolean;
  84209. needAlphaTesting(): boolean;
  84210. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84211. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84212. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84213. getAnimatables(): BABYLON.IAnimatable[];
  84214. getActiveTextures(): BABYLON.BaseTexture[];
  84215. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84216. dispose(forceDisposeEffect?: boolean): void;
  84217. clone(name: string): MixMaterial;
  84218. serialize(): any;
  84219. getClassName(): string;
  84220. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84221. }
  84222. }
  84223. declare module BABYLON {
  84224. /** @hidden */
  84225. export var normalPixelShader: {
  84226. name: string;
  84227. shader: string;
  84228. };
  84229. }
  84230. declare module BABYLON {
  84231. /** @hidden */
  84232. export var normalVertexShader: {
  84233. name: string;
  84234. shader: string;
  84235. };
  84236. }
  84237. declare module BABYLON {
  84238. export class NormalMaterial extends BABYLON.PushMaterial {
  84239. private _diffuseTexture;
  84240. diffuseTexture: BABYLON.BaseTexture;
  84241. diffuseColor: BABYLON.Color3;
  84242. private _disableLighting;
  84243. disableLighting: boolean;
  84244. private _maxSimultaneousLights;
  84245. maxSimultaneousLights: number;
  84246. constructor(name: string, scene: BABYLON.Scene);
  84247. needAlphaBlending(): boolean;
  84248. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84249. needAlphaTesting(): boolean;
  84250. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84251. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84253. getAnimatables(): BABYLON.IAnimatable[];
  84254. getActiveTextures(): BABYLON.BaseTexture[];
  84255. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84256. dispose(forceDisposeEffect?: boolean): void;
  84257. clone(name: string): NormalMaterial;
  84258. serialize(): any;
  84259. getClassName(): string;
  84260. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84261. }
  84262. }
  84263. declare module BABYLON {
  84264. /** @hidden */
  84265. export var shadowOnlyPixelShader: {
  84266. name: string;
  84267. shader: string;
  84268. };
  84269. }
  84270. declare module BABYLON {
  84271. /** @hidden */
  84272. export var shadowOnlyVertexShader: {
  84273. name: string;
  84274. shader: string;
  84275. };
  84276. }
  84277. declare module BABYLON {
  84278. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84279. private _activeLight;
  84280. private _needAlphaBlending;
  84281. constructor(name: string, scene: BABYLON.Scene);
  84282. shadowColor: BABYLON.Color3;
  84283. needAlphaBlending(): boolean;
  84284. needAlphaTesting(): boolean;
  84285. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84286. get activeLight(): BABYLON.IShadowLight;
  84287. set activeLight(light: BABYLON.IShadowLight);
  84288. private _getFirstShadowLightForMesh;
  84289. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84290. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84291. clone(name: string): ShadowOnlyMaterial;
  84292. serialize(): any;
  84293. getClassName(): string;
  84294. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84295. }
  84296. }
  84297. declare module BABYLON {
  84298. /** @hidden */
  84299. export var simplePixelShader: {
  84300. name: string;
  84301. shader: string;
  84302. };
  84303. }
  84304. declare module BABYLON {
  84305. /** @hidden */
  84306. export var simpleVertexShader: {
  84307. name: string;
  84308. shader: string;
  84309. };
  84310. }
  84311. declare module BABYLON {
  84312. export class SimpleMaterial extends BABYLON.PushMaterial {
  84313. private _diffuseTexture;
  84314. diffuseTexture: BABYLON.BaseTexture;
  84315. diffuseColor: BABYLON.Color3;
  84316. private _disableLighting;
  84317. disableLighting: boolean;
  84318. private _maxSimultaneousLights;
  84319. maxSimultaneousLights: number;
  84320. constructor(name: string, scene: BABYLON.Scene);
  84321. needAlphaBlending(): boolean;
  84322. needAlphaTesting(): boolean;
  84323. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84324. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84325. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84326. getAnimatables(): BABYLON.IAnimatable[];
  84327. getActiveTextures(): BABYLON.BaseTexture[];
  84328. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84329. dispose(forceDisposeEffect?: boolean): void;
  84330. clone(name: string): SimpleMaterial;
  84331. serialize(): any;
  84332. getClassName(): string;
  84333. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84334. }
  84335. }
  84336. declare module BABYLON {
  84337. /** @hidden */
  84338. export var skyPixelShader: {
  84339. name: string;
  84340. shader: string;
  84341. };
  84342. }
  84343. declare module BABYLON {
  84344. /** @hidden */
  84345. export var skyVertexShader: {
  84346. name: string;
  84347. shader: string;
  84348. };
  84349. }
  84350. declare module BABYLON {
  84351. /**
  84352. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84353. * @see https://doc.babylonjs.com/extensions/sky
  84354. */
  84355. export class SkyMaterial extends BABYLON.PushMaterial {
  84356. /**
  84357. * Defines the overall luminance of sky in interval ]0, 1[.
  84358. */
  84359. luminance: number;
  84360. /**
  84361. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84362. */
  84363. turbidity: number;
  84364. /**
  84365. * Defines the sky appearance (light intensity).
  84366. */
  84367. rayleigh: number;
  84368. /**
  84369. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84370. */
  84371. mieCoefficient: number;
  84372. /**
  84373. * Defines the amount of haze particles following the Mie scattering theory.
  84374. */
  84375. mieDirectionalG: number;
  84376. /**
  84377. * Defines the distance of the sun according to the active scene camera.
  84378. */
  84379. distance: number;
  84380. /**
  84381. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84382. * "inclined".
  84383. */
  84384. inclination: number;
  84385. /**
  84386. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84387. * an object direction and a reference direction.
  84388. */
  84389. azimuth: number;
  84390. /**
  84391. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84392. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84393. */
  84394. sunPosition: BABYLON.Vector3;
  84395. /**
  84396. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84397. * .sunPosition property.
  84398. */
  84399. useSunPosition: boolean;
  84400. /**
  84401. * Defines an offset vector used to get a horizon offset.
  84402. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84403. */
  84404. cameraOffset: BABYLON.Vector3;
  84405. private _cameraPosition;
  84406. /**
  84407. * Instantiates a new sky material.
  84408. * This material allows to create dynamic and texture free
  84409. * effects for skyboxes by taking care of the atmosphere state.
  84410. * @see https://doc.babylonjs.com/extensions/sky
  84411. * @param name Define the name of the material in the scene
  84412. * @param scene Define the scene the material belong to
  84413. */
  84414. constructor(name: string, scene: BABYLON.Scene);
  84415. /**
  84416. * Specifies if the material will require alpha blending
  84417. * @returns a boolean specifying if alpha blending is needed
  84418. */
  84419. needAlphaBlending(): boolean;
  84420. /**
  84421. * Specifies if this material should be rendered in alpha test mode
  84422. * @returns false as the sky material doesn't need alpha testing.
  84423. */
  84424. needAlphaTesting(): boolean;
  84425. /**
  84426. * Get the texture used for alpha test purpose.
  84427. * @returns null as the sky material has no texture.
  84428. */
  84429. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84430. /**
  84431. * Get if the submesh is ready to be used and all its information available.
  84432. * Child classes can use it to update shaders
  84433. * @param mesh defines the mesh to check
  84434. * @param subMesh defines which submesh to check
  84435. * @param useInstances specifies that instances should be used
  84436. * @returns a boolean indicating that the submesh is ready or not
  84437. */
  84438. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84439. /**
  84440. * Binds the submesh to this material by preparing the effect and shader to draw
  84441. * @param world defines the world transformation matrix
  84442. * @param mesh defines the mesh containing the submesh
  84443. * @param subMesh defines the submesh to bind the material to
  84444. */
  84445. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84446. /**
  84447. * Get the list of animatables in the material.
  84448. * @returns the list of animatables object used in the material
  84449. */
  84450. getAnimatables(): BABYLON.IAnimatable[];
  84451. /**
  84452. * Disposes the material
  84453. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84454. */
  84455. dispose(forceDisposeEffect?: boolean): void;
  84456. /**
  84457. * Makes a duplicate of the material, and gives it a new name
  84458. * @param name defines the new name for the duplicated material
  84459. * @returns the cloned material
  84460. */
  84461. clone(name: string): SkyMaterial;
  84462. /**
  84463. * Serializes this material in a JSON representation
  84464. * @returns the serialized material object
  84465. */
  84466. serialize(): any;
  84467. /**
  84468. * Gets the current class name of the material e.g. "SkyMaterial"
  84469. * Mainly use in serialization.
  84470. * @returns the class name
  84471. */
  84472. getClassName(): string;
  84473. /**
  84474. * Creates a sky material from parsed material data
  84475. * @param source defines the JSON representation of the material
  84476. * @param scene defines the hosting scene
  84477. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84478. * @returns a new sky material
  84479. */
  84480. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84481. }
  84482. }
  84483. declare module BABYLON {
  84484. /** @hidden */
  84485. export var terrainPixelShader: {
  84486. name: string;
  84487. shader: string;
  84488. };
  84489. }
  84490. declare module BABYLON {
  84491. /** @hidden */
  84492. export var terrainVertexShader: {
  84493. name: string;
  84494. shader: string;
  84495. };
  84496. }
  84497. declare module BABYLON {
  84498. export class TerrainMaterial extends BABYLON.PushMaterial {
  84499. private _mixTexture;
  84500. mixTexture: BABYLON.BaseTexture;
  84501. private _diffuseTexture1;
  84502. diffuseTexture1: BABYLON.Texture;
  84503. private _diffuseTexture2;
  84504. diffuseTexture2: BABYLON.Texture;
  84505. private _diffuseTexture3;
  84506. diffuseTexture3: BABYLON.Texture;
  84507. private _bumpTexture1;
  84508. bumpTexture1: BABYLON.Texture;
  84509. private _bumpTexture2;
  84510. bumpTexture2: BABYLON.Texture;
  84511. private _bumpTexture3;
  84512. bumpTexture3: BABYLON.Texture;
  84513. diffuseColor: BABYLON.Color3;
  84514. specularColor: BABYLON.Color3;
  84515. specularPower: number;
  84516. private _disableLighting;
  84517. disableLighting: boolean;
  84518. private _maxSimultaneousLights;
  84519. maxSimultaneousLights: number;
  84520. constructor(name: string, scene: BABYLON.Scene);
  84521. needAlphaBlending(): boolean;
  84522. needAlphaTesting(): boolean;
  84523. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84524. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84525. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84526. getAnimatables(): BABYLON.IAnimatable[];
  84527. getActiveTextures(): BABYLON.BaseTexture[];
  84528. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84529. dispose(forceDisposeEffect?: boolean): void;
  84530. clone(name: string): TerrainMaterial;
  84531. serialize(): any;
  84532. getClassName(): string;
  84533. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84534. }
  84535. }
  84536. declare module BABYLON {
  84537. /** @hidden */
  84538. export var triplanarPixelShader: {
  84539. name: string;
  84540. shader: string;
  84541. };
  84542. }
  84543. declare module BABYLON {
  84544. /** @hidden */
  84545. export var triplanarVertexShader: {
  84546. name: string;
  84547. shader: string;
  84548. };
  84549. }
  84550. declare module BABYLON {
  84551. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84552. mixTexture: BABYLON.BaseTexture;
  84553. private _diffuseTextureX;
  84554. diffuseTextureX: BABYLON.BaseTexture;
  84555. private _diffuseTextureY;
  84556. diffuseTextureY: BABYLON.BaseTexture;
  84557. private _diffuseTextureZ;
  84558. diffuseTextureZ: BABYLON.BaseTexture;
  84559. private _normalTextureX;
  84560. normalTextureX: BABYLON.BaseTexture;
  84561. private _normalTextureY;
  84562. normalTextureY: BABYLON.BaseTexture;
  84563. private _normalTextureZ;
  84564. normalTextureZ: BABYLON.BaseTexture;
  84565. tileSize: number;
  84566. diffuseColor: BABYLON.Color3;
  84567. specularColor: BABYLON.Color3;
  84568. specularPower: number;
  84569. private _disableLighting;
  84570. disableLighting: boolean;
  84571. private _maxSimultaneousLights;
  84572. maxSimultaneousLights: number;
  84573. constructor(name: string, scene: BABYLON.Scene);
  84574. needAlphaBlending(): boolean;
  84575. needAlphaTesting(): boolean;
  84576. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84577. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84578. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84579. getAnimatables(): BABYLON.IAnimatable[];
  84580. getActiveTextures(): BABYLON.BaseTexture[];
  84581. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84582. dispose(forceDisposeEffect?: boolean): void;
  84583. clone(name: string): TriPlanarMaterial;
  84584. serialize(): any;
  84585. getClassName(): string;
  84586. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84587. }
  84588. }
  84589. declare module BABYLON {
  84590. /** @hidden */
  84591. export var waterPixelShader: {
  84592. name: string;
  84593. shader: string;
  84594. };
  84595. }
  84596. declare module BABYLON {
  84597. /** @hidden */
  84598. export var waterVertexShader: {
  84599. name: string;
  84600. shader: string;
  84601. };
  84602. }
  84603. declare module BABYLON {
  84604. export class WaterMaterial extends BABYLON.PushMaterial {
  84605. renderTargetSize: BABYLON.Vector2;
  84606. private _bumpTexture;
  84607. bumpTexture: BABYLON.BaseTexture;
  84608. diffuseColor: BABYLON.Color3;
  84609. specularColor: BABYLON.Color3;
  84610. specularPower: number;
  84611. private _disableLighting;
  84612. disableLighting: boolean;
  84613. private _maxSimultaneousLights;
  84614. maxSimultaneousLights: number;
  84615. /**
  84616. * @param {number}: Represents the wind force
  84617. */
  84618. windForce: number;
  84619. /**
  84620. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84621. */
  84622. windDirection: BABYLON.Vector2;
  84623. /**
  84624. * @param {number}: Wave height, represents the height of the waves
  84625. */
  84626. waveHeight: number;
  84627. /**
  84628. * @param {number}: Bump height, represents the bump height related to the bump map
  84629. */
  84630. bumpHeight: number;
  84631. /**
  84632. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84633. */
  84634. private _bumpSuperimpose;
  84635. bumpSuperimpose: boolean;
  84636. /**
  84637. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84638. */
  84639. private _fresnelSeparate;
  84640. fresnelSeparate: boolean;
  84641. /**
  84642. * @param {boolean}: bump Waves modify the reflection.
  84643. */
  84644. private _bumpAffectsReflection;
  84645. bumpAffectsReflection: boolean;
  84646. /**
  84647. * @param {number}: The water color blended with the refraction (near)
  84648. */
  84649. waterColor: BABYLON.Color3;
  84650. /**
  84651. * @param {number}: The blend factor related to the water color
  84652. */
  84653. colorBlendFactor: number;
  84654. /**
  84655. * @param {number}: The water color blended with the reflection (far)
  84656. */
  84657. waterColor2: BABYLON.Color3;
  84658. /**
  84659. * @param {number}: The blend factor related to the water color (reflection, far)
  84660. */
  84661. colorBlendFactor2: number;
  84662. /**
  84663. * @param {number}: Represents the maximum length of a wave
  84664. */
  84665. waveLength: number;
  84666. /**
  84667. * @param {number}: Defines the waves speed
  84668. */
  84669. waveSpeed: number;
  84670. /**
  84671. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84672. * will avoid calculating useless pixels in the pixel shader of the water material.
  84673. */
  84674. disableClipPlane: boolean;
  84675. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84676. private _mesh;
  84677. private _refractionRTT;
  84678. private _reflectionRTT;
  84679. private _reflectionTransform;
  84680. private _lastTime;
  84681. private _lastDeltaTime;
  84682. private _useLogarithmicDepth;
  84683. private _waitingRenderList;
  84684. private _imageProcessingConfiguration;
  84685. private _imageProcessingObserver;
  84686. /**
  84687. * Gets a boolean indicating that current material needs to register RTT
  84688. */
  84689. get hasRenderTargetTextures(): boolean;
  84690. /**
  84691. * Constructor
  84692. */
  84693. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84694. get useLogarithmicDepth(): boolean;
  84695. set useLogarithmicDepth(value: boolean);
  84696. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84697. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84698. addToRenderList(node: any): void;
  84699. enableRenderTargets(enable: boolean): void;
  84700. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84701. get renderTargetsEnabled(): boolean;
  84702. needAlphaBlending(): boolean;
  84703. needAlphaTesting(): boolean;
  84704. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84705. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84706. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84707. private _createRenderTargets;
  84708. getAnimatables(): BABYLON.IAnimatable[];
  84709. getActiveTextures(): BABYLON.BaseTexture[];
  84710. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84711. dispose(forceDisposeEffect?: boolean): void;
  84712. clone(name: string): WaterMaterial;
  84713. serialize(): any;
  84714. getClassName(): string;
  84715. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84716. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84717. }
  84718. }
  84719. declare module BABYLON {
  84720. /** @hidden */
  84721. export var asciiartPixelShader: {
  84722. name: string;
  84723. shader: string;
  84724. };
  84725. }
  84726. declare module BABYLON {
  84727. /**
  84728. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84729. *
  84730. * It basically takes care rendering the font front the given font size to a texture.
  84731. * This is used later on in the postprocess.
  84732. */
  84733. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84734. private _font;
  84735. private _text;
  84736. private _charSize;
  84737. /**
  84738. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84739. */
  84740. get charSize(): number;
  84741. /**
  84742. * Create a new instance of the Ascii Art FontTexture class
  84743. * @param name the name of the texture
  84744. * @param font the font to use, use the W3C CSS notation
  84745. * @param text the caracter set to use in the rendering.
  84746. * @param scene the scene that owns the texture
  84747. */
  84748. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84749. /**
  84750. * Gets the max char width of a font.
  84751. * @param font the font to use, use the W3C CSS notation
  84752. * @return the max char width
  84753. */
  84754. private getFontWidth;
  84755. /**
  84756. * Gets the max char height of a font.
  84757. * @param font the font to use, use the W3C CSS notation
  84758. * @return the max char height
  84759. */
  84760. private getFontHeight;
  84761. /**
  84762. * Clones the current AsciiArtTexture.
  84763. * @return the clone of the texture.
  84764. */
  84765. clone(): AsciiArtFontTexture;
  84766. /**
  84767. * Parses a json object representing the texture and returns an instance of it.
  84768. * @param source the source JSON representation
  84769. * @param scene the scene to create the texture for
  84770. * @return the parsed texture
  84771. */
  84772. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84773. }
  84774. /**
  84775. * Option available in the Ascii Art Post Process.
  84776. */
  84777. export interface IAsciiArtPostProcessOptions {
  84778. /**
  84779. * The font to use following the w3c font definition.
  84780. */
  84781. font?: string;
  84782. /**
  84783. * The character set to use in the postprocess.
  84784. */
  84785. characterSet?: string;
  84786. /**
  84787. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84788. * This number is defined between 0 and 1;
  84789. */
  84790. mixToTile?: number;
  84791. /**
  84792. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84793. * This number is defined between 0 and 1;
  84794. */
  84795. mixToNormal?: number;
  84796. }
  84797. /**
  84798. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84799. *
  84800. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84801. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84802. */
  84803. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84804. /**
  84805. * The font texture used to render the char in the post process.
  84806. */
  84807. private _asciiArtFontTexture;
  84808. /**
  84809. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84810. * This number is defined between 0 and 1;
  84811. */
  84812. mixToTile: number;
  84813. /**
  84814. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84815. * This number is defined between 0 and 1;
  84816. */
  84817. mixToNormal: number;
  84818. /**
  84819. * Instantiates a new Ascii Art Post Process.
  84820. * @param name the name to give to the postprocess
  84821. * @camera the camera to apply the post process to.
  84822. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84823. */
  84824. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84825. }
  84826. }
  84827. declare module BABYLON {
  84828. /** @hidden */
  84829. export var digitalrainPixelShader: {
  84830. name: string;
  84831. shader: string;
  84832. };
  84833. }
  84834. declare module BABYLON {
  84835. /**
  84836. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84837. *
  84838. * It basically takes care rendering the font front the given font size to a texture.
  84839. * This is used later on in the postprocess.
  84840. */
  84841. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84842. private _font;
  84843. private _text;
  84844. private _charSize;
  84845. /**
  84846. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84847. */
  84848. get charSize(): number;
  84849. /**
  84850. * Create a new instance of the Digital Rain FontTexture class
  84851. * @param name the name of the texture
  84852. * @param font the font to use, use the W3C CSS notation
  84853. * @param text the caracter set to use in the rendering.
  84854. * @param scene the scene that owns the texture
  84855. */
  84856. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84857. /**
  84858. * Gets the max char width of a font.
  84859. * @param font the font to use, use the W3C CSS notation
  84860. * @return the max char width
  84861. */
  84862. private getFontWidth;
  84863. /**
  84864. * Gets the max char height of a font.
  84865. * @param font the font to use, use the W3C CSS notation
  84866. * @return the max char height
  84867. */
  84868. private getFontHeight;
  84869. /**
  84870. * Clones the current DigitalRainFontTexture.
  84871. * @return the clone of the texture.
  84872. */
  84873. clone(): DigitalRainFontTexture;
  84874. /**
  84875. * Parses a json object representing the texture and returns an instance of it.
  84876. * @param source the source JSON representation
  84877. * @param scene the scene to create the texture for
  84878. * @return the parsed texture
  84879. */
  84880. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84881. }
  84882. /**
  84883. * Option available in the Digital Rain Post Process.
  84884. */
  84885. export interface IDigitalRainPostProcessOptions {
  84886. /**
  84887. * The font to use following the w3c font definition.
  84888. */
  84889. font?: string;
  84890. /**
  84891. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84892. * This number is defined between 0 and 1;
  84893. */
  84894. mixToTile?: number;
  84895. /**
  84896. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84897. * This number is defined between 0 and 1;
  84898. */
  84899. mixToNormal?: number;
  84900. }
  84901. /**
  84902. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84903. *
  84904. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84905. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84906. */
  84907. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84908. /**
  84909. * The font texture used to render the char in the post process.
  84910. */
  84911. private _digitalRainFontTexture;
  84912. /**
  84913. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84914. * This number is defined between 0 and 1;
  84915. */
  84916. mixToTile: number;
  84917. /**
  84918. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84919. * This number is defined between 0 and 1;
  84920. */
  84921. mixToNormal: number;
  84922. /**
  84923. * Instantiates a new Digital Rain Post Process.
  84924. * @param name the name to give to the postprocess
  84925. * @camera the camera to apply the post process to.
  84926. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84927. */
  84928. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84929. }
  84930. }
  84931. declare module BABYLON {
  84932. /** @hidden */
  84933. export var brickProceduralTexturePixelShader: {
  84934. name: string;
  84935. shader: string;
  84936. };
  84937. }
  84938. declare module BABYLON {
  84939. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84940. private _numberOfBricksHeight;
  84941. private _numberOfBricksWidth;
  84942. private _jointColor;
  84943. private _brickColor;
  84944. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84945. updateShaderUniforms(): void;
  84946. get numberOfBricksHeight(): number;
  84947. set numberOfBricksHeight(value: number);
  84948. get numberOfBricksWidth(): number;
  84949. set numberOfBricksWidth(value: number);
  84950. get jointColor(): BABYLON.Color3;
  84951. set jointColor(value: BABYLON.Color3);
  84952. get brickColor(): BABYLON.Color3;
  84953. set brickColor(value: BABYLON.Color3);
  84954. /**
  84955. * Serializes this brick procedural texture
  84956. * @returns a serialized brick procedural texture object
  84957. */
  84958. serialize(): any;
  84959. /**
  84960. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84961. * @param parsedTexture defines parsed texture data
  84962. * @param scene defines the current scene
  84963. * @param rootUrl defines the root URL containing brick procedural texture information
  84964. * @returns a parsed Brick Procedural BABYLON.Texture
  84965. */
  84966. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84967. }
  84968. }
  84969. declare module BABYLON {
  84970. /** @hidden */
  84971. export var cloudProceduralTexturePixelShader: {
  84972. name: string;
  84973. shader: string;
  84974. };
  84975. }
  84976. declare module BABYLON {
  84977. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84978. private _skyColor;
  84979. private _cloudColor;
  84980. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84981. updateShaderUniforms(): void;
  84982. get skyColor(): BABYLON.Color4;
  84983. set skyColor(value: BABYLON.Color4);
  84984. get cloudColor(): BABYLON.Color4;
  84985. set cloudColor(value: BABYLON.Color4);
  84986. /**
  84987. * Serializes this cloud procedural texture
  84988. * @returns a serialized cloud procedural texture object
  84989. */
  84990. serialize(): any;
  84991. /**
  84992. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84993. * @param parsedTexture defines parsed texture data
  84994. * @param scene defines the current scene
  84995. * @param rootUrl defines the root URL containing cloud procedural texture information
  84996. * @returns a parsed Cloud Procedural BABYLON.Texture
  84997. */
  84998. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84999. }
  85000. }
  85001. declare module BABYLON {
  85002. /** @hidden */
  85003. export var fireProceduralTexturePixelShader: {
  85004. name: string;
  85005. shader: string;
  85006. };
  85007. }
  85008. declare module BABYLON {
  85009. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85010. private _time;
  85011. private _speed;
  85012. private _autoGenerateTime;
  85013. private _fireColors;
  85014. private _alphaThreshold;
  85015. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85016. updateShaderUniforms(): void;
  85017. render(useCameraPostProcess?: boolean): void;
  85018. static get PurpleFireColors(): BABYLON.Color3[];
  85019. static get GreenFireColors(): BABYLON.Color3[];
  85020. static get RedFireColors(): BABYLON.Color3[];
  85021. static get BlueFireColors(): BABYLON.Color3[];
  85022. get autoGenerateTime(): boolean;
  85023. set autoGenerateTime(value: boolean);
  85024. get fireColors(): BABYLON.Color3[];
  85025. set fireColors(value: BABYLON.Color3[]);
  85026. get time(): number;
  85027. set time(value: number);
  85028. get speed(): BABYLON.Vector2;
  85029. set speed(value: BABYLON.Vector2);
  85030. get alphaThreshold(): number;
  85031. set alphaThreshold(value: number);
  85032. /**
  85033. * Serializes this fire procedural texture
  85034. * @returns a serialized fire procedural texture object
  85035. */
  85036. serialize(): any;
  85037. /**
  85038. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85039. * @param parsedTexture defines parsed texture data
  85040. * @param scene defines the current scene
  85041. * @param rootUrl defines the root URL containing fire procedural texture information
  85042. * @returns a parsed Fire Procedural BABYLON.Texture
  85043. */
  85044. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85045. }
  85046. }
  85047. declare module BABYLON {
  85048. /** @hidden */
  85049. export var grassProceduralTexturePixelShader: {
  85050. name: string;
  85051. shader: string;
  85052. };
  85053. }
  85054. declare module BABYLON {
  85055. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85056. private _grassColors;
  85057. private _groundColor;
  85058. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85059. updateShaderUniforms(): void;
  85060. get grassColors(): BABYLON.Color3[];
  85061. set grassColors(value: BABYLON.Color3[]);
  85062. get groundColor(): BABYLON.Color3;
  85063. set groundColor(value: BABYLON.Color3);
  85064. /**
  85065. * Serializes this grass procedural texture
  85066. * @returns a serialized grass procedural texture object
  85067. */
  85068. serialize(): any;
  85069. /**
  85070. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85071. * @param parsedTexture defines parsed texture data
  85072. * @param scene defines the current scene
  85073. * @param rootUrl defines the root URL containing grass procedural texture information
  85074. * @returns a parsed Grass Procedural BABYLON.Texture
  85075. */
  85076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85077. }
  85078. }
  85079. declare module BABYLON {
  85080. /** @hidden */
  85081. export var marbleProceduralTexturePixelShader: {
  85082. name: string;
  85083. shader: string;
  85084. };
  85085. }
  85086. declare module BABYLON {
  85087. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85088. private _numberOfTilesHeight;
  85089. private _numberOfTilesWidth;
  85090. private _amplitude;
  85091. private _jointColor;
  85092. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85093. updateShaderUniforms(): void;
  85094. get numberOfTilesHeight(): number;
  85095. set numberOfTilesHeight(value: number);
  85096. get amplitude(): number;
  85097. set amplitude(value: number);
  85098. get numberOfTilesWidth(): number;
  85099. set numberOfTilesWidth(value: number);
  85100. get jointColor(): BABYLON.Color3;
  85101. set jointColor(value: BABYLON.Color3);
  85102. /**
  85103. * Serializes this marble procedural texture
  85104. * @returns a serialized marble procedural texture object
  85105. */
  85106. serialize(): any;
  85107. /**
  85108. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85109. * @param parsedTexture defines parsed texture data
  85110. * @param scene defines the current scene
  85111. * @param rootUrl defines the root URL containing marble procedural texture information
  85112. * @returns a parsed Marble Procedural BABYLON.Texture
  85113. */
  85114. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85115. }
  85116. }
  85117. declare module BABYLON {
  85118. /** @hidden */
  85119. export var normalMapProceduralTexturePixelShader: {
  85120. name: string;
  85121. shader: string;
  85122. };
  85123. }
  85124. declare module BABYLON {
  85125. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85126. private _baseTexture;
  85127. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85128. updateShaderUniforms(): void;
  85129. render(useCameraPostProcess?: boolean): void;
  85130. resize(size: any, generateMipMaps: any): void;
  85131. get baseTexture(): BABYLON.Texture;
  85132. set baseTexture(texture: BABYLON.Texture);
  85133. /**
  85134. * Serializes this normal map procedural texture
  85135. * @returns a serialized normal map procedural texture object
  85136. */
  85137. serialize(): any;
  85138. /**
  85139. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85140. * @param parsedTexture defines parsed texture data
  85141. * @param scene defines the current scene
  85142. * @param rootUrl defines the root URL containing normal map procedural texture information
  85143. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85144. */
  85145. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85146. }
  85147. }
  85148. declare module BABYLON {
  85149. /** @hidden */
  85150. export var perlinNoiseProceduralTexturePixelShader: {
  85151. name: string;
  85152. shader: string;
  85153. };
  85154. }
  85155. declare module BABYLON {
  85156. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85157. time: number;
  85158. timeScale: number;
  85159. translationSpeed: number;
  85160. private _currentTranslation;
  85161. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85162. updateShaderUniforms(): void;
  85163. render(useCameraPostProcess?: boolean): void;
  85164. resize(size: any, generateMipMaps: any): void;
  85165. /**
  85166. * Serializes this perlin noise procedural texture
  85167. * @returns a serialized perlin noise procedural texture object
  85168. */
  85169. serialize(): any;
  85170. /**
  85171. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85172. * @param parsedTexture defines parsed texture data
  85173. * @param scene defines the current scene
  85174. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85175. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85176. */
  85177. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85178. }
  85179. }
  85180. declare module BABYLON {
  85181. /** @hidden */
  85182. export var roadProceduralTexturePixelShader: {
  85183. name: string;
  85184. shader: string;
  85185. };
  85186. }
  85187. declare module BABYLON {
  85188. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85189. private _roadColor;
  85190. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85191. updateShaderUniforms(): void;
  85192. get roadColor(): BABYLON.Color3;
  85193. set roadColor(value: BABYLON.Color3);
  85194. /**
  85195. * Serializes this road procedural texture
  85196. * @returns a serialized road procedural texture object
  85197. */
  85198. serialize(): any;
  85199. /**
  85200. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85201. * @param parsedTexture defines parsed texture data
  85202. * @param scene defines the current scene
  85203. * @param rootUrl defines the root URL containing road procedural texture information
  85204. * @returns a parsed Road Procedural BABYLON.Texture
  85205. */
  85206. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85207. }
  85208. }
  85209. declare module BABYLON {
  85210. /** @hidden */
  85211. export var starfieldProceduralTexturePixelShader: {
  85212. name: string;
  85213. shader: string;
  85214. };
  85215. }
  85216. declare module BABYLON {
  85217. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85218. private _time;
  85219. private _alpha;
  85220. private _beta;
  85221. private _zoom;
  85222. private _formuparam;
  85223. private _stepsize;
  85224. private _tile;
  85225. private _brightness;
  85226. private _darkmatter;
  85227. private _distfading;
  85228. private _saturation;
  85229. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85230. updateShaderUniforms(): void;
  85231. get time(): number;
  85232. set time(value: number);
  85233. get alpha(): number;
  85234. set alpha(value: number);
  85235. get beta(): number;
  85236. set beta(value: number);
  85237. get formuparam(): number;
  85238. set formuparam(value: number);
  85239. get stepsize(): number;
  85240. set stepsize(value: number);
  85241. get zoom(): number;
  85242. set zoom(value: number);
  85243. get tile(): number;
  85244. set tile(value: number);
  85245. get brightness(): number;
  85246. set brightness(value: number);
  85247. get darkmatter(): number;
  85248. set darkmatter(value: number);
  85249. get distfading(): number;
  85250. set distfading(value: number);
  85251. get saturation(): number;
  85252. set saturation(value: number);
  85253. /**
  85254. * Serializes this starfield procedural texture
  85255. * @returns a serialized starfield procedural texture object
  85256. */
  85257. serialize(): any;
  85258. /**
  85259. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85260. * @param parsedTexture defines parsed texture data
  85261. * @param scene defines the current scene
  85262. * @param rootUrl defines the root URL containing startfield procedural texture information
  85263. * @returns a parsed Starfield Procedural BABYLON.Texture
  85264. */
  85265. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85266. }
  85267. }
  85268. declare module BABYLON {
  85269. /** @hidden */
  85270. export var woodProceduralTexturePixelShader: {
  85271. name: string;
  85272. shader: string;
  85273. };
  85274. }
  85275. declare module BABYLON {
  85276. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85277. private _ampScale;
  85278. private _woodColor;
  85279. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85280. updateShaderUniforms(): void;
  85281. get ampScale(): number;
  85282. set ampScale(value: number);
  85283. get woodColor(): BABYLON.Color3;
  85284. set woodColor(value: BABYLON.Color3);
  85285. /**
  85286. * Serializes this wood procedural texture
  85287. * @returns a serialized wood procedural texture object
  85288. */
  85289. serialize(): any;
  85290. /**
  85291. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85292. * @param parsedTexture defines parsed texture data
  85293. * @param scene defines the current scene
  85294. * @param rootUrl defines the root URL containing wood procedural texture information
  85295. * @returns a parsed Wood Procedural BABYLON.Texture
  85296. */
  85297. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85298. }
  85299. }